xref: /wlan-dirver/qca-wifi-host-cmn/dp/wifi3.0/dp_tx.h (revision 2f4b444fb7e689b83a4ab0e7b3b38f0bf4def8e0)
1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 #ifndef __DP_TX_H
19 #define __DP_TX_H
20 
21 #include <qdf_types.h>
22 #include <qdf_nbuf.h>
23 #include "dp_types.h"
24 #if defined(MESH_MODE_SUPPORT) || defined(FEATURE_PERPKT_INFO)
25 #include "if_meta_hdr.h"
26 #endif
27 #include "dp_internal.h"
28 #include "hal_tx.h"
29 
30 #define DP_INVALID_VDEV_ID 0xFF
31 
32 #define DP_TX_MAX_NUM_FRAGS 6
33 
34 /*
35  * DP_TX_DESC_FLAG_FRAG flags should always be defined to 0x1
36  * please do not change this flag's definition
37  */
38 #define DP_TX_DESC_FLAG_FRAG		0x1
39 #define DP_TX_DESC_FLAG_TO_FW		0x2
40 #define DP_TX_DESC_FLAG_SIMPLE		0x4
41 #define DP_TX_DESC_FLAG_RAW		0x8
42 #define DP_TX_DESC_FLAG_MESH		0x10
43 #define DP_TX_DESC_FLAG_QUEUED_TX	0x20
44 #define DP_TX_DESC_FLAG_COMPLETED_TX	0x40
45 #define DP_TX_DESC_FLAG_ME		0x80
46 #define DP_TX_DESC_FLAG_TDLS_FRAME	0x100
47 #define DP_TX_DESC_FLAG_ALLOCATED	0x200
48 #define DP_TX_DESC_FLAG_MESH_MODE	0x400
49 #define DP_TX_DESC_FLAG_UNMAP_DONE	0x800
50 #define DP_TX_DESC_FLAG_TX_COMP_ERR	0x1000
51 #define DP_TX_DESC_FLAG_FLUSH		0x2000
52 
53 #define DP_TX_EXT_DESC_FLAG_METADATA_VALID 0x1
54 
55 #define DP_TX_FREE_SINGLE_BUF(soc, buf)                  \
56 do {                                                           \
57 	qdf_nbuf_unmap(soc->osdev, buf, QDF_DMA_TO_DEVICE);  \
58 	qdf_nbuf_free(buf);                                    \
59 } while (0)
60 
61 #define OCB_HEADER_VERSION	 1
62 
63 #ifdef TX_PER_PDEV_DESC_POOL
64 #ifdef QCA_LL_TX_FLOW_CONTROL_V2
65 #define DP_TX_GET_DESC_POOL_ID(vdev) (vdev->vdev_id)
66 #else /* QCA_LL_TX_FLOW_CONTROL_V2 */
67 #define DP_TX_GET_DESC_POOL_ID(vdev) (vdev->pdev->pdev_id)
68 #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
69 	#define DP_TX_GET_RING_ID(vdev) (vdev->pdev->pdev_id)
70 #else
71 	#ifdef TX_PER_VDEV_DESC_POOL
72 		#define DP_TX_GET_DESC_POOL_ID(vdev) (vdev->vdev_id)
73 		#define DP_TX_GET_RING_ID(vdev) (vdev->pdev->pdev_id)
74 	#endif /* TX_PER_VDEV_DESC_POOL */
75 #endif /* TX_PER_PDEV_DESC_POOL */
76 #define DP_TX_QUEUE_MASK 0x3
77 
78 #define MAX_CDP_SEC_TYPE 12
79 
80 /* number of dwords for htt_tx_msdu_desc_ext2_t */
81 #define DP_TX_MSDU_INFO_META_DATA_DWORDS 7
82 
83 #define dp_tx_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_TX, params)
84 #define dp_tx_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_TX, params)
85 #define dp_tx_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_DP_TX, params)
86 #define dp_tx_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_TX, params)
87 #define dp_tx_info(params...) \
88 	__QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_TX, ## params)
89 #define dp_tx_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_TX, params)
90 
91 #define dp_tx_comp_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_TX_COMP, params)
92 #define dp_tx_comp_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_TX_COMP, params)
93 #define dp_tx_comp_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_TX_COMP, params)
94 #define dp_tx_comp_info(params...) \
95 	__QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_TX_COMP, ## params)
96 #define dp_tx_comp_info_rl(params...) \
97 	__QDF_TRACE_RL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_TX_COMP, ## params)
98 #define dp_tx_comp_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_TX_COMP, params)
99 
100 #ifndef QCA_HOST_MODE_WIFI_DISABLED
101 
102 /**
103  * struct dp_tx_frag_info_s
104  * @vaddr: hlos vritual address for buffer
105  * @paddr_lo: physical address lower 32bits
106  * @paddr_hi: physical address higher bits
107  * @len: length of the buffer
108  */
109 struct dp_tx_frag_info_s {
110 	uint8_t  *vaddr;
111 	uint32_t paddr_lo;
112 	uint16_t paddr_hi;
113 	uint16_t len;
114 };
115 
116 /**
117  * struct dp_tx_seg_info_s - Segmentation Descriptor
118  * @nbuf: NBUF pointer if segment corresponds to separate nbuf
119  * @frag_cnt: Fragment count in this segment
120  * @total_len: Total length of segment
121  * @frags: per-Fragment information
122  * @next: pointer to next MSDU segment
123  */
124 struct dp_tx_seg_info_s  {
125 	qdf_nbuf_t nbuf;
126 	uint16_t frag_cnt;
127 	uint16_t total_len;
128 	struct dp_tx_frag_info_s frags[DP_TX_MAX_NUM_FRAGS];
129 	struct dp_tx_seg_info_s *next;
130 };
131 
132 #endif /* QCA_HOST_MODE_WIFI_DISABLED */
133 
134 /**
135  * struct dp_tx_sg_info_s - Scatter Gather Descriptor
136  * @num_segs: Number of segments (TSO/ME) in the frame
137  * @total_len: Total length of the frame
138  * @curr_seg: Points to current segment descriptor to be processed. Chain of
139  * 	      descriptors for SG frames/multicast-unicast converted packets.
140  *
141  * Used for SG (802.3 or Raw) frames and Multicast-Unicast converted frames to
142  * carry fragmentation information
143  * Raw Frames will be handed over to driver as an SKB chain with MPDU boundaries
144  * indicated through flags in SKB CB (first_msdu and last_msdu). This will be
145  * converted into set of skb sg (nr_frags) structures.
146  */
147 struct dp_tx_sg_info_s {
148 	uint32_t num_segs;
149 	uint32_t total_len;
150 	struct dp_tx_seg_info_s *curr_seg;
151 };
152 
153 /**
154  * struct dp_tx_queue - Tx queue
155  * @desc_pool_id: Descriptor Pool to be used for the tx queue
156  * @ring_id: TCL descriptor ring ID corresponding to the tx queue
157  *
158  * Tx queue contains information of the software (Descriptor pool)
159  * and hardware resources (TCL ring id) to be used for a particular
160  * transmit queue (obtained from skb_queue_mapping in case of linux)
161  */
162 struct dp_tx_queue {
163 	uint8_t desc_pool_id;
164 	uint8_t ring_id;
165 };
166 
167 /**
168  * struct dp_tx_msdu_info_s - MSDU Descriptor
169  * @frm_type: Frame type - Regular/TSO/SG/Multicast enhancement
170  * @tx_queue: Tx queue on which this MSDU should be transmitted
171  * @num_seg: Number of segments (TSO)
172  * @tid: TID (override) that is sent from HLOS
173  * @u.tso_info: TSO information for TSO frame types
174  * 	     (chain of the TSO segments, number of segments)
175  * @u.sg_info: Scatter Gather information for non-TSO SG frames
176  * @meta_data: Mesh meta header information
177  * @exception_fw: Duplicate frame to be sent to firmware
178  * @ppdu_cookie: 16-bit ppdu_cookie that has to be replayed back in completions
179  * @ix_tx_sniffer: Indicates if the packet has to be sniffed
180  *
181  * This structure holds the complete MSDU information needed to program the
182  * Hardware TCL and MSDU extension descriptors for different frame types
183  *
184  */
185 struct dp_tx_msdu_info_s {
186 	enum dp_tx_frm_type frm_type;
187 	struct dp_tx_queue tx_queue;
188 	uint32_t num_seg;
189 	uint8_t tid;
190 	uint8_t exception_fw;
191 	uint8_t is_tx_sniffer;
192 	union {
193 		struct qdf_tso_info_t tso_info;
194 		struct dp_tx_sg_info_s sg_info;
195 	} u;
196 	uint32_t meta_data[DP_TX_MSDU_INFO_META_DATA_DWORDS];
197 	uint16_t ppdu_cookie;
198 };
199 
200 #ifndef QCA_HOST_MODE_WIFI_DISABLED
201 /**
202  * dp_tx_deinit_pair_by_index() - Deinit TX rings based on index
203  * @soc: core txrx context
204  * @index: index of ring to deinit
205  *
206  * Deinit 1 TCL and 1 WBM2SW release ring on as needed basis using
207  * index of the respective TCL/WBM2SW release in soc structure.
208  * For example, if the index is 2 then &soc->tcl_data_ring[2]
209  * and &soc->tx_comp_ring[2] will be deinitialized.
210  *
211  * Return: none
212  */
213 void dp_tx_deinit_pair_by_index(struct dp_soc *soc, int index);
214 #endif /* QCA_HOST_MODE_WIFI_DISABLED */
215 
216 void dp_tx_tso_cmn_desc_pool_deinit(struct dp_soc *soc, uint8_t num_pool);
217 void dp_tx_tso_cmn_desc_pool_free(struct dp_soc *soc, uint8_t num_pool);
218 QDF_STATUS dp_tx_tso_cmn_desc_pool_alloc(struct dp_soc *soc,
219 					 uint8_t num_pool,
220 					 uint16_t num_desc);
221 QDF_STATUS dp_tx_tso_cmn_desc_pool_init(struct dp_soc *soc,
222 					uint8_t num_pool,
223 					uint16_t num_desc);
224 
225 void dp_tx_tso_cmn_desc_pool_deinit(struct dp_soc *soc, uint8_t num_pool);
226 void dp_tx_tso_cmn_desc_pool_free(struct dp_soc *soc, uint8_t num_pool);
227 QDF_STATUS dp_tx_tso_cmn_desc_pool_alloc(struct dp_soc *soc,
228 					 uint8_t num_pool,
229 					 uint16_t num_desc);
230 QDF_STATUS dp_tx_tso_cmn_desc_pool_init(struct dp_soc *soc,
231 					uint8_t num_pool,
232 					uint16_t num_desc);
233 
234 #ifndef QCA_HOST_MODE_WIFI_DISABLED
235 /**
236  * dp_tso_attach() - TSO Attach handler
237  * @txrx_soc: Opaque Dp handle
238  *
239  * Reserve TSO descriptor buffers
240  *
241  * Return: QDF_STATUS_E_FAILURE on failure or
242  * QDF_STATUS_SUCCESS on success
243  */
244 QDF_STATUS dp_tso_soc_attach(struct cdp_soc_t *txrx_soc);
245 
246 /**
247  * dp_tso_detach() - TSO Detach handler
248  * @txrx_soc: Opaque Dp handle
249  *
250  * Deallocate TSO descriptor buffers
251  *
252  * Return: QDF_STATUS_E_FAILURE on failure or
253  * QDF_STATUS_SUCCESS on success
254  */
255 QDF_STATUS dp_tso_soc_detach(struct cdp_soc_t *txrx_soc);
256 
257 qdf_nbuf_t dp_tx_send(struct cdp_soc_t *soc, uint8_t vdev_id, qdf_nbuf_t nbuf);
258 
259 qdf_nbuf_t dp_tx_send_vdev_id_check(struct cdp_soc_t *soc, uint8_t vdev_id,
260 				    qdf_nbuf_t nbuf);
261 
262 qdf_nbuf_t dp_tx_send_exception(struct cdp_soc_t *soc, uint8_t vdev_id,
263 				qdf_nbuf_t nbuf,
264 				struct cdp_tx_exception_metadata *tx_exc);
265 
266 qdf_nbuf_t dp_tx_send_exception_vdev_id_check(struct cdp_soc_t *soc,
267 					      uint8_t vdev_id,
268 					      qdf_nbuf_t nbuf,
269 				struct cdp_tx_exception_metadata *tx_exc);
270 
271 qdf_nbuf_t dp_tx_send_mesh(struct cdp_soc_t *soc, uint8_t vdev_id,
272 			   qdf_nbuf_t nbuf);
273 qdf_nbuf_t
274 dp_tx_send_msdu_single(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
275 		       struct dp_tx_msdu_info_s *msdu_info, uint16_t peer_id,
276 		       struct cdp_tx_exception_metadata *tx_exc_metadata);
277 
278 #if QDF_LOCK_STATS
279 noinline qdf_nbuf_t
280 dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
281 			 struct dp_tx_msdu_info_s *msdu_info);
282 #else
283 qdf_nbuf_t dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
284 				    struct dp_tx_msdu_info_s *msdu_info);
285 #endif
286 #ifdef FEATURE_WLAN_TDLS
287 /**
288  * dp_tx_non_std() - Allow the control-path SW to send data frames
289  * @soc_hdl: Datapath soc handle
290  * @vdev_id: id of vdev
291  * @tx_spec: what non-standard handling to apply to the tx data frames
292  * @msdu_list: NULL-terminated list of tx MSDUs
293  *
294  * Return: NULL on success,
295  *         nbuf when it fails to send
296  */
297 qdf_nbuf_t dp_tx_non_std(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
298 			 enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list);
299 #endif
300 int dp_tx_frame_is_drop(struct dp_vdev *vdev, uint8_t *srcmac, uint8_t *dstmac);
301 
302 /**
303  * dp_tx_comp_handler() - Tx completion handler
304  * @int_ctx: pointer to DP interrupt context
305  * @soc: core txrx main context
306  * @hal_srng: Opaque HAL SRNG pointer
307  * @ring_id: completion ring id
308  * @quota: No. of packets/descriptors that can be serviced in one loop
309  *
310  * This function will collect hardware release ring element contents and
311  * handle descriptor contents. Based on contents, free packet or handle error
312  * conditions
313  *
314  * Return: Number of TX completions processed
315  */
316 uint32_t dp_tx_comp_handler(struct dp_intr *int_ctx, struct dp_soc *soc,
317 			    hal_ring_handle_t hal_srng, uint8_t ring_id,
318 			    uint32_t quota);
319 
320 QDF_STATUS
321 dp_tx_prepare_send_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
322 
323 QDF_STATUS
324 dp_tx_prepare_send_igmp_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
325 
326 #endif /* QCA_HOST_MODE_WIFI_DISABLED */
327 
328 #if defined(QCA_HOST_MODE_WIFI_DISABLED) || !defined(ATH_SUPPORT_IQUE)
329 static inline void dp_tx_me_exit(struct dp_pdev *pdev)
330 {
331 	return;
332 }
333 #endif
334 
335 /**
336  * dp_tx_pdev_init() - dp tx pdev init
337  * @pdev: physical device instance
338  *
339  * Return: QDF_STATUS_SUCCESS: success
340  *         QDF_STATUS_E_RESOURCES: Error return
341  */
342 static inline QDF_STATUS dp_tx_pdev_init(struct dp_pdev *pdev)
343 {
344 	struct dp_soc *soc = pdev->soc;
345 
346 	/* Initialize Flow control counters */
347 	qdf_atomic_init(&pdev->num_tx_outstanding);
348 	pdev->tx_descs_max = 0;
349 	if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
350 		/* Initialize descriptors in TCL Ring */
351 		hal_tx_init_data_ring(soc->hal_soc,
352 				soc->tcl_data_ring[pdev->pdev_id].hal_srng);
353 	}
354 
355 	return QDF_STATUS_SUCCESS;
356 }
357 
358 
359 #ifndef FEATURE_WDS
360 static inline void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status)
361 {
362 	return;
363 }
364 #endif
365 
366 #ifndef QCA_MULTIPASS_SUPPORT
367 static inline
368 bool dp_tx_multipass_process(struct dp_soc *soc, struct dp_vdev *vdev,
369 			     qdf_nbuf_t nbuf,
370 			     struct dp_tx_msdu_info_s *msdu_info)
371 {
372 	return true;
373 }
374 
375 static inline
376 void dp_tx_vdev_multipass_deinit(struct dp_vdev *vdev)
377 {
378 }
379 
380 #else
381 bool dp_tx_multipass_process(struct dp_soc *soc, struct dp_vdev *vdev,
382 			     qdf_nbuf_t nbuf,
383 			     struct dp_tx_msdu_info_s *msdu_info);
384 
385 void dp_tx_vdev_multipass_deinit(struct dp_vdev *vdev);
386 #endif
387 
388 /**
389  * dp_tx_hw_to_qdf()- convert hw status to qdf status
390  * @status: hw status
391  *
392  * Return: qdf tx rx status
393  */
394 static inline enum qdf_dp_tx_rx_status dp_tx_hw_to_qdf(uint16_t status)
395 {
396 	switch (status) {
397 	case HAL_TX_TQM_RR_FRAME_ACKED:
398 		return QDF_TX_RX_STATUS_OK;
399 	case HAL_TX_TQM_RR_REM_CMD_TX:
400 		return QDF_TX_RX_STATUS_NO_ACK;
401 	case HAL_TX_TQM_RR_REM_CMD_REM:
402 	case HAL_TX_TQM_RR_REM_CMD_NOTX:
403 	case HAL_TX_TQM_RR_REM_CMD_AGED:
404 		return QDF_TX_RX_STATUS_FW_DISCARD;
405 	default:
406 		return QDF_TX_RX_STATUS_DEFAULT;
407 	}
408 }
409 
410 #ifndef QCA_HOST_MODE_WIFI_DISABLED
411 /**
412  * dp_tx_get_queue() - Returns Tx queue IDs to be used for this Tx frame
413  * @vdev: DP Virtual device handle
414  * @nbuf: Buffer pointer
415  * @queue: queue ids container for nbuf
416  *
417  * TX packet queue has 2 instances, software descriptors id and dma ring id
418  * Based on tx feature and hardware configuration queue id combination could be
419  * different.
420  * For example -
421  * With XPS enabled,all TX descriptor pools and dma ring are assigned per cpu id
422  * With no XPS,lock based resource protection, Descriptor pool ids are different
423  * for each vdev, dma ring id will be same as single pdev id
424  *
425  * Return: None
426  */
427 #ifdef QCA_OL_TX_MULTIQ_SUPPORT
428 static inline void dp_tx_get_queue(struct dp_vdev *vdev,
429 				   qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
430 {
431 	uint16_t queue_offset = qdf_nbuf_get_queue_mapping(nbuf) &
432 				DP_TX_QUEUE_MASK;
433 
434 	queue->desc_pool_id = queue_offset;
435 	queue->ring_id = qdf_get_cpu();
436 
437 	dp_tx_debug("pool_id:%d ring_id: %d",
438 		    queue->desc_pool_id, queue->ring_id);
439 
440 }
441 
442 /*
443  * dp_tx_get_hal_ring_hdl()- Get the hal_tx_ring_hdl for data transmission
444  * @dp_soc - DP soc structure pointer
445  * @ring_id - Transmit Queue/ring_id to be used when XPS is enabled
446  *
447  * Return - HAL ring handle
448  */
449 static inline hal_ring_handle_t dp_tx_get_hal_ring_hdl(struct dp_soc *soc,
450 						       uint8_t ring_id)
451 {
452 	if (ring_id == soc->num_tcl_data_rings)
453 		return soc->tcl_cmd_credit_ring.hal_srng;
454 
455 	return soc->tcl_data_ring[ring_id].hal_srng;
456 }
457 
458 #else /* QCA_OL_TX_MULTIQ_SUPPORT */
459 
460 static inline void dp_tx_get_queue(struct dp_vdev *vdev,
461 				   qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
462 {
463 	/* get flow id */
464 	queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
465 	queue->ring_id = DP_TX_GET_RING_ID(vdev);
466 
467 	dp_tx_debug("pool_id:%d ring_id: %d skb %pK ",
468 		    queue->desc_pool_id, queue->ring_id, nbuf);
469 }
470 
471 static inline hal_ring_handle_t dp_tx_get_hal_ring_hdl(struct dp_soc *soc,
472 						       uint8_t ring_id)
473 {
474 	return soc->tcl_data_ring[ring_id].hal_srng;
475 }
476 #endif
477 
478 #ifdef QCA_OL_TX_LOCK_LESS_ACCESS
479 /*
480  * dp_tx_hal_ring_access_start()- hal_tx_ring access for data transmission
481  * @dp_soc - DP soc structure pointer
482  * @hal_ring_hdl - HAL ring handle
483  *
484  * Return - None
485  */
486 static inline int dp_tx_hal_ring_access_start(struct dp_soc *soc,
487 					      hal_ring_handle_t hal_ring_hdl)
488 {
489 	return hal_srng_access_start_unlocked(soc->hal_soc, hal_ring_hdl);
490 }
491 
492 /*
493  * dp_tx_hal_ring_access_end()- hal_tx_ring access for data transmission
494  * @dp_soc - DP soc structure pointer
495  * @hal_ring_hdl - HAL ring handle
496  *
497  * Return - None
498  */
499 static inline void dp_tx_hal_ring_access_end(struct dp_soc *soc,
500 					     hal_ring_handle_t hal_ring_hdl)
501 {
502 	hal_srng_access_end_unlocked(soc->hal_soc, hal_ring_hdl);
503 }
504 
505 /*
506  * dp_tx_hal_ring_access_reap()- hal_tx_ring access for data transmission
507  * @dp_soc - DP soc structure pointer
508  * @hal_ring_hdl - HAL ring handle
509  *
510  * Return - None
511  */
512 static inline void dp_tx_hal_ring_access_end_reap(struct dp_soc *soc,
513 						  hal_ring_handle_t
514 						  hal_ring_hdl)
515 {
516 }
517 
518 #else
519 static inline int dp_tx_hal_ring_access_start(struct dp_soc *soc,
520 					      hal_ring_handle_t hal_ring_hdl)
521 {
522 	return hal_srng_access_start(soc->hal_soc, hal_ring_hdl);
523 }
524 
525 static inline void dp_tx_hal_ring_access_end(struct dp_soc *soc,
526 					     hal_ring_handle_t hal_ring_hdl)
527 {
528 	hal_srng_access_end(soc->hal_soc, hal_ring_hdl);
529 }
530 
531 static inline void dp_tx_hal_ring_access_end_reap(struct dp_soc *soc,
532 						  hal_ring_handle_t
533 						  hal_ring_hdl)
534 {
535 	hal_srng_access_end_reap(soc->hal_soc, hal_ring_hdl);
536 }
537 #endif
538 
539 #ifdef ATH_TX_PRI_OVERRIDE
540 #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf) \
541 	((_msdu_info)->tid = qdf_nbuf_get_priority(_nbuf))
542 #else
543 #define DP_TX_TID_OVERRIDE(_msdu_info, _nbuf)
544 #endif
545 
546 /* TODO TX_FEATURE_NOT_YET */
547 static inline void dp_tx_comp_process_exception(struct dp_tx_desc_s *tx_desc)
548 {
549 	return;
550 }
551 /* TODO TX_FEATURE_NOT_YET */
552 
553 void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
554 		      bool force_free);
555 QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev);
556 QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev);
557 void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev);
558 QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc);
559 QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc);
560 void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc);
561 void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc);
562 void
563 dp_handle_wbm_internal_error(struct dp_soc *soc, void *hal_desc,
564 			     uint32_t buf_type);
565 #else /* QCA_HOST_MODE_WIFI_DISABLED */
566 
567 static inline
568 QDF_STATUS dp_soc_tx_desc_sw_pools_alloc(struct dp_soc *soc)
569 {
570 	return QDF_STATUS_SUCCESS;
571 }
572 
573 static inline
574 QDF_STATUS dp_soc_tx_desc_sw_pools_init(struct dp_soc *soc)
575 {
576 	return QDF_STATUS_SUCCESS;
577 }
578 
579 static inline void dp_soc_tx_desc_sw_pools_free(struct dp_soc *soc)
580 {
581 }
582 
583 static inline void dp_soc_tx_desc_sw_pools_deinit(struct dp_soc *soc)
584 {
585 }
586 
587 static inline
588 void dp_tx_desc_flush(struct dp_pdev *pdev, struct dp_vdev *vdev,
589 		      bool force_free)
590 {
591 }
592 
593 static inline QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev)
594 {
595 	return QDF_STATUS_SUCCESS;
596 }
597 
598 static inline QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev)
599 {
600 	return QDF_STATUS_SUCCESS;
601 }
602 
603 static inline void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev)
604 {
605 }
606 
607 #endif /* QCA_HOST_MODE_WIFI_DISABLED */
608 
609 #ifdef FEATURE_PERPKT_INFO
610 QDF_STATUS
611 dp_get_completion_indication_for_stack(struct dp_soc *soc,
612 				       struct dp_pdev *pdev,
613 				       struct dp_peer *peer,
614 				       struct hal_tx_completion_status *ts,
615 				       qdf_nbuf_t netbuf,
616 				       uint64_t time_latency);
617 
618 void dp_send_completion_to_stack(struct dp_soc *soc,  struct dp_pdev *pdev,
619 			    uint16_t peer_id, uint32_t ppdu_id,
620 			    qdf_nbuf_t netbuf);
621 #else
622 static inline
623 QDF_STATUS dp_get_completion_indication_for_stack(struct dp_soc *soc,
624 				       struct dp_pdev *pdev,
625 				       struct dp_peer *peer,
626 				       struct hal_tx_completion_status *ts,
627 				       qdf_nbuf_t netbuf,
628 				       uint64_t time_latency)
629 {
630 	return QDF_STATUS_E_NOSUPPORT;
631 }
632 
633 static inline
634 void dp_send_completion_to_stack(struct dp_soc *soc,  struct dp_pdev *pdev,
635 			    uint16_t peer_id, uint32_t ppdu_id,
636 			    qdf_nbuf_t netbuf)
637 {
638 }
639 #endif
640 
641 #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
642 void dp_send_completion_to_pkt_capture(struct dp_soc *soc,
643 				       struct dp_tx_desc_s *desc,
644 				       struct hal_tx_completion_status *ts);
645 #else
646 static inline void
647 dp_send_completion_to_pkt_capture(struct dp_soc *soc,
648 				  struct dp_tx_desc_s *desc,
649 				  struct hal_tx_completion_status *ts)
650 {
651 }
652 #endif
653 
654 #ifndef QCA_HOST_MODE_WIFI_DISABLED
655 #ifdef WLAN_DP_FEATURE_SW_LATENCY_MGR
656 /**
657  * dp_tx_update_stats() - Update soc level tx stats
658  * @soc: DP soc handle
659  * @nbuf: packet being transmitted
660  *
661  * Returns: none
662  */
663 void dp_tx_update_stats(struct dp_soc *soc,
664 			qdf_nbuf_t nbuf);
665 
666 /**
667  * dp_tx_attempt_coalescing() - Check and attempt TCL register write coalescing
668  * @soc: Datapath soc handle
669  * @tx_desc: tx packet descriptor
670  * @tid: TID for pkt transmission
671  *
672  * Returns: 1, if coalescing is to be done
673  *	    0, if coalescing is not to be done
674  */
675 int
676 dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
677 			 struct dp_tx_desc_s *tx_desc,
678 			 uint8_t tid);
679 
680 /**
681  * dp_tx_ring_access_end() - HAL ring access end for data transmission
682  * @soc: Datapath soc handle
683  * @hal_ring_hdl: HAL ring handle
684  * @coalesce: Coalesce the current write or not
685  *
686  * Returns: none
687  */
688 void
689 dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
690 		      int coalesce);
691 #else
692 /**
693  * dp_tx_update_stats() - Update soc level tx stats
694  * @soc: DP soc handle
695  * @nbuf: packet being transmitted
696  *
697  * Returns: none
698  */
699 static inline void dp_tx_update_stats(struct dp_soc *soc,
700 				      qdf_nbuf_t nbuf) { }
701 static inline void
702 dp_tx_ring_access_end(struct dp_soc *soc, hal_ring_handle_t hal_ring_hdl,
703 		      int coalesce)
704 {
705 	dp_tx_hal_ring_access_end(soc, hal_ring_hdl);
706 }
707 
708 static inline int
709 dp_tx_attempt_coalescing(struct dp_soc *soc, struct dp_vdev *vdev,
710 			 struct dp_tx_desc_s *tx_desc,
711 			 uint8_t tid)
712 {
713 	return 0;
714 }
715 
716 #endif /* WLAN_DP_FEATURE_SW_LATENCY_MGR */
717 
718 #ifdef FEATURE_RUNTIME_PM
719 void
720 dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
721 			      hal_ring_handle_t hal_ring_hdl,
722 			      int coalesce);
723 #else
724 static inline void
725 dp_tx_ring_access_end_wrapper(struct dp_soc *soc,
726 			      hal_ring_handle_t hal_ring_hdl,
727 			      int coalesce)
728 {
729 	dp_tx_ring_access_end(soc, hal_ring_hdl, coalesce);
730 }
731 #endif
732 #endif /* QCA_HOST_MODE_WIFI_DISABLED */
733 
734 #ifdef DP_TX_HW_DESC_HISTORY
735 static inline void
736 dp_tx_hw_desc_update_evt(uint8_t *hal_tx_desc_cached,
737 			 hal_ring_handle_t hal_ring_hdl,
738 			 struct dp_soc *soc)
739 {
740 	struct dp_tx_hw_desc_evt *evt;
741 	uint64_t idx = 0;
742 
743 	if (!soc->tx_hw_desc_history)
744 		return;
745 
746 	idx = ++soc->tx_hw_desc_history->index;
747 	if (idx == DP_TX_HW_DESC_HIST_MAX)
748 		soc->tx_hw_desc_history->index = 0;
749 	idx = qdf_do_div_rem(idx, DP_TX_HW_DESC_HIST_MAX);
750 
751 	evt = &soc->tx_hw_desc_history->entry[idx];
752 	qdf_mem_copy(evt->tcl_desc, hal_tx_desc_cached, HAL_TX_DESC_LEN_BYTES);
753 	evt->posted = qdf_get_log_timestamp();
754 	hal_get_sw_hptp(soc->hal_soc, hal_ring_hdl, &evt->tp, &evt->hp);
755 }
756 #else
757 static inline void
758 dp_tx_hw_desc_update_evt(uint8_t *hal_tx_desc_cached,
759 			 hal_ring_handle_t hal_ring_hdl,
760 			 struct dp_soc *soc)
761 {
762 }
763 #endif
764 
765 #ifdef WLAN_FEATURE_TSF_UPLINK_DELAY
766 /**
767  * dp_set_delta_tsf() - Set delta_tsf to dp_soc structure
768  * @soc_hdl: cdp soc pointer
769  * @vdev_id: vdev id
770  * @delta_tsf: difference between TSF clock and qtimer
771  *
772  * Return: None
773  */
774 void dp_set_delta_tsf(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
775 		      uint32_t delta_tsf);
776 
777 /**
778  * dp_set_tsf_report_ul_delay() - Enable or disable reporting uplink delay
779  * @soc_hdl: cdp soc pointer
780  * @vdev_id: vdev id
781  * @enable: true to enable and false to disable
782  *
783  * Return: QDF_STATUS
784  */
785 QDF_STATUS dp_set_tsf_ul_delay_report(struct cdp_soc_t *soc_hdl,
786 				      uint8_t vdev_id, bool enable);
787 
788 /**
789  * dp_get_uplink_delay() - Get uplink delay value
790  * @soc_hdl: cdp soc pointer
791  * @vdev_id: vdev id
792  * @val: pointer to save uplink delay value
793  *
794  * Return: QDF_STATUS
795  */
796 QDF_STATUS dp_get_uplink_delay(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
797 			       uint32_t *val);
798 #endif /* WLAN_FEATURE_TSF_UPLINK_TSF */
799 
800 #endif
801