xref: /wlan-driver/qca-wifi-host-cmn/dp/wifi3.0/monitor/2.0/dp_mon_2.0.h (revision 5113495b16420b49004c444715d2daae2066e7dc) !
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_MON_2_0_H_
19 #define _DP_MON_2_0_H_
20 
21 #if !defined(DISABLE_MON_CONFIG)
22 #include <qdf_lock.h>
23 #include <dp_types.h>
24 #include <dp_mon.h>
25 #include <dp_mon_filter.h>
26 #include <dp_htt.h>
27 #include <dp_mon.h>
28 #ifdef WLAN_PKT_CAPTURE_TX_2_0
29 #include <dp_tx_mon_2.0.h>
30 #endif
31 #define DP_MON_RING_FILL_LEVEL_DEFAULT 2048
32 #define DP_MON_DATA_BUFFER_SIZE     2048
33 #define DP_MON_DESC_MAGIC 0xdeadabcd
34 #define DP_MON_MAX_STATUS_BUF 1200
35 #define DP_MON_QUEUE_DEPTH_MAX 16
36 #define DP_MON_MSDU_LOGGING 0
37 #define DP_MON_MPDU_LOGGING 1
38 #define DP_MON_DESC_ADDR_MASK 0x000000FFFFFFFFFF
39 #define DP_MON_DESC_ADDR_SHIFT 40
40 #define DP_MON_DESC_FIXED_ADDR_MASK 0xFFFFFF
41 #define DP_MON_DESC_FIXED_ADDR ((uint64_t)DP_MON_DESC_FIXED_ADDR_MASK << \
42 	DP_MON_DESC_COOKIE_LSB)
43 #define DP_MON_DESC_COOKIE_MASK 0xFFFFFF0000000000
44 #define DP_MON_DESC_COOKIE_SHIFT 24
45 #define DP_MON_DESC_COOKIE_LSB 40
46 #define DP_MON_GET_COOKIE(mon_desc) \
47 	((uint32_t)(((unsigned long long)(mon_desc) & DP_MON_DESC_COOKIE_MASK) \
48 	>> DP_MON_DESC_COOKIE_LSB))
49 
50 #ifdef DP_RX_MON_DESC_64_BIT
51 #define  DP_MON_GET_DESC(mon_desc) \
52 	((struct dp_mon_desc *)(uintptr_t)(((unsigned long long)(mon_desc) & \
53 	DP_MON_DESC_ADDR_MASK) | ((unsigned long long)DP_MON_DESC_FIXED_ADDR)))
54 
55 #else
56 #define  DP_MON_GET_DESC(mon_desc) \
57 	((struct dp_mon_desc *)(uintptr_t)(((unsigned long)(mon_desc) & \
58 	DP_MON_DESC_ADDR_MASK)))
59 #endif
60 
61 #define DP_MON_DECAP_FORMAT_INVALID 0xff
62 #define DP_MON_MIN_FRAGS_FOR_RESTITCH 2
63 
64 #ifdef MONITOR_TLV_RECORDING_ENABLE
65 #define MONITOR_TLV_RECORDING_RX 1
66 #define MONITOR_TLV_RECORDING_TX 2
67 #define MONITOR_TLV_RECORDING_RXTX 3
68 
69 #define MAX_TLV_LOGGING_SIZE 1024
70 
71 #define MAX_PPDU_START_TLV_NUM 38
72 #define MAX_MPDU_TLV_NUM 160
73 #define MAX_PPDU_END_TLV_NUM 57
74 
75 #define MAX_NUM_PPDU_RECORD 4
76 #define MAX_TLVS_PER_PPDU 255
77 
78 /*
79  * struct dp_mon_tlv_info - recorded information of each TLV
80  * @tlv_tag: tlv tag
81  * @data: union of struct of fields to be recorded for each TLV
82  *
83  * Tag and its corresponding important fields are stored in this struct
84  */
85 struct dp_mon_tlv_info {
86 	uint32_t tlv_tag:10;
87 	union {
88 		struct hal_ppdu_start_tlv_record ppdu_start;
89 		struct hal_ppdu_start_user_info_tlv_record  ppdu_start_user_info;
90 		struct hal_mpdu_start_tlv_record mpdu_start;
91 		struct hal_mpdu_end_tlv_record mpdu_end;
92 		struct hal_header_tlv_record header;
93 		struct hal_msdu_end_tlv_record msdu_end;
94 		struct hal_mon_buffer_addr_tlv_record mon_buffer_addr;
95 		struct hal_phy_location_tlv_record phy_location;
96 		struct hal_ppdu_end_user_stats_tlv_record ppdu_end_user_stats;
97 		struct hal_pcu_ppdu_end_info_tlv_record pcu_ppdu_end_info;
98 		struct hal_phy_rx_ht_sig_tlv_record phy_rx_ht_sig;
99 		uint32_t data:22;
100 	} data;
101 };
102 
103 /*
104  * struct dp_tx_mon_tlv_info - recorded information of each Tx TLV
105  * @tlv_tag: tlv tag
106  * @data: union of struct of fields to be recorded for each TLV
107  *
108  * Tag and its corresponding important fields are stored in this struct
109  */
110 
111 struct dp_tx_mon_tlv_info {
112 	uint32_t tlv_tag:10;
113 	union {
114 		/*struct of Tx TLVs to be added here*/
115 		uint32_t data:22;
116 	} data;
117 };
118 
119 /**
120  * struct dp_mon_tlv_logger - contains indexes and other data of the buffer
121  * @buff: buffer in which TLVs are stored
122  * @curr_ppdu_pos: position of the next ppdu to be written
123  * @ppdu_start_idx: starting index form which PPDU start level TLVs are stored for a ppdu
124  * @mpdu_idx: starting index form which MPDU TLVs are stored for a ppdu
125  * @ppdu_end_idx: starting index form which PPDU end level TLVs are stored for a ppdu
126  * @max_ppdu_start_idx: ending index for PPDU start level TLVs for a ppdu
127  * @max_mpdu_idx: ending index for MPDU level TLVs for a ppdu
128  * @max_ppdu_end_idx: ending index for PPDU end level TLVs for a ppdu
129  * @wrap_flag: flag toggle between consecutive PPDU
130  * @tlv_logging_enable: check is tlv logging is enabled
131  *
132  */
133 struct dp_mon_tlv_logger {
134 	void *buff;
135 	uint16_t curr_ppdu_pos;
136 	uint16_t ppdu_start_idx;
137 	uint16_t mpdu_idx;
138 	uint16_t ppdu_end_idx;
139 	uint16_t max_ppdu_start_idx;
140 	uint16_t max_ppdu_end_idx;
141 	uint16_t max_mpdu_idx;
142 	uint8_t wrap_flag;
143 	bool tlv_logging_enable;
144 };
145 #endif
146 
147 /* monitor frame filter modes */
148 enum dp_mon_frm_filter_mode {
149 	/* mode filter pass */
150 	DP_MON_FRM_FILTER_MODE_FP = 0,
151 	/* mode monitor direct */
152 	DP_MON_FRM_FILTER_MODE_MD = 1,
153 	/* mode monitor other */
154 	DP_MON_FRM_FILTER_MODE_MO = 2,
155 	/* mode filter pass monitor other */
156 	DP_MON_FRM_FILTER_MODE_FP_MO = 3,
157 };
158 
159 /* mpdu filter categories */
160 enum dp_mpdu_filter_category {
161 	/* category filter pass */
162 	DP_MPDU_FILTER_CATEGORY_FP = 0,
163 	/* category monitor direct */
164 	DP_MPDU_FILTER_CATEGORY_MD = 1,
165 	/* category monitor other */
166 	DP_MPDU_FILTER_CATEGORY_MO = 2,
167 	/* category filter pass monitor override */
168 	DP_MPDU_FILTER_CATEGORY_FP_MO = 3,
169 };
170 
171 /**
172  * struct dp_mon_filter_be - Monitor TLV filter
173  * @rx_tlv_filter: Rx MON TLV filter
174  * @tx_tlv_filter: Tx MON TLV filter
175  * @tx_valid: enable/disable Tx Mon TLV filter
176  */
177 struct dp_mon_filter_be {
178 	struct dp_mon_filter rx_tlv_filter;
179 #ifdef WLAN_PKT_CAPTURE_TX_2_0
180 	struct htt_tx_ring_tlv_filter tx_tlv_filter;
181 #endif
182 	bool tx_valid;
183 };
184 
185 /**
186  * struct dp_mon_desc
187  *
188  * @buf_addr: virtual address
189  * @paddr: physical address
190  * @in_use: desc is in use
191  * @unmapped: used to mark desc an unmapped if the corresponding
192  * nbuf is already unmapped
193  * @cookie_2: unique cookie provided as part of 64 bit cookie to HW
194  * @end_offset: offset in status buffer where DMA ended
195  * @cookie: unique desc identifier
196  * @magic: magic number to validate desc data
197  */
198 struct dp_mon_desc {
199 	uint8_t *buf_addr;
200 	qdf_dma_addr_t paddr;
201 	uint32_t in_use:1,
202 		unmapped:1,
203 		cookie_2:24;
204 	uint16_t end_offset;
205 	uint32_t cookie;
206 	uint32_t magic;
207 };
208 
209 /**
210  * struct dp_mon_desc_list_elem_t
211  * @next: Next pointer to form free list
212  * @mon_desc: DP mon descriptor
213  */
214 union dp_mon_desc_list_elem_t {
215 	union dp_mon_desc_list_elem_t *next;
216 	struct dp_mon_desc mon_desc;
217 };
218 
219 /**
220  * struct dp_mon_desc_pool - monitor desc pool
221  * @pool_size: number of descriptor in the pool
222  * @array: pointer to array of descriptor
223  * @freelist: pointer to free descriptor list
224  * @lock: Protection for the descriptor pool
225  * @owner: owner for nbuf
226  * @buf_size: Buffer size
227  * @buf_alignment: Buffer alignment
228  * @pf_cache: page frag cache
229  */
230 struct dp_mon_desc_pool {
231 	uint32_t pool_size;
232 	union dp_mon_desc_list_elem_t *array;
233 	union dp_mon_desc_list_elem_t *freelist;
234 	qdf_spinlock_t lock;
235 	uint8_t owner;
236 	uint16_t buf_size;
237 	uint8_t buf_alignment;
238 	qdf_frag_cache_t pf_cache;
239 };
240 
241 /*
242  * NB: intentionally not using kernel-doc comment because the kernel-doc
243  *     script does not handle the TAILQ_HEAD macro
244  * struct dp_mon_pdev_be - BE specific monitor pdev object
245  * @mon_pdev: monitor pdev structure
246  * @filter_be: filters sent to fw
247  * @tx_mon_mode: tx monitor mode
248  * @tx_mon_filter_length: tx monitor filter length
249  * @tx_monitor_be: pointer to tx monitor be structure
250  * @tx_stats: tx monitor drop stats
251  * @rx_mon_wq_lock: Rx mon workqueue lock
252  * @rx_mon_workqueue: Rx mon workqueue
253  * @rx_mon_work: Rx mon work
254  * @rx_mon_queue: RxMON queue
255  * @rx_mon_free_queue: RxMON ppdu info free element queue
256  * @ppdu_info_lock: RxPPDU ppdu info queue lock
257  * @rx_mon_queue_depth: RxMON queue depth
258  * @ppdu_info_cache: PPDU info cache
259  * @desc_count: reaped status desc count
260  * @status: reaped status buffer per ppdu
261  * @lite_mon_rx_config: rx litemon config
262  * @lite_mon_tx_config: tx litemon config
263  * @prev_rxmon_desc: prev destination desc
264  * @prev_rxmon_cookie: prev rxmon cookie
265  * @prev_rxmon_pkt_desc: prev packet buff desc
266  * @prev_rxmon_pkt_cookie: prev packet buff desc cookie
267  * @total_free_elem: total free element in queue
268  * @rx_tlv_logger: Rx TLV logger struct
269  */
270 struct dp_mon_pdev_be {
271 	struct dp_mon_pdev mon_pdev;
272 	struct dp_mon_filter_be **filter_be;
273 #ifdef WLAN_PKT_CAPTURE_TX_2_0
274 	uint8_t tx_mon_mode;
275 	uint8_t tx_mon_filter_length;
276 	struct dp_pdev_tx_monitor_be tx_monitor_be;
277 	struct dp_tx_monitor_drop_stats tx_stats;
278 #endif
279 #if defined(WLAN_PKT_CAPTURE_RX_2_0) && defined(QCA_MONITOR_2_0_PKT_SUPPORT)
280 	qdf_spinlock_t rx_mon_wq_lock;
281 	qdf_workqueue_t *rx_mon_workqueue;
282 	qdf_work_t rx_mon_work;
283 
284 	TAILQ_HEAD(, hal_rx_ppdu_info) rx_mon_queue;
285 	TAILQ_HEAD(, hal_rx_ppdu_info) rx_mon_free_queue;
286 	qdf_spinlock_t ppdu_info_lock;
287 	qdf_kmem_cache_t ppdu_info_cache;
288 #endif
289 	uint16_t rx_mon_queue_depth;
290 	uint16_t desc_count;
291 	struct dp_mon_desc *status[DP_MON_MAX_STATUS_BUF];
292 #ifdef QCA_SUPPORT_LITE_MONITOR
293 	struct dp_lite_mon_rx_config *lite_mon_rx_config;
294 	struct dp_lite_mon_tx_config *lite_mon_tx_config;
295 #endif
296 	void *prev_rxmon_desc;
297 	uint32_t prev_rxmon_cookie;
298 	void *prev_rxmon_pkt_desc;
299 	uint32_t prev_rxmon_pkt_cookie;
300 	uint32_t total_free_elem;
301 #ifdef MONITOR_TLV_RECORDING_ENABLE
302 	struct dp_mon_tlv_logger *rx_tlv_log;
303 	struct dp_mon_tlv_logger *tx_tlv_log;
304 #endif
305 };
306 
307 /**
308  * struct dp_mon_soc_be - BE specific monitor soc
309  * @mon_soc: Monitor soc structure
310  * @tx_mon_buf_ring: TxMon replenish ring
311  * @tx_mon_dst_ring: TxMon Destination ring
312  * @tx_desc_mon: descriptor pool for tx mon src ring
313  * @rx_desc_mon: descriptor pool for rx mon src ring
314  * @rx_mon_ring_fill_level: rx mon ring refill level
315  * @tx_mon_ring_fill_level: tx mon ring refill level
316  * @tx_low_thresh_intrs: number of tx mon low threshold interrupts received
317  * @rx_low_thresh_intrs: number of rx mon low threshold interrupts received
318  * @is_dp_mon_soc_initialized: flag to indicate soc is initialized
319  */
320 struct dp_mon_soc_be {
321 	struct dp_mon_soc mon_soc;
322 	/* Source ring for Tx monitor */
323 	struct dp_srng tx_mon_buf_ring;
324 	struct dp_srng tx_mon_dst_ring[MAX_NUM_LMAC_HW];
325 
326 	/* Sw descriptor pool for tx mon source ring */
327 	struct dp_mon_desc_pool tx_desc_mon;
328 	/* Sw descriptor pool for rx mon source ring */
329 	struct dp_mon_desc_pool rx_desc_mon;
330 
331 	uint16_t rx_mon_ring_fill_level;
332 	uint16_t tx_mon_ring_fill_level;
333 	uint32_t tx_low_thresh_intrs;
334 	uint32_t rx_low_thresh_intrs;
335 
336 	bool is_dp_mon_soc_initialized;
337 };
338 #endif
339 
340 /**
341  * dp_mon_desc_pool_init() - Monitor descriptor pool init
342  * @mon_desc_pool: mon desc pool
343  * @pool_size: Pool size
344  *
345  * Return: non-zero for failure, zero for success
346  */
347 QDF_STATUS
348 dp_mon_desc_pool_init(struct dp_mon_desc_pool *mon_desc_pool,
349 		      uint32_t pool_size);
350 
351 /**
352  * dp_mon_desc_pool_deinit()- monitor descriptor pool deinit
353  * @mon_desc_pool: mon desc pool
354  *
355  * Return: None
356  *
357  */
358 void dp_mon_desc_pool_deinit(struct dp_mon_desc_pool *mon_desc_pool);
359 
360 /**
361  * dp_mon_desc_pool_free()- monitor descriptor pool free
362  * @soc: DP soc handle
363  * @mon_desc_pool: mon desc pool
364  * @ctx_type: DP context type
365  *
366  * Return: None
367  *
368  */
369 void dp_mon_desc_pool_free(struct dp_soc *soc,
370 			   struct dp_mon_desc_pool *mon_desc_pool,
371 			   enum dp_ctxt_type ctx_type);
372 
373 /**
374  * dp_mon_desc_pool_alloc() - Monitor descriptor pool alloc
375  * @soc: DP soc handle
376  * @ctx_type: DP context type
377  * @pool_size: Pool size
378  * @mon_desc_pool: mon desc pool
379  *
380  * Return: non-zero for failure, zero for success
381  */
382 QDF_STATUS dp_mon_desc_pool_alloc(struct dp_soc *soc,
383 				  enum dp_ctxt_type ctx_type,
384 				  uint32_t pool_size,
385 				  struct dp_mon_desc_pool *mon_desc_pool);
386 
387 /**
388  * dp_mon_pool_frag_unmap_and_free() - free the mon desc frag called during
389  *			    de-initialization of wifi module.
390  *
391  * @dp_soc: DP soc handle
392  * @mon_desc_pool: monitor descriptor pool pointer
393  *
394  * Return: None
395  */
396 void dp_mon_pool_frag_unmap_and_free(struct dp_soc *dp_soc,
397 				     struct dp_mon_desc_pool *mon_desc_pool);
398 
399 /**
400  * dp_mon_buffers_replenish() - replenish monitor ring with nbufs
401  *
402  * @dp_soc: core txrx main context
403  * @dp_mon_srng: dp monitor circular ring
404  * @mon_desc_pool: Pointer to free mon descriptor pool
405  * @num_req_buffers: number of buffer to be replenished
406  * @desc_list: list of descs if called from dp_rx_process
407  *	       or NULL during dp rx initialization or out of buffer
408  *	       interrupt.
409  * @tail: tail of descs list
410  * @replenish_cnt_ref: pointer to update replenish_cnt
411  *
412  * Return: return success or failure
413  */
414 QDF_STATUS dp_mon_buffers_replenish(struct dp_soc *dp_soc,
415 				struct dp_srng *dp_mon_srng,
416 				struct dp_mon_desc_pool *mon_desc_pool,
417 				uint32_t num_req_buffers,
418 				union dp_mon_desc_list_elem_t **desc_list,
419 				union dp_mon_desc_list_elem_t **tail,
420 				uint32_t *replenish_cnt_ref);
421 
422 /**
423  * dp_mon_filter_show_tx_filter_be() - Show the set filters
424  * @mode: The filter modes
425  * @filter: tlv filter
426  */
427 void dp_mon_filter_show_tx_filter_be(enum dp_mon_filter_mode mode,
428 				     struct dp_mon_filter_be *filter);
429 
430 /**
431  * dp_mon_filter_show_rx_filter_be() - Show the set filters
432  * @mode: The filter modes
433  * @filter: tlv filter
434  */
435 void dp_mon_filter_show_rx_filter_be(enum dp_mon_filter_mode mode,
436 				     struct dp_mon_filter_be *filter);
437 
438 /**
439  * dp_vdev_set_monitor_mode_buf_rings_tx_2_0() - Add buffers to tx ring
440  * @pdev: Pointer to dp_pdev object
441  * @num_of_buffers: Number of buffers to allocate
442  *
443  * Return: QDF_STATUS
444  */
445 QDF_STATUS dp_vdev_set_monitor_mode_buf_rings_tx_2_0(struct dp_pdev *pdev,
446 						     uint16_t num_of_buffers);
447 
448 /**
449  * dp_vdev_set_monitor_mode_buf_rings_rx_2_0() - Add buffers to rx ring
450  * @pdev: Pointer to dp_pdev object
451  *
452  * Return: QDF_STATUS
453  */
454 QDF_STATUS dp_vdev_set_monitor_mode_buf_rings_rx_2_0(struct dp_pdev *pdev);
455 
456 #ifdef QCA_ENHANCED_STATS_SUPPORT
457 /**
458  * dp_mon_get_puncture_type() - Get puncture type
459  * @puncture_pattern: puncture bitmap
460  * @bw: Bandwidth
461  */
462 enum cdp_punctured_modes
463 dp_mon_get_puncture_type(uint16_t puncture_pattern, uint8_t bw);
464 #endif
465 
466 /**
467  * dp_mon_desc_get() - get monitor sw descriptor
468  *
469  * @cookie: cookie
470  *
471  * Return: dp_mon_desc
472  */
473 static inline
dp_mon_desc_get(uint64_t * cookie)474 struct dp_mon_desc *dp_mon_desc_get(uint64_t *cookie)
475 {
476 	return (struct dp_mon_desc *)cookie;
477 }
478 
479 /**
480  * __dp_mon_add_to_free_desc_list() - Adds to a local free descriptor list
481  *
482  * @head: pointer to the head of local free list
483  * @tail: pointer to the tail of local free list
484  * @new: new descriptor that is added to the free list
485  * @func_name: caller func name
486  *
487  * Return: void
488  */
489 static inline
__dp_mon_add_to_free_desc_list(union dp_mon_desc_list_elem_t ** head,union dp_mon_desc_list_elem_t ** tail,struct dp_mon_desc * new,const char * func_name)490 void __dp_mon_add_to_free_desc_list(union dp_mon_desc_list_elem_t **head,
491 				    union dp_mon_desc_list_elem_t **tail,
492 				    struct dp_mon_desc *new,
493 				    const char *func_name)
494 {
495 	if (!(head && new))
496 		return;
497 
498 	new->buf_addr = NULL;
499 	new->in_use = 0;
500 
501 	((union dp_mon_desc_list_elem_t *)new)->next = *head;
502 	*head = (union dp_mon_desc_list_elem_t *)new;
503 	 /* reset tail if head->next is NULL */
504 	if (!*tail || !(*head)->next)
505 		*tail = *head;
506 }
507 
508 #define dp_mon_add_to_free_desc_list(head, tail, new) \
509 	__dp_mon_add_to_free_desc_list(head, tail, new, __func__)
510 
511 /**
512  * dp_mon_add_desc_list_to_free_list() - append unused desc_list back to
513  * freelist.
514  *
515  * @soc: core txrx main context
516  * @local_desc_list: local desc list provided by the caller
517  * @tail: attach the point to last desc of local desc list
518  * @mon_desc_pool: monitor descriptor pool pointer
519  */
520 
521 void
522 dp_mon_add_desc_list_to_free_list(struct dp_soc *soc,
523 				  union dp_mon_desc_list_elem_t **local_desc_list,
524 				  union dp_mon_desc_list_elem_t **tail,
525 				  struct dp_mon_desc_pool *mon_desc_pool);
526 
527 /**
528  * dp_rx_mon_add_frag_to_skb() - Add page frag to skb
529  *
530  * @ppdu_info: PPDU status info
531  * @nbuf: SKB to which frag need to be added
532  * @status_frag: Frag to add
533  *
534  * Return: void
535  */
536 static inline void
dp_rx_mon_add_frag_to_skb(struct hal_rx_ppdu_info * ppdu_info,qdf_nbuf_t nbuf,qdf_frag_t status_frag)537 dp_rx_mon_add_frag_to_skb(struct hal_rx_ppdu_info *ppdu_info,
538 			  qdf_nbuf_t nbuf,
539 			  qdf_frag_t status_frag)
540 {
541 	uint16_t num_frags;
542 
543 	num_frags = qdf_nbuf_get_nr_frags(nbuf);
544 	if (num_frags < QDF_NBUF_MAX_FRAGS) {
545 		qdf_nbuf_add_rx_frag(status_frag, nbuf,
546 				     ppdu_info->data - (unsigned char *)status_frag,
547 				     ppdu_info->hdr_len,
548 				     RX_MONITOR_BUFFER_SIZE,
549 				     false);
550 	} else {
551 		dp_mon_err("num_frags exceeding MAX frags");
552 		qdf_assert_always(0);
553 	}
554 }
555 
556 #if !defined(DISABLE_MON_CONFIG) && (defined(WLAN_PKT_CAPTURE_TX_2_0) || \
557 	defined(WLAN_PKT_CAPTURE_RX_2_0))
558 /**
559  * dp_mon_get_context_size_be() - get BE specific size for mon pdev/soc
560  * @context_type: context type for which the size is needed
561  *
562  * Return: size in bytes for the context_type
563  */
564 static inline
dp_mon_get_context_size_be(enum dp_context_type context_type)565 qdf_size_t dp_mon_get_context_size_be(enum dp_context_type context_type)
566 {
567 	switch (context_type) {
568 	case DP_CONTEXT_TYPE_MON_SOC:
569 		return sizeof(struct dp_mon_soc_be);
570 	case DP_CONTEXT_TYPE_MON_PDEV:
571 		return sizeof(struct dp_mon_pdev_be);
572 	default:
573 		return 0;
574 	}
575 }
576 #endif
577 
578 /**
579  * dp_get_be_mon_soc_from_dp_mon_soc() - get dp_mon_soc_be from dp_mon_soc
580  * @soc: dp_mon_soc pointer
581  *
582  * Return: dp_mon_soc_be pointer
583  */
584 static inline
dp_get_be_mon_soc_from_dp_mon_soc(struct dp_mon_soc * soc)585 struct dp_mon_soc_be *dp_get_be_mon_soc_from_dp_mon_soc(struct dp_mon_soc *soc)
586 {
587 	return (struct dp_mon_soc_be *)soc;
588 }
589 
590 /**
591  * dp_get_be_mon_pdev_from_dp_mon_pdev() - get dp_mon_pdev_be from dp_mon_pdev
592  * @mon_pdev: dp_mon_pdev pointer
593  *
594  * Return: dp_mon_pdev_be pointer
595  */
596 static inline
dp_get_be_mon_pdev_from_dp_mon_pdev(struct dp_mon_pdev * mon_pdev)597 struct dp_mon_pdev_be *dp_get_be_mon_pdev_from_dp_mon_pdev(struct dp_mon_pdev *mon_pdev)
598 {
599 	return (struct dp_mon_pdev_be *)mon_pdev;
600 }
601 
602 #ifdef QCA_ENHANCED_STATS_SUPPORT
603 /*
604  * dp_enable_enhanced_stats_2_0() - BE Wrapper to enable stats
605  * @soc: Datapath soc handle
606  * @pdev_id: Pdev Id on which stats will get enable
607  *
608  * Return: status success/failure
609  */
610 QDF_STATUS
611 dp_enable_enhanced_stats_2_0(struct cdp_soc_t *soc, uint8_t pdev_id);
612 
613 /*
614  * dp_disable_enhanced_stats_2_0() - BE Wrapper to disable stats
615  * @soc: Datapath soc handle
616  * @pdev_id: Pdev Id on which stats will get disable
617  *
618  * Return: status success/failure
619  */
620 QDF_STATUS
621 dp_disable_enhanced_stats_2_0(struct cdp_soc_t *soc, uint8_t pdev_id);
622 #endif /* QCA_ENHANCED_STATS_SUPPORT */
623 
624 #ifdef WLAN_PKT_CAPTURE_RX_2_0
625 static inline unsigned long long
dp_mon_get_debug_desc_addr(union dp_mon_desc_list_elem_t ** desc_list)626 dp_mon_get_debug_desc_addr(union dp_mon_desc_list_elem_t **desc_list)
627 {
628 	unsigned long long desc;
629 
630 	desc = (unsigned long)&((*desc_list)->mon_desc);
631 	desc = (unsigned long long)((unsigned long long)desc & DP_MON_DESC_ADDR_MASK);
632 	desc = (desc | ((unsigned long long)(*desc_list)->mon_desc.cookie_2 << DP_MON_DESC_ADDR_SHIFT));
633 	return desc;
634 }
635 #else
636 static inline unsigned long long
dp_mon_get_debug_desc_addr(union dp_mon_desc_list_elem_t ** desc_list)637 dp_mon_get_debug_desc_addr(union dp_mon_desc_list_elem_t **desc_list)
638 {
639 	unsigned long long desc = (unsigned long long)&((*desc_list)->mon_desc);
640 	return desc;
641 }
642 #endif
643 #endif /* _DP_MON_2_0_H_ */
644