xref: /wlan-dirver/qca-wifi-host-cmn/dp/wifi3.0/monitor/2.0/dp_tx_mon_2.0.h (revision dd839c21357ab2adc0e39ac8487643913d22372f)
1 /*
2  * Copyright (c) 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 any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef _DP_TX_MON_2_0_H_
19 #define _DP_TX_MON_2_0_H_
20 
21 #include <qdf_nbuf_frag.h>
22 #include <hal_be_api_mon.h>
23 
24 struct dp_mon_desc;
25 
26 /**
27  * struct dp_tx_mon_desc_list - structure to store descriptor linked list
28  * @desc_list: descriptor list
29  * @tail: descriptor list tail
30  * @tx_mon_reap_cnt: tx monitor reap count
31  */
32 struct dp_tx_mon_desc_list {
33 	union dp_mon_desc_list_elem_t *desc_list;
34 	union dp_mon_desc_list_elem_t *tail;
35 	uint32_t tx_mon_reap_cnt;
36 };
37 
38 /**
39  * dp_tx_mon_buf_desc_pool_deinit() - deinit tx monitor descriptor pool
40  * @soc: dp soc handle
41  *
42  */
43 void
44 dp_tx_mon_buf_desc_pool_deinit(struct dp_soc *soc);
45 
46 /**
47  * dp_tx_mon_buf_desc_pool_init() - init tx monitor descriptor pool
48  * @soc: dp soc handle
49  *
50  * Return: QDF_STATUS_SUCCESS: Success
51  *         QDF_STATUS_E_FAILURE: Error
52  */
53 QDF_STATUS
54 dp_tx_mon_buf_desc_pool_init(struct dp_soc *soc);
55 
56 /**
57  * dp_tx_mon_buf_desc_pool_free() - free tx monitor descriptor pool
58  * @soc: dp soc handle
59  *
60  */
61 void dp_tx_mon_buf_desc_pool_free(struct dp_soc *soc);
62 
63 /**
64  * dp_tx_mon_update_end_reason() - API to update end reason
65  *
66  * @mon_pdev: DP_MON_PDEV handle
67  * @ppdu_id: ppdu_id
68  * @end_reason: monitor destination descriptor end reason
69  *
70  * Return: void
71  */
72 void dp_tx_mon_update_end_reason(struct dp_mon_pdev *mon_pdev,
73 				 int ppdu_id, int end_reason);
74 
75 /**
76  * dp_tx_mon_status_free_packet_buf() - API to free packet buffer
77  * @pdev: pdev Handle
78  * @status_frag: status frag
79  * @end_offset: status fragment end offset
80  * @mon_desc_list_ref: tx monitor descriptor list reference
81  *
82  * Return: void
83  */
84 void
85 dp_tx_mon_status_free_packet_buf(struct dp_pdev *pdev,
86 				 qdf_frag_t status_frag,
87 				 uint32_t end_offset,
88 				 struct dp_tx_mon_desc_list *mon_desc_list_ref);
89 
90 #if defined(WLAN_TX_PKT_CAPTURE_ENH_BE) && defined(WLAN_PKT_CAPTURE_TX_2_0) && \
91 	defined(BE_PKTLOG_SUPPORT)
92 /**
93  * dp_tx_process_pktlog_be() - process pktlog
94  * @soc: dp soc handle
95  * @pdev: dp pdev handle
96  * @status_frag: frag pointer which needs to be added to nbuf
97  * @end_offset: Offset in frag to be added to nbuf_frags
98  *
99  * Return:
100  * * 0             - OK to runtime suspend the device
101  * * -EINVAL - invalid argument
102  * * -ENOMEM - out of memory
103  */
104 QDF_STATUS
105 dp_tx_process_pktlog_be(struct dp_soc *soc, struct dp_pdev *pdev,
106 			void *status_frag, uint32_t end_offset);
107 #else
108 static inline QDF_STATUS
109 dp_tx_process_pktlog_be(struct dp_soc *soc, struct dp_pdev *pdev,
110 			void *status_frag, uint32_t end_offset)
111 {
112 	return QDF_STATUS_SUCCESS;
113 }
114 #endif
115 
116 /**
117  * dp_tx_mon_process_status_tlv() - API to processed TLV
118  * invoked from interrupt handler
119  *
120  * @soc: DP_SOC handle
121  * @pdev: DP_PDEV handle
122  * @mon_ring_desc: descriptor status info
123  * @status_frag: status buffer frag address
124  * @end_offset: end offset of buffer that has valid buffer
125  * @mon_desc_list_ref: tx monitor descriptor list reference
126  *
127  * Return: QDF_STATUS
128  */
129 QDF_STATUS
130 dp_tx_mon_process_status_tlv(struct dp_soc *soc,
131 			     struct dp_pdev *pdev,
132 			     struct hal_mon_desc *mon_ring_desc,
133 			     qdf_frag_t status_frag,
134 			     uint32_t end_offset,
135 			     struct dp_tx_mon_desc_list *mon_desc_list_ref);
136 
137 /**
138  * dp_tx_mon_process_2_0() - tx monitor interrupt process
139  * @soc: dp soc handle
140  * @int_ctx: interrupt context
141  * @mac_id: mac id
142  * @quota: quota to process
143  *
144  */
145 uint32_t
146 dp_tx_mon_process_2_0(struct dp_soc *soc, struct dp_intr *int_ctx,
147 		      uint32_t mac_id, uint32_t quota);
148 
149 /**
150  * dp_tx_mon_print_ring_stat_2_0() - Print monitor ring stats
151  * @pdev: dp pdev handle
152  *
153  */
154 void
155 dp_tx_mon_print_ring_stat_2_0(struct dp_pdev *pdev);
156 
157 /* The maximum buffer length allocated for radiotap for monitor status buffer */
158 #define MAX_MONITOR_HEADER (512)
159 #define MAX_DUMMY_FRM_BODY (128)
160 
161 #define MAX_STATUS_BUFFER_IN_PPDU (128)
162 #define TXMON_NO_BUFFER_SZ (64)
163 
164 #define DP_BA_ACK_FRAME_SIZE (sizeof(struct ieee80211_ctlframe_addr2) + 36)
165 #define DP_ACK_FRAME_SIZE (sizeof(struct ieee80211_frame_min_one))
166 #define DP_CTS_FRAME_SIZE (sizeof(struct ieee80211_frame_min_one))
167 #define DP_ACKNOACK_FRAME_SIZE (sizeof(struct ieee80211_frame) + 16)
168 
169 #define DP_IEEE80211_BAR_CTL_TID_S 12
170 #define DP_IEEE80211_BAR_CTL_TID_M 0xf
171 #define DP_IEEE80211_BAR_CTL_POLICY_S 0
172 #define DP_IEEE80211_BAR_CTL_POLICY_M 0x1
173 #define DP_IEEE80211_BA_S_SEQ_S 4
174 #define DP_IEEE80211_BAR_CTL_COMBA 0x0004
175 
176 #define TXMON_PPDU(ppdu_info, field)	ppdu_info->field
177 #define TXMON_PPDU_USR(ppdu_info, user_index, field)	\
178 			ppdu_info->hal_txmon.rx_user_status[user_index].field
179 #define TXMON_PPDU_COM(ppdu_info, field) ppdu_info->hal_txmon.rx_status.field
180 #define TXMON_PPDU_HAL(ppdu_info, field) ppdu_info->hal_txmon.field
181 
182 #define HE_DATA_CNT	6
183 
184 #define INITIATOR_WINDOW 0
185 #define RESPONSE_WINDOW 1
186 
187 #ifdef WLAN_PKT_CAPTURE_TX_2_0
188 /**
189  * enum bf_type -  tx monitor supported Beamformed type
190  * @NO_BF:
191  * @LEGACY_BF:
192  * @SU_BF:
193  * @MU_BF:
194  */
195 enum bf_type {
196 	NO_BF = 0,
197 	LEGACY_BF,
198 	SU_BF,
199 	MU_BF
200 };
201 
202 /**
203  * enum dot11b_preamble_type - tx monitor supported 11b preamble type
204  * @SHORT_PREAMBLE:
205  * @LONG_PREAMBLE:
206  */
207 enum dot11b_preamble_type {
208 	SHORT_PREAMBLE = 0,
209 	LONG_PREAMBLE,
210 };
211 
212 /**
213  * enum bw_type - tx monitor supported bandwidth type
214  * @TXMON_BW_20_MHZ:
215  * @TXMON_BW_40_MHZ:
216  * @TXMON_BW_80_MHZ:
217  * @TXMON_BW_160_MHZ:
218  * @TXMON_BW_240_MHZ:
219  * @TXMON_BW_320_MHZ:
220  */
221 enum bw_type {
222 	TXMON_BW_20_MHZ = 0,
223 	TXMON_BW_40_MHZ,
224 	TXMON_BW_80_MHZ,
225 	TXMON_BW_160_MHZ,
226 	TXMON_BW_240_MHZ,
227 	TXMON_BW_320_MHZ
228 };
229 
230 /**
231  * enum ppdu_start_reason - tx monitor supported PPDU start reason type
232  * @TXMON_FES_PROTECTION_FRAME:
233  * @TXMON_FES_AFTER_PROTECTION:
234  * @TXMON_FES_ONLY:
235  * @TXMON_RESPONSE_FRAME:
236  * @TXMON_TRIG_RESPONSE_FRAME:
237  * @TXMON_DYNAMIC_PROTECTION_FES_ONLY:
238  */
239 enum ppdu_start_reason {
240 	TXMON_FES_PROTECTION_FRAME,
241 	TXMON_FES_AFTER_PROTECTION,
242 	TXMON_FES_ONLY,
243 	TXMON_RESPONSE_FRAME,
244 	TXMON_TRIG_RESPONSE_FRAME,
245 	TXMON_DYNAMIC_PROTECTION_FES_ONLY
246 };
247 
248 /**
249  * enum guard_interval - tx monitor supported Guard interval type
250  * @TXMON_GI_0_8_US:
251  * @TXMON_GI_0_4_US:
252  * @TXMON_GI_1_6_US:
253  * @TXMON_GI_3_2_US:
254  */
255 enum guard_interval {
256 	TXMON_GI_0_8_US = 0,
257 	TXMON_GI_0_4_US,
258 	TXMON_GI_1_6_US,
259 	TXMON_GI_3_2_US
260 };
261 
262 /**
263  * enum RU_size_start - tx monitor supported RU size start type
264  * @TXMON_RU_26:
265  * @TXMON_RU_52:
266  * @TXMON_RU_106:
267  * @TXMON_RU_242:
268  * @TXMON_RU_484:
269  * @TXMON_RU_996:
270  * @TXMON_RU_1992:
271  * @TXMON_RU_FULLBW_240:
272  * @TXMON_RU_FULLBW_320:
273  * @TXMON_RU_MULTI_LARGE:
274  * @TXMON_RU_78:
275  * @TXMON_RU_132:
276  */
277 enum RU_size_start {
278 	TXMON_RU_26 = 0,
279 	TXMON_RU_52,
280 	TXMON_RU_106,
281 	TXMON_RU_242,
282 	TXMON_RU_484,
283 	TXMON_RU_996,
284 	TXMON_RU_1992,
285 	TXMON_RU_FULLBW_240,
286 	TXMON_RU_FULLBW_320,
287 	TXMON_RU_MULTI_LARGE,
288 	TXMON_RU_78,
289 	TXMON_RU_132
290 };
291 
292 /**
293  * enum response_type_expected - expected response type
294  * @TXMON_RESP_NO_RESP:
295  * @TXMON_RESP_ACK:
296  * @TXMON_RESP_BA_64_BITMAP:
297  * @TXMON_RESP_BA_256:
298  * @TXMON_RESP_ACTIONNOACK:
299  * @TXMON_RESP_ACK_BA:
300  * @TXMON_RESP_CTS:
301  * @TXMON_RESP_ACK_DATA:
302  * @TXMON_RESP_NDP_ACK:
303  * @TXMON_RESP_NDP_MODIFIED_ACK:
304  * @TXMON_RESP_NDP_BA:
305  * @TXMON_RESP_NDP_CTS:
306  * @TXMON_RESP_NDP_ACK_OR_NDP_MODIFIED_ACK:
307  * @TXMON_RESP_UL_MU_BA:
308  * @TXMON_RESP_UL_MU_BA_AND_DATA:
309  * @TXMON_RESP_UL_MU_CBF:
310  * @TXMON_RESP_UL_MU_FRAMES:
311  * @TXMON_RESP_ANY_RESP_TO_DEVICE:
312  * @TXMON_RESP_ANY_RESP_ACCEPTED:
313  * @TXMON_RESP_FRAMELESS_PHYRX_RESP_ACCEPTED:
314  * @TXMON_RESP_RANGING_NDP_AND_LMR:
315  * @TXMON_RESP_BA_512:
316  * @TXMON_RESP_BA_1024:
317  * @TXMON_RESP_UL_MU_RANGING_CTS2S:
318  * @TXMON_RESP_UL_MU_RANGING_NDP:
319  * @TXMON_RESP_UL_MU_RANGING_LMR:
320  */
321 enum response_type_expected {
322 	TXMON_RESP_NO_RESP = 0,
323 	TXMON_RESP_ACK,
324 	TXMON_RESP_BA_64_BITMAP,
325 	TXMON_RESP_BA_256,
326 	TXMON_RESP_ACTIONNOACK,
327 	TXMON_RESP_ACK_BA,
328 	TXMON_RESP_CTS,
329 	TXMON_RESP_ACK_DATA,
330 	TXMON_RESP_NDP_ACK,
331 	TXMON_RESP_NDP_MODIFIED_ACK,
332 	TXMON_RESP_NDP_BA,
333 	TXMON_RESP_NDP_CTS,
334 	TXMON_RESP_NDP_ACK_OR_NDP_MODIFIED_ACK,
335 	TXMON_RESP_UL_MU_BA,
336 	TXMON_RESP_UL_MU_BA_AND_DATA,
337 	TXMON_RESP_UL_MU_CBF,
338 	TXMON_RESP_UL_MU_FRAMES,
339 	TXMON_RESP_ANY_RESP_TO_DEVICE,
340 	TXMON_RESP_ANY_RESP_ACCEPTED,
341 	TXMON_RESP_FRAMELESS_PHYRX_RESP_ACCEPTED,
342 	TXMON_RESP_RANGING_NDP_AND_LMR,
343 	TXMON_RESP_BA_512,
344 	TXMON_RESP_BA_1024,
345 	TXMON_RESP_UL_MU_RANGING_CTS2S,
346 	TXMON_RESP_UL_MU_RANGING_NDP,
347 	TXMON_RESP_UL_MU_RANGING_LMR
348 };
349 
350 /**
351  * enum resposne_to_respone - tx monitor supported response to response type
352  * @TXMON_RESP_TO_RESP_NONE:
353  * @TXMON_RESP_TO_RESP_SU_BA:
354  * @TXMON_RESP_TO_RESP_MU_BA:
355  * @TXMON_RESP_TO_RESP_CMD:
356  */
357 enum resposne_to_respone {
358 	TXMON_RESP_TO_RESP_NONE = 0,
359 	TXMON_RESP_TO_RESP_SU_BA,
360 	TXMON_RESP_TO_RESP_MU_BA,
361 	TXMON_RESP_TO_RESP_CMD
362 };
363 
364 /**
365  * enum medium_protection_type - tx monitor supported protection type
366  * @TXMON_MEDIUM_NO_PROTECTION:
367  * @TXMON_MEDIUM_RTS_LEGACY:
368  * @TXMON_MEDIUM_RTS_11AC_STATIC_BW:
369  * @TXMON_MEDIUM_RTS_11AC_DYNAMIC_BW:
370  * @TXMON_MEDIUM_CTS2SELF:
371  * @TXMON_MEDIUM_QOS_NULL_NO_ACK_3ADDR:
372  * @TXMON_MEDIUM_QOS_NULL_NO_ACK_4ADDR:
373  */
374 enum medium_protection_type {
375 	TXMON_MEDIUM_NO_PROTECTION,
376 	TXMON_MEDIUM_RTS_LEGACY,
377 	TXMON_MEDIUM_RTS_11AC_STATIC_BW,
378 	TXMON_MEDIUM_RTS_11AC_DYNAMIC_BW,
379 	TXMON_MEDIUM_CTS2SELF,
380 	TXMON_MEDIUM_QOS_NULL_NO_ACK_3ADDR,
381 	TXMON_MEDIUM_QOS_NULL_NO_ACK_4ADDR,
382 };
383 
384 /**
385  * enum ndp_frame - tx monitor supported ndp frame type
386  * @TXMON_NO_NDP_TRANSMISSION:
387  * @TXMON_BEAMFORMING_NDP:
388  * @TXMON_HE_RANGING_NDP:
389  * @TXMON_HE_FEEDBACK_NDP:
390  */
391 enum ndp_frame {
392 	TXMON_NO_NDP_TRANSMISSION,
393 	TXMON_BEAMFORMING_NDP,
394 	TXMON_HE_RANGING_NDP,
395 	TXMON_HE_FEEDBACK_NDP,
396 };
397 
398 /**
399  * enum tx_ppdu_info_type - tx monitor supported ppdu type
400  * @TX_PROT_PPDU_INFO:
401  * @TX_DATA_PPDU_INFO:
402  */
403 enum tx_ppdu_info_type {
404 	TX_PROT_PPDU_INFO,
405 	TX_DATA_PPDU_INFO,
406 };
407 
408 /**
409  * struct dp_tx_ppdu_info - structure to store tx ppdu info
410  * @ppdu_id: current ppdu info ppdu id
411  * @frame_type: ppdu info frame type
412  * @cur_usr_idx: current user index of ppdu info
413  * @ulist: union of linked lists
414  * @tx_ppdu_info_dlist_elem: support adding to double linked list
415  * @tx_ppdu_info_slist_elem: support adding to single linked list
416  * @hal_txmon: hal tx monitor info for that ppdu
417  */
418 struct dp_tx_ppdu_info {
419 	uint32_t ppdu_id;
420 	uint8_t frame_type;
421 	uint8_t cur_usr_idx;
422 
423 	union {
424 		TAILQ_ENTRY(dp_tx_ppdu_info) tx_ppdu_info_dlist_elem;
425 		STAILQ_ENTRY(dp_tx_ppdu_info) tx_ppdu_info_slist_elem;
426 	} ulist;
427 
428 	#define tx_ppdu_info_list_elem ulist.tx_ppdu_info_dlist_elem
429 	#define tx_ppdu_info_queue_elem ulist.tx_ppdu_info_slist_elem
430 
431 	struct hal_tx_ppdu_info hal_txmon;
432 };
433 
434 /**
435  * struct dp_tx_monitor_drop_stats - structure to store tx monitor drop
436  *                                   statistics
437  * @ppdu_drop_cnt: ppdu drop counter
438  * @mpdu_drop_cnt: mpdu drop counter
439  * @tlv_drop_cnt: tlv drop counter
440  * @pkt_buf_recv: tx monitor packet buffer received
441  * @pkt_buf_free: tx monitor packet buffer free
442  * @pkt_buf_processed: tx monitor packet buffer processed
443  * @pkt_buf_to_stack: tx monitor packet buffer send to stack
444  * @status_buf_recv: tx monitor status buffer received
445  * @status_buf_free: tx monitor status buffer free
446  * @totat_tx_mon_replenish_cnt: tx monitor replenish count
447  * @total_tx_mon_reap_cnt: tx monitor reap count
448  * @tx_mon_stuck: tx monitor stuck count
449  * @total_tx_mon_stuck: tx monitor stuck count
450  * @ppdu_info_drop_th: count ppdu info been dropped due threshold reached
451  * @ppdu_info_drop_flush: count ppdu info been dropped due to flush detected
452  * @ppdu_info_drop_trunc: count ppdu info been dropped due to truncated
453  */
454 struct dp_tx_monitor_drop_stats {
455 	uint64_t ppdu_drop_cnt;
456 	uint64_t mpdu_drop_cnt;
457 	uint64_t tlv_drop_cnt;
458 
459 	uint64_t pkt_buf_recv;
460 	uint64_t pkt_buf_free;
461 	uint64_t pkt_buf_processed;
462 	uint64_t pkt_buf_to_stack;
463 
464 	uint64_t status_buf_recv;
465 	uint64_t status_buf_free;
466 
467 	uint64_t totat_tx_mon_replenish_cnt;
468 	uint64_t total_tx_mon_reap_cnt;
469 	uint8_t tx_mon_stuck;
470 	uint32_t total_tx_mon_stuck;
471 
472 	uint64_t ppdu_info_drop_th;
473 	uint64_t ppdu_info_drop_flush;
474 	uint64_t ppdu_info_drop_trunc;
475 };
476 
477 /**
478  * enum dp_tx_monitor_mode - tx monitor supported mode
479  * @TX_MON_BE_DISABLE: tx monitor disable
480  * @TX_MON_BE_FULL_CAPTURE: tx monitor mode to capture full packet
481  * @TX_MON_BE_PEER_FILTER: tx monitor mode to capture peer filter
482  */
483 enum dp_tx_monitor_mode {
484 	TX_MON_BE_DISABLE,
485 	TX_MON_BE_FULL_CAPTURE,
486 	TX_MON_BE_PEER_FILTER,
487 };
488 
489 /**
490  * enum dp_tx_monitor_framework_mode - tx monitor framework mode
491  * @TX_MON_BE_FRM_WRK_DISABLE: tx monitor frame work disable
492  * @TX_MON_BE_FRM_WRK_FULL_CAPTURE: tx monitor frame work full capture
493  * @TX_MON_BE_FRM_WRK_128B_CAPTURE: tx monitor frame work 128B capture
494  */
495 enum dp_tx_monitor_framework_mode {
496 	TX_MON_BE_FRM_WRK_DISABLE,
497 	TX_MON_BE_FRM_WRK_FULL_CAPTURE,
498 	TX_MON_BE_FRM_WRK_128B_CAPTURE,
499 };
500 
501 #define TX_TAILQ_INSERT_TAIL(pdev, tx_ppdu_info)			\
502 	do {								\
503 		STAILQ_INSERT_TAIL(&pdev->tx_ppdu_info_list,		\
504 				   tx_ppdu_info, tx_ppdu_info_list_elem);\
505 		pdev->tx_ppdu_info_queue_depth++;			\
506 	} while (0)
507 
508 #define TX_TAILQ_REMOVE(pdev, tx_ppdu_info)				\
509 	do {								\
510 		TAILQ_REMOVE(&pdev->tx_ppdu_info_list, tx_ppdu_info,	\
511 			     tx_ppdu_info_list_elem);			\
512 		pdev->tx_ppdu_info_queue_depth--;			\
513 	} while (0)
514 
515 #define TX_TAILQ_FIRST(pdev) TAILQ_FIRST(&pdev->tx_ppdu_info_list)
516 
517 #define TX_TAILQ_FOREACH_SAFE(pdev, tx_ppdu_info)			\
518 	do {								\
519 		struct dp_tx_ppdu_info *tx_ppdu_info_next = NULL;	\
520 		TAILQ_FOREACH_SAFE(tx_ppdu_info,			\
521 				   &pdev->tx_ppdu_info_list,		\
522 				   tx_ppdu_info_list_elem,		\
523 				   tx_ppdu_info_next);			\
524 	} while (0)
525 
526 #ifdef WLAN_TX_MON_CORE_DEBUG
527 /**
528  * struct dp_pdev_tx_monitor_be - info to store tx capture information in pdev
529  * @be_ppdu_id: current ppdu id
530  * @mode: tx monitor core framework current mode
531  * @stats: tx monitor drop stats for that mac
532  *
533  */
534 struct dp_pdev_tx_monitor_be {
535 	uint32_t be_ppdu_id;
536 	uint32_t mode;
537 	struct dp_tx_monitor_drop_stats stats;
538 };
539 
540 /**
541  * struct dp_peer_tx_capture_be - Tx monitor peer structure
542  *
543  * This is a dummy structure
544  */
545 struct dp_peer_tx_capture_be {
546 };
547 #endif
548 
549 #ifdef WLAN_TX_PKT_CAPTURE_ENH_BE
550 /**
551  * struct dp_txmon_frag_vec - a contiguous range of physical memory address
552  * @frag_buf: frag buffer address
553  * @end_offset: byte offset within the frag buffer where valid data resides
554  */
555 struct dp_txmon_frag_vec {
556 	qdf_frag_t frag_buf;
557 	uint32_t end_offset;
558 };
559 
560 /*
561  * NB: intentionally not using kernel-doc comment because the kernel-doc
562  *     script does not handle the STAILQ_HEAD macro
563  * struct dp_pdev_tx_monitor_be - info to store tx capture information in pdev
564  * @be_ppdu_id: current ppdu id
565  * @be_end_reason_bitmap: current end reason bitmap
566  * @mode: tx monitor current mode
567  * @tx_mon_list_lock: spinlock protection to list
568  * @post_ppdu_workqueue: tx monitor workqueue representation
569  * @post_ppdu_work: tx monitor post ppdu work
570  * @tx_ppdu_info_list_depth: list depth counter
571  * @tx_ppdu_info_list: ppdu info list to hold ppdu
572  * @defer_ppdu_info_list_depth: defer ppdu list depth counter
573  * @defer_ppdu_info_list: defer ppdu info list to hold defer ppdu
574  * @stats: tx monitor drop stats for that mac
575  * @tx_prot_ppdu_info: tx monitor protection ppdu info
576  * @tx_data_ppdu_info: tx monitor data ppdu info
577  * @last_prot_ppdu_info: last tx monitor protection ppdu info
578  * @last_data_ppdu_info: last tx monitor data ppdu info
579  * @prot_status_info: protection status info
580  * @data_status_info: data status info
581  * @last_tsft: last received tsft
582  * @last_ppdu_timestamp: last received ppdu_timestamp
583  * @last_frag_q_idx: last index of frag buffer
584  * @cur_frag_q_idx: current index of frag buffer
585  * @status_frag_queue: array of status frag queue to hold 64 status buffer
586  */
587 struct dp_pdev_tx_monitor_be {
588 	uint32_t be_ppdu_id;
589 	uint32_t be_end_reason_bitmap;
590 	uint32_t mode;
591 
592 	qdf_spinlock_t tx_mon_list_lock;
593 
594 	qdf_work_t post_ppdu_work;
595 	qdf_workqueue_t *post_ppdu_workqueue;
596 
597 	uint32_t tx_ppdu_info_list_depth;
598 
599 	STAILQ_HEAD(, dp_tx_ppdu_info) tx_ppdu_info_queue;
600 
601 	uint32_t defer_ppdu_info_list_depth;
602 
603 	STAILQ_HEAD(, dp_tx_ppdu_info) defer_tx_ppdu_info_queue;
604 
605 	struct dp_tx_monitor_drop_stats stats;
606 
607 	struct dp_tx_ppdu_info *tx_prot_ppdu_info;
608 	struct dp_tx_ppdu_info *tx_data_ppdu_info;
609 
610 	struct dp_tx_ppdu_info *last_prot_ppdu_info;
611 	struct dp_tx_ppdu_info *last_data_ppdu_info;
612 
613 	struct hal_tx_status_info prot_status_info;
614 	struct hal_tx_status_info data_status_info;
615 
616 	uint64_t last_tsft;
617 	uint32_t last_ppdu_timestamp;
618 
619 	uint8_t last_frag_q_idx;
620 	uint8_t cur_frag_q_idx;
621 	struct dp_txmon_frag_vec frag_q_vec[MAX_STATUS_BUFFER_IN_PPDU];
622 };
623 
624 /**
625  * struct dp_peer_tx_capture_be - Tx monitor peer structure
626  *
627  * need to be added here
628  */
629 struct dp_peer_tx_capture_be {
630 };
631 
632 /**
633  * dp_tx_mon_free_usr_mpduq() - API to free user mpduq
634  * @tx_ppdu_info: pointer to tx_ppdu_info
635  * @usr_idx: user index
636  * @tx_mon_be: pointer to tx monitor be
637  *
638  * Return: void
639  */
640 void dp_tx_mon_free_usr_mpduq(struct dp_tx_ppdu_info *tx_ppdu_info,
641 			      uint8_t usr_idx,
642 			      struct dp_pdev_tx_monitor_be *tx_mon_be);
643 
644 #endif /* WLAN_TX_PKT_CAPTURE_ENH_BE */
645 
646 /**
647  * dp_tx_mon_ppdu_info_free() - API to free dp_tx_ppdu_info
648  * @tx_ppdu_info: pointer to tx_ppdu_info
649  *
650  * Return: void
651  */
652 void dp_tx_mon_ppdu_info_free(struct dp_tx_ppdu_info *tx_ppdu_info);
653 
654 /**
655  * dp_tx_mon_free_ppdu_info() - API to free dp_tx_ppdu_info
656  * @tx_ppdu_info: pointer to tx_ppdu_info
657  * @tx_mon_be: pointer to tx monitor be
658  *
659  * Return: void
660  */
661 void dp_tx_mon_free_ppdu_info(struct dp_tx_ppdu_info *tx_ppdu_info,
662 			      struct dp_pdev_tx_monitor_be *tx_mon_be);
663 
664 /**
665  * dp_tx_mon_get_ppdu_info() - API to allocate dp_tx_ppdu_info
666  * @pdev: pdev handle
667  * @type: type of ppdu_info data or protection
668  * @num_user: number user in a ppdu_info
669  * @ppdu_id: ppdu_id number
670  *
671  * Return: pointer to dp_tx_ppdu_info
672  */
673 struct dp_tx_ppdu_info *dp_tx_mon_get_ppdu_info(struct dp_pdev *pdev,
674 						enum tx_ppdu_info_type type,
675 						uint8_t num_user,
676 						uint32_t ppdu_id);
677 
678 #endif /* WLAN_PKT_CAPTURE_TX_2_0 */
679 
680 #if (defined(WIFI_MONITOR_SUPPORT) && defined(WLAN_TX_PKT_CAPTURE_ENH_BE))
681 /**
682  * dp_config_enh_tx_monitor_2_0()- API to validate tx monitor feature
683  * @pdev: DP_PDEV handle
684  * @val: user provided value
685  *
686  * Return: QDF_STATUS
687  */
688 QDF_STATUS dp_config_enh_tx_monitor_2_0(struct dp_pdev *pdev, uint8_t val);
689 #endif
690 
691 #ifdef WLAN_TX_MON_CORE_DEBUG
692 /**
693  * dp_config_enh_tx_core_monitor_2_0()- API to validate core framework
694  * @pdev: DP_PDEV handle
695  * @val: user provided value
696  *
697  * Return: QDF_STATUS
698  */
699 QDF_STATUS dp_config_enh_tx_core_monitor_2_0(struct dp_pdev *pdev, uint8_t val);
700 #endif
701 
702 #ifdef WLAN_PKT_CAPTURE_TX_2_0
703 QDF_STATUS dp_tx_mon_pdev_htt_srng_setup_2_0(struct dp_soc *soc,
704 					     struct dp_pdev *pdev,
705 					     int mac_id,
706 					     int mac_for_pdev);
707 QDF_STATUS dp_tx_mon_soc_htt_srng_setup_2_0(struct dp_soc *soc,
708 					    int mac_id);
709 QDF_STATUS dp_tx_mon_pdev_rings_alloc_2_0(struct dp_pdev *pdev, uint32_t lmac_id);
710 void dp_tx_mon_pdev_rings_free_2_0(struct dp_pdev *pdev, uint32_t lmac_id);
711 QDF_STATUS dp_tx_mon_pdev_rings_init_2_0(struct dp_pdev *pdev, uint32_t lmac_id);
712 void dp_tx_mon_pdev_rings_deinit_2_0(struct dp_pdev *pdev, uint32_t lmac_id);
713 QDF_STATUS dp_tx_mon_soc_init_2_0(struct dp_soc *soc);
714 QDF_STATUS dp_tx_mon_soc_attach_2_0(struct dp_soc *soc, uint32_t lmac_id);
715 QDF_STATUS dp_tx_mon_soc_detach_2_0(struct dp_soc *soc, uint32_t lmac_id);
716 void dp_tx_mon_soc_deinit_2_0(struct dp_soc *soc, uint32_t lmac_id);
717 void dp_print_pdev_tx_monitor_stats_2_0(struct dp_pdev *pdev);
718 QDF_STATUS
719 dp_tx_mon_buffers_alloc(struct dp_soc *soc, uint32_t size);
720 void
721 dp_tx_mon_buffers_free(struct dp_soc *soc);
722 QDF_STATUS
723 dp_tx_mon_buf_desc_pool_alloc(struct dp_soc *soc);
724 void dp_tx_ppdu_stats_attach_2_0(struct dp_pdev *pdev);
725 QDF_STATUS dp_config_enh_tx_monitor_2_0(struct dp_pdev *pdev, uint8_t val);
726 QDF_STATUS dp_peer_set_tx_capture_enabled_2_0(struct dp_pdev *pdev_handle,
727 					      struct dp_peer *peer_handle,
728 					      uint8_t is_tx_pkt_cap_enable,
729 					      uint8_t *peer_mac);
730 void dp_tx_ppdu_stats_detach_2_0(struct dp_pdev *pdev);
731 #else
732 static inline
733 QDF_STATUS dp_tx_mon_pdev_htt_srng_setup_2_0(struct dp_soc *soc,
734 					     struct dp_pdev *pdev,
735 					     int mac_id,
736 					     int mac_for_pdev)
737 {
738 	return QDF_STATUS_SUCCESS;
739 }
740 
741 static inline
742 QDF_STATUS dp_tx_mon_soc_htt_srng_setup_2_0(struct dp_soc *soc,
743 					    int mac_id)
744 {
745 	return QDF_STATUS_SUCCESS;
746 }
747 
748 static inline
749 QDF_STATUS dp_tx_mon_pdev_rings_alloc_2_0(struct dp_pdev *pdev, uint32_t lmac_id)
750 {
751 	return QDF_STATUS_SUCCESS;
752 }
753 
754 static inline
755 void dp_tx_mon_pdev_rings_free_2_0(struct dp_pdev *pdev, uint32_t lmac_id)
756 {
757 }
758 
759 static inline
760 QDF_STATUS dp_tx_mon_pdev_rings_init_2_0(struct dp_pdev *pdev, uint32_t lmac_id)
761 {
762 	return QDF_STATUS_SUCCESS;
763 }
764 
765 static inline
766 void dp_tx_mon_pdev_rings_deinit_2_0(struct dp_pdev *pdev, uint32_t lmac_id)
767 {
768 }
769 
770 static inline
771 QDF_STATUS dp_tx_mon_soc_init_2_0(struct dp_soc *soc)
772 {
773 	return QDF_STATUS_SUCCESS;
774 }
775 
776 static inline
777 QDF_STATUS dp_tx_mon_soc_attach_2_0(struct dp_soc *soc, uint32_t lmac_id)
778 {
779 	return QDF_STATUS_SUCCESS;
780 }
781 
782 static inline
783 QDF_STATUS dp_tx_mon_soc_detach_2_0(struct dp_soc *soc, uint32_t lmac_id)
784 {
785 	return QDF_STATUS_SUCCESS;
786 }
787 
788 static inline
789 void dp_tx_mon_soc_deinit_2_0(struct dp_soc *soc, uint32_t lmac_id)
790 {
791 }
792 
793 static inline void
794 dp_print_pdev_tx_monitor_stats_2_0(struct dp_pdev *pdev)
795 {
796 }
797 
798 static inline QDF_STATUS
799 dp_tx_mon_buffers_alloc(struct dp_soc *soc, uint32_t size)
800 {
801 	return QDF_STATUS_SUCCESS;
802 }
803 
804 static inline void
805 dp_tx_mon_buffers_free(struct dp_soc *soc)
806 {
807 }
808 
809 static inline QDF_STATUS
810 dp_tx_mon_buf_desc_pool_alloc(struct dp_soc *soc)
811 {
812 	return QDF_STATUS_SUCCESS;
813 }
814 
815 static inline void
816 dp_tx_ppdu_stats_attach_2_0(struct dp_pdev *pdev)
817 {
818 }
819 
820 static inline QDF_STATUS
821 dp_config_enh_tx_monitor_2_0(struct dp_pdev *pdev, uint8_t val)
822 {
823 	return QDF_STATUS_SUCCESS;
824 }
825 
826 static inline QDF_STATUS
827 dp_peer_set_tx_capture_enabled_2_0(struct dp_pdev *pdev_handle,
828 				   struct dp_peer *peer_handle,
829 				   uint8_t is_tx_pkt_cap_enable,
830 				   uint8_t *peer_mac)
831 {
832 	return QDF_STATUS_SUCCESS;
833 }
834 
835 static inline void
836 dp_tx_ppdu_stats_detach_2_0(struct dp_pdev *pdev)
837 {
838 }
839 #endif
840 
841 #endif /* _DP_TX_MON_2_0_H_ */
842