1 /*
2  * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2024 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_H_
19 #define _DP_MON_H_
20 
21 #include "qdf_trace.h"
22 #include "dp_internal.h"
23 #include "dp_types.h"
24 #include "dp_htt.h"
25 #include "dp_rx_mon.h"
26 
27 #include <dp_mon_filter.h>
28 #ifdef WLAN_TX_PKT_CAPTURE_ENH
29 #include "dp_tx_capture.h"
30 #endif
31 
32 #ifdef QCA_SUPPORT_LITE_MONITOR
33 #include "dp_lite_mon.h"
34 #endif
35 
36 #define DP_INTR_POLL_TIMER_MS	5
37 #define DP_HIST_TRACK_SIZE 50
38 
39 #define MON_VDEV_TIMER_INIT 0x1
40 #define MON_VDEV_TIMER_RUNNING 0x2
41 
42 /* Budget to reap monitor status ring */
43 #define DP_MON_REAP_BUDGET 1024
44 #define MON_BUF_MIN_ENTRIES 64
45 
46 /* 40MHZ BW 2 20MHZ sub bands */
47 #define SUB40BW 2
48 /* 80MHZ BW 4 20MHZ sub bands */
49 #define SUB80BW 4
50 /* 160MHZ BW 8 20MHZ sub bands */
51 #define SUB160BW 8
52 /* 320MHZ BW 16 20MHZ sub bands */
53 #define SUB320BW 16
54 
55 #define RNG_ERR		"SRNG setup failed for"
56 #define dp_mon_info(params...) \
57 	__QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_MON, ## params)
58 #define dp_mon_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_MON, params)
59 #define dp_mon_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_MON, params)
60 #define dp_mon_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_MON, params)
61 
62 #define dp_mon_warn_rl(params...) QDF_TRACE_WARN_RL(QDF_MODULE_ID_MON, params)
63 #define dp_mon_debug_rl(params...) QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_MON, params)
64 #define dp_mon_info_rl(params...) \
65 	__QDF_TRACE_RL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_MON, ## params)
66 
67 #ifdef WLAN_FEATURE_LOCAL_PKT_CAPTURE
68 #define IS_LOCAL_PKT_CAPTURE_RUNNING(var, field) ((var)->field)
69 #else
70 #define IS_LOCAL_PKT_CAPTURE_RUNNING(var, field) 0
71 #endif
72 
73 #ifdef QCA_ENHANCED_STATS_SUPPORT
74 typedef struct dp_peer_extd_tx_stats dp_mon_peer_tx_stats;
75 typedef struct dp_peer_extd_rx_stats dp_mon_peer_rx_stats;
76 
77 #define DP_UPDATE_MON_STATS(_tgtobj, _srcobj) \
78 	DP_UPDATE_EXTD_STATS(_tgtobj, _srcobj)
79 #endif
80 
81 #ifndef WLAN_TX_PKT_CAPTURE_ENH
82 struct dp_pdev_tx_capture {
83 };
84 
85 struct dp_peer_tx_capture {
86 };
87 #endif
88 
89 /**
90  * struct ieee80211_ctlframe_addr2 - control frame addr
91  * @i_fc: frame control
92  * @i_aidordur: aid or duration
93  * @i_addr1: address 1
94  * @i_addr2: address 2
95  */
96 struct ieee80211_ctlframe_addr2 {
97 	uint8_t i_fc[2];
98 	uint8_t i_aidordur[2];
99 	uint8_t i_addr1[QDF_NET_MAC_ADDR_MAX_LEN];
100 	uint8_t i_addr2[QDF_NET_MAC_ADDR_MAX_LEN];
101 } __packed;
102 
103 #ifndef WLAN_TX_PKT_CAPTURE_ENH
104 static inline void
dp_process_ppdu_stats_update_failed_bitmap(struct dp_pdev * pdev,void * data,uint32_t ppdu_id,uint32_t size)105 dp_process_ppdu_stats_update_failed_bitmap(struct dp_pdev *pdev,
106 					   void *data,
107 					   uint32_t ppdu_id,
108 					   uint32_t size)
109 {
110 }
111 #endif
112 
113 #ifdef DP_CON_MON_MSI_ENABLED
dp_is_monitor_mode_using_poll(struct dp_soc * soc)114 static inline bool dp_is_monitor_mode_using_poll(struct dp_soc *soc)
115 {
116 	return false;
117 }
118 #else
dp_is_monitor_mode_using_poll(struct dp_soc * soc)119 static inline bool dp_is_monitor_mode_using_poll(struct dp_soc *soc)
120 {
121 	return true;
122 }
123 #endif
124 
125 /**
126  * dp_mon_soc_attach() - DP monitor soc attach
127  * @soc: Datapath SOC handle
128  *
129  * Return: QDF_STATUS_SUCCESS: Success
130  *         QDF_STATUS_E_NOMEM: Error
131  */
132 QDF_STATUS dp_mon_soc_attach(struct dp_soc *soc);
133 
134 /**
135  * dp_mon_soc_detach() - DP monitor soc detach
136  * @soc: Datapath SOC handle
137  *
138  * Return: QDF_STATUS_SUCCESS: Success
139  *         QDF_STATUS_E_FAILURE: Error
140  */
141 QDF_STATUS dp_mon_soc_detach(struct dp_soc *soc);
142 
143 /**
144  * dp_mon_soc_cfg_init() - DP monitor soc config init
145  * @soc: Datapath SOC handle
146  *
147  * Return: QDF_STATUS_SUCCESS: Success
148  *         QDF_STATUS_E_FAILURE: Error
149  */
150 QDF_STATUS dp_mon_soc_cfg_init(struct dp_soc *soc);
151 
152 /**
153  * dp_mon_pdev_attach() - DP monitor pdev attach
154  * @pdev: Datapath pdev handle
155  *
156  * Return: QDF_STATUS_SUCCESS: Success
157  *         QDF_STATUS_E_NOMEM: Error
158  */
159 QDF_STATUS dp_mon_pdev_attach(struct dp_pdev *pdev);
160 
161 /**
162  * dp_mon_pdev_detach() - DP monitor pdev detach
163  * @pdev: Datapath pdev handle
164  *
165  * Return: QDF_STATUS_SUCCESS: Success
166  *         QDF_STATUS_E_FAILURE: Error
167  */
168 QDF_STATUS dp_mon_pdev_detach(struct dp_pdev *pdev);
169 
170 /**
171  * dp_mon_pdev_init() - DP monitor pdev init
172  * @pdev: Datapath pdev handle
173  *
174  * Return: QDF_STATUS_SUCCESS: Success
175  *         QDF_STATUS_E_FAILURE: Error
176  */
177 QDF_STATUS dp_mon_pdev_init(struct dp_pdev *pdev);
178 
179 /**
180  * dp_mon_pdev_deinit() - DP monitor pdev deinit
181  * @pdev: Datapath pdev handle
182  *
183  * Return: QDF_STATUS_SUCCESS: Success
184  *         QDF_STATUS_E_FAILURE: Error
185  */
186 QDF_STATUS dp_mon_pdev_deinit(struct dp_pdev *pdev);
187 
188 /**
189  * dp_mon_vdev_attach() - DP monitor vdev attach
190  * @vdev: Datapath vdev handle
191  *
192  * Return: QDF_STATUS_SUCCESS: Success
193  *         QDF_STATUS_E_NOMEM: Error
194  */
195 QDF_STATUS dp_mon_vdev_attach(struct dp_vdev *vdev);
196 
197 /**
198  * dp_mon_vdev_detach() - DP monitor vdev detach
199  * @vdev: Datapath vdev handle
200  *
201  * Return: QDF_STATUS_SUCCESS: Success
202  *         QDF_STATUS_E_FAILURE: Error
203  */
204 QDF_STATUS dp_mon_vdev_detach(struct dp_vdev *vdev);
205 
206 /**
207  * dp_mon_peer_attach() - DP monitor peer attach
208  * @peer: Datapath peer handle
209  *
210  * Return: QDF_STATUS_SUCCESS: Success
211  *         QDF_STATUS_E_NOMEM: Error
212  */
213 #if defined(WLAN_TX_PKT_CAPTURE_ENH) || defined(FEATURE_PERPKT_INFO)
214 QDF_STATUS dp_mon_peer_attach(struct dp_peer *peer);
215 #else
216 static inline
dp_mon_peer_attach(struct dp_peer * peer)217 QDF_STATUS dp_mon_peer_attach(struct dp_peer *peer)
218 {
219 	return QDF_STATUS_SUCCESS;
220 }
221 #endif
222 
223 /**
224  * dp_mon_peer_detach() - DP monitor peer detach
225  * @peer: Datapath peer handle
226  *
227  * Return: QDF_STATUS_SUCCESS: Success
228  *         QDF_STATUS_E_FAILURE: Error
229  */
230 QDF_STATUS dp_mon_peer_detach(struct dp_peer *peer);
231 
232 /**
233  * dp_mon_peer_get_peerstats_ctx() - Get peer stats context from monitor peer
234  * @peer: Datapath peer handle
235  *
236  * Return: peerstats_ctx
237  */
238 struct cdp_peer_rate_stats_ctx *dp_mon_peer_get_peerstats_ctx(struct
239 							      dp_peer *peer);
240 
241 #ifdef QCA_ENHANCED_STATS_SUPPORT
242 /**
243  * dp_mon_peer_reset_stats() - Reset monitor peer stats
244  * @peer: Datapath peer handle
245  *
246  * Return: none
247  */
248 void dp_mon_peer_reset_stats(struct dp_peer *peer);
249 
250 /**
251  * dp_mon_peer_get_stats() - Get monitor peer stats
252  *
253  * @peer: Datapath peer handle
254  * @arg: Pointer to stats struct
255  * @type: Update type
256  *
257  * Return: none
258  */
259 void dp_mon_peer_get_stats(struct dp_peer *peer, void *arg,
260 			   enum cdp_stat_update_type type);
261 
262 /**
263  * dp_mon_invalid_peer_update_pdev_stats() - Update pdev stats from
264  *					invalid monitor peer
265  * @pdev: Datapath pdev handle
266  *
267  * Return: none
268  */
269 void dp_mon_invalid_peer_update_pdev_stats(struct dp_pdev *pdev);
270 
271 /**
272  * dp_mon_peer_get_stats_param() - Get stats param value from monitor peer
273  * @peer: Datapath peer handle
274  * @type: Stats type requested
275  * @buf: Pointer to buffer for stats param
276  *
277  * Return: QDF_STATUS
278  */
279 QDF_STATUS dp_mon_peer_get_stats_param(struct dp_peer *peer,
280 				       enum cdp_peer_stats_type type,
281 				       cdp_peer_stats_param_t *buf);
282 #else
dp_mon_peer_reset_stats(struct dp_peer * peer)283 static inline void dp_mon_peer_reset_stats(struct dp_peer *peer)
284 {
285 }
286 
287 static inline
dp_mon_peer_get_stats(struct dp_peer * peer,void * arg,enum cdp_stat_update_type type)288 void dp_mon_peer_get_stats(struct dp_peer *peer, void *arg,
289 			   enum cdp_stat_update_type type)
290 {
291 }
292 
dp_mon_invalid_peer_update_pdev_stats(struct dp_pdev * pdev)293 static inline void dp_mon_invalid_peer_update_pdev_stats(struct dp_pdev *pdev)
294 {
295 }
296 
297 static inline
dp_mon_peer_get_stats_param(struct dp_peer * peer,enum cdp_peer_stats_type type,cdp_peer_stats_param_t * buf)298 QDF_STATUS dp_mon_peer_get_stats_param(struct dp_peer *peer,
299 				       enum cdp_peer_stats_type type,
300 				       cdp_peer_stats_param_t *buf)
301 {
302 	return QDF_STATUS_E_FAILURE;
303 }
304 #endif
305 
306 /**
307  * dp_mon_cdp_ops_register() - Register monitor cdp ops
308  * @soc: Datapath soc handle
309  *
310  */
311 void dp_mon_cdp_ops_register(struct dp_soc *soc);
312 
313 /**
314  * dp_mon_cdp_ops_deregister() - deregister monitor cdp ops
315  * @soc: Datapath soc handle
316  *
317  */
318 void dp_mon_cdp_ops_deregister(struct dp_soc *soc);
319 
320 /**
321  * dp_mon_intr_ops_deregister() - deregister monitor interrupt ops
322  * @soc: Datapath soc handle
323  *
324  */
325 void dp_mon_intr_ops_deregister(struct dp_soc *soc);
326 
327 /**
328  * dp_mon_feature_ops_deregister() - deregister monitor feature ops
329  * @soc: Datapath soc handle
330  *
331  */
332 void dp_mon_feature_ops_deregister(struct dp_soc *soc);
333 
334 /**
335  * dp_mon_ops_free() - free monitor ops
336  * @soc: Datapath soc handle
337  *
338  */
339 void dp_mon_ops_free(struct dp_soc *soc);
340 
341 /**
342  * dp_mon_ops_register() - Register monitor ops
343  * @soc: Datapath soc handle
344  *
345  */
346 void dp_mon_ops_register(struct dp_soc *soc);
347 
348 #ifndef DISABLE_MON_CONFIG
349 void dp_mon_register_intr_ops(struct dp_soc *soc);
350 #else
dp_mon_register_intr_ops(struct dp_soc * soc)351 static inline void dp_mon_register_intr_ops(struct dp_soc *soc)
352 {}
353 #endif
354 
355 /**
356  * dp_mon_htt_srng_setup() - DP mon htt srng setup
357  * @soc: Datapath soc handle
358  * @pdev: Datapath pdev handle
359  * @mac_id: mac id
360  * @mac_for_pdev: mac id mapped pdev
361  *
362  * Return: QDF_STATUS_SUCCESS: Success
363  *         QDF_STATUS_E_FAILURE: Error
364  */
365 QDF_STATUS dp_mon_htt_srng_setup(struct dp_soc *soc,
366 				 struct dp_pdev *pdev,
367 				 int mac_id,
368 				 int mac_for_pdev);
369 
370 /**
371  * dp_config_debug_sniffer()- API to enable/disable debug sniffer
372  * @pdev: DP_PDEV handle
373  * @val: user provided value
374  *
375  * Return: 0 for success. nonzero for failure.
376  */
377 #if defined(QCA_MCOPY_SUPPORT) || defined(QCA_TX_CAPTURE_SUPPORT)
378 QDF_STATUS
379 dp_config_debug_sniffer(struct dp_pdev *pdev, int val);
380 #else
381 static inline QDF_STATUS
dp_config_debug_sniffer(struct dp_pdev * pdev,int val)382 dp_config_debug_sniffer(struct dp_pdev *pdev, int val) {
383 	return QDF_STATUS_E_INVAL;
384 }
385 #endif /* QCA_MCOPY_SUPPORT || QCA_TX_CAPTURE_SUPPORT */
386 
387 /**
388  * dp_mon_config_undecoded_metadata_capture()- API to enable/disable undecoded
389  *                                             metadata capture
390  * @pdev: DP_PDEV handle
391  * @val: user provided value
392  *
393  * Return: 0 for success. nonzero for failure.
394  */
395 #ifdef QCA_UNDECODED_METADATA_SUPPORT
396 QDF_STATUS
397 dp_mon_config_undecoded_metadata_capture(struct dp_pdev *pdev, int val);
398 #else
399 static inline QDF_STATUS
dp_mon_config_undecoded_metadata_capture(struct dp_pdev * pdev,int val)400 dp_mon_config_undecoded_metadata_capture(struct dp_pdev *pdev, int val) {
401 	return QDF_STATUS_E_INVAL;
402 }
403 #endif /* QCA_UNDECODED_METADATA_SUPPORT */
404 
405 /**
406  * dp_htt_ppdu_stats_attach() - attach resources for HTT PPDU stats processing
407  * @pdev: Datapath PDEV handle
408  *
409  * Return: QDF_STATUS_SUCCESS: Success
410  *         QDF_STATUS_E_NOMEM: Error
411  */
412 QDF_STATUS dp_htt_ppdu_stats_attach(struct dp_pdev *pdev);
413 
414 /**
415  * dp_htt_ppdu_stats_detach() - detach stats resources
416  * @pdev: Datapath PDEV handle
417  *
418  * Return: void
419  */
420 void dp_htt_ppdu_stats_detach(struct dp_pdev *pdev);
421 
422 /**
423  * dp_set_bpr_enable() - API to enable/disable bpr feature
424  * @pdev: DP_PDEV handle.
425  * @val: Provided value.
426  *
427  * Return: 0 for success. nonzero for failure.
428  */
429 #ifdef QCA_SUPPORT_BPR
430 QDF_STATUS
431 dp_set_bpr_enable(struct dp_pdev *pdev, int val);
432 #endif
433 
434 #ifdef ATH_SUPPORT_NAC
435 int dp_set_filter_neigh_peers(struct dp_pdev *pdev,
436 				     bool val);
437 #endif /* ATH_SUPPORT_NAC */
438 
439 #ifdef WLAN_ATF_ENABLE
440 void dp_set_atf_stats_enable(struct dp_pdev *pdev, bool value);
441 #endif
442 
443 /**
444  * dp_mon_set_bsscolor() - sets bsscolor for tx capture
445  * @pdev: Datapath PDEV handle
446  * @bsscolor: new bsscolor
447  */
448 void
449 dp_mon_set_bsscolor(struct dp_pdev *pdev, uint8_t bsscolor);
450 
451 /**
452  * dp_pdev_get_filter_ucast_data() - get DP PDEV monitor ucast filter
453  * @pdev_handle: Datapath PDEV handle
454  *
455  * Return: true on ucast filter flag set
456  */
457 bool dp_pdev_get_filter_ucast_data(struct cdp_pdev *pdev_handle);
458 
459 /**
460  * dp_pdev_get_filter_mcast_data() - get DP PDEV monitor mcast filter
461  * @pdev_handle: Datapath PDEV handle
462  *
463  * Return: true on mcast filter flag set
464  */
465 bool dp_pdev_get_filter_mcast_data(struct cdp_pdev *pdev_handle);
466 
467 /**
468  * dp_pdev_get_filter_non_data() - get DP PDEV monitor non_data filter
469  * @pdev_handle: Datapath PDEV handle
470  *
471  * Return: true on non data filter flag set
472  */
473 bool dp_pdev_get_filter_non_data(struct cdp_pdev *pdev_handle);
474 
475 /**
476  * dp_set_pktlog_wifi3() - attach txrx vdev
477  * @pdev: Datapath PDEV handle
478  * @event: which event's notifications are being subscribed to
479  * @enable: WDI event subscribe or not. (True or False)
480  *
481  * Return: Success, NULL on failure
482  */
483 #ifdef WDI_EVENT_ENABLE
484 int dp_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event,
485 			bool enable);
486 #endif
487 
488 /* MCL specific functions */
489 #if defined(DP_CON_MON) && !defined(REMOVE_PKT_LOG)
490 /**
491  * dp_pktlogmod_exit() - API to cleanup pktlog info
492  * @pdev: Pdev handle
493  *
494  * Return: none
495  */
496 void dp_pktlogmod_exit(struct dp_pdev *pdev);
497 #else
498 static inline
dp_pktlogmod_exit(struct dp_pdev * handle)499 void dp_pktlogmod_exit(struct dp_pdev *handle)
500 {
501 }
502 #endif
503 
504 #ifdef QCA_MONITOR_PKT_SUPPORT
505 /**
506  * dp_vdev_set_monitor_mode_buf_rings() - set monitor mode buf rings
507  * @pdev: DP pdev object
508  *
509  * Allocate SW descriptor pool, buffers, link descriptor memory
510  * Initialize monitor related SRNGs
511  *
512  * Return: QDF_STATUS
513  */
514 QDF_STATUS dp_vdev_set_monitor_mode_buf_rings(struct dp_pdev *pdev);
515 
516 /**
517  * dp_vdev_set_monitor_mode_rings() - set monitor mode rings
518  * @pdev: DP pdev object
519  * @delayed_replenish:
520  *
521  * Allocate SW descriptor pool, buffers, link descriptor memory
522  * Initialize monitor related SRNGs
523  *
524  * Return: QDF_STATUS
525  */
526 QDF_STATUS dp_vdev_set_monitor_mode_rings(struct dp_pdev *pdev,
527 					  uint8_t delayed_replenish);
528 
529 #else
530 static inline QDF_STATUS
dp_vdev_set_monitor_mode_buf_rings(struct dp_pdev * pdev)531 dp_vdev_set_monitor_mode_buf_rings(struct dp_pdev *pdev)
532 {
533 	return QDF_STATUS_SUCCESS;
534 }
535 
536 static inline QDF_STATUS
dp_vdev_set_monitor_mode_rings(struct dp_pdev * pdev,uint8_t delayed_replenish)537 dp_vdev_set_monitor_mode_rings(struct dp_pdev *pdev,
538 			       uint8_t delayed_replenish)
539 {
540 	return QDF_STATUS_SUCCESS;
541 }
542 #endif
543 
544 #if defined(WDI_EVENT_ENABLE) &&\
545 	(defined(QCA_ENHANCED_STATS_SUPPORT) || !defined(REMOVE_PKT_LOG) ||\
546 	 defined(WLAN_FEATURE_PKT_CAPTURE_V2))
547 /**
548  * dp_ppdu_stats_ind_handler() - PPDU stats msg handler
549  * @soc:	 HTT SOC handle
550  * @msg_word:    Pointer to payload
551  * @htt_t2h_msg: HTT msg nbuf
552  *
553  * Return: True if buffer should be freed by caller.
554  */
555 bool dp_ppdu_stats_ind_handler(struct htt_soc *soc,
556 			       uint32_t *msg_word,
557 			       qdf_nbuf_t htt_t2h_msg);
558 #endif
559 
560 #if defined(QCA_ENHANCED_STATS_SUPPORT) || \
561 	(!defined(WLAN_TX_PKT_CAPTURE_ENH) || defined(WLAN_PKT_CAPTURE_TX_2_0))
562 /**
563  * dp_ppdu_desc_deliver(): Function to deliver Tx PPDU status descriptor
564  * to upper layer
565  * @pdev: DP pdev handle
566  * @ppdu_info: per PPDU TLV descriptor
567  *
568  * return: void
569  */
570 void dp_ppdu_desc_deliver(struct dp_pdev *pdev, struct ppdu_info *ppdu_info);
571 #endif
572 
573 #ifdef QCA_RSSI_DB2DBM
574 /**
575  * dp_mon_pdev_params_rssi_dbm_conv() --> to set rssi in dbm conversion
576  *						params into monitor pdev.
577  * @cdp_soc: dp soc handle.
578  * @params: cdp_rssi_db2dbm_param_dp structure value.
579  *
580  * Return: QDF_STATUS_SUCCESS if value set successfully
581  *         QDF_STATUS_E_INVAL false if error
582  */
583 QDF_STATUS
584 dp_mon_pdev_params_rssi_dbm_conv(struct cdp_soc_t *cdp_soc,
585 				 struct cdp_rssi_db2dbm_param_dp *params);
586 #else
587 static inline QDF_STATUS
dp_mon_pdev_params_rssi_dbm_conv(struct cdp_soc_t * cdp_soc,struct cdp_rssi_db2dbm_param_dp * params)588 dp_mon_pdev_params_rssi_dbm_conv(struct cdp_soc_t *cdp_soc,
589 				 struct cdp_rssi_db2dbm_param_dp *params)
590 {
591 	return QDF_STATUS_E_INVAL;
592 }
593 #endif /* QCA_RSSI_DB2DBM */
594 
595 #if !defined(DISABLE_MON_CONFIG)
596 typedef	QDF_STATUS (*mon_pdev_htt_srng_setup_fp)(struct dp_soc *soc,
597 						 struct dp_pdev *pdev,
598 						 int mac_id,
599 						 int mac_for_pdev);
600 #endif
601 typedef	QDF_STATUS (*mon_rings_alloc_fp)(struct dp_pdev *pdev);
602 typedef	void (*mon_rings_free_fp)(struct dp_pdev *pdev);
603 typedef	QDF_STATUS (*mon_rings_init_fp)(struct dp_pdev *pdev);
604 typedef	void (*mon_rings_deinit_fp)(struct dp_pdev *pdev);
605 typedef	QDF_STATUS (*mon_soc_attach_fp)(struct dp_soc *soc);
606 typedef	QDF_STATUS (*mon_soc_detach_fp)(struct dp_soc *soc);
607 typedef	QDF_STATUS (*mon_soc_init_fp)(struct dp_soc *soc);
608 typedef	void (*mon_soc_deinit_fp)(struct dp_soc *soc);
609 
610 struct dp_mon_ops {
611 	QDF_STATUS (*mon_soc_cfg_init)(struct dp_soc *soc);
612 	mon_soc_attach_fp mon_soc_attach[2];
613 	mon_soc_detach_fp mon_soc_detach[2];
614 	mon_soc_init_fp mon_soc_init[2];
615 	mon_soc_deinit_fp mon_soc_deinit[2];
616 	QDF_STATUS (*mon_pdev_alloc)(struct dp_pdev *pdev);
617 	void (*mon_pdev_free)(struct dp_pdev *pdev);
618 	QDF_STATUS (*mon_pdev_attach)(struct dp_pdev *pdev);
619 	QDF_STATUS (*mon_pdev_detach)(struct dp_pdev *pdev);
620 	QDF_STATUS (*mon_pdev_init)(struct dp_pdev *pdev);
621 	QDF_STATUS (*mon_pdev_deinit)(struct dp_pdev *pdev);
622 	QDF_STATUS (*mon_vdev_attach)(struct dp_vdev *vdev);
623 	QDF_STATUS (*mon_vdev_detach)(struct dp_vdev *vdev);
624 	QDF_STATUS (*mon_peer_attach)(struct dp_peer *peer);
625 	QDF_STATUS (*mon_peer_detach)(struct dp_peer *peer);
626 	struct cdp_peer_rate_stats_ctx *(*mon_peer_get_peerstats_ctx)(struct
627 								dp_peer *peer);
628 	void (*mon_peer_reset_stats)(struct dp_peer *peer);
629 	void (*mon_peer_get_stats)(struct dp_peer *peer, void *arg,
630 				   enum cdp_stat_update_type type);
631 	void (*mon_invalid_peer_update_pdev_stats)(struct dp_pdev *pdev);
632 	QDF_STATUS (*mon_peer_get_stats_param)(struct dp_peer *peer,
633 					       enum cdp_peer_stats_type type,
634 					       cdp_peer_stats_param_t *buf);
635 	QDF_STATUS (*mon_config_debug_sniffer)(struct dp_pdev *pdev, int val);
636 	void (*mon_flush_rings)(struct dp_soc *soc);
637 #if !defined(DISABLE_MON_CONFIG)
638 	mon_pdev_htt_srng_setup_fp mon_pdev_htt_srng_setup[2];
639 	QDF_STATUS (*mon_soc_htt_srng_setup)(struct dp_soc *soc);
640 #endif
641 #if !defined(DISABLE_MON_CONFIG) && defined(MON_ENABLE_DROP_FOR_MAC)
642 	uint32_t (*mon_drop_packets_for_mac)(struct dp_pdev *pdev,
643 					     uint32_t mac_id,
644 					     uint32_t quota,
645 					     bool force_flush);
646 #endif
647 #if defined(DP_CON_MON)
648 	void (*mon_service_rings)(struct  dp_soc *soc, uint32_t quota);
649 #endif
650 #ifndef DISABLE_MON_CONFIG
651 	uint32_t (*mon_rx_process)(struct dp_soc *soc,
652 				   struct dp_intr *int_ctx,
653 				   uint32_t mac_id,
654 				   uint32_t quota);
655 	uint32_t (*mon_tx_process)(struct dp_soc *soc,
656 				   struct dp_intr *int_ctx,
657 				   uint32_t mac_id,
658 				   uint32_t quota);
659 	void (*print_txmon_ring_stat)(struct dp_pdev *pdev);
660 #endif
661 	void (*mon_peer_tx_init)(struct dp_pdev *pdev, struct dp_peer *peer);
662 	void (*mon_peer_tx_cleanup)(struct dp_vdev *vdev,
663 				    struct dp_peer *peer);
664 #ifdef WIFI_MONITOR_SUPPORT
665 	void (*mon_peer_tid_peer_id_update)(struct dp_peer *peer,
666 					    uint16_t peer_id);
667 	void (*mon_tx_ppdu_stats_attach)(struct dp_pdev *pdev);
668 	void (*mon_tx_ppdu_stats_detach)(struct dp_pdev *pdev);
669 	QDF_STATUS (*mon_tx_capture_debugfs_init)(struct dp_pdev *pdev);
670 	void (*mon_peer_tx_capture_filter_check)(struct dp_pdev *pdev,
671 						 struct dp_peer *peer);
672 	QDF_STATUS (*mon_tx_add_to_comp_queue)(struct dp_soc *soc,
673 					       struct dp_tx_desc_s *desc,
674 					       struct hal_tx_completion_status *ts,
675 					       uint16_t peer_id);
676 	QDF_STATUS (*mon_update_msdu_to_list)(struct dp_soc *soc,
677 					      struct dp_pdev *pdev,
678 					      struct dp_peer *peer,
679 					      struct hal_tx_completion_status *ts,
680 					      qdf_nbuf_t netbuf);
681 	QDF_STATUS
682 	(*mon_peer_tx_capture_get_stats)(struct dp_peer *peer,
683 					 struct cdp_peer_tx_capture_stats *sts);
684 	QDF_STATUS
685 	(*mon_pdev_tx_capture_get_stats)(struct dp_pdev *pdev,
686 					 struct cdp_pdev_tx_capture_stats *sts);
687 #endif
688 #if defined(WDI_EVENT_ENABLE) &&\
689 	(defined(QCA_ENHANCED_STATS_SUPPORT) || !defined(REMOVE_PKT_LOG) ||\
690 	 defined(WLAN_FEATURE_PKT_CAPTURE_V2))
691 	bool (*mon_ppdu_stats_ind_handler)(struct htt_soc *soc,
692 					   uint32_t *msg_word,
693 					   qdf_nbuf_t htt_t2h_msg);
694 #endif
695 	QDF_STATUS (*mon_htt_ppdu_stats_attach)(struct dp_pdev *pdev);
696 	void (*mon_htt_ppdu_stats_detach)(struct dp_pdev *pdev);
697 	void (*mon_print_pdev_rx_mon_stats)(struct dp_pdev *pdev);
698 
699 #ifdef WIFI_MONITOR_SUPPORT
700 	void (*mon_print_pdev_tx_capture_stats)(struct dp_pdev *pdev);
701 	QDF_STATUS (*mon_config_enh_tx_capture)(struct dp_pdev *pdev,
702 						uint8_t val);
703 	QDF_STATUS (*mon_tx_peer_filter)(struct dp_pdev *pdev_handle,
704 					 struct dp_peer *peer_handle,
705 					 uint8_t is_tx_pkt_cap_enable,
706 					 uint8_t *peer_mac);
707 #endif
708 #ifdef WLAN_RX_PKT_CAPTURE_ENH
709 	QDF_STATUS (*mon_config_enh_rx_capture)(struct dp_pdev *pdev,
710 						uint8_t val);
711 #endif
712 #ifdef QCA_SUPPORT_BPR
713 	QDF_STATUS (*mon_set_bpr_enable)(struct dp_pdev *pdev, int val);
714 #endif
715 #ifdef ATH_SUPPORT_NAC
716 	int (*mon_set_filter_neigh_peers)(struct dp_pdev *pdev, bool val);
717 #endif
718 #ifdef WLAN_ATF_ENABLE
719 	void (*mon_set_atf_stats_enable)(struct dp_pdev *pdev, bool value);
720 #endif
721 	void (*mon_set_bsscolor)(struct dp_pdev *pdev, uint8_t bsscolor);
722 	bool (*mon_pdev_get_filter_ucast_data)(struct cdp_pdev *pdev_handle);
723 	bool (*mon_pdev_get_filter_non_data)(struct cdp_pdev *pdev_handle);
724 	bool (*mon_pdev_get_filter_mcast_data)(struct cdp_pdev *pdev_handle);
725 #ifdef WDI_EVENT_ENABLE
726 	int (*mon_set_pktlog_wifi3)(struct dp_pdev *pdev, uint32_t event,
727 				    bool enable);
728 #endif
729 #if defined(DP_CON_MON) && !defined(REMOVE_PKT_LOG)
730 	void (*mon_pktlogmod_exit)(struct dp_pdev *pdev);
731 #endif
732 	QDF_STATUS (*mon_vdev_set_monitor_mode_buf_rings)(struct dp_pdev *pdev);
733 	QDF_STATUS (*mon_vdev_set_monitor_mode_rings)(struct dp_pdev *pdev,
734 						      uint8_t delayed_replenish);
735 	void (*mon_neighbour_peers_detach)(struct dp_pdev *pdev);
736 #ifdef FEATURE_NAC_RSSI
737 	QDF_STATUS (*mon_filter_neighbour_peer)(struct dp_pdev *pdev,
738 						uint8_t *rx_pkt_hdr);
739 #endif
740 	void (*mon_vdev_timer_init)(struct dp_soc *soc);
741 	void (*mon_vdev_timer_start)(struct dp_soc *soc);
742 	bool (*mon_vdev_timer_stop)(struct dp_soc *soc);
743 	void (*mon_vdev_timer_deinit)(struct dp_soc *soc);
744 	void (*mon_reap_timer_init)(struct dp_soc *soc);
745 	bool (*mon_reap_timer_start)(struct dp_soc *soc,
746 				     enum cdp_mon_reap_source source);
747 	bool (*mon_reap_timer_stop)(struct dp_soc *soc,
748 				    enum cdp_mon_reap_source source);
749 	void (*mon_reap_timer_deinit)(struct dp_soc *soc);
750 #ifdef QCA_MCOPY_SUPPORT
751 	QDF_STATUS (*mon_mcopy_check_deliver)(struct dp_pdev *pdev,
752 					      uint16_t peer_id,
753 					      uint32_t ppdu_id,
754 					      uint8_t first_msdu);
755 #endif
756 	void (*mon_neighbour_peer_add_ast)(struct dp_pdev *pdev,
757 					   struct dp_peer *ta_peer,
758 					   uint8_t *mac_addr,
759 					   qdf_nbuf_t nbuf,
760 					   uint32_t flags);
761 #ifdef QCA_ENHANCED_STATS_SUPPORT
762 	void (*mon_filter_setup_enhanced_stats)(struct dp_pdev *pdev);
763 	void (*mon_filter_reset_enhanced_stats)(struct dp_pdev *pdev);
764 	void (*mon_tx_stats_update)(struct dp_mon_peer *mon_peer,
765 				    struct cdp_tx_completion_ppdu_user *ppdu);
766 	void (*mon_tx_enable_enhanced_stats)(struct dp_pdev *pdev);
767 	void (*mon_tx_disable_enhanced_stats)(struct dp_pdev *pdev);
768 	void (*mon_ppdu_desc_deliver)(struct dp_pdev *pdev,
769 				      struct ppdu_info *ppdu_info);
770 	bool (*mon_ppdu_stats_feat_enable_check)(struct dp_pdev *pdev);
771 	void (*mon_ppdu_desc_notify)(struct dp_pdev *pdev, qdf_nbuf_t nbuf);
772 #endif
773 #ifdef QCA_MCOPY_SUPPORT
774 	void (*mon_filter_setup_mcopy_mode)(struct dp_pdev *pdev);
775 	void (*mon_filter_reset_mcopy_mode)(struct dp_pdev *pdev);
776 #endif
777 #if defined(ATH_SUPPORT_NAC_RSSI) || defined(ATH_SUPPORT_NAC)
778 	void (*mon_filter_setup_smart_monitor)(struct dp_pdev *pdev);
779 	void (*mon_filter_reset_smart_monitor)(struct dp_pdev *pdev);
780 #endif
781 	void (*mon_filter_set_reset_mon_mac_filter)(struct dp_pdev *pdev,
782 						    bool val);
783 #ifdef WLAN_RX_PKT_CAPTURE_ENH
784 	void (*mon_filter_setup_rx_enh_capture)(struct dp_pdev *pdev);
785 	void (*mon_filter_reset_rx_enh_capture)(struct dp_pdev *pdev);
786 #endif
787 	void (*mon_filter_setup_rx_mon_mode)(struct dp_pdev *pdev);
788 	void (*mon_filter_reset_rx_mon_mode)(struct dp_pdev *pdev);
789 	void (*mon_filter_setup_tx_mon_mode)(struct dp_pdev *pdev);
790 	void (*mon_filter_reset_tx_mon_mode)(struct dp_pdev *pdev);
791 #ifdef WDI_EVENT_ENABLE
792 	void (*mon_filter_setup_rx_pkt_log_full)(struct dp_pdev *pdev);
793 	void (*mon_filter_reset_rx_pkt_log_full)(struct dp_pdev *pdev);
794 	void (*mon_filter_setup_rx_pkt_log_lite)(struct dp_pdev *pdev);
795 	void (*mon_filter_reset_rx_pkt_log_lite)(struct dp_pdev *pdev);
796 	void (*mon_filter_setup_rx_pkt_log_cbf)(struct dp_pdev *pdev);
797 	void (*mon_filter_reset_rx_pkt_log_cbf)(struct dp_pdev *pdev);
798 #ifdef BE_PKTLOG_SUPPORT
799 	void (*mon_filter_setup_pktlog_hybrid)(struct dp_pdev *pdev);
800 	void (*mon_filter_reset_pktlog_hybrid)(struct dp_pdev *pdev);
801 #endif
802 #endif
803 	QDF_STATUS (*rx_mon_filter_update)(struct dp_pdev *pdev);
804 	QDF_STATUS (*tx_mon_filter_update)(struct dp_pdev *pdev);
805 	QDF_STATUS (*set_mon_mode_buf_rings_tx)(struct dp_pdev *pdev,
806 						uint16_t num_buf);
807 
808 	QDF_STATUS (*tx_mon_filter_alloc)(struct dp_pdev *pdev);
809 	void (*tx_mon_filter_dealloc)(struct dp_pdev *pdev);
810 	mon_rings_alloc_fp mon_rings_alloc[2];
811 	mon_rings_free_fp mon_rings_free[2];
812 	mon_rings_init_fp mon_rings_init[2];
813 	mon_rings_deinit_fp mon_rings_deinit[2];
814 
815 	QDF_STATUS (*rx_mon_buffers_alloc)(struct dp_pdev *pdev);
816 	void (*rx_mon_buffers_free)(struct dp_pdev *pdev);
817 	void (*rx_mon_desc_pool_init)(struct dp_pdev *pdev);
818 	void (*rx_mon_desc_pool_deinit)(struct dp_pdev *pdev);
819 	QDF_STATUS (*rx_mon_desc_pool_alloc)(struct dp_pdev *pdev);
820 	void (*rx_mon_desc_pool_free)(struct dp_pdev *pdev);
821 	void (*tx_mon_desc_pool_init)(struct dp_pdev *pdev);
822 	void (*tx_mon_desc_pool_deinit)(struct dp_pdev *pdev);
823 	QDF_STATUS (*tx_mon_desc_pool_alloc)(struct dp_pdev *pdev);
824 	void (*tx_mon_desc_pool_free)(struct dp_pdev *pdev);
825 	void (*rx_mon_enable)(uint32_t *msg_word,
826 			      struct htt_rx_ring_tlv_filter *tlv_filter);
827 	void (*rx_hdr_length_set)(uint32_t *msg_word,
828 				  struct htt_rx_ring_tlv_filter *tlv_filter);
829 	void (*rx_packet_length_set)(uint32_t *msg_word,
830 				     struct htt_rx_ring_tlv_filter *tlv_filter);
831 	void (*rx_wmask_subscribe)(struct dp_soc *soc,
832 				   uint32_t *msg_word, int pdev_id,
833 				   struct htt_rx_ring_tlv_filter *tlv_filter);
834 	void (*rx_pkt_tlv_offset)(uint32_t *msg_word,
835 				  struct htt_rx_ring_tlv_filter *tlv_filter);
836 	void (*rx_enable_mpdu_logging)(uint32_t *msg_word,
837 				       struct htt_rx_ring_tlv_filter *tlv_filter);
838 	void (*rx_enable_fpmo)(uint32_t *msg_word,
839 			       struct htt_rx_ring_tlv_filter *tlv_filter);
840 #ifndef DISABLE_MON_CONFIG
841 	void (*mon_register_intr_ops)(struct dp_soc *soc);
842 #endif
843 	void (*mon_register_feature_ops)(struct dp_soc *soc);
844 #ifdef QCA_ENHANCED_STATS_SUPPORT
845 	void (*mon_rx_stats_update)(struct dp_mon_peer *mon_peer,
846 				    struct cdp_rx_indication_ppdu *ppdu,
847 				    struct cdp_rx_stats_ppdu_user *ppdu_user);
848 	void (*mon_rx_populate_ppdu_usr_info)(struct mon_rx_user_status *rx_user_status,
849 					      struct cdp_rx_stats_ppdu_user *ppdu_user);
850 	void (*mon_rx_populate_ppdu_info)(struct hal_rx_ppdu_info *hal_ppdu_info,
851 					  struct cdp_rx_indication_ppdu *ppdu);
852 #endif
853 	QDF_STATUS (*rx_mon_refill_buf_ring)(struct dp_intr *int_ctx);
854 	QDF_STATUS (*tx_mon_refill_buf_ring)(struct dp_intr *int_ctx);
855 #ifdef QCA_UNDECODED_METADATA_SUPPORT
856 	QDF_STATUS (*mon_config_undecoded_metadata_capture)
857 	    (struct dp_pdev *pdev, int val);
858 	void (*mon_filter_setup_undecoded_metadata_capture)
859 	    (struct dp_pdev *pdev);
860 	void (*mon_filter_reset_undecoded_metadata_capture)
861 	    (struct dp_pdev *pdev);
862 #endif
863 	QDF_STATUS (*mon_pdev_ext_init)(struct dp_pdev *pdev);
864 	QDF_STATUS (*mon_pdev_ext_deinit)(struct dp_pdev *pdev);
865 	QDF_STATUS (*mon_rx_pdev_tlv_logger_init)(struct dp_pdev *pdev);
866 	QDF_STATUS (*mon_rx_pdev_tlv_logger_deinit)(struct dp_pdev *pdev);
867 	QDF_STATUS (*mon_lite_mon_alloc)(struct dp_pdev *pdev);
868 	void (*mon_lite_mon_dealloc)(struct dp_pdev *pdev);
869 	void (*mon_lite_mon_vdev_delete)(struct dp_pdev *pdev,
870 					 struct dp_vdev *vdev);
871 	void (*mon_lite_mon_disable_rx)(struct dp_pdev *pdev);
872 	bool (*mon_lite_mon_is_rx_adv_filter_enable)(struct dp_pdev *pdev);
873 	/* Print advanced monitor stats */
874 	void (*mon_rx_print_advanced_stats)
875 		(struct dp_soc *soc, struct dp_pdev *pdev);
876 	QDF_STATUS (*mon_rx_ppdu_info_cache_create)(struct dp_pdev *pdev);
877 	void (*mon_rx_ppdu_info_cache_destroy)(struct dp_pdev *pdev);
878 	void (*mon_mac_filter_set)(uint32_t *msg_word,
879 				   struct htt_rx_ring_tlv_filter *tlv_filter);
880 #ifdef WLAN_FEATURE_LOCAL_PKT_CAPTURE
881 	QDF_STATUS (*start_local_pkt_capture)(struct dp_pdev *pdev);
882 	QDF_STATUS (*stop_local_pkt_capture)(struct dp_pdev *pdev);
883 	bool (*is_local_pkt_capture_running)(struct dp_pdev *pdev);
884 #endif /* WLAN_FEATURE_LOCAL_PKT_CAPTURE */
885 };
886 
887 /**
888  * struct dp_mon_soc_stats - monitor stats
889  * @frag_alloc: Number of frags allocated
890  * @frag_free: Number of frags freed
891  * @empty_queue: Number of frags freed due to empty queue
892  */
893 struct dp_mon_soc_stats {
894 	uint32_t frag_alloc;
895 	uint32_t frag_free;
896 	uint32_t empty_queue;
897 };
898 
899 struct dp_mon_soc {
900 	/* Holds all monitor related fields extracted from dp_soc */
901 	/* Holds pointer to monitor ops */
902 	/* monitor link descriptor pages */
903 	struct qdf_mem_multi_page_t mon_link_desc_pages[MAX_NUM_LMAC_HW];
904 
905 	/* total link descriptors for monitor mode for each radio */
906 	uint32_t total_mon_link_descs[MAX_NUM_LMAC_HW];
907 
908 	 /* Monitor Link descriptor memory banks */
909 	struct link_desc_bank
910 		mon_link_desc_banks[MAX_NUM_LMAC_HW][MAX_MON_LINK_DESC_BANKS];
911 	uint32_t num_mon_link_desc_banks[MAX_NUM_LMAC_HW];
912 	/* Smart monitor capability for HKv2 */
913 	uint8_t hw_nac_monitor_support;
914 
915 	/* Full monitor mode support */
916 	bool full_mon_mode;
917 
918 	/*interrupt timer*/
919 	qdf_timer_t mon_reap_timer;
920 	uint8_t reap_timer_init;
921 
922 	qdf_spinlock_t reap_timer_lock;
923 
924 	/* Bitmap to record trigger sources of the reap timer */
925 	qdf_bitmap(mon_reap_src_bitmap, CDP_MON_REAP_SOURCE_NUM);
926 
927 	qdf_timer_t mon_vdev_timer;
928 	uint8_t mon_vdev_timer_state;
929 
930 	struct dp_mon_ops *mon_ops;
931 	bool monitor_mode_v2;
932 #ifndef DISABLE_MON_CONFIG
933 	uint32_t (*mon_rx_process)(struct dp_soc *soc,
934 				   struct dp_intr *int_ctx,
935 				   uint32_t mac_id,
936 				   uint32_t quota);
937 #endif
938 
939 #ifdef WLAN_TX_PKT_CAPTURE_ENH
940 	struct dp_soc_tx_capture dp_soc_tx_capt;
941 #endif
942 	/* monitor stats */
943 	struct dp_mon_soc_stats stats;
944 };
945 
946 #ifdef WLAN_CONFIG_TELEMETRY_AGENT
947 struct dp_mon_peer_airtime_consumption {
948 	uint32_t consumption;
949 	uint16_t avg_consumption_per_sec;
950 };
951 
952 /**
953  * struct dp_mon_peer_airtime_stats - Monitor peer airtime stats
954  * @tx_airtime_consumption: tx artime consumption of peer
955  * @rx_airtime_consumption: rx airtime consumption of peer
956  * @last_update_time: Time when last avergae of airtime is done
957  */
958 struct dp_mon_peer_airtime_stats {
959 	struct dp_mon_peer_airtime_consumption tx_airtime_consumption[WME_AC_MAX];
960 	struct dp_mon_peer_airtime_consumption rx_airtime_consumption[WME_AC_MAX];
961 	uint64_t last_update_time;
962 };
963 
964 /**
965  * struct dp_mon_peer_deterministic - Monitor peer deterministic stats
966  * @deter: Deterministic stats per data tid
967  * @avg_tx_rate: Avg TX rate
968  */
969 struct dp_mon_peer_deterministic {
970 	struct cdp_peer_deter_stats deter[CDP_DATA_TID_MAX];
971 	uint64_t avg_tx_rate;
972 };
973 #endif
974 
975 /**
976  * struct dp_mon_peer_stats - Monitor peer stats
977  * @tx: tx stats
978  * @rx: rx stats
979  * @airtime_stats: mon peer airtime stats
980  * @deter_stats: Deterministic stats
981  */
982 struct dp_mon_peer_stats {
983 #ifdef QCA_ENHANCED_STATS_SUPPORT
984 	dp_mon_peer_tx_stats tx;
985 	dp_mon_peer_rx_stats rx;
986 #ifdef WLAN_CONFIG_TELEMETRY_AGENT
987 	struct dp_mon_peer_airtime_stats airtime_stats;
988 	struct dp_mon_peer_deterministic deter_stats;
989 #endif
990 #endif
991 };
992 
993 struct dp_mon_peer {
994 #ifdef WLAN_TX_PKT_CAPTURE_ENH
995 	struct dp_peer_tx_capture tx_capture;
996 #endif
997 #ifdef FEATURE_PERPKT_INFO
998 	/* delayed ba ppdu stats handling */
999 	struct cdp_delayed_tx_completion_ppdu_user delayed_ba_ppdu_stats;
1000 	/* delayed ba flag */
1001 	bool last_delayed_ba;
1002 	/* delayed ba ppdu id */
1003 	uint32_t last_delayed_ba_ppduid;
1004 #endif
1005 	uint8_t tx_cap_enabled:1, /* Peer's tx-capture is enabled */
1006 		rx_cap_enabled:1; /* Peer's rx-capture is enabled */
1007 
1008 	/* Peer level flag to check peer based pktlog enabled or
1009 	 * disabled
1010 	 */
1011 	uint8_t peer_based_pktlog_filter;
1012 
1013 	/* Monitor peer stats */
1014 	struct dp_mon_peer_stats stats;
1015 
1016 	/* peer extended statistics context */
1017 	struct cdp_peer_rate_stats_ctx *peerstats_ctx;
1018 };
1019 
1020 struct dp_rx_mon_rssi_offset {
1021 	/* Temperature based rssi offset */
1022 	int32_t rssi_temp_offset;
1023 	/* Low noise amplifier bypass offset */
1024 	int32_t xlna_bypass_offset;
1025 	/* Low noise amplifier bypass threshold */
1026 	int32_t xlna_bypass_threshold;
1027 	/* 3 Bytes of xbar_config are used for RF to BB mapping */
1028 	uint32_t xbar_config;
1029 	/* min noise floor in active chains per channel */
1030 	int8_t min_nf_dbm;
1031 	/* this value is sum of temp_oofset + min_nf*/
1032 	int32_t rssi_offset;
1033 };
1034 
1035 struct dp_ring_ppdu_id_tracker {
1036 	uint64_t time_ppdu_id_mon_dest;
1037 	uint32_t ppdu_id_mon_dest;
1038 	uint64_t time_ppdu_id_mon_status;
1039 	uint32_t ppdu_id_mon_status;
1040 	uint32_t dest_hp;
1041 	uint32_t dest_tp;
1042 	int32_t dest_hw_hp;
1043 	int32_t dest_hw_tp;
1044 	uint32_t status_hp;
1045 	uint32_t status_tp;
1046 	int32_t status_hw_hp;
1047 	int32_t status_hw_tp;
1048 };
1049 
1050 struct  dp_mon_pdev {
1051 	/* monitor */
1052 	bool monitor_configured;
1053 	uint32_t mon_vdev_id;
1054 
1055 	struct dp_mon_filter **filter;	/* Monitor Filter pointer */
1056 
1057 	/* advance filter mode and type*/
1058 	uint8_t mon_filter_mode;
1059 	uint16_t fp_mgmt_filter;
1060 	uint16_t fp_ctrl_filter;
1061 	uint16_t fp_data_filter;
1062 	uint16_t mo_mgmt_filter;
1063 	uint16_t mo_ctrl_filter;
1064 	uint16_t mo_data_filter;
1065 	uint16_t md_data_filter;
1066 
1067 #ifdef WLAN_TX_PKT_CAPTURE_ENH
1068 	struct dp_pdev_tx_capture tx_capture;
1069 	bool stop_tx_capture_work_q_timer;
1070 #endif
1071 
1072 	/* tx packet capture enhancement */
1073 	enum cdp_tx_enh_capture_mode tx_capture_enabled;
1074 	/* Stuck count on monitor destination ring MPDU process */
1075 	uint32_t mon_dest_ring_stuck_cnt;
1076 	/* monitor mode lock */
1077 	qdf_spinlock_t mon_lock;
1078 
1079 	/* Monitor mode operation channel */
1080 	int mon_chan_num;
1081 
1082 	/* Monitor mode operation frequency */
1083 	qdf_freq_t mon_chan_freq;
1084 
1085 	/* Monitor mode band */
1086 	enum reg_wifi_band mon_chan_band;
1087 
1088 	uint32_t mon_ppdu_status;
1089 	/* monitor mode status/destination ring PPDU and MPDU count */
1090 	struct cdp_pdev_mon_stats rx_mon_stats;
1091 	/* Monitor mode interface and status storage */
1092 	struct dp_vdev *mvdev;
1093 	struct cdp_mon_status rx_mon_recv_status;
1094 	/* to track duplicate link descriptor indications by HW for a WAR */
1095 	uint64_t mon_last_linkdesc_paddr;
1096 	/* to track duplicate buffer indications by HW for a WAR */
1097 	uint32_t mon_last_buf_cookie;
1098 
1099 #ifdef QCA_SUPPORT_FULL_MON
1100 	/* List to maintain all MPDUs for a PPDU in monitor mode */
1101 	TAILQ_HEAD(, dp_mon_mpdu) mon_mpdu_q;
1102 
1103 	/* TODO: define per-user mpdu list
1104 	 * struct dp_mon_mpdu_list mpdu_list[MAX_MU_USERS];
1105 	 */
1106 	struct hal_rx_mon_desc_info *mon_desc;
1107 	struct dp_ring_ppdu_id_tracker hist_ppdu_id_mon_d[DP_HIST_TRACK_SIZE];
1108 	struct dp_ring_ppdu_id_tracker hist_ppdu_id_mon_s[DP_HIST_TRACK_SIZE];
1109 	uint8_t hist_mon_dest_idx;
1110 	uint8_t hist_mon_status_idx;
1111 #endif
1112 	bool set_reset_mon;
1113 	bool is_bkpressure;
1114 	/* Flag to hold on to monitor destination ring */
1115 	bool hold_mon_dest_ring;
1116 	uint64_t reap_status[DP_MON_STATUS_MAX];
1117 	uint64_t prev_status[DP_MON_STATUS_MAX];
1118 	uint64_t status_match[DP_MON_STATUS_MAX];
1119 
1120 	/* Flag to indicate monitor rings are initialized */
1121 	uint8_t pdev_mon_init;
1122 #ifndef REMOVE_PKT_LOG
1123 	bool pkt_log_init;
1124 	struct pktlog_dev_t *pl_dev; /* Pktlog pdev */
1125 #endif /* #ifndef REMOVE_PKT_LOG */
1126 
1127 	/* Smart Mesh */
1128 	bool filter_neighbour_peers;
1129 
1130 	/*flag to indicate neighbour_peers_list not empty */
1131 	bool neighbour_peers_added;
1132 	/* smart mesh mutex */
1133 	qdf_spinlock_t neighbour_peer_mutex;
1134 	/* Neighnour peer list */
1135 	TAILQ_HEAD(, dp_neighbour_peer) neighbour_peers_list;
1136 	/* Enhanced Stats is enabled */
1137 	uint8_t enhanced_stats_en;
1138 	qdf_nbuf_queue_t rx_status_q;
1139 
1140 	/* 128 bytes mpdu header queue per user for ppdu */
1141 	qdf_nbuf_queue_t mpdu_q[MAX_MU_USERS];
1142 
1143 	/* is this a mpdu header TLV and not msdu header TLV */
1144 	bool is_mpdu_hdr[MAX_MU_USERS];
1145 
1146 	/* per user 128 bytes msdu header list for MPDU */
1147 	struct msdu_list msdu_list[MAX_MU_USERS];
1148 
1149 	/* RX enhanced capture mode */
1150 	uint8_t rx_enh_capture_mode;
1151 	/* Rx per peer enhanced capture mode */
1152 	bool rx_enh_capture_peer;
1153 	struct dp_vdev *rx_enh_monitor_vdev;
1154 	/* RX enhanced capture trailer enable/disable flag */
1155 	bool is_rx_enh_capture_trailer_enabled;
1156 #ifdef WLAN_RX_PKT_CAPTURE_ENH
1157 	/* RX per MPDU/PPDU information */
1158 	struct cdp_rx_indication_mpdu mpdu_ind;
1159 #endif
1160 
1161 	/* Packet log mode */
1162 	uint8_t rx_pktlog_mode;
1163 	/* Enable pktlog logging cbf */
1164 	bool rx_pktlog_cbf;
1165 
1166 #ifdef BE_PKTLOG_SUPPORT
1167 	/* Enable pktlog logging hybrid */
1168 	bool pktlog_hybrid_mode;
1169 #endif
1170 	bool tx_sniffer_enable;
1171 	/* mirror copy mode */
1172 	enum m_copy_mode mcopy_mode;
1173 	bool bpr_enable;
1174 	/* Pdev level flag to check peer based pktlog enabled or
1175 	 * disabled
1176 	 */
1177 	uint8_t dp_peer_based_pktlog;
1178 
1179 #ifdef WLAN_ATF_ENABLE
1180 	/* ATF stats enable */
1181 	bool dp_atf_stats_enable;
1182 #endif
1183 
1184 	/* Maintains first status buffer's paddr of a PPDU */
1185 	uint64_t status_buf_addr;
1186 	struct hal_rx_ppdu_info ppdu_info;
1187 
1188 	/* ppdu_id of last received HTT TX stats */
1189 	uint32_t last_ppdu_id;
1190 	struct {
1191 		uint8_t last_user;
1192 		qdf_nbuf_t buf;
1193 	} tx_ppdu_info;
1194 
1195 	struct {
1196 		uint32_t tx_ppdu_id;
1197 		uint16_t tx_peer_id;
1198 		uint32_t rx_ppdu_id;
1199 	} m_copy_id;
1200 
1201 	/* To check if PPDU Tx stats are enabled for Pktlog */
1202 	bool pktlog_ppdu_stats;
1203 
1204 #ifdef ATH_SUPPORT_NAC_RSSI
1205 	bool nac_rssi_filtering;
1206 #endif
1207 
1208 	/* ppdu_stats lock for queue concurrency between cores*/
1209 	qdf_spinlock_t ppdu_stats_lock;
1210 
1211 	/* list of ppdu tlvs */
1212 	TAILQ_HEAD(, ppdu_info) ppdu_info_list;
1213 	TAILQ_HEAD(, ppdu_info) sched_comp_ppdu_list;
1214 
1215 	uint32_t sched_comp_list_depth;
1216 	uint16_t delivered_sched_cmdid;
1217 	uint16_t last_sched_cmdid;
1218 	uint32_t tlv_count;
1219 	uint32_t list_depth;
1220 
1221 	struct {
1222 		qdf_nbuf_t last_nbuf; /*Ptr to mgmt last buf */
1223 		uint8_t *mgmt_buf; /* Ptr to mgmt. payload in HTT ppdu stats */
1224 		uint32_t mgmt_buf_len; /* Len of mgmt. payload in ppdu stats */
1225 		uint32_t ppdu_id;
1226 	} mgmtctrl_frm_info;
1227 	/* Context of cal client timer */
1228 	struct cdp_cal_client *cal_client_ctx;
1229 	uint32_t *ppdu_tlv_buf; /* Buffer to hold HTT ppdu stats TLVs*/
1230 
1231 	qdf_nbuf_t mcopy_status_nbuf;
1232 	bool is_dp_mon_pdev_initialized;
1233 	/* indicates if spcl vap is configured */
1234 	bool scan_spcl_vap_configured;
1235 	bool undecoded_metadata_capture;
1236 #ifdef QCA_UNDECODED_METADATA_SUPPORT
1237 	uint32_t phyrx_error_mask;
1238 	uint32_t phyrx_error_mask_cont;
1239 #endif
1240 #ifdef QCA_SUPPORT_SCAN_SPCL_VAP_STATS
1241 	/* enable spcl vap stats reset on ch change */
1242 	bool reset_scan_spcl_vap_stats_enable;
1243 #endif
1244 	bool is_tlv_hdr_64_bit;
1245 	/* TLV header size*/
1246 	uint8_t tlv_hdr_size;
1247 
1248 	/* Invalid monitor peer to account for stats in mcopy mode */
1249 	struct dp_mon_peer *invalid_mon_peer;
1250 
1251 	bool rssi_dbm_conv_support;
1252 	struct dp_rx_mon_rssi_offset rssi_offsets;
1253 	uint8_t phy_ppdu_id_size;
1254 #ifdef WLAN_FEATURE_LOCAL_PKT_CAPTURE
1255 	bool is_local_pkt_capture_running;
1256 	/* Maintain MSDU list on PPDU */
1257 	qdf_nbuf_queue_t msdu_queue;
1258 	/* Maintain MPDU list of PPDU */
1259 	qdf_nbuf_queue_t mpdu_queue;
1260 	/* To  check if 1st MPDU of PPDU */
1261 	bool first_mpdu;
1262 	/* LPC lock */
1263 	qdf_spinlock_t lpc_lock;
1264 #endif
1265 };
1266 
1267 struct  dp_mon_vdev {
1268 	/* callback to hand rx monitor 802.11 MPDU to the OS shim */
1269 	ol_txrx_rx_mon_fp osif_rx_mon;
1270 #ifdef QCA_SUPPORT_SCAN_SPCL_VAP_STATS
1271 	struct cdp_scan_spcl_vap_stats *scan_spcl_vap_stats;
1272 #endif
1273 };
1274 
1275 #if defined(QCA_TX_CAPTURE_SUPPORT) || defined(QCA_ENHANCED_STATS_SUPPORT)
1276 void dp_deliver_mgmt_frm(struct dp_pdev *pdev, qdf_nbuf_t nbuf);
1277 #else
1278 static inline
dp_deliver_mgmt_frm(struct dp_pdev * pdev,qdf_nbuf_t nbuf)1279 void dp_deliver_mgmt_frm(struct dp_pdev *pdev, qdf_nbuf_t nbuf)
1280 {
1281 }
1282 #endif
1283 
1284 #if defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) ||\
1285 	defined(WLAN_SUPPORT_RX_FLOW_TAG)
1286 /**
1287  * dp_rx_mon_update_protocol_flow_tag() - Performs necessary checks for monitor
1288  *                                       mode and then tags appropriate packets
1289  * @soc: core txrx main context
1290  * @dp_pdev: pdev on which packet is received
1291  * @msdu: QDF packet buffer on which the protocol tag should be set
1292  * @rx_desc: base address where the RX TLVs start
1293  *
1294  * Return: void
1295  */
1296 void dp_rx_mon_update_protocol_flow_tag(struct dp_soc *soc,
1297 					struct dp_pdev *dp_pdev,
1298 					qdf_nbuf_t msdu, void *rx_desc);
1299 #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG || WLAN_SUPPORT_RX_FLOW_TAG */
1300 
1301 #if !defined(WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG) &&\
1302 	!defined(WLAN_SUPPORT_RX_FLOW_TAG)
1303 /**
1304  * dp_rx_mon_update_protocol_flow_tag() - Performs necessary checks for monitor
1305  *                                       mode and then tags appropriate packets
1306  * @soc: core txrx main context
1307  * @dp_pdev: pdev on which packet is received
1308  * @msdu: QDF packet buffer on which the protocol tag should be set
1309  * @rx_desc: base address where the RX TLVs start
1310  *
1311  * Return: void
1312  */
1313 static inline
dp_rx_mon_update_protocol_flow_tag(struct dp_soc * soc,struct dp_pdev * dp_pdev,qdf_nbuf_t msdu,void * rx_desc)1314 void dp_rx_mon_update_protocol_flow_tag(struct dp_soc *soc,
1315 					struct dp_pdev *dp_pdev,
1316 					qdf_nbuf_t msdu, void *rx_desc)
1317 {
1318 }
1319 #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG || WLAN_SUPPORT_RX_FLOW_TAG */
1320 
1321 #ifndef WLAN_TX_PKT_CAPTURE_ENH
1322 /**
1323  * dp_peer_tid_queue_init() - Initialize ppdu stats queue per TID
1324  * @peer: Datapath peer
1325  *
1326  */
dp_peer_tid_queue_init(struct dp_peer * peer)1327 static inline void dp_peer_tid_queue_init(struct dp_peer *peer)
1328 {
1329 }
1330 
1331 /**
1332  * dp_peer_tid_queue_cleanup() - remove ppdu stats queue per TID
1333  * @peer: Datapath peer
1334  *
1335  */
dp_peer_tid_queue_cleanup(struct dp_peer * peer)1336 static inline void dp_peer_tid_queue_cleanup(struct dp_peer *peer)
1337 {
1338 }
1339 
1340 /**
1341  * dp_peer_update_80211_hdr() - dp peer update 80211 hdr
1342  * @vdev: Datapath vdev
1343  * @peer: Datapath peer
1344  *
1345  */
1346 static inline void
dp_peer_update_80211_hdr(struct dp_vdev * vdev,struct dp_peer * peer)1347 dp_peer_update_80211_hdr(struct dp_vdev *vdev, struct dp_peer *peer)
1348 {
1349 }
1350 
1351 /**
1352  * dp_get_peer_tx_capture_stats() - to get peer tx capture stats
1353  * @peer: DP PEER handle
1354  * @stats: pointor to peer tx capture stats
1355  *
1356  * return: QDF_STATUS
1357  */
1358 static inline QDF_STATUS
dp_get_peer_tx_capture_stats(struct dp_peer * peer,struct cdp_peer_tx_capture_stats * stats)1359 dp_get_peer_tx_capture_stats(struct dp_peer *peer,
1360 			     struct cdp_peer_tx_capture_stats *stats)
1361 {
1362 	return QDF_STATUS_E_FAILURE;
1363 }
1364 
1365 /**
1366  * dp_get_pdev_tx_capture_stats() - to get pdev tx capture stats
1367  * @pdev: DP PDEV handle
1368  * @stats: pointor to pdev tx capture stats
1369  *
1370  * return: QDF_STATUS
1371  */
1372 static inline QDF_STATUS
dp_get_pdev_tx_capture_stats(struct dp_pdev * pdev,struct cdp_pdev_tx_capture_stats * stats)1373 dp_get_pdev_tx_capture_stats(struct dp_pdev *pdev,
1374 			     struct cdp_pdev_tx_capture_stats *stats)
1375 {
1376 	return QDF_STATUS_E_FAILURE;
1377 }
1378 #endif
1379 
1380 #ifdef WLAN_TX_PKT_CAPTURE_ENH
1381 extern uint8_t
1382 dp_cpu_ring_map[DP_NSS_CPU_RING_MAP_MAX][WLAN_CFG_INT_NUM_CONTEXTS_MAX];
1383 #endif
1384 
1385 /**
1386  * dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap() - Get ppdu stats tlv
1387  * bitmap for sniffer mode
1388  * @bitmap: received bitmap
1389  *
1390  * Return: expected bitmap value, returns zero if doesn't match with
1391  * either 64-bit Tx window or 256-bit window tlv bitmap
1392  */
1393 int
1394 dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(uint32_t bitmap);
1395 
1396 #if (defined(DP_CON_MON) || defined(WDI_EVENT_ENABLE)) &&\
1397 	(!defined(REMOVE_PKT_LOG))
1398 /**
1399  * dp_pkt_log_init() - API to initialize packet log
1400  * @soc_hdl: Datapath soc handle
1401  * @pdev_id: id of data path pdev handle
1402  * @scn: HIF context
1403  *
1404  * Return: none
1405  */
1406 void dp_pkt_log_init(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, void *scn);
1407 #else
1408 static inline void
dp_pkt_log_init(struct cdp_soc_t * soc_hdl,uint8_t pdev_id,void * scn)1409 dp_pkt_log_init(struct cdp_soc_t *soc_hdl, uint8_t pdev_id, void *scn)
1410 {
1411 }
1412 #endif
1413 
1414 #if defined(WDI_EVENT_ENABLE) && defined(QCA_ENHANCED_STATS_SUPPORT)
1415 QDF_STATUS dp_peer_stats_notify(struct dp_pdev *pdev, struct dp_peer *peer);
1416 #else
dp_peer_stats_notify(struct dp_pdev * pdev,struct dp_peer * peer)1417 static inline QDF_STATUS dp_peer_stats_notify(struct dp_pdev *pdev,
1418 					      struct dp_peer *peer)
1419 {
1420 	return QDF_STATUS_SUCCESS;
1421 }
1422 #endif
1423 
1424 #if defined(FEATURE_PERPKT_INFO) && defined(WDI_EVENT_ENABLE)
1425 void dp_send_stats_event(struct dp_pdev *pdev, struct dp_peer *peer,
1426 			 uint16_t peer_id);
1427 #else
1428 static inline
dp_send_stats_event(struct dp_pdev * pdev,struct dp_peer * peer,uint16_t peer_id)1429 void dp_send_stats_event(struct dp_pdev *pdev, struct dp_peer *peer,
1430 			 uint16_t peer_id)
1431 {
1432 }
1433 #endif
1434 
1435 #ifndef WLAN_TX_PKT_CAPTURE_ENH
1436 /**
1437  * dp_tx_ppdu_stats_process - Deferred PPDU stats handler
1438  * @context: Opaque work context (PDEV)
1439  *
1440  * Return: none
1441  */
dp_tx_ppdu_stats_process(void * context)1442 static  inline void dp_tx_ppdu_stats_process(void *context)
1443 {
1444 }
1445 
1446 /**
1447  * dp_tx_capture_htt_frame_counter: increment counter for htt_frame_type
1448  * @pdev: DP pdev handle
1449  * @htt_frame_type: htt frame type received from fw
1450  *
1451  * return: void
1452  */
1453 static inline
dp_tx_capture_htt_frame_counter(struct dp_pdev * pdev,uint32_t htt_frame_type)1454 void dp_tx_capture_htt_frame_counter(struct dp_pdev *pdev,
1455 				     uint32_t htt_frame_type)
1456 {
1457 }
1458 
1459 #endif
1460 
1461 /**
1462  * dp_rx_cookie_2_mon_link_desc_va() - Converts cookie to a virtual address of
1463  *				   the MSDU Link Descriptor
1464  * @pdev: core txrx pdev context
1465  * @buf_info: buf_info includes cookie that used to lookup virtual address of
1466  * link descriptor. Normally this is just an index into a per pdev array.
1467  * @mac_id: mac id
1468  *
1469  * This is the VA of the link descriptor in monitor mode destination ring,
1470  * that HAL layer later uses to retrieve the list of MSDU's for a given MPDU.
1471  *
1472  * Return: void *: Virtual Address of the Rx descriptor
1473  */
1474 static inline
dp_rx_cookie_2_mon_link_desc_va(struct dp_pdev * pdev,struct hal_buf_info * buf_info,int mac_id)1475 void *dp_rx_cookie_2_mon_link_desc_va(struct dp_pdev *pdev,
1476 				      struct hal_buf_info *buf_info,
1477 				      int mac_id)
1478 {
1479 	void *link_desc_va;
1480 	struct qdf_mem_multi_page_t *pages;
1481 	uint16_t page_id = LINK_DESC_COOKIE_PAGE_ID(buf_info->sw_cookie);
1482 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
1483 
1484 	if (!mon_soc)
1485 		return NULL;
1486 
1487 	pages = &mon_soc->mon_link_desc_pages[mac_id];
1488 	if (!pages)
1489 		return NULL;
1490 
1491 	if (qdf_unlikely(page_id >= pages->num_pages))
1492 		return NULL;
1493 
1494 	link_desc_va = pages->dma_pages[page_id].page_v_addr_start +
1495 		(buf_info->paddr - pages->dma_pages[page_id].page_p_addr);
1496 
1497 	return link_desc_va;
1498 }
1499 
1500 /**
1501  * dp_soc_is_full_mon_enable() - Return if full monitor mode is enabled
1502  * @pdev: point to dp pdev
1503  *
1504  * Return: Full monitor mode status
1505  */
dp_soc_is_full_mon_enable(struct dp_pdev * pdev)1506 static inline bool dp_soc_is_full_mon_enable(struct dp_pdev *pdev)
1507 {
1508 	return (pdev->soc->monitor_soc->full_mon_mode &&
1509 		pdev->monitor_pdev->monitor_configured) ? true : false;
1510 }
1511 
1512 /**
1513  * dp_monitor_is_enable_mcopy_mode() - check if mcopy mode is enabled
1514  * @pdev: point to dp pdev
1515  *
1516  * Return: true if mcopy mode is enabled
1517  */
dp_monitor_is_enable_mcopy_mode(struct dp_pdev * pdev)1518 static inline bool dp_monitor_is_enable_mcopy_mode(struct dp_pdev *pdev)
1519 {
1520 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1521 		return false;
1522 
1523 	return pdev->monitor_pdev->mcopy_mode;
1524 }
1525 
1526 /**
1527  * dp_monitor_is_enable_tx_sniffer() - check if tx sniffer is enabled
1528  * @pdev: point to dp pdev
1529  *
1530  * Return: true if tx sniffer is enabled
1531  */
dp_monitor_is_enable_tx_sniffer(struct dp_pdev * pdev)1532 static inline bool dp_monitor_is_enable_tx_sniffer(struct dp_pdev *pdev)
1533 {
1534 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1535 		return false;
1536 
1537 	return pdev->monitor_pdev->tx_sniffer_enable;
1538 }
1539 
1540 /**
1541  * dp_monitor_is_configured() - check if monitor configured is set
1542  * @pdev: point to dp pdev
1543  *
1544  * Return: true if monitor configured is set
1545  */
dp_monitor_is_configured(struct dp_pdev * pdev)1546 static inline bool dp_monitor_is_configured(struct dp_pdev *pdev)
1547 {
1548 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1549 		return false;
1550 
1551 	return pdev->monitor_pdev->monitor_configured;
1552 }
1553 
1554 /**
1555  * dp_monitor_check_com_info_ppdu_id() - check if msdu ppdu_id matches with
1556  * com info ppdu_id
1557  * @pdev: point to dp pdev
1558  * @rx_desc: point to rx_desc
1559  *
1560  * Return: success if ppdu_id matches
1561  */
dp_monitor_check_com_info_ppdu_id(struct dp_pdev * pdev,void * rx_desc)1562 static inline QDF_STATUS dp_monitor_check_com_info_ppdu_id(struct dp_pdev *pdev,
1563 							   void *rx_desc)
1564 {
1565 	struct cdp_mon_status *rs;
1566 	struct dp_mon_pdev *mon_pdev;
1567 	uint32_t msdu_ppdu_id = 0;
1568 
1569 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1570 		return QDF_STATUS_E_FAILURE;
1571 
1572 	mon_pdev = pdev->monitor_pdev;
1573 	if (qdf_likely(1 != mon_pdev->ppdu_info.rx_status.rxpcu_filter_pass))
1574 		return QDF_STATUS_E_FAILURE;
1575 
1576 	rs = &pdev->monitor_pdev->rx_mon_recv_status;
1577 	if (!rs || rs->cdp_rs_rxdma_err)
1578 		return QDF_STATUS_E_FAILURE;
1579 
1580 	msdu_ppdu_id = hal_rx_get_ppdu_id(pdev->soc->hal_soc, rx_desc);
1581 	if (msdu_ppdu_id != mon_pdev->ppdu_info.com_info.ppdu_id) {
1582 		QDF_TRACE(QDF_MODULE_ID_DP,
1583 			  QDF_TRACE_LEVEL_ERROR,
1584 			  "msdu_ppdu_id=%x,com_info.ppdu_id=%x",
1585 			  msdu_ppdu_id,
1586 			  mon_pdev->ppdu_info.com_info.ppdu_id);
1587 		return QDF_STATUS_E_FAILURE;
1588 	}
1589 
1590 	return QDF_STATUS_SUCCESS;
1591 }
1592 
1593 /**
1594  * dp_monitor_get_rx_status() - get rx status
1595  * @pdev: point to dp pdev
1596  *
1597  * Return: return rx status pointer
1598  */
1599 static inline struct mon_rx_status*
dp_monitor_get_rx_status(struct dp_pdev * pdev)1600 dp_monitor_get_rx_status(struct dp_pdev *pdev)
1601 {
1602 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1603 		return NULL;
1604 
1605 	return &pdev->monitor_pdev->ppdu_info.rx_status;
1606 }
1607 
1608 /**
1609  * dp_monitor_is_chan_band_known() - check if monitor chan band known
1610  * @pdev: point to dp pdev
1611  *
1612  * Return: true if chan band known
1613  */
dp_monitor_is_chan_band_known(struct dp_pdev * pdev)1614 static inline bool dp_monitor_is_chan_band_known(struct dp_pdev *pdev)
1615 {
1616 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1617 		return false;
1618 
1619 	if (pdev->monitor_pdev->mon_chan_band != REG_BAND_UNKNOWN)
1620 		return true;
1621 
1622 	return false;
1623 }
1624 
1625 /**
1626  * dp_monitor_get_chan_band() - get chan band
1627  * @pdev: point to dp pdev
1628  *
1629  * Return: wifi channel band
1630  */
1631 static inline enum reg_wifi_band
dp_monitor_get_chan_band(struct dp_pdev * pdev)1632 dp_monitor_get_chan_band(struct dp_pdev *pdev)
1633 {
1634 	return pdev->monitor_pdev->mon_chan_band;
1635 }
1636 
1637 /**
1638  * dp_monitor_print_tx_stats() - print tx stats from monitor pdev
1639  * @pdev: point to dp pdev
1640  *
1641  */
dp_monitor_print_tx_stats(struct dp_pdev * pdev)1642 static inline void dp_monitor_print_tx_stats(struct dp_pdev *pdev)
1643 {
1644 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1645 		return;
1646 
1647 	DP_PRINT_STATS("ppdu info schedule completion list depth: %d",
1648 		       pdev->monitor_pdev->sched_comp_list_depth);
1649 	DP_PRINT_STATS("delivered sched cmdid: %d",
1650 		       pdev->monitor_pdev->delivered_sched_cmdid);
1651 	DP_PRINT_STATS("cur sched cmdid: %d",
1652 		       pdev->monitor_pdev->last_sched_cmdid);
1653 	DP_PRINT_STATS("ppdu info list depth: %d",
1654 		       pdev->monitor_pdev->list_depth);
1655 }
1656 
1657 /**
1658  * dp_monitor_set_chan_num() - set channel number
1659  * @pdev: point to dp pdev
1660  * @chan_num: channel number
1661  *
1662  */
dp_monitor_set_chan_num(struct dp_pdev * pdev,int chan_num)1663 static inline void dp_monitor_set_chan_num(struct dp_pdev *pdev, int chan_num)
1664 {
1665 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1666 		return;
1667 
1668 	pdev->monitor_pdev->mon_chan_num = chan_num;
1669 }
1670 
1671 /**
1672  * dp_monitor_get_chan_num() - get channel number
1673  * @pdev: DP pdev handle
1674  *
1675  * Return: channel number
1676  */
dp_monitor_get_chan_num(struct dp_pdev * pdev)1677 static inline int dp_monitor_get_chan_num(struct dp_pdev *pdev)
1678 {
1679 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1680 		return 0;
1681 
1682 	return pdev->monitor_pdev->mon_chan_num;
1683 }
1684 
1685 /**
1686  * dp_monitor_set_chan_freq() - set channel frequency
1687  * @pdev: point to dp pdev
1688  * @chan_freq: channel frequency
1689  *
1690  */
1691 static inline void
dp_monitor_set_chan_freq(struct dp_pdev * pdev,qdf_freq_t chan_freq)1692 dp_monitor_set_chan_freq(struct dp_pdev *pdev, qdf_freq_t chan_freq)
1693 {
1694 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1695 		return;
1696 
1697 	pdev->monitor_pdev->mon_chan_freq = chan_freq;
1698 }
1699 
1700 /**
1701  * dp_monitor_get_chan_freq() - get channel frequency
1702  * @pdev: DP pdev handle
1703  *
1704  * Return: channel frequency
1705  */
1706 static inline qdf_freq_t
dp_monitor_get_chan_freq(struct dp_pdev * pdev)1707 dp_monitor_get_chan_freq(struct dp_pdev *pdev)
1708 {
1709 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1710 		return 0;
1711 
1712 	return pdev->monitor_pdev->mon_chan_freq;
1713 }
1714 
1715 /**
1716  * dp_monitor_set_chan_band() - set channel band
1717  * @pdev: point to dp pdev
1718  * @chan_band: channel band
1719  *
1720  */
1721 static inline void
dp_monitor_set_chan_band(struct dp_pdev * pdev,enum reg_wifi_band chan_band)1722 dp_monitor_set_chan_band(struct dp_pdev *pdev, enum reg_wifi_band chan_band)
1723 {
1724 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1725 		return;
1726 
1727 	pdev->monitor_pdev->mon_chan_band = chan_band;
1728 }
1729 
1730 /**
1731  * dp_monitor_get_mpdu_status() - get mpdu status
1732  * @pdev: point to dp pdev
1733  * @soc: point to dp soc
1734  * @rx_tlv_hdr: point to rx tlv header
1735  *
1736  */
dp_monitor_get_mpdu_status(struct dp_pdev * pdev,struct dp_soc * soc,uint8_t * rx_tlv_hdr)1737 static inline void dp_monitor_get_mpdu_status(struct dp_pdev *pdev,
1738 					      struct dp_soc *soc,
1739 					      uint8_t *rx_tlv_hdr)
1740 {
1741 	struct dp_mon_pdev *mon_pdev;
1742 
1743 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
1744 		return;
1745 
1746 	mon_pdev = pdev->monitor_pdev;
1747 	hal_rx_mon_hw_desc_get_mpdu_status(soc->hal_soc, rx_tlv_hdr,
1748 					   &mon_pdev->ppdu_info.rx_status);
1749 }
1750 
1751 #ifdef FEATURE_NAC_RSSI
1752 /**
1753  * dp_monitor_drop_inv_peer_pkts() - drop invalid peer pkts
1754  * @vdev: point to dp vdev
1755  *
1756  * Return: success if sta mode and filter for neighbour peers enabled
1757  */
dp_monitor_drop_inv_peer_pkts(struct dp_vdev * vdev)1758 static inline QDF_STATUS dp_monitor_drop_inv_peer_pkts(struct dp_vdev *vdev)
1759 {
1760 	struct dp_pdev *pdev = vdev->pdev;
1761 	struct dp_soc *soc = pdev->soc;
1762 
1763 	if (!soc->monitor_soc)
1764 		return QDF_STATUS_E_FAILURE;
1765 
1766 	if (!soc->monitor_soc->hw_nac_monitor_support &&
1767 	    pdev->monitor_pdev->filter_neighbour_peers &&
1768 	    vdev->opmode == wlan_op_mode_sta)
1769 		return QDF_STATUS_SUCCESS;
1770 
1771 	return QDF_STATUS_E_FAILURE;
1772 }
1773 #else
dp_monitor_drop_inv_peer_pkts(struct dp_vdev * vdev)1774 static inline QDF_STATUS dp_monitor_drop_inv_peer_pkts(struct dp_vdev *vdev)
1775 {
1776 	return QDF_STATUS_E_FAILURE;
1777 }
1778 #endif
1779 
1780 /**
1781  * dp_peer_ppdu_delayed_ba_init() - Initialize ppdu in peer
1782  * @peer: Datapath peer
1783  *
1784  * return: void
1785  */
1786 #ifdef FEATURE_PERPKT_INFO
dp_peer_ppdu_delayed_ba_init(struct dp_peer * peer)1787 static inline void dp_peer_ppdu_delayed_ba_init(struct dp_peer *peer)
1788 {
1789 	struct dp_mon_peer *mon_peer = peer->monitor_peer;
1790 
1791 	if (!mon_peer)
1792 		return;
1793 
1794 	qdf_mem_zero(&mon_peer->delayed_ba_ppdu_stats,
1795 		     sizeof(struct cdp_delayed_tx_completion_ppdu_user));
1796 	mon_peer->last_delayed_ba = false;
1797 	mon_peer->last_delayed_ba_ppduid = 0;
1798 }
1799 #else
dp_peer_ppdu_delayed_ba_init(struct dp_peer * peer)1800 static inline void dp_peer_ppdu_delayed_ba_init(struct dp_peer *peer)
1801 {
1802 }
1803 #endif
1804 
1805 /**
1806  * dp_monitor_vdev_register_osif() - Register osif rx mon
1807  * @vdev: point to vdev
1808  * @txrx_ops: point to ol txrx ops
1809  *
1810  * Return: void
1811  */
dp_monitor_vdev_register_osif(struct dp_vdev * vdev,struct ol_txrx_ops * txrx_ops)1812 static inline void dp_monitor_vdev_register_osif(struct dp_vdev *vdev,
1813 						 struct ol_txrx_ops *txrx_ops)
1814 {
1815 	if (!vdev->monitor_vdev)
1816 		return;
1817 
1818 	vdev->monitor_vdev->osif_rx_mon = txrx_ops->rx.mon;
1819 }
1820 
1821 /**
1822  * dp_monitor_get_monitor_vdev_from_pdev() - Get monitor vdev
1823  * @pdev: point to pdev
1824  *
1825  * Return: pointer to vdev
1826  */
1827 static inline struct dp_vdev*
dp_monitor_get_monitor_vdev_from_pdev(struct dp_pdev * pdev)1828 dp_monitor_get_monitor_vdev_from_pdev(struct dp_pdev *pdev)
1829 {
1830 	if (!pdev || !pdev->monitor_pdev || !pdev->monitor_pdev->mvdev)
1831 		return NULL;
1832 
1833 	return pdev->monitor_pdev->mvdev;
1834 }
1835 
1836 /**
1837  * dp_monitor_is_vdev_timer_running() - Get vdev timer status
1838  * @soc: point to soc
1839  *
1840  * Return: true if timer running
1841  */
dp_monitor_is_vdev_timer_running(struct dp_soc * soc)1842 static inline bool dp_monitor_is_vdev_timer_running(struct dp_soc *soc)
1843 {
1844 	if (qdf_unlikely(!soc || !soc->monitor_soc))
1845 		return false;
1846 
1847 	return !!(soc->monitor_soc->mon_vdev_timer_state &
1848 		  MON_VDEV_TIMER_RUNNING);
1849 }
1850 
1851 /**
1852  * dp_monitor_get_link_desc_pages() - Get link desc pages
1853  * @soc: point to soc
1854  * @mac_id: mac id
1855  *
1856  * Return: return point to link desc pages
1857  */
1858 static inline struct qdf_mem_multi_page_t*
dp_monitor_get_link_desc_pages(struct dp_soc * soc,uint32_t mac_id)1859 dp_monitor_get_link_desc_pages(struct dp_soc *soc, uint32_t mac_id)
1860 {
1861 	if (qdf_unlikely(!soc || !soc->monitor_soc))
1862 		return NULL;
1863 
1864 	return &soc->monitor_soc->mon_link_desc_pages[mac_id];
1865 }
1866 
1867 #ifndef WLAN_SOFTUMAC_SUPPORT
1868 /*
1869  * dp_monitor_get_link_desc_ring() - Get link desc ring
1870  * @soc: point to soc
1871  * @mac_id: mac id
1872  *
1873  * Return: return point to link desc ring
1874  */
1875 static inline hal_ring_handle_t
dp_monitor_get_link_desc_ring(struct dp_soc * soc,uint32_t mac_id)1876 dp_monitor_get_link_desc_ring(struct dp_soc *soc, uint32_t mac_id)
1877 {
1878 	return soc->rxdma_mon_desc_ring[mac_id].hal_srng;
1879 }
1880 
1881 static inline uint32_t
dp_monitor_get_num_link_desc_ring_entries(struct dp_soc * soc,uint32_t mac_id)1882 dp_monitor_get_num_link_desc_ring_entries(struct dp_soc *soc, uint32_t mac_id)
1883 {
1884 	struct dp_srng *ring;
1885 
1886 	ring = &soc->rxdma_mon_desc_ring[mac_id];
1887 
1888 	return ring->alloc_size / hal_srng_get_entrysize(soc->hal_soc,
1889 							 RXDMA_MONITOR_DESC);
1890 }
1891 #else
1892 static inline hal_ring_handle_t
dp_monitor_get_link_desc_ring(struct dp_soc * soc,uint32_t mac_id)1893 dp_monitor_get_link_desc_ring(struct dp_soc *soc, uint32_t mac_id)
1894 {
1895 	return soc->sw2rxdma_link_ring[mac_id].hal_srng;
1896 }
1897 
1898 static inline uint32_t
dp_monitor_get_num_link_desc_ring_entries(struct dp_soc * soc,uint32_t mac_id)1899 dp_monitor_get_num_link_desc_ring_entries(struct dp_soc *soc, uint32_t mac_id)
1900 {
1901 	struct dp_srng *ring;
1902 
1903 	ring = &soc->sw2rxdma_link_ring[mac_id];
1904 
1905 	return ring->alloc_size / hal_srng_get_entrysize(soc->hal_soc,
1906 							 SW2RXDMA_LINK_RELEASE);
1907 }
1908 #endif
1909 
1910 /**
1911  * dp_monitor_get_total_link_descs() - Get total link descs
1912  * @soc: point to soc
1913  * @mac_id: mac id
1914  *
1915  * Return: return point total link descs
1916  */
1917 static inline uint32_t *
dp_monitor_get_total_link_descs(struct dp_soc * soc,uint32_t mac_id)1918 dp_monitor_get_total_link_descs(struct dp_soc *soc, uint32_t mac_id)
1919 {
1920 	return &soc->monitor_soc->total_mon_link_descs[mac_id];
1921 }
1922 
1923 /**
1924  * dp_monitor_pdev_attach() - Monitor pdev attach
1925  * @pdev: point to pdev
1926  *
1927  * Return: return QDF_STATUS
1928  */
dp_monitor_pdev_attach(struct dp_pdev * pdev)1929 static inline QDF_STATUS dp_monitor_pdev_attach(struct dp_pdev *pdev)
1930 {
1931 	struct dp_mon_ops *monitor_ops;
1932 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
1933 
1934 	/*
1935 	 * mon_soc uninitialized modular support enabled
1936 	 * monitor related attach/detach/init/deinit
1937 	 * will be done while monitor insmod
1938 	 */
1939 	if (!mon_soc)
1940 		return QDF_STATUS_SUCCESS;
1941 
1942 	monitor_ops = mon_soc->mon_ops;
1943 	if (!monitor_ops || !monitor_ops->mon_pdev_attach) {
1944 		dp_mon_debug("callback not registered");
1945 		return QDF_STATUS_E_FAILURE;
1946 	}
1947 
1948 	return monitor_ops->mon_pdev_attach(pdev);
1949 }
1950 
1951 /**
1952  * dp_monitor_pdev_detach() - Monitor pdev detach
1953  * @pdev: point to pdev
1954  *
1955  * Return: return QDF_STATUS
1956  */
dp_monitor_pdev_detach(struct dp_pdev * pdev)1957 static inline QDF_STATUS dp_monitor_pdev_detach(struct dp_pdev *pdev)
1958 {
1959 	struct dp_mon_ops *monitor_ops;
1960 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
1961 
1962 	/*
1963 	 * mon_soc uninitialized modular support enabled
1964 	 * monitor related attach/detach/init/deinit
1965 	 * will be done while monitor insmod
1966 	 */
1967 	if (!mon_soc)
1968 		return QDF_STATUS_SUCCESS;
1969 
1970 	monitor_ops = mon_soc->mon_ops;
1971 	if (!monitor_ops || !monitor_ops->mon_pdev_detach) {
1972 		dp_mon_debug("callback not registered");
1973 		return QDF_STATUS_E_FAILURE;
1974 	}
1975 
1976 	return monitor_ops->mon_pdev_detach(pdev);
1977 }
1978 
1979 /**
1980  * dp_monitor_vdev_attach() - Monitor vdev attach
1981  * @vdev: point to vdev
1982  *
1983  * Return: return QDF_STATUS
1984  */
dp_monitor_vdev_attach(struct dp_vdev * vdev)1985 static inline QDF_STATUS dp_monitor_vdev_attach(struct dp_vdev *vdev)
1986 {
1987 	struct dp_mon_ops *monitor_ops;
1988 	struct dp_mon_soc *mon_soc = vdev->pdev->soc->monitor_soc;
1989 
1990 	if (!mon_soc)
1991 		return QDF_STATUS_E_FAILURE;
1992 
1993 	monitor_ops = mon_soc->mon_ops;
1994 	if (!monitor_ops || !monitor_ops->mon_vdev_attach) {
1995 		dp_mon_debug("callback not registered");
1996 		return QDF_STATUS_E_FAILURE;
1997 	}
1998 
1999 	return monitor_ops->mon_vdev_attach(vdev);
2000 }
2001 
2002 /**
2003  * dp_monitor_vdev_detach() - Monitor vdev detach
2004  * @vdev: point to vdev
2005  *
2006  * Return: return QDF_STATUS
2007  */
dp_monitor_vdev_detach(struct dp_vdev * vdev)2008 static inline QDF_STATUS dp_monitor_vdev_detach(struct dp_vdev *vdev)
2009 {
2010 	struct dp_mon_ops *monitor_ops;
2011 	struct dp_mon_soc *mon_soc = vdev->pdev->soc->monitor_soc;
2012 
2013 	if (!mon_soc)
2014 		return QDF_STATUS_E_FAILURE;
2015 
2016 	monitor_ops = mon_soc->mon_ops;
2017 	if (!monitor_ops || !monitor_ops->mon_vdev_detach) {
2018 		dp_mon_debug("callback not registered");
2019 		return QDF_STATUS_E_FAILURE;
2020 	}
2021 
2022 	return monitor_ops->mon_vdev_detach(vdev);
2023 }
2024 
2025 /**
2026  * dp_monitor_peer_attach() - Monitor peer attach
2027  * @soc: point to soc
2028  * @peer: point to peer
2029  *
2030  * Return: return QDF_STATUS
2031  */
dp_monitor_peer_attach(struct dp_soc * soc,struct dp_peer * peer)2032 static inline QDF_STATUS dp_monitor_peer_attach(struct dp_soc *soc,
2033 						struct dp_peer *peer)
2034 {
2035 	struct dp_mon_ops *monitor_ops;
2036 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2037 
2038 	if (!mon_soc)
2039 		return QDF_STATUS_E_FAILURE;
2040 
2041 	monitor_ops = mon_soc->mon_ops;
2042 	if (!monitor_ops || !monitor_ops->mon_peer_attach) {
2043 		dp_mon_debug("callback not registered");
2044 		return QDF_STATUS_E_FAILURE;
2045 	}
2046 
2047 	return monitor_ops->mon_peer_attach(peer);
2048 }
2049 
2050 /**
2051  * dp_monitor_peer_detach() - Monitor peer detach
2052  * @soc: point to soc
2053  * @peer: point to peer
2054  *
2055  * Return: return QDF_STATUS
2056  */
dp_monitor_peer_detach(struct dp_soc * soc,struct dp_peer * peer)2057 static inline QDF_STATUS dp_monitor_peer_detach(struct dp_soc *soc,
2058 						struct dp_peer *peer)
2059 {
2060 	struct dp_mon_ops *monitor_ops;
2061 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2062 
2063 	if (!mon_soc)
2064 		return QDF_STATUS_E_FAILURE;
2065 
2066 	monitor_ops = mon_soc->mon_ops;
2067 	if (!monitor_ops || !monitor_ops->mon_peer_detach) {
2068 		dp_mon_debug("callback not registered");
2069 		return QDF_STATUS_E_FAILURE;
2070 	}
2071 
2072 	return monitor_ops->mon_peer_detach(peer);
2073 }
2074 
2075 /**
2076  * dp_monitor_peer_get_peerstats_ctx() - Get peerstats context from monitor peer
2077  * @soc: Datapath soc handle
2078  * @peer: Datapath peer handle
2079  *
2080  * Return: peer stats context
2081  */
2082 static inline struct cdp_peer_rate_stats_ctx*
dp_monitor_peer_get_peerstats_ctx(struct dp_soc * soc,struct dp_peer * peer)2083 dp_monitor_peer_get_peerstats_ctx(struct dp_soc *soc, struct dp_peer *peer)
2084 {
2085 	struct dp_mon_ops *monitor_ops;
2086 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2087 
2088 	if (!mon_soc)
2089 		return NULL;
2090 
2091 	monitor_ops = mon_soc->mon_ops;
2092 	if (!monitor_ops || !monitor_ops->mon_peer_get_peerstats_ctx) {
2093 		dp_mon_debug("callback not registered");
2094 		return NULL;
2095 	}
2096 
2097 	return monitor_ops->mon_peer_get_peerstats_ctx(peer);
2098 }
2099 
2100 /**
2101  * dp_monitor_peer_reset_stats() - Reset monitor peer stats
2102  * @soc: Datapath soc handle
2103  * @peer: Datapath peer handle
2104  *
2105  * Return: none
2106  */
dp_monitor_peer_reset_stats(struct dp_soc * soc,struct dp_peer * peer)2107 static inline void dp_monitor_peer_reset_stats(struct dp_soc *soc,
2108 					       struct dp_peer *peer)
2109 {
2110 	struct dp_mon_ops *monitor_ops;
2111 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2112 
2113 	if (!mon_soc)
2114 		return;
2115 
2116 	monitor_ops = mon_soc->mon_ops;
2117 	if (!monitor_ops || !monitor_ops->mon_peer_reset_stats) {
2118 		dp_mon_debug("callback not registered");
2119 		return;
2120 	}
2121 
2122 	monitor_ops->mon_peer_reset_stats(peer);
2123 }
2124 
2125 /**
2126  * dp_monitor_peer_get_stats() - Get monitor peer stats
2127  * @soc: Datapath soc handle
2128  * @peer: Datapath peer handle
2129  * @arg: Pointer to stats struct
2130  * @type: Update type
2131  *
2132  * Return: none
2133  */
2134 static inline
dp_monitor_peer_get_stats(struct dp_soc * soc,struct dp_peer * peer,void * arg,enum cdp_stat_update_type type)2135 void dp_monitor_peer_get_stats(struct dp_soc *soc, struct dp_peer *peer,
2136 			       void *arg, enum cdp_stat_update_type type)
2137 {
2138 	struct dp_mon_ops *monitor_ops;
2139 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2140 
2141 	if (!mon_soc)
2142 		return;
2143 
2144 	monitor_ops = mon_soc->mon_ops;
2145 	if (!monitor_ops || !monitor_ops->mon_peer_get_stats) {
2146 		dp_mon_debug("callback not registered");
2147 		return;
2148 	}
2149 
2150 	monitor_ops->mon_peer_get_stats(peer, arg, type);
2151 }
2152 
2153 /**
2154  * dp_monitor_invalid_peer_update_pdev_stats() - Update pdev stats from
2155  *						invalid monitor peer
2156  * @soc: Datapath soc handle
2157  * @pdev: Datapath pdev handle
2158  *
2159  * Return: none
2160  */
2161 static inline
dp_monitor_invalid_peer_update_pdev_stats(struct dp_soc * soc,struct dp_pdev * pdev)2162 void dp_monitor_invalid_peer_update_pdev_stats(struct dp_soc *soc,
2163 					       struct dp_pdev *pdev)
2164 {
2165 	struct dp_mon_ops *monitor_ops;
2166 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2167 
2168 	if (!mon_soc)
2169 		return;
2170 
2171 	monitor_ops = mon_soc->mon_ops;
2172 	if (!monitor_ops || !monitor_ops->mon_invalid_peer_update_pdev_stats) {
2173 		dp_mon_debug("callback not registered");
2174 		return;
2175 	}
2176 
2177 	monitor_ops->mon_invalid_peer_update_pdev_stats(pdev);
2178 }
2179 
2180 /**
2181  * dp_monitor_peer_get_stats_param() - Get stats param value from monitor peer
2182  * @soc: Datapath soc handle
2183  * @peer: Datapath peer handle
2184  * @type: Stats type requested
2185  * @buf: Pointer to buffer for stats param
2186  *
2187  * Return: QDF_STATUS
2188  */
2189 static inline QDF_STATUS
dp_monitor_peer_get_stats_param(struct dp_soc * soc,struct dp_peer * peer,enum cdp_peer_stats_type type,cdp_peer_stats_param_t * buf)2190 dp_monitor_peer_get_stats_param(struct dp_soc *soc, struct dp_peer *peer,
2191 				enum cdp_peer_stats_type type,
2192 				cdp_peer_stats_param_t *buf)
2193 {
2194 	struct dp_mon_ops *monitor_ops;
2195 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2196 
2197 	if (!mon_soc)
2198 		return QDF_STATUS_E_FAILURE;
2199 
2200 	monitor_ops = mon_soc->mon_ops;
2201 	if (!monitor_ops || !monitor_ops->mon_peer_get_stats_param) {
2202 		dp_mon_debug("callback not registered");
2203 		return QDF_STATUS_E_FAILURE;
2204 	}
2205 
2206 	return monitor_ops->mon_peer_get_stats_param(peer, type, buf);
2207 }
2208 
2209 /**
2210  * dp_monitor_pdev_init() - Monitor pdev init
2211  * @pdev: point to pdev
2212  *
2213  * Return: return QDF_STATUS
2214  */
dp_monitor_pdev_init(struct dp_pdev * pdev)2215 static inline QDF_STATUS dp_monitor_pdev_init(struct dp_pdev *pdev)
2216 {
2217 	struct dp_mon_ops *monitor_ops;
2218 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
2219 
2220 	/*
2221 	 * mon_soc uninitialized when modular support enabled
2222 	 * monitor related attach/detach/init/deinit
2223 	 * will be done while monitor insmod
2224 	 */
2225 	if (!mon_soc)
2226 		return QDF_STATUS_SUCCESS;
2227 
2228 	monitor_ops = mon_soc->mon_ops;
2229 	if (!monitor_ops || !monitor_ops->mon_pdev_init) {
2230 		dp_mon_debug("callback not registered");
2231 		return QDF_STATUS_E_FAILURE;
2232 	}
2233 
2234 	return monitor_ops->mon_pdev_init(pdev);
2235 }
2236 
2237 /**
2238  * dp_monitor_pdev_deinit() - Monitor pdev deinit
2239  * @pdev: point to pdev
2240  *
2241  * Return: return QDF_STATUS
2242  */
dp_monitor_pdev_deinit(struct dp_pdev * pdev)2243 static inline QDF_STATUS dp_monitor_pdev_deinit(struct dp_pdev *pdev)
2244 {
2245 	struct dp_mon_ops *monitor_ops;
2246 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
2247 
2248 	/*
2249 	 * mon_soc uninitialized modular when support enabled
2250 	 * monitor related attach/detach/init/deinit
2251 	 * will be done while monitor insmod
2252 	 */
2253 	if (!mon_soc)
2254 		return QDF_STATUS_SUCCESS;
2255 
2256 	monitor_ops = mon_soc->mon_ops;
2257 	if (!monitor_ops || !monitor_ops->mon_pdev_deinit) {
2258 		dp_mon_debug("callback not registered");
2259 		return QDF_STATUS_E_FAILURE;
2260 	}
2261 
2262 	return monitor_ops->mon_pdev_deinit(pdev);
2263 }
2264 
2265 /**
2266  * dp_monitor_soc_cfg_init() - Monitor sco cfg init
2267  * @soc: point to soc
2268  *
2269  * Return: return QDF_STATUS
2270  */
dp_monitor_soc_cfg_init(struct dp_soc * soc)2271 static inline QDF_STATUS dp_monitor_soc_cfg_init(struct dp_soc *soc)
2272 {
2273 	struct dp_mon_ops *monitor_ops;
2274 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2275 
2276 	/*
2277 	 * this API is getting call from dp_soc_init,
2278 	 * mon_soc will be uninitialized when monitor support enabled
2279 	 * So returning QDF_STATUS_SUCCESS.
2280 	 * soc cfg init will be done while monitor insmod.
2281 	 */
2282 	if (!mon_soc)
2283 		return QDF_STATUS_SUCCESS;
2284 
2285 	monitor_ops = mon_soc->mon_ops;
2286 	if (!monitor_ops || !monitor_ops->mon_soc_cfg_init) {
2287 		dp_mon_debug("callback not registered");
2288 		return QDF_STATUS_E_FAILURE;
2289 	}
2290 
2291 	return monitor_ops->mon_soc_cfg_init(soc);
2292 }
2293 
2294 /**
2295  * dp_monitor_config_debug_sniffer() - Monitor config debug sniffer
2296  * @pdev: point to pdev
2297  * @val: val
2298  *
2299  * Return: return QDF_STATUS
2300  */
dp_monitor_config_debug_sniffer(struct dp_pdev * pdev,int val)2301 static inline QDF_STATUS dp_monitor_config_debug_sniffer(struct dp_pdev *pdev,
2302 							 int val)
2303 {
2304 	struct dp_mon_ops *monitor_ops;
2305 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
2306 
2307 	if (!mon_soc)
2308 		return QDF_STATUS_E_FAILURE;
2309 
2310 	monitor_ops = mon_soc->mon_ops;
2311 	if (!monitor_ops || !monitor_ops->mon_config_debug_sniffer) {
2312 		dp_mon_debug("callback not registered");
2313 		return QDF_STATUS_E_FAILURE;
2314 	}
2315 
2316 	return monitor_ops->mon_config_debug_sniffer(pdev, val);
2317 }
2318 
2319 /**
2320  * dp_monitor_flush_rings() - Flush monitor rings
2321  * @soc: point to soc
2322  *
2323  * Return: None
2324  */
dp_monitor_flush_rings(struct dp_soc * soc)2325 static inline void dp_monitor_flush_rings(struct dp_soc *soc)
2326 {
2327 	struct dp_mon_ops *monitor_ops;
2328 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2329 
2330 	if (!mon_soc) {
2331 		dp_mon_debug("monitor soc is NULL");
2332 		return;
2333 	}
2334 
2335 	monitor_ops = mon_soc->mon_ops;
2336 	if (!monitor_ops || !monitor_ops->mon_flush_rings) {
2337 		dp_mon_debug("callback not registered");
2338 		return;
2339 	}
2340 
2341 	return monitor_ops->mon_flush_rings(soc);
2342 }
2343 
2344 /**
2345  * dp_monitor_config_undecoded_metadata_capture() - Monitor config
2346  * undecoded metadata capture
2347  * @pdev: point to pdev
2348  * @val: val
2349  *
2350  * Return: return QDF_STATUS
2351  */
2352 #ifdef QCA_UNDECODED_METADATA_SUPPORT
2353 static inline
dp_monitor_config_undecoded_metadata_capture(struct dp_pdev * pdev,int val)2354 QDF_STATUS dp_monitor_config_undecoded_metadata_capture(struct dp_pdev *pdev,
2355 							int val)
2356 {
2357 	struct dp_mon_ops *monitor_ops;
2358 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
2359 
2360 	if (!mon_soc)
2361 		return QDF_STATUS_E_FAILURE;
2362 
2363 	monitor_ops = mon_soc->mon_ops;
2364 	if (!monitor_ops ||
2365 	    !monitor_ops->mon_config_undecoded_metadata_capture) {
2366 		dp_mon_debug("callback not registered");
2367 		return QDF_STATUS_E_FAILURE;
2368 	}
2369 
2370 	return monitor_ops->mon_config_undecoded_metadata_capture(pdev, val);
2371 }
2372 
2373 static inline QDF_STATUS
dp_monitor_config_undecoded_metadata_phyrx_error_mask(struct dp_pdev * pdev,int mask,int mask_cont)2374 dp_monitor_config_undecoded_metadata_phyrx_error_mask(struct dp_pdev *pdev,
2375 						      int mask, int mask_cont)
2376 {
2377 	struct dp_mon_ops *monitor_ops;
2378 	struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
2379 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
2380 
2381 	if (!mon_soc)
2382 		return QDF_STATUS_E_FAILURE;
2383 
2384 	if (!mon_pdev)
2385 		return QDF_STATUS_E_FAILURE;
2386 
2387 	monitor_ops = mon_soc->mon_ops;
2388 	if (!monitor_ops ||
2389 	    !monitor_ops->mon_config_undecoded_metadata_capture) {
2390 		dp_mon_debug("callback not registered");
2391 		return QDF_STATUS_E_FAILURE;
2392 	}
2393 
2394 	if (!mon_pdev->undecoded_metadata_capture) {
2395 		qdf_info("mask:0x%x mask_cont:0x%x", mask, mask_cont);
2396 		return QDF_STATUS_SUCCESS;
2397 	}
2398 
2399 	mon_pdev->phyrx_error_mask = mask;
2400 	mon_pdev->phyrx_error_mask_cont = mask_cont;
2401 
2402 	return monitor_ops->mon_config_undecoded_metadata_capture(pdev, 1);
2403 }
2404 
2405 static inline QDF_STATUS
dp_monitor_get_undecoded_metadata_phyrx_error_mask(struct dp_pdev * pdev,int * mask,int * mask_cont)2406 dp_monitor_get_undecoded_metadata_phyrx_error_mask(struct dp_pdev *pdev,
2407 						   int *mask, int *mask_cont)
2408 {
2409 	struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
2410 
2411 	if (!mon_pdev)
2412 		return QDF_STATUS_E_FAILURE;
2413 
2414 	*mask = mon_pdev->phyrx_error_mask;
2415 	*mask_cont = mon_pdev->phyrx_error_mask_cont;
2416 
2417 	return QDF_STATUS_SUCCESS;
2418 }
2419 #else
2420 static inline
dp_monitor_config_undecoded_metadata_capture(struct dp_pdev * pdev,int val)2421 QDF_STATUS dp_monitor_config_undecoded_metadata_capture(struct dp_pdev *pdev,
2422 							int val)
2423 {
2424 	return QDF_STATUS_SUCCESS;
2425 }
2426 
2427 static inline QDF_STATUS
dp_monitor_config_undecoded_metadata_phyrx_error_mask(struct dp_pdev * pdev,int mask1,int mask2)2428 dp_monitor_config_undecoded_metadata_phyrx_error_mask(struct dp_pdev *pdev,
2429 						      int mask1, int mask2)
2430 {
2431 	return QDF_STATUS_SUCCESS;
2432 }
2433 
2434 static inline QDF_STATUS
dp_monitor_get_undecoded_metadata_phyrx_error_mask(struct dp_pdev * pdev,int * mask,int * mask_cont)2435 dp_monitor_get_undecoded_metadata_phyrx_error_mask(struct dp_pdev *pdev,
2436 						   int *mask, int *mask_cont)
2437 {
2438 	return QDF_STATUS_SUCCESS;
2439 }
2440 #endif /* QCA_UNDECODED_METADATA_SUPPORT */
2441 
2442 /**
2443  * dp_monitor_htt_srng_setup() - Setup htt srng
2444  * @soc: point to soc
2445  * @pdev: point to pdev
2446  * @mac_id: lmac id
2447  * @mac_for_pdev: pdev id
2448  *
2449  * Return: QDF_STATUS
2450  */
2451 #if !defined(DISABLE_MON_CONFIG)
dp_monitor_htt_srng_setup(struct dp_soc * soc,struct dp_pdev * pdev,int mac_id,int mac_for_pdev)2452 static inline QDF_STATUS dp_monitor_htt_srng_setup(struct dp_soc *soc,
2453 						   struct dp_pdev *pdev,
2454 						   int mac_id,
2455 						   int mac_for_pdev)
2456 {
2457 	struct dp_mon_ops *monitor_ops;
2458 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2459 	QDF_STATUS status = QDF_STATUS_SUCCESS;
2460 
2461 	if (!mon_soc) {
2462 		dp_mon_debug("monitor soc is NULL");
2463 		return QDF_STATUS_SUCCESS;
2464 	}
2465 
2466 	monitor_ops = mon_soc->mon_ops;
2467 	if (!monitor_ops) {
2468 		dp_mon_err("monitor_ops is NULL");
2469 		return QDF_STATUS_E_FAILURE;
2470 	}
2471 
2472 	if (monitor_ops->mon_pdev_htt_srng_setup[0]) {
2473 		status = monitor_ops->mon_pdev_htt_srng_setup[0](soc, pdev,
2474 							mac_id, mac_for_pdev);
2475 		if (QDF_IS_STATUS_ERROR(status)) {
2476 			dp_mon_err("error: %d", status);
2477 			goto error;
2478 		}
2479 	}
2480 
2481 	if (monitor_ops->mon_pdev_htt_srng_setup[1]) {
2482 		status = monitor_ops->mon_pdev_htt_srng_setup[1](soc, pdev,
2483 							mac_id, mac_for_pdev);
2484 		if (QDF_IS_STATUS_ERROR(status)) {
2485 			dp_mon_err("error: %d", status);
2486 			goto error;
2487 		}
2488 	}
2489 
2490 error:
2491 	return status;
2492 }
2493 
dp_monitor_soc_htt_srng_setup(struct dp_soc * soc)2494 static inline QDF_STATUS dp_monitor_soc_htt_srng_setup(struct dp_soc *soc)
2495 {
2496 	struct dp_mon_ops *monitor_ops;
2497 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2498 
2499 	if (!mon_soc) {
2500 		dp_mon_debug("monitor soc is NULL");
2501 		return QDF_STATUS_SUCCESS;
2502 	}
2503 
2504 	monitor_ops = mon_soc->mon_ops;
2505 	if (!monitor_ops || !monitor_ops->mon_soc_htt_srng_setup) {
2506 		dp_mon_debug("callback not registered");
2507 		return QDF_STATUS_E_FAILURE;
2508 	}
2509 
2510 	return monitor_ops->mon_soc_htt_srng_setup(soc);
2511 }
2512 #else
dp_monitor_htt_srng_setup(struct dp_soc * soc,struct dp_pdev * pdev,int mac_id,int mac_for_pdev)2513 static inline QDF_STATUS dp_monitor_htt_srng_setup(struct dp_soc *soc,
2514 						   struct dp_pdev *pdev,
2515 						   int mac_id,
2516 						   int mac_for_pdev)
2517 {
2518 	return QDF_STATUS_SUCCESS;
2519 }
2520 #endif
2521 
2522 /**
2523  * dp_monitor_service_mon_rings() - service monitor rings
2524  * @soc: point to soc
2525  * @quota: reap budget
2526  *
2527  * Return: None
2528  */
2529 #if defined(DP_CON_MON)
2530 static inline
dp_monitor_service_mon_rings(struct dp_soc * soc,uint32_t quota)2531 void dp_monitor_service_mon_rings(struct dp_soc *soc, uint32_t quota)
2532 {
2533 	struct dp_mon_ops *monitor_ops;
2534 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2535 
2536 	if (!mon_soc) {
2537 		dp_mon_debug("monitor soc is NULL");
2538 		return;
2539 	}
2540 
2541 	monitor_ops = mon_soc->mon_ops;
2542 	if (!monitor_ops || !monitor_ops->mon_service_rings) {
2543 		dp_mon_debug("callback not registered");
2544 		return;
2545 	}
2546 
2547 	return monitor_ops->mon_service_rings(soc, quota);
2548 }
2549 #endif
2550 
2551 /**
2552  * dp_monitor_process() - Process monitor
2553  * @soc: point to soc
2554  * @int_ctx: interrupt ctx
2555  * @mac_id: lma
2556  * @quota:
2557  *
2558  * Return: None
2559  */
2560 #ifndef DISABLE_MON_CONFIG
2561 static inline
dp_monitor_process(struct dp_soc * soc,struct dp_intr * int_ctx,uint32_t mac_id,uint32_t quota)2562 uint32_t dp_monitor_process(struct dp_soc *soc, struct dp_intr *int_ctx,
2563 			       uint32_t mac_id, uint32_t quota)
2564 {
2565 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2566 
2567 	if (!mon_soc) {
2568 		dp_mon_debug("monitor soc is NULL");
2569 		return 0;
2570 	}
2571 
2572 	if (!mon_soc->mon_rx_process) {
2573 		dp_mon_debug("callback not registered");
2574 		return 0;
2575 	}
2576 
2577 	return mon_soc->mon_rx_process(soc, int_ctx, mac_id, quota);
2578 }
2579 
2580 static inline
dp_tx_mon_process(struct dp_soc * soc,struct dp_intr * int_ctx,uint32_t mac_id,uint32_t quota)2581 uint32_t dp_tx_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
2582 			   uint32_t mac_id, uint32_t quota)
2583 {
2584 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2585 	struct dp_mon_ops *monitor_ops;
2586 
2587 	if (!mon_soc) {
2588 		dp_mon_debug("monitor soc is NULL");
2589 		return 0;
2590 	}
2591 
2592 	monitor_ops = mon_soc->mon_ops;
2593 	if (!monitor_ops || !monitor_ops->mon_tx_process) {
2594 		dp_mon_debug("callback not registered");
2595 		return 0;
2596 	}
2597 
2598 	return monitor_ops->mon_tx_process(soc, int_ctx, mac_id, quota);
2599 }
2600 
2601 static inline
dp_tx_mon_buf_refill(struct dp_intr * int_ctx)2602 uint32_t dp_tx_mon_buf_refill(struct dp_intr *int_ctx)
2603 {
2604 	struct dp_soc *soc = int_ctx->soc;
2605 	struct dp_mon_ops *monitor_ops;
2606 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2607 
2608 	if (!mon_soc) {
2609 		dp_mon_debug("monitor soc is NULL");
2610 		return 0;
2611 	}
2612 
2613 	monitor_ops = mon_soc->mon_ops;
2614 	if (!monitor_ops || !monitor_ops->tx_mon_refill_buf_ring) {
2615 		dp_mon_debug("callback not registered");
2616 		return 0;
2617 	}
2618 
2619 	return monitor_ops->tx_mon_refill_buf_ring(int_ctx);
2620 }
2621 
2622 static inline
dp_rx_mon_buf_refill(struct dp_intr * int_ctx)2623 uint32_t dp_rx_mon_buf_refill(struct dp_intr *int_ctx)
2624 {
2625 	struct dp_soc *soc = int_ctx->soc;
2626 	struct dp_mon_ops *monitor_ops;
2627 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2628 
2629 	if (!mon_soc) {
2630 		dp_mon_debug("monitor soc is NULL");
2631 		return 0;
2632 	}
2633 
2634 	monitor_ops = mon_soc->mon_ops;
2635 	if (!monitor_ops || !monitor_ops->rx_mon_refill_buf_ring) {
2636 		dp_mon_debug("callback not registered");
2637 		return 0;
2638 	}
2639 
2640 	return monitor_ops->rx_mon_refill_buf_ring(int_ctx);
2641 }
2642 
2643 static inline
dp_print_txmon_ring_stat_from_hal(struct dp_pdev * pdev)2644 void dp_print_txmon_ring_stat_from_hal(struct dp_pdev *pdev)
2645 {
2646 	struct dp_soc *soc = pdev->soc;
2647 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2648 	struct dp_mon_ops *monitor_ops;
2649 
2650 	if (!mon_soc) {
2651 		dp_mon_debug("monitor soc is NULL");
2652 		return;
2653 	}
2654 
2655 	monitor_ops = mon_soc->mon_ops;
2656 	if (!monitor_ops || !monitor_ops->print_txmon_ring_stat) {
2657 		dp_mon_debug("callback not registered");
2658 		return;
2659 	}
2660 
2661 	monitor_ops->print_txmon_ring_stat(pdev);
2662 }
2663 
2664 #else
2665 static inline
dp_monitor_process(struct dp_soc * soc,struct dp_intr * int_ctx,uint32_t mac_id,uint32_t quota)2666 uint32_t dp_monitor_process(struct dp_soc *soc, struct dp_intr *int_ctx,
2667 			       uint32_t mac_id, uint32_t quota)
2668 {
2669 	return 0;
2670 }
2671 
2672 static inline uint32_t
dp_tx_mon_process(struct dp_soc * soc,struct dp_intr * int_ctx,uint32_t mac_id,uint32_t quota)2673 dp_tx_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
2674 		  uint32_t mac_id, uint32_t quota)
2675 {
2676 	return 0;
2677 }
2678 
2679 static inline
dp_tx_mon_buf_refill(struct dp_intr * int_ctx)2680 uint32_t dp_tx_mon_buf_refill(struct dp_intr *int_ctx)
2681 {
2682 	return 0;
2683 }
2684 
2685 static inline
dp_rx_mon_buf_refill(struct dp_intr * int_ctx)2686 uint32_t dp_rx_mon_buf_refill(struct dp_intr *int_ctx)
2687 {
2688 	return 0;
2689 }
2690 
2691 static inline
dp_print_txmon_ring_stat_from_hal(struct dp_pdev * pdev)2692 void dp_print_txmon_ring_stat_from_hal(struct dp_pdev *pdev)
2693 {
2694 }
2695 #endif
2696 
2697 /**
2698  * dp_monitor_drop_packets_for_mac() - monitor_drop_packets_for_mac
2699  * @pdev: point to pdev
2700  * @mac_id:
2701  * @quota:
2702  *
2703  * Return:
2704  */
2705 #if !defined(DISABLE_MON_CONFIG) && defined(MON_ENABLE_DROP_FOR_MAC)
2706 static inline
dp_monitor_drop_packets_for_mac(struct dp_pdev * pdev,uint32_t mac_id,uint32_t quota)2707 uint32_t dp_monitor_drop_packets_for_mac(struct dp_pdev *pdev,
2708 					 uint32_t mac_id, uint32_t quota)
2709 {
2710 	struct dp_mon_ops *monitor_ops;
2711 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
2712 
2713 	if (!mon_soc) {
2714 		dp_mon_debug("monitor soc is NULL");
2715 		return 0;
2716 	}
2717 
2718 	monitor_ops = mon_soc->mon_ops;
2719 	if (!monitor_ops || !monitor_ops->mon_drop_packets_for_mac) {
2720 		dp_mon_debug("callback not registered");
2721 		return 0;
2722 	}
2723 
2724 	return monitor_ops->mon_drop_packets_for_mac(pdev,
2725 						     mac_id, quota, false);
2726 }
2727 #else
2728 static inline
dp_monitor_drop_packets_for_mac(struct dp_pdev * pdev,uint32_t mac_id,uint32_t quota)2729 uint32_t dp_monitor_drop_packets_for_mac(struct dp_pdev *pdev,
2730 					 uint32_t mac_id, uint32_t quota)
2731 {
2732 	return 0;
2733 }
2734 #endif
2735 
2736 /**
2737  * dp_monitor_peer_tx_init() - peer tx init
2738  * @pdev: point to pdev
2739  * @peer: point to peer
2740  *
2741  * Return: None
2742  */
dp_monitor_peer_tx_init(struct dp_pdev * pdev,struct dp_peer * peer)2743 static inline void dp_monitor_peer_tx_init(struct dp_pdev *pdev,
2744 					   struct dp_peer *peer)
2745 {
2746 	struct dp_mon_ops *monitor_ops;
2747 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
2748 
2749 	if (!mon_soc) {
2750 		dp_mon_debug("monitor soc is NULL");
2751 		return;
2752 	}
2753 
2754 	monitor_ops = mon_soc->mon_ops;
2755 	if (!monitor_ops || !monitor_ops->mon_peer_tx_init) {
2756 		dp_mon_debug("callback not registered");
2757 		return;
2758 	}
2759 
2760 	return monitor_ops->mon_peer_tx_init(pdev, peer);
2761 }
2762 
2763 /**
2764  * dp_monitor_peer_tx_cleanup() - peer tx cleanup
2765  * @vdev: point to vdev
2766  * @peer: point to peer
2767  *
2768  * Return: None
2769  */
dp_monitor_peer_tx_cleanup(struct dp_vdev * vdev,struct dp_peer * peer)2770 static inline void dp_monitor_peer_tx_cleanup(struct dp_vdev *vdev,
2771 					      struct dp_peer *peer)
2772 {
2773 	struct dp_mon_ops *monitor_ops;
2774 	struct dp_mon_soc *mon_soc = vdev->pdev->soc->monitor_soc;
2775 
2776 	if (!mon_soc) {
2777 		dp_mon_debug("monitor soc is NULL");
2778 		return;
2779 	}
2780 
2781 	monitor_ops = mon_soc->mon_ops;
2782 	if (!monitor_ops || !monitor_ops->mon_peer_tx_cleanup) {
2783 		dp_mon_debug("callback not registered");
2784 		return;
2785 	}
2786 
2787 	return monitor_ops->mon_peer_tx_cleanup(vdev, peer);
2788 }
2789 
2790 #ifdef WIFI_MONITOR_SUPPORT
2791 /**
2792  * dp_monitor_peer_tid_peer_id_update() - peer tid update
2793  * @soc: point to soc
2794  * @peer: point to peer
2795  * @peer_id: peer id
2796  *
2797  * Return: None
2798  */
2799 static inline
dp_monitor_peer_tid_peer_id_update(struct dp_soc * soc,struct dp_peer * peer,uint16_t peer_id)2800 void dp_monitor_peer_tid_peer_id_update(struct dp_soc *soc,
2801 					struct dp_peer *peer,
2802 					uint16_t peer_id)
2803 {
2804 	struct dp_mon_ops *monitor_ops;
2805 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2806 
2807 	if (!mon_soc) {
2808 		dp_mon_debug("monitor soc is NULL");
2809 		return;
2810 	}
2811 
2812 	monitor_ops = mon_soc->mon_ops;
2813 	if (!monitor_ops || !monitor_ops->mon_peer_tid_peer_id_update) {
2814 		dp_mon_debug("callback not registered");
2815 		return;
2816 	}
2817 
2818 	return monitor_ops->mon_peer_tid_peer_id_update(peer, peer_id);
2819 }
2820 
2821 /**
2822  * dp_monitor_tx_ppdu_stats_attach() - Attach tx ppdu stats
2823  * @pdev: point to pdev
2824  *
2825  * Return: None
2826  */
dp_monitor_tx_ppdu_stats_attach(struct dp_pdev * pdev)2827 static inline void dp_monitor_tx_ppdu_stats_attach(struct dp_pdev *pdev)
2828 {
2829 	struct dp_mon_ops *monitor_ops;
2830 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
2831 
2832 	if (!mon_soc) {
2833 		dp_mon_debug("monitor soc is NULL");
2834 		return;
2835 	}
2836 
2837 	monitor_ops = mon_soc->mon_ops;
2838 	if (!monitor_ops || !monitor_ops->mon_tx_ppdu_stats_attach) {
2839 		dp_mon_debug("callback not registered");
2840 		return;
2841 	}
2842 
2843 	return monitor_ops->mon_tx_ppdu_stats_attach(pdev);
2844 }
2845 
2846 /**
2847  * dp_monitor_tx_ppdu_stats_detach() - Detach tx ppdu stats
2848  * @pdev: point to pdev
2849  *
2850  * Return: None
2851  */
dp_monitor_tx_ppdu_stats_detach(struct dp_pdev * pdev)2852 static inline void dp_monitor_tx_ppdu_stats_detach(struct dp_pdev *pdev)
2853 {
2854 	struct dp_mon_ops *monitor_ops;
2855 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
2856 
2857 	if (!mon_soc) {
2858 		dp_mon_debug("monitor soc is NULL");
2859 		return;
2860 	}
2861 
2862 	monitor_ops = mon_soc->mon_ops;
2863 	if (!monitor_ops || !monitor_ops->mon_tx_ppdu_stats_detach) {
2864 		dp_mon_debug("callback not registered");
2865 		return;
2866 	}
2867 
2868 	return monitor_ops->mon_tx_ppdu_stats_detach(pdev);
2869 }
2870 
2871 /**
2872  * dp_monitor_tx_capture_debugfs_init() - Init tx capture debugfs
2873  * @pdev: point to pdev
2874  *
2875  * Return: QDF_STATUS_SUCCESS
2876  */
2877 static inline
dp_monitor_tx_capture_debugfs_init(struct dp_pdev * pdev)2878 QDF_STATUS dp_monitor_tx_capture_debugfs_init(struct dp_pdev *pdev)
2879 {
2880 	struct dp_mon_ops *monitor_ops;
2881 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
2882 
2883 	if (!mon_soc) {
2884 		dp_mon_debug("monitor soc is NULL");
2885 		return QDF_STATUS_E_FAILURE;
2886 	}
2887 
2888 	monitor_ops = mon_soc->mon_ops;
2889 	if (!monitor_ops || !monitor_ops->mon_tx_capture_debugfs_init) {
2890 		dp_mon_debug("callback not registered");
2891 		return QDF_STATUS_E_FAILURE;
2892 	}
2893 
2894 	return monitor_ops->mon_tx_capture_debugfs_init(pdev);
2895 }
2896 
2897 /**
2898  * dp_monitor_peer_tx_capture_filter_check() - Check tx capture filter
2899  * @pdev: point to pdev
2900  * @peer: point to peer
2901  *
2902  * Return: None
2903  */
dp_monitor_peer_tx_capture_filter_check(struct dp_pdev * pdev,struct dp_peer * peer)2904 static inline void dp_monitor_peer_tx_capture_filter_check(struct dp_pdev *pdev,
2905 							   struct dp_peer *peer)
2906 {
2907 	struct dp_mon_ops *monitor_ops;
2908 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
2909 
2910 	if (!mon_soc) {
2911 		dp_mon_debug("monitor soc is NULL");
2912 		return;
2913 	}
2914 
2915 	monitor_ops = mon_soc->mon_ops;
2916 	if (!monitor_ops || !monitor_ops->mon_peer_tx_capture_filter_check) {
2917 		dp_mon_debug("callback not registered");
2918 		return;
2919 	}
2920 
2921 	return monitor_ops->mon_peer_tx_capture_filter_check(pdev, peer);
2922 }
2923 
2924 /**
2925  * dp_monitor_tx_add_to_comp_queue() - add completion msdu to queue
2926  *
2927  * This API returns QDF_STATUS_SUCCESS in case where buffer is added
2928  * to txmonitor queue successfully caller will not free the buffer in
2929  * this case. In other cases this API return QDF_STATUS_E_FAILURE and
2930  * caller frees the buffer
2931  *
2932  * @soc: point to soc
2933  * @desc: point to tx desc
2934  * @ts: Tx completion status from HAL/HTT descriptor
2935  * @peer_id: DP peer id
2936  *
2937  * Return: QDF_STATUS
2938  *
2939  */
2940 static inline
dp_monitor_tx_add_to_comp_queue(struct dp_soc * soc,struct dp_tx_desc_s * desc,struct hal_tx_completion_status * ts,uint16_t peer_id)2941 QDF_STATUS dp_monitor_tx_add_to_comp_queue(struct dp_soc *soc,
2942 					   struct dp_tx_desc_s *desc,
2943 					   struct hal_tx_completion_status *ts,
2944 					   uint16_t peer_id)
2945 {
2946 	struct dp_mon_ops *monitor_ops;
2947 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2948 
2949 	if (!mon_soc) {
2950 		dp_mon_debug("monitor soc is NULL");
2951 		return QDF_STATUS_E_FAILURE;
2952 	}
2953 
2954 	monitor_ops = mon_soc->mon_ops;
2955 	if (!monitor_ops || !monitor_ops->mon_tx_add_to_comp_queue) {
2956 		dp_mon_debug("callback not registered");
2957 		return QDF_STATUS_E_FAILURE;
2958 	}
2959 
2960 	return monitor_ops->mon_tx_add_to_comp_queue(soc, desc, ts, peer_id);
2961 }
2962 
2963 static inline
monitor_update_msdu_to_list(struct dp_soc * soc,struct dp_pdev * pdev,struct dp_peer * peer,struct hal_tx_completion_status * ts,qdf_nbuf_t netbuf)2964 QDF_STATUS monitor_update_msdu_to_list(struct dp_soc *soc,
2965 				       struct dp_pdev *pdev,
2966 				       struct dp_peer *peer,
2967 				       struct hal_tx_completion_status *ts,
2968 				       qdf_nbuf_t netbuf)
2969 {
2970 	struct dp_mon_ops *monitor_ops;
2971 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
2972 
2973 	if (!mon_soc) {
2974 		dp_mon_debug("monitor soc is NULL");
2975 		return QDF_STATUS_SUCCESS;
2976 	}
2977 
2978 	monitor_ops = mon_soc->mon_ops;
2979 	if (!monitor_ops || !monitor_ops->mon_update_msdu_to_list) {
2980 		dp_mon_debug("callback not registered");
2981 		return QDF_STATUS_E_FAILURE;
2982 	}
2983 
2984 	return monitor_ops->mon_update_msdu_to_list(soc, pdev,
2985 						    peer, ts, netbuf);
2986 }
2987 
2988 /**
2989  * dp_monitor_peer_tx_capture_get_stats - to get Peer Tx Capture stats
2990  * @soc: DP SOC handle
2991  * @peer: DP PEER handle
2992  * @stats: Pointer Peer tx capture stats
2993  *
2994  * Return: QDF_STATUS_E_FAILURE or QDF_STATUS_SUCCESS
2995  */
2996 static inline QDF_STATUS
dp_monitor_peer_tx_capture_get_stats(struct dp_soc * soc,struct dp_peer * peer,struct cdp_peer_tx_capture_stats * stats)2997 dp_monitor_peer_tx_capture_get_stats(struct dp_soc *soc, struct dp_peer *peer,
2998 				     struct cdp_peer_tx_capture_stats *stats)
2999 {
3000 	struct dp_mon_ops *monitor_ops;
3001 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
3002 
3003 	if (!mon_soc) {
3004 		dp_mon_debug("monitor soc is NULL");
3005 		return QDF_STATUS_E_FAILURE;
3006 	}
3007 
3008 	monitor_ops = mon_soc->mon_ops;
3009 	if (!monitor_ops || !monitor_ops->mon_peer_tx_capture_get_stats) {
3010 		dp_mon_debug("callback not registered");
3011 		return QDF_STATUS_E_FAILURE;
3012 	}
3013 
3014 	return monitor_ops->mon_peer_tx_capture_get_stats(peer, stats);
3015 }
3016 
3017 /**
3018  * dp_monitor_pdev_tx_capture_get_stats - to get pdev tx capture stats
3019  * @soc: DP SOC handle
3020  * @pdev: DP PDEV handle
3021  * @stats: Pointer to pdev tx capture stats
3022  *
3023  * Return: QDF_STATUS_E_FAILURE or QDF_STATUS_SUCCESS
3024  */
3025 static inline QDF_STATUS
dp_monitor_pdev_tx_capture_get_stats(struct dp_soc * soc,struct dp_pdev * pdev,struct cdp_pdev_tx_capture_stats * stats)3026 dp_monitor_pdev_tx_capture_get_stats(struct dp_soc *soc, struct dp_pdev *pdev,
3027 				     struct cdp_pdev_tx_capture_stats *stats)
3028 {
3029 	struct dp_mon_ops *monitor_ops;
3030 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
3031 
3032 	if (!mon_soc) {
3033 		dp_mon_debug("monitor soc is NULL");
3034 		return QDF_STATUS_E_FAILURE;
3035 	}
3036 
3037 	monitor_ops = mon_soc->mon_ops;
3038 	if (!monitor_ops || !monitor_ops->mon_pdev_tx_capture_get_stats) {
3039 		dp_mon_debug("callback not registered");
3040 		return QDF_STATUS_E_FAILURE;
3041 	}
3042 
3043 	return monitor_ops->mon_pdev_tx_capture_get_stats(pdev, stats);
3044 }
3045 #else
3046 static inline
dp_monitor_peer_tid_peer_id_update(struct dp_soc * soc,struct dp_peer * peer,uint16_t peer_id)3047 void dp_monitor_peer_tid_peer_id_update(struct dp_soc *soc,
3048 					struct dp_peer *peer,
3049 					uint16_t peer_id)
3050 {
3051 }
3052 
dp_monitor_tx_ppdu_stats_attach(struct dp_pdev * pdev)3053 static inline void dp_monitor_tx_ppdu_stats_attach(struct dp_pdev *pdev)
3054 {
3055 }
3056 
dp_monitor_tx_ppdu_stats_detach(struct dp_pdev * pdev)3057 static inline void dp_monitor_tx_ppdu_stats_detach(struct dp_pdev *pdev)
3058 {
3059 }
3060 
3061 static inline
dp_monitor_tx_capture_debugfs_init(struct dp_pdev * pdev)3062 QDF_STATUS dp_monitor_tx_capture_debugfs_init(struct dp_pdev *pdev)
3063 {
3064 	return QDF_STATUS_E_FAILURE;
3065 }
3066 
dp_monitor_peer_tx_capture_filter_check(struct dp_pdev * pdev,struct dp_peer * peer)3067 static inline void dp_monitor_peer_tx_capture_filter_check(struct dp_pdev *pdev,
3068 							   struct dp_peer *peer)
3069 {
3070 }
3071 
3072 static inline
dp_monitor_tx_add_to_comp_queue(struct dp_soc * soc,struct dp_tx_desc_s * desc,struct hal_tx_completion_status * ts,uint16_t peer_id)3073 QDF_STATUS dp_monitor_tx_add_to_comp_queue(struct dp_soc *soc,
3074 					   struct dp_tx_desc_s *desc,
3075 					   struct hal_tx_completion_status *ts,
3076 					   uint16_t peer_id)
3077 {
3078 	return QDF_STATUS_E_FAILURE;
3079 }
3080 
3081 static inline
monitor_update_msdu_to_list(struct dp_soc * soc,struct dp_pdev * pdev,struct dp_peer * peer,struct hal_tx_completion_status * ts,qdf_nbuf_t netbuf)3082 QDF_STATUS monitor_update_msdu_to_list(struct dp_soc *soc,
3083 				       struct dp_pdev *pdev,
3084 				       struct dp_peer *peer,
3085 				       struct hal_tx_completion_status *ts,
3086 				       qdf_nbuf_t netbuf)
3087 {
3088 	return QDF_STATUS_E_FAILURE;
3089 }
3090 
3091 static inline QDF_STATUS
dp_monitor_peer_tx_capture_get_stats(struct dp_soc * soc,struct dp_peer * peer,struct cdp_peer_tx_capture_stats * stats)3092 dp_monitor_peer_tx_capture_get_stats(struct dp_soc *soc, struct dp_peer *peer,
3093 				     struct cdp_peer_tx_capture_stats *stats)
3094 {
3095 	return QDF_STATUS_E_FAILURE;
3096 }
3097 
3098 static inline QDF_STATUS
dp_monitor_pdev_tx_capture_get_stats(struct dp_soc * soc,struct dp_pdev * pdev,struct cdp_pdev_tx_capture_stats * stats)3099 dp_monitor_pdev_tx_capture_get_stats(struct dp_soc *soc, struct dp_pdev *pdev,
3100 				     struct cdp_pdev_tx_capture_stats *stats)
3101 {
3102 	return QDF_STATUS_E_FAILURE;
3103 }
3104 #endif
3105 
3106 /**
3107  * dp_monitor_ppdu_stats_ind_handler() - PPDU stats msg handler
3108  * @soc:     HTT SOC handle
3109  * @msg_word:    Pointer to payload
3110  * @htt_t2h_msg: HTT msg nbuf
3111  *
3112  * Return: True if buffer should be freed by caller.
3113  */
3114 #if defined(WDI_EVENT_ENABLE) &&\
3115 	(defined(QCA_ENHANCED_STATS_SUPPORT) || !defined(REMOVE_PKT_LOG) ||\
3116 	 defined(WLAN_FEATURE_PKT_CAPTURE_V2))
dp_monitor_ppdu_stats_ind_handler(struct htt_soc * soc,uint32_t * msg_word,qdf_nbuf_t htt_t2h_msg)3117 static inline bool dp_monitor_ppdu_stats_ind_handler(struct htt_soc *soc,
3118 						     uint32_t *msg_word,
3119 						     qdf_nbuf_t htt_t2h_msg)
3120 {
3121 	struct dp_mon_ops *monitor_ops;
3122 	struct dp_mon_soc *mon_soc = soc->dp_soc->monitor_soc;
3123 
3124 	if (!mon_soc) {
3125 		dp_mon_debug("monitor soc is NULL");
3126 		return true;
3127 	}
3128 
3129 	monitor_ops = mon_soc->mon_ops;
3130 	if (!monitor_ops || !monitor_ops->mon_ppdu_stats_ind_handler) {
3131 		dp_mon_debug("callback not registered");
3132 		return true;
3133 	}
3134 
3135 	return monitor_ops->mon_ppdu_stats_ind_handler(soc, msg_word,
3136 						       htt_t2h_msg);
3137 }
3138 #else
dp_monitor_ppdu_stats_ind_handler(struct htt_soc * soc,uint32_t * msg_word,qdf_nbuf_t htt_t2h_msg)3139 static inline bool dp_monitor_ppdu_stats_ind_handler(struct htt_soc *soc,
3140 						     uint32_t *msg_word,
3141 						     qdf_nbuf_t htt_t2h_msg)
3142 {
3143 	return true;
3144 }
3145 #endif
3146 
3147 /**
3148  * dp_monitor_htt_ppdu_stats_attach() - attach resources for HTT PPDU
3149  * stats processing
3150  * @pdev: Datapath PDEV handle
3151  *
3152  * Return: QDF_STATUS
3153  */
dp_monitor_htt_ppdu_stats_attach(struct dp_pdev * pdev)3154 static inline QDF_STATUS dp_monitor_htt_ppdu_stats_attach(struct dp_pdev *pdev)
3155 {
3156 	struct dp_mon_ops *monitor_ops;
3157 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3158 
3159 	if (!mon_soc) {
3160 		dp_mon_debug("monitor soc is NULL");
3161 		return QDF_STATUS_SUCCESS;
3162 	}
3163 
3164 	monitor_ops = mon_soc->mon_ops;
3165 	if (!monitor_ops || !monitor_ops->mon_htt_ppdu_stats_attach) {
3166 		dp_mon_debug("callback not registered");
3167 		return QDF_STATUS_E_FAILURE;
3168 	}
3169 
3170 	return monitor_ops->mon_htt_ppdu_stats_attach(pdev);
3171 }
3172 
3173 /**
3174  * dp_monitor_htt_ppdu_stats_detach() - detach stats resources
3175  * @pdev: Datapath PDEV handle
3176  *
3177  * Return: void
3178  */
dp_monitor_htt_ppdu_stats_detach(struct dp_pdev * pdev)3179 static inline void dp_monitor_htt_ppdu_stats_detach(struct dp_pdev *pdev)
3180 {
3181 	struct dp_mon_ops *monitor_ops;
3182 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3183 
3184 	if (!mon_soc) {
3185 		dp_mon_debug("monitor soc is NULL");
3186 		return;
3187 	}
3188 
3189 	monitor_ops = mon_soc->mon_ops;
3190 	if (!monitor_ops || !monitor_ops->mon_htt_ppdu_stats_detach) {
3191 		dp_mon_debug("callback not registered");
3192 		return;
3193 	}
3194 
3195 	return monitor_ops->mon_htt_ppdu_stats_detach(pdev);
3196 }
3197 
3198 /**
3199  * dp_monitor_print_pdev_rx_mon_stats() - print rx mon stats
3200  * @pdev: Datapath PDEV handle
3201  *
3202  * Return: void
3203  */
dp_monitor_print_pdev_rx_mon_stats(struct dp_pdev * pdev)3204 static inline void dp_monitor_print_pdev_rx_mon_stats(struct dp_pdev *pdev)
3205 {
3206 	struct dp_mon_ops *monitor_ops;
3207 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3208 
3209 	if (!mon_soc) {
3210 		dp_mon_debug("monitor soc is NULL");
3211 		return;
3212 	}
3213 
3214 	monitor_ops = mon_soc->mon_ops;
3215 	if (!monitor_ops || !monitor_ops->mon_print_pdev_rx_mon_stats) {
3216 		dp_mon_debug("callback not registered");
3217 		return;
3218 	}
3219 
3220 	return monitor_ops->mon_print_pdev_rx_mon_stats(pdev);
3221 }
3222 
3223 #ifdef WIFI_MONITOR_SUPPORT
3224 /**
3225  * dp_monitor_print_pdev_tx_capture_stats() - print tx capture stats
3226  * @pdev: Datapath PDEV handle
3227  *
3228  * Return: void
3229  */
dp_monitor_print_pdev_tx_capture_stats(struct dp_pdev * pdev)3230 static inline void dp_monitor_print_pdev_tx_capture_stats(struct dp_pdev *pdev)
3231 {
3232 	struct dp_mon_ops *monitor_ops;
3233 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3234 
3235 	if (!mon_soc) {
3236 		dp_mon_debug("monitor soc is NULL");
3237 		return;
3238 	}
3239 
3240 	monitor_ops = mon_soc->mon_ops;
3241 	if (!monitor_ops || !monitor_ops->mon_print_pdev_tx_capture_stats) {
3242 		dp_mon_debug("callback not registered");
3243 		return;
3244 	}
3245 
3246 	return monitor_ops->mon_print_pdev_tx_capture_stats(pdev);
3247 }
3248 
3249 /**
3250  * dp_monitor_config_enh_tx_capture() - configure tx capture
3251  * @pdev: Datapath PDEV handle
3252  * @val: mode
3253  *
3254  * Return: status
3255  */
dp_monitor_config_enh_tx_capture(struct dp_pdev * pdev,uint32_t val)3256 static inline QDF_STATUS dp_monitor_config_enh_tx_capture(struct dp_pdev *pdev,
3257 							  uint32_t val)
3258 {
3259 	struct dp_mon_ops *monitor_ops;
3260 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3261 
3262 	if (!mon_soc) {
3263 		dp_mon_debug("monitor soc is NULL");
3264 		return QDF_STATUS_E_FAILURE;
3265 	}
3266 
3267 	monitor_ops = mon_soc->mon_ops;
3268 	if (!monitor_ops || !monitor_ops->mon_config_enh_tx_capture) {
3269 		dp_mon_debug("callback not registered");
3270 		return QDF_STATUS_E_FAILURE;
3271 	}
3272 
3273 	return monitor_ops->mon_config_enh_tx_capture(pdev, val);
3274 }
3275 
3276 /**
3277  * dp_monitor_tx_peer_filter() -  add tx monitor peer filter
3278  * @pdev: Datapath PDEV handle
3279  * @peer: Datapath PEER handle
3280  * @is_tx_pkt_cap_enable: flag for tx capture enable/disable
3281  * @peer_mac: peer mac address
3282  *
3283  * Return: status
3284  */
dp_monitor_tx_peer_filter(struct dp_pdev * pdev,struct dp_peer * peer,uint8_t is_tx_pkt_cap_enable,uint8_t * peer_mac)3285 static inline QDF_STATUS dp_monitor_tx_peer_filter(struct dp_pdev *pdev,
3286 						   struct dp_peer *peer,
3287 						   uint8_t is_tx_pkt_cap_enable,
3288 						   uint8_t *peer_mac)
3289 {
3290 	struct dp_mon_ops *monitor_ops;
3291 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3292 
3293 	if (!mon_soc) {
3294 		qdf_err("monitor soc is NULL");
3295 		return QDF_STATUS_E_FAILURE;
3296 	}
3297 
3298 	monitor_ops = mon_soc->mon_ops;
3299 	if (!monitor_ops || !monitor_ops->mon_tx_peer_filter) {
3300 		qdf_err("callback not registered");
3301 		return QDF_STATUS_E_FAILURE;
3302 	}
3303 
3304 	return monitor_ops->mon_tx_peer_filter(pdev, peer, is_tx_pkt_cap_enable,
3305 					       peer_mac);
3306 }
3307 #endif
3308 
3309 #ifdef WLAN_RX_PKT_CAPTURE_ENH
dp_monitor_config_enh_rx_capture(struct dp_pdev * pdev,uint32_t val)3310 static inline QDF_STATUS dp_monitor_config_enh_rx_capture(struct dp_pdev *pdev,
3311 							  uint32_t val)
3312 {
3313 	struct dp_mon_ops *monitor_ops;
3314 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3315 
3316 	if (!mon_soc) {
3317 		dp_mon_debug("monitor soc is NULL");
3318 		return QDF_STATUS_E_FAILURE;
3319 	}
3320 
3321 	monitor_ops = mon_soc->mon_ops;
3322 	if (!monitor_ops || !monitor_ops->mon_config_enh_rx_capture) {
3323 		dp_mon_debug("callback not registered");
3324 		return QDF_STATUS_E_FAILURE;
3325 	}
3326 
3327 	return monitor_ops->mon_config_enh_rx_capture(pdev, val);
3328 }
3329 #else
dp_monitor_config_enh_rx_capture(struct dp_pdev * pdev,uint32_t val)3330 static inline QDF_STATUS dp_monitor_config_enh_rx_capture(struct dp_pdev *pdev,
3331 							  uint32_t val)
3332 {
3333 	return QDF_STATUS_E_INVAL;
3334 }
3335 #endif
3336 
3337 #ifdef QCA_SUPPORT_BPR
dp_monitor_set_bpr_enable(struct dp_pdev * pdev,uint32_t val)3338 static inline QDF_STATUS dp_monitor_set_bpr_enable(struct dp_pdev *pdev,
3339 						   uint32_t val)
3340 {
3341 	struct dp_mon_ops *monitor_ops;
3342 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3343 
3344 	if (!mon_soc) {
3345 		dp_mon_debug("monitor soc is NULL");
3346 		return QDF_STATUS_E_FAILURE;
3347 	}
3348 
3349 	monitor_ops = mon_soc->mon_ops;
3350 	if (!monitor_ops || !monitor_ops->mon_set_bpr_enable) {
3351 		dp_mon_debug("callback not registered");
3352 		return QDF_STATUS_E_FAILURE;
3353 	}
3354 
3355 	return monitor_ops->mon_set_bpr_enable(pdev, val);
3356 }
3357 #else
dp_monitor_set_bpr_enable(struct dp_pdev * pdev,uint32_t val)3358 static inline QDF_STATUS dp_monitor_set_bpr_enable(struct dp_pdev *pdev,
3359 						   uint32_t val)
3360 {
3361 	return QDF_STATUS_E_FAILURE;
3362 }
3363 #endif
3364 
3365 #ifdef ATH_SUPPORT_NAC
3366 static inline
dp_monitor_set_filter_neigh_peers(struct dp_pdev * pdev,bool val)3367 int dp_monitor_set_filter_neigh_peers(struct dp_pdev *pdev, bool val)
3368 {
3369 	struct dp_mon_ops *monitor_ops;
3370 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3371 
3372 	if (!mon_soc) {
3373 		dp_mon_debug("monitor soc is NULL");
3374 		return 0;
3375 	}
3376 
3377 	monitor_ops = mon_soc->mon_ops;
3378 	if (!monitor_ops || !monitor_ops->mon_set_filter_neigh_peers) {
3379 		dp_mon_debug("callback not registered");
3380 		return 0;
3381 	}
3382 
3383 	return monitor_ops->mon_set_filter_neigh_peers(pdev, val);
3384 }
3385 #else
3386 static inline
dp_monitor_set_filter_neigh_peers(struct dp_pdev * pdev,bool val)3387 int dp_monitor_set_filter_neigh_peers(struct dp_pdev *pdev, bool val)
3388 {
3389 	return 0;
3390 }
3391 #endif
3392 
3393 #ifdef WLAN_ATF_ENABLE
3394 static inline
dp_monitor_set_atf_stats_enable(struct dp_pdev * pdev,bool value)3395 void dp_monitor_set_atf_stats_enable(struct dp_pdev *pdev, bool value)
3396 {
3397 	struct dp_mon_ops *monitor_ops;
3398 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3399 
3400 	if (!mon_soc) {
3401 		dp_mon_debug("monitor soc is NULL");
3402 		return;
3403 	}
3404 
3405 	monitor_ops = mon_soc->mon_ops;
3406 	if (!monitor_ops || !monitor_ops->mon_set_atf_stats_enable) {
3407 		dp_mon_debug("callback not registered");
3408 		return;
3409 	}
3410 
3411 	return monitor_ops->mon_set_atf_stats_enable(pdev, value);
3412 }
3413 #else
3414 static inline
dp_monitor_set_atf_stats_enable(struct dp_pdev * pdev,bool value)3415 void dp_monitor_set_atf_stats_enable(struct dp_pdev *pdev, bool value)
3416 {
3417 }
3418 #endif
3419 
3420 static inline
dp_monitor_set_bsscolor(struct dp_pdev * pdev,uint8_t bsscolor)3421 void dp_monitor_set_bsscolor(struct dp_pdev *pdev, uint8_t bsscolor)
3422 {
3423 	struct dp_mon_ops *monitor_ops;
3424 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3425 
3426 	if (!mon_soc) {
3427 		dp_mon_debug("monitor soc is NULL");
3428 		return;
3429 	}
3430 
3431 	monitor_ops = mon_soc->mon_ops;
3432 	if (!monitor_ops || !monitor_ops->mon_set_bsscolor) {
3433 		dp_mon_debug("callback not registered");
3434 		return;
3435 	}
3436 
3437 	return monitor_ops->mon_set_bsscolor(pdev, bsscolor);
3438 }
3439 
3440 static inline
dp_monitor_pdev_get_filter_mcast_data(struct cdp_pdev * pdev_handle)3441 bool dp_monitor_pdev_get_filter_mcast_data(struct cdp_pdev *pdev_handle)
3442 {
3443 	struct dp_mon_ops *monitor_ops;
3444 	struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
3445 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3446 
3447 	if (!mon_soc) {
3448 		dp_mon_debug("monitor soc is NULL");
3449 		return false;
3450 	}
3451 
3452 	monitor_ops = mon_soc->mon_ops;
3453 	if (!monitor_ops || !monitor_ops->mon_pdev_get_filter_mcast_data) {
3454 		dp_mon_debug("callback not registered");
3455 		return false;
3456 	}
3457 
3458 	return monitor_ops->mon_pdev_get_filter_mcast_data(pdev_handle);
3459 }
3460 
3461 static inline
dp_monitor_pdev_get_filter_non_data(struct cdp_pdev * pdev_handle)3462 bool dp_monitor_pdev_get_filter_non_data(struct cdp_pdev *pdev_handle)
3463 {
3464 	struct dp_mon_ops *monitor_ops;
3465 	struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
3466 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3467 
3468 	if (!mon_soc) {
3469 		dp_mon_debug("monitor soc is NULL");
3470 		return false;
3471 	}
3472 
3473 	monitor_ops = mon_soc->mon_ops;
3474 	if (!monitor_ops || !monitor_ops->mon_pdev_get_filter_non_data) {
3475 		dp_mon_debug("callback not registered");
3476 		return false;
3477 	}
3478 
3479 	return monitor_ops->mon_pdev_get_filter_non_data(pdev_handle);
3480 }
3481 
3482 static inline
dp_monitor_pdev_get_filter_ucast_data(struct cdp_pdev * pdev_handle)3483 bool dp_monitor_pdev_get_filter_ucast_data(struct cdp_pdev *pdev_handle)
3484 {
3485 	struct dp_mon_ops *monitor_ops;
3486 	struct dp_pdev *pdev = (struct dp_pdev *)pdev_handle;
3487 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3488 
3489 	if (!mon_soc) {
3490 		dp_mon_debug("monitor soc is NULL");
3491 		return false;
3492 	}
3493 
3494 	monitor_ops = mon_soc->mon_ops;
3495 	if (!monitor_ops || !monitor_ops->mon_pdev_get_filter_ucast_data) {
3496 		dp_mon_debug("callback not registered");
3497 		return false;
3498 	}
3499 
3500 	return monitor_ops->mon_pdev_get_filter_ucast_data(pdev_handle);
3501 }
3502 
3503 #ifdef WDI_EVENT_ENABLE
3504 static inline
dp_monitor_set_pktlog_wifi3(struct dp_pdev * pdev,uint32_t event,bool enable)3505 int dp_monitor_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event,
3506 				bool enable)
3507 {
3508 	struct dp_mon_ops *monitor_ops;
3509 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3510 
3511 	if (!mon_soc) {
3512 		dp_mon_debug("monitor soc is NULL");
3513 		return 0;
3514 	}
3515 
3516 	monitor_ops = mon_soc->mon_ops;
3517 	if (!monitor_ops || !monitor_ops->mon_set_pktlog_wifi3) {
3518 		dp_mon_debug("callback not registered");
3519 		return 0;
3520 	}
3521 
3522 	return monitor_ops->mon_set_pktlog_wifi3(pdev, event, enable);
3523 }
3524 #else
3525 static inline
dp_monitor_set_pktlog_wifi3(struct dp_pdev * pdev,uint32_t event,bool enable)3526 int dp_monitor_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event,
3527 				bool enable)
3528 {
3529 	return 0;
3530 }
3531 #endif
3532 
3533 #if defined(DP_CON_MON) && !defined(REMOVE_PKT_LOG)
dp_monitor_pktlogmod_exit(struct dp_pdev * pdev)3534 static inline void dp_monitor_pktlogmod_exit(struct dp_pdev *pdev)
3535 {
3536 	struct dp_mon_ops *monitor_ops;
3537 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3538 
3539 	if (!mon_soc) {
3540 		dp_mon_debug("monitor soc is NULL");
3541 		return;
3542 	}
3543 
3544 	monitor_ops = mon_soc->mon_ops;
3545 	if (!monitor_ops || !monitor_ops->mon_pktlogmod_exit) {
3546 		dp_mon_debug("callback not registered");
3547 		return;
3548 	}
3549 
3550 	return monitor_ops->mon_pktlogmod_exit(pdev);
3551 }
3552 #else
dp_monitor_pktlogmod_exit(struct dp_pdev * pdev)3553 static inline void dp_monitor_pktlogmod_exit(struct dp_pdev *pdev) {}
3554 #endif
3555 
3556 static inline
dp_monitor_vdev_set_monitor_mode_buf_rings(struct dp_pdev * pdev)3557 QDF_STATUS dp_monitor_vdev_set_monitor_mode_buf_rings(struct dp_pdev *pdev)
3558 {
3559 	struct dp_mon_ops *monitor_ops;
3560 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3561 
3562 	if (!mon_soc) {
3563 		dp_mon_debug("monitor soc is NULL");
3564 		return QDF_STATUS_E_FAILURE;
3565 	}
3566 
3567 	monitor_ops = mon_soc->mon_ops;
3568 	if (!monitor_ops || !monitor_ops->mon_vdev_set_monitor_mode_buf_rings) {
3569 		dp_mon_debug("callback not registered");
3570 		return QDF_STATUS_E_FAILURE;
3571 	}
3572 
3573 	return monitor_ops->mon_vdev_set_monitor_mode_buf_rings(pdev);
3574 }
3575 
3576 static inline
dp_monitor_neighbour_peers_detach(struct dp_pdev * pdev)3577 void dp_monitor_neighbour_peers_detach(struct dp_pdev *pdev)
3578 {
3579 	struct dp_mon_ops *monitor_ops;
3580 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3581 
3582 	if (!mon_soc) {
3583 		dp_mon_debug("monitor soc is NULL");
3584 		return;
3585 	}
3586 
3587 	monitor_ops = mon_soc->mon_ops;
3588 	if (!monitor_ops || !monitor_ops->mon_neighbour_peers_detach) {
3589 		dp_mon_debug("callback not registered");
3590 		return;
3591 	}
3592 
3593 	return monitor_ops->mon_neighbour_peers_detach(pdev);
3594 }
3595 
3596 #ifdef FEATURE_NAC_RSSI
dp_monitor_filter_neighbour_peer(struct dp_pdev * pdev,uint8_t * rx_pkt_hdr)3597 static inline QDF_STATUS dp_monitor_filter_neighbour_peer(struct dp_pdev *pdev,
3598 							  uint8_t *rx_pkt_hdr)
3599 {
3600 	struct dp_mon_ops *monitor_ops;
3601 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3602 
3603 	if (!mon_soc) {
3604 		dp_mon_debug("monitor soc is NULL");
3605 		return QDF_STATUS_E_FAILURE;
3606 	}
3607 
3608 	monitor_ops = mon_soc->mon_ops;
3609 	if (!monitor_ops || !monitor_ops->mon_filter_neighbour_peer) {
3610 		dp_mon_debug("callback not registered");
3611 		return QDF_STATUS_E_FAILURE;
3612 	}
3613 
3614 	return monitor_ops->mon_filter_neighbour_peer(pdev, rx_pkt_hdr);
3615 }
3616 #else
dp_monitor_filter_neighbour_peer(struct dp_pdev * pdev,uint8_t * rx_pkt_hdr)3617 static inline QDF_STATUS dp_monitor_filter_neighbour_peer(struct dp_pdev *pdev,
3618 							  uint8_t *rx_pkt_hdr)
3619 {
3620 	return QDF_STATUS_E_FAILURE;
3621 }
3622 #endif
3623 
3624 static inline
dp_monitor_reap_timer_init(struct dp_soc * soc)3625 void dp_monitor_reap_timer_init(struct dp_soc *soc)
3626 {
3627 	struct dp_mon_ops *monitor_ops;
3628 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
3629 
3630 	if (!mon_soc) {
3631 		dp_mon_debug("monitor soc is NULL");
3632 		return;
3633 	}
3634 
3635 	monitor_ops = mon_soc->mon_ops;
3636 	if (!monitor_ops || !monitor_ops->mon_reap_timer_init) {
3637 		dp_mon_debug("callback not registered");
3638 		return;
3639 	}
3640 
3641 	monitor_ops->mon_reap_timer_init(soc);
3642 }
3643 
3644 static inline
dp_monitor_reap_timer_deinit(struct dp_soc * soc)3645 void dp_monitor_reap_timer_deinit(struct dp_soc *soc)
3646 {
3647 	struct dp_mon_ops *monitor_ops;
3648 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
3649 
3650 	if (!mon_soc) {
3651 		dp_mon_debug("monitor soc is NULL");
3652 		return;
3653 	}
3654 
3655 	monitor_ops = mon_soc->mon_ops;
3656 	if (!monitor_ops || !monitor_ops->mon_reap_timer_deinit) {
3657 		dp_mon_debug("callback not registered");
3658 		return;
3659 	}
3660 
3661 	monitor_ops->mon_reap_timer_deinit(soc);
3662 }
3663 
3664 /**
3665  * dp_monitor_reap_timer_start() - start reap timer of monitor status ring
3666  * @soc: point to soc
3667  * @source: trigger source
3668  *
3669  * Return: true if timer-start is performed, false otherwise.
3670  */
3671 static inline bool
dp_monitor_reap_timer_start(struct dp_soc * soc,enum cdp_mon_reap_source source)3672 dp_monitor_reap_timer_start(struct dp_soc *soc,
3673 			    enum cdp_mon_reap_source source)
3674 {
3675 	struct dp_mon_ops *monitor_ops;
3676 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
3677 
3678 	if (!mon_soc) {
3679 		dp_mon_debug("monitor soc is NULL");
3680 		return false;
3681 	}
3682 
3683 	monitor_ops = mon_soc->mon_ops;
3684 	if (!monitor_ops || !monitor_ops->mon_reap_timer_start) {
3685 		dp_mon_debug("callback not registered");
3686 		return false;
3687 	}
3688 
3689 	return monitor_ops->mon_reap_timer_start(soc, source);
3690 }
3691 
3692 /**
3693  * dp_monitor_reap_timer_stop() - stop reap timer of monitor status ring
3694  * @soc: point to soc
3695  * @source: trigger source
3696  *
3697  * Return: true if timer-stop is performed, false otherwise.
3698  */
3699 static inline bool
dp_monitor_reap_timer_stop(struct dp_soc * soc,enum cdp_mon_reap_source source)3700 dp_monitor_reap_timer_stop(struct dp_soc *soc,
3701 			   enum cdp_mon_reap_source source)
3702 {
3703 	struct dp_mon_ops *monitor_ops;
3704 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
3705 
3706 	if (!mon_soc) {
3707 		dp_mon_debug("monitor soc is NULL");
3708 		return false;
3709 	}
3710 
3711 	monitor_ops = mon_soc->mon_ops;
3712 	if (!monitor_ops || !monitor_ops->mon_reap_timer_stop) {
3713 		dp_mon_debug("callback not registered");
3714 		return false;
3715 	}
3716 
3717 	return monitor_ops->mon_reap_timer_stop(soc, source);
3718 }
3719 
3720 static inline
dp_monitor_vdev_timer_init(struct dp_soc * soc)3721 void dp_monitor_vdev_timer_init(struct dp_soc *soc)
3722 {
3723 	struct dp_mon_ops *monitor_ops;
3724 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
3725 
3726 	if (!mon_soc) {
3727 		dp_mon_debug("monitor soc is NULL");
3728 		return;
3729 	}
3730 
3731 	monitor_ops = mon_soc->mon_ops;
3732 	if (!monitor_ops || !monitor_ops->mon_vdev_timer_init) {
3733 		dp_mon_debug("callback not registered");
3734 		return;
3735 	}
3736 
3737 	monitor_ops->mon_vdev_timer_init(soc);
3738 }
3739 
3740 static inline
dp_monitor_vdev_timer_deinit(struct dp_soc * soc)3741 void dp_monitor_vdev_timer_deinit(struct dp_soc *soc)
3742 {
3743 	struct dp_mon_ops *monitor_ops;
3744 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
3745 
3746 	if (!mon_soc) {
3747 		dp_mon_debug("monitor soc is NULL");
3748 		return;
3749 	}
3750 
3751 	monitor_ops = mon_soc->mon_ops;
3752 	if (!monitor_ops || !monitor_ops->mon_vdev_timer_deinit) {
3753 		dp_mon_debug("callback not registered");
3754 		return;
3755 	}
3756 
3757 	monitor_ops->mon_vdev_timer_deinit(soc);
3758 }
3759 
3760 static inline
dp_monitor_vdev_timer_start(struct dp_soc * soc)3761 void dp_monitor_vdev_timer_start(struct dp_soc *soc)
3762 {
3763 	struct dp_mon_ops *monitor_ops;
3764 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
3765 
3766 	if (!mon_soc) {
3767 		dp_mon_debug("monitor soc is NULL");
3768 		return;
3769 	}
3770 
3771 	monitor_ops = mon_soc->mon_ops;
3772 	if (!monitor_ops || !monitor_ops->mon_vdev_timer_start) {
3773 		dp_mon_debug("callback not registered");
3774 		return;
3775 	}
3776 
3777 	monitor_ops->mon_vdev_timer_start(soc);
3778 }
3779 
3780 static inline
dp_monitor_vdev_timer_stop(struct dp_soc * soc)3781 bool dp_monitor_vdev_timer_stop(struct dp_soc *soc)
3782 {
3783 	struct dp_mon_ops *monitor_ops;
3784 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
3785 
3786 	if (!mon_soc) {
3787 		dp_mon_debug("monitor soc is NULL");
3788 		return false;
3789 	}
3790 
3791 	monitor_ops = mon_soc->mon_ops;
3792 	if (!monitor_ops || !monitor_ops->mon_vdev_timer_stop) {
3793 		dp_mon_debug("callback not registered");
3794 		return false;
3795 	}
3796 
3797 	return monitor_ops->mon_vdev_timer_stop(soc);
3798 }
3799 
3800 #ifdef QCA_MCOPY_SUPPORT
3801 static inline
dp_monitor_mcopy_check_deliver(struct dp_pdev * pdev,uint16_t peer_id,uint32_t ppdu_id,uint8_t first_msdu)3802 QDF_STATUS dp_monitor_mcopy_check_deliver(struct dp_pdev *pdev,
3803 					  uint16_t peer_id, uint32_t ppdu_id,
3804 					  uint8_t first_msdu)
3805 {
3806 	struct dp_mon_ops *monitor_ops;
3807 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3808 
3809 	if (!mon_soc) {
3810 		dp_mon_debug("monitor soc is NULL");
3811 		return QDF_STATUS_E_FAILURE;
3812 	}
3813 
3814 	monitor_ops = mon_soc->mon_ops;
3815 	if (!monitor_ops || !monitor_ops->mon_mcopy_check_deliver) {
3816 		dp_mon_debug("callback not registered");
3817 		return QDF_STATUS_E_FAILURE;
3818 	}
3819 
3820 	return monitor_ops->mon_mcopy_check_deliver(pdev, peer_id,
3821 						    ppdu_id, first_msdu);
3822 }
3823 #else
3824 static inline
dp_monitor_mcopy_check_deliver(struct dp_pdev * pdev,uint16_t peer_id,uint32_t ppdu_id,uint8_t first_msdu)3825 QDF_STATUS dp_monitor_mcopy_check_deliver(struct dp_pdev *pdev,
3826 					  uint16_t peer_id, uint32_t ppdu_id,
3827 					  uint8_t first_msdu)
3828 {
3829 	return QDF_STATUS_SUCCESS;
3830 }
3831 #endif
3832 
3833 /**
3834  * dp_monitor_neighbour_peer_add_ast() - Add ast entry
3835  * @pdev: point to dp pdev
3836  * @ta_peer: point to peer
3837  * @mac_addr: mac address
3838  * @nbuf: point to nbuf
3839  * @flags: flags
3840  *
3841  * Return: void
3842  */
3843 static inline void
dp_monitor_neighbour_peer_add_ast(struct dp_pdev * pdev,struct dp_peer * ta_peer,uint8_t * mac_addr,qdf_nbuf_t nbuf,uint32_t flags)3844 dp_monitor_neighbour_peer_add_ast(struct dp_pdev *pdev,
3845 				  struct dp_peer *ta_peer,
3846 				  uint8_t *mac_addr,
3847 				  qdf_nbuf_t nbuf,
3848 				  uint32_t flags)
3849 {
3850 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
3851 	struct dp_mon_ops *monitor_ops;
3852 
3853 	if (!mon_soc) {
3854 		dp_mon_debug("monitor soc is NULL");
3855 		return;
3856 	}
3857 
3858 	monitor_ops = mon_soc->mon_ops;
3859 	if (!monitor_ops || !monitor_ops->mon_neighbour_peer_add_ast) {
3860 		dp_mon_debug("callback not registered");
3861 		return;
3862 	}
3863 
3864 	return monitor_ops->mon_neighbour_peer_add_ast(pdev, ta_peer, mac_addr,
3865 						       nbuf, flags);
3866 }
3867 
3868 /**
3869  * dp_monitor_vdev_delete() - delete monitor vdev
3870  * @soc: point to dp soc
3871  * @vdev: point to dp vdev
3872  *
3873  * Return: void
3874  */
dp_monitor_vdev_delete(struct dp_soc * soc,struct dp_vdev * vdev)3875 static inline void dp_monitor_vdev_delete(struct dp_soc *soc,
3876 					  struct dp_vdev *vdev)
3877 {
3878 	if (soc->intr_mode == DP_INTR_POLL) {
3879 		qdf_timer_sync_cancel(&soc->int_timer);
3880 		dp_monitor_flush_rings(soc);
3881 	} else if (soc->intr_mode == DP_INTR_MSI) {
3882 		dp_monitor_vdev_timer_stop(soc);
3883 		dp_monitor_flush_rings(soc);
3884 	}
3885 
3886 	dp_monitor_vdev_detach(vdev);
3887 }
3888 
3889 #ifdef DP_POWER_SAVE
3890 /**
3891  * dp_monitor_reap_timer_suspend() - Stop monitor reap timer
3892  * and reap any pending frames in ring
3893  * @soc: DP soc context
3894  *
3895  * Return: void
3896  */
3897 static inline void
dp_monitor_reap_timer_suspend(struct dp_soc * soc)3898 dp_monitor_reap_timer_suspend(struct dp_soc *soc)
3899 {
3900 	if (dp_monitor_reap_timer_stop(soc, CDP_MON_REAP_SOURCE_ANY))
3901 		dp_monitor_service_mon_rings(soc, DP_MON_REAP_BUDGET);
3902 }
3903 
3904 #endif
3905 
3906 /**
3907  * dp_monitor_neighbour_peer_list_remove() - remove neighbour peer list
3908  * @pdev: point to dp pdev
3909  * @vdev: point to dp vdev
3910  * @peer: point to dp_neighbour_peer
3911  *
3912  * Return: void
3913  */
3914 static inline
dp_monitor_neighbour_peer_list_remove(struct dp_pdev * pdev,struct dp_vdev * vdev,struct dp_neighbour_peer * peer)3915 void dp_monitor_neighbour_peer_list_remove(struct dp_pdev *pdev,
3916 					   struct dp_vdev *vdev,
3917 					   struct dp_neighbour_peer *peer)
3918 {
3919 	struct dp_mon_pdev *mon_pdev;
3920 	struct dp_neighbour_peer *temp_peer = NULL;
3921 
3922 	if (qdf_unlikely(!pdev || !pdev->monitor_pdev))
3923 		return;
3924 
3925 	mon_pdev = pdev->monitor_pdev;
3926 	qdf_spin_lock_bh(&mon_pdev->neighbour_peer_mutex);
3927 	if (!pdev->soc->monitor_soc->hw_nac_monitor_support) {
3928 		TAILQ_FOREACH(peer, &mon_pdev->neighbour_peers_list,
3929 			      neighbour_peer_list_elem) {
3930 				QDF_ASSERT(peer->vdev != vdev);
3931 			}
3932 	} else {
3933 		TAILQ_FOREACH_SAFE(peer, &mon_pdev->neighbour_peers_list,
3934 				   neighbour_peer_list_elem, temp_peer) {
3935 			if (peer->vdev == vdev) {
3936 				TAILQ_REMOVE(&mon_pdev->neighbour_peers_list,
3937 					     peer,
3938 					     neighbour_peer_list_elem);
3939 				qdf_mem_free(peer);
3940 			}
3941 		}
3942 	}
3943 	qdf_spin_unlock_bh(&mon_pdev->neighbour_peer_mutex);
3944 }
3945 
3946 static inline
dp_monitor_pdev_set_mon_vdev(struct dp_vdev * vdev)3947 void dp_monitor_pdev_set_mon_vdev(struct dp_vdev *vdev)
3948 {
3949 	if (!vdev->pdev->monitor_pdev)
3950 		return;
3951 
3952 	vdev->pdev->monitor_pdev->mvdev = vdev;
3953 }
3954 
3955 static inline
dp_monitor_pdev_config_scan_spcl_vap(struct dp_pdev * pdev,bool val)3956 void dp_monitor_pdev_config_scan_spcl_vap(struct dp_pdev *pdev, bool val)
3957 {
3958 	if (!pdev || !pdev->monitor_pdev)
3959 		return;
3960 
3961 	pdev->monitor_pdev->scan_spcl_vap_configured = val;
3962 }
3963 
3964 #ifdef QCA_SUPPORT_SCAN_SPCL_VAP_STATS
3965 static inline
dp_monitor_pdev_reset_scan_spcl_vap_stats_enable(struct dp_pdev * pdev,bool val)3966 void dp_monitor_pdev_reset_scan_spcl_vap_stats_enable(struct dp_pdev *pdev,
3967 						      bool val)
3968 {
3969 	if (!pdev || !pdev->monitor_pdev)
3970 		return;
3971 
3972 	pdev->monitor_pdev->reset_scan_spcl_vap_stats_enable = val;
3973 }
3974 #else
3975 static inline
dp_monitor_pdev_reset_scan_spcl_vap_stats_enable(struct dp_pdev * pdev,bool val)3976 void dp_monitor_pdev_reset_scan_spcl_vap_stats_enable(struct dp_pdev *pdev,
3977 						      bool val)
3978 {
3979 }
3980 #endif
3981 
3982 #if defined(CONFIG_MON_WORD_BASED_TLV)
3983 static inline void
dp_mon_rx_wmask_subscribe(struct dp_soc * soc,uint32_t * msg_word,int pdev_id,struct htt_rx_ring_tlv_filter * tlv_filter)3984 dp_mon_rx_wmask_subscribe(struct dp_soc *soc,
3985 			  uint32_t *msg_word, int pdev_id,
3986 			  struct htt_rx_ring_tlv_filter *tlv_filter)
3987 {
3988 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
3989 	struct dp_mon_ops *monitor_ops;
3990 
3991 	if (!mon_soc) {
3992 		dp_mon_debug("mon soc is NULL");
3993 		return;
3994 
3995 	}
3996 
3997 	monitor_ops = mon_soc->mon_ops;
3998 	if (!monitor_ops || !monitor_ops->rx_wmask_subscribe) {
3999 		dp_mon_debug("callback not registered");
4000 		return;
4001 	}
4002 
4003 	monitor_ops->rx_wmask_subscribe(soc, msg_word, pdev_id, tlv_filter);
4004 }
4005 #else
4006 static inline void
dp_mon_rx_wmask_subscribe(struct dp_soc * soc,uint32_t * msg_word,int pdev_id,struct htt_rx_ring_tlv_filter * tlv_filter)4007 dp_mon_rx_wmask_subscribe(struct dp_soc *soc,
4008 			  uint32_t *msg_word, int pdev_id,
4009 			  struct htt_rx_ring_tlv_filter *tlv_filter)
4010 {
4011 }
4012 #endif
4013 
4014 static inline void
dp_mon_rx_enable_pkt_tlv_offset(struct dp_soc * soc,uint32_t * msg_word,struct htt_rx_ring_tlv_filter * tlv_filter)4015 dp_mon_rx_enable_pkt_tlv_offset(struct dp_soc *soc, uint32_t *msg_word,
4016 				struct htt_rx_ring_tlv_filter *tlv_filter)
4017 {
4018 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
4019 	struct dp_mon_ops *monitor_ops;
4020 
4021 	if (!mon_soc) {
4022 		dp_mon_debug("mon soc is NULL");
4023 		return;
4024 	}
4025 
4026 	monitor_ops = mon_soc->mon_ops;
4027 	if (!monitor_ops || !monitor_ops->rx_pkt_tlv_offset) {
4028 		dp_mon_debug("callback not registered");
4029 		return;
4030 	}
4031 
4032 	monitor_ops->rx_pkt_tlv_offset(msg_word, tlv_filter);
4033 }
4034 
4035 static inline void
dp_mon_rx_enable_mpdu_logging(struct dp_soc * soc,uint32_t * msg_word,struct htt_rx_ring_tlv_filter * tlv_filter)4036 dp_mon_rx_enable_mpdu_logging(struct dp_soc *soc, uint32_t *msg_word,
4037 			      struct htt_rx_ring_tlv_filter *tlv_filter)
4038 {
4039 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
4040 	struct dp_mon_ops *monitor_ops;
4041 
4042 	if (!mon_soc) {
4043 		dp_mon_debug("mon soc is NULL");
4044 		return;
4045 
4046 	}
4047 
4048 	monitor_ops = mon_soc->mon_ops;
4049 	if (!monitor_ops || !monitor_ops->rx_enable_mpdu_logging) {
4050 		dp_mon_debug("callback not registered");
4051 		return;
4052 	}
4053 
4054 	monitor_ops->rx_enable_mpdu_logging(msg_word, tlv_filter);
4055 }
4056 
4057 /**
4058  * dp_mon_rx_enable_fpmo() - set fpmo filters
4059  * @soc: dp soc handle
4060  * @msg_word: msg word
4061  * @tlv_filter: rx fing filter config
4062  *
4063  * Return: void
4064  */
4065 static inline void
dp_mon_rx_enable_fpmo(struct dp_soc * soc,uint32_t * msg_word,struct htt_rx_ring_tlv_filter * tlv_filter)4066 dp_mon_rx_enable_fpmo(struct dp_soc *soc, uint32_t *msg_word,
4067 		      struct htt_rx_ring_tlv_filter *tlv_filter)
4068 {
4069 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
4070 	struct dp_mon_ops *monitor_ops;
4071 
4072 	if (!mon_soc) {
4073 		dp_mon_debug("mon soc is NULL");
4074 		return;
4075 	}
4076 
4077 	monitor_ops = mon_soc->mon_ops;
4078 	if (!monitor_ops || !monitor_ops->rx_enable_fpmo) {
4079 		dp_mon_debug("callback not registered");
4080 		return;
4081 	}
4082 
4083 	monitor_ops->rx_enable_fpmo(msg_word, tlv_filter);
4084 }
4085 
4086 /**
4087  * dp_mon_rx_hdr_length_set() - set rx hdr tlv length
4088  * @soc: dp soc handle
4089  * @msg_word: msg word
4090  * @tlv_filter: rx fing filter config
4091  *
4092  * Return: void
4093  */
4094 static inline void
dp_mon_rx_hdr_length_set(struct dp_soc * soc,uint32_t * msg_word,struct htt_rx_ring_tlv_filter * tlv_filter)4095 dp_mon_rx_hdr_length_set(struct dp_soc *soc, uint32_t *msg_word,
4096 			 struct htt_rx_ring_tlv_filter *tlv_filter)
4097 {
4098 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
4099 	struct dp_mon_ops *monitor_ops;
4100 
4101 	if (!mon_soc) {
4102 		dp_mon_debug("mon soc is NULL");
4103 		return;
4104 	}
4105 
4106 	monitor_ops = mon_soc->mon_ops;
4107 	if (!monitor_ops || !monitor_ops->rx_hdr_length_set) {
4108 		dp_mon_debug("callback not registered");
4109 		return;
4110 	}
4111 
4112 	monitor_ops->rx_hdr_length_set(msg_word, tlv_filter);
4113 }
4114 
4115 static inline void
dp_mon_rx_packet_length_set(struct dp_soc * soc,uint32_t * msg_word,struct htt_rx_ring_tlv_filter * tlv_filter)4116 dp_mon_rx_packet_length_set(struct dp_soc *soc, uint32_t *msg_word,
4117 			    struct htt_rx_ring_tlv_filter *tlv_filter)
4118 {
4119 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
4120 	struct dp_mon_ops *monitor_ops;
4121 
4122 	if (!mon_soc) {
4123 		dp_mon_debug("mon soc is NULL");
4124 		return;
4125 
4126 	}
4127 
4128 	monitor_ops = mon_soc->mon_ops;
4129 	if (!monitor_ops || !monitor_ops->rx_packet_length_set) {
4130 		dp_mon_debug("callback not registered");
4131 		return;
4132 	}
4133 
4134 	monitor_ops->rx_packet_length_set(msg_word, tlv_filter);
4135 }
4136 
4137 static inline void
dp_rx_mon_enable(struct dp_soc * soc,uint32_t * msg_word,struct htt_rx_ring_tlv_filter * tlv_filter)4138 dp_rx_mon_enable(struct dp_soc *soc, uint32_t *msg_word,
4139 		 struct htt_rx_ring_tlv_filter *tlv_filter)
4140 {
4141 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
4142 	struct dp_mon_ops *monitor_ops;
4143 
4144 	if (!mon_soc) {
4145 		dp_mon_debug("mon soc is NULL");
4146 		return;
4147 	}
4148 
4149 	monitor_ops = mon_soc->mon_ops;
4150 	if (!monitor_ops || !monitor_ops->rx_mon_enable) {
4151 		dp_mon_debug("callback not registered");
4152 		return;
4153 	}
4154 
4155 	monitor_ops->rx_mon_enable(msg_word, tlv_filter);
4156 }
4157 
4158 static inline void
dp_mon_rx_mac_filter_set(struct dp_soc * soc,uint32_t * msg_word,struct htt_rx_ring_tlv_filter * tlv_filter)4159 dp_mon_rx_mac_filter_set(struct dp_soc *soc, uint32_t *msg_word,
4160 			 struct htt_rx_ring_tlv_filter *tlv_filter)
4161 {
4162 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
4163 	struct dp_mon_ops *monitor_ops;
4164 
4165 	if (!mon_soc) {
4166 		dp_mon_debug("mon soc is NULL");
4167 		return;
4168 	}
4169 
4170 	monitor_ops = mon_soc->mon_ops;
4171 	if (!monitor_ops || !monitor_ops->mon_mac_filter_set) {
4172 		dp_mon_debug("callback not registered");
4173 		return;
4174 	}
4175 
4176 	monitor_ops->mon_mac_filter_set(msg_word, tlv_filter);
4177 }
4178 
4179 #ifdef QCA_ENHANCED_STATS_SUPPORT
4180 QDF_STATUS dp_peer_qos_stats_notify(struct dp_pdev *dp_pdev,
4181 				    struct cdp_rx_stats_ppdu_user *ppdu_user);
4182 #endif
4183 
4184 /**
4185  * dp_print_pdev_rx_mon_stats() - print rx mon stats
4186  * @pdev: device object
4187  *
4188  * Return: void
4189  */
4190 void
4191 dp_print_pdev_rx_mon_stats(struct dp_pdev *pdev);
4192 
4193 /**
4194  * dp_mcopy_check_deliver() - mcopy check deliver
4195  * @pdev: DP pdev handle
4196  * @peer_id: peer id
4197  * @ppdu_id: ppdu
4198  * @first_msdu: flag to indicate first msdu of ppdu
4199  * Return: 0 on success, not 0 on failure
4200  */
4201 QDF_STATUS dp_mcopy_check_deliver(struct dp_pdev *pdev,
4202 				  uint16_t peer_id,
4203 				  uint32_t ppdu_id,
4204 				  uint8_t first_msdu);
4205 
4206 /**
4207  * dp_pdev_set_advance_monitor_filter() - Set DP PDEV monitor filter
4208  * @soc_hdl: soc handle
4209  * @pdev_id: id of Datapath PDEV handle
4210  * @filter_val: Flag to select Filter for monitor mode
4211  *
4212  * Return: 0 on success, not 0 on failure
4213  */
4214 #ifdef QCA_ADVANCE_MON_FILTER_SUPPORT
4215 QDF_STATUS
4216 dp_pdev_set_advance_monitor_filter(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
4217 				   struct cdp_monitor_filter *filter_val);
4218 #else
4219 static inline QDF_STATUS
dp_pdev_set_advance_monitor_filter(struct cdp_soc_t * soc_hdl,uint8_t pdev_id,struct cdp_monitor_filter * filter_val)4220 dp_pdev_set_advance_monitor_filter(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
4221 				   struct cdp_monitor_filter *filter_val)
4222 {
4223 	return QDF_STATUS_E_INVAL;
4224 }
4225 #endif /* QCA_ADVANCE_MON_FILTER_SUPPORT */
4226 
4227 /**
4228  * dp_deliver_tx_mgmt() - Deliver mgmt frame for tx capture
4229  * @cdp_soc : data path soc handle
4230  * @pdev_id : pdev_id
4231  * @nbuf: Management frame buffer
4232  *
4233  * Return: QDF_STATUS_SUCCESS on success
4234  *	   QDF_STATUS_E_FAILURE on failure
4235  */
4236 QDF_STATUS
4237 dp_deliver_tx_mgmt(struct cdp_soc_t *cdp_soc, uint8_t pdev_id, qdf_nbuf_t nbuf);
4238 
4239 /**
4240  * dp_filter_neighbour_peer() - API to filter neighbour peer
4241  * @pdev : DP pdev handle
4242  * @rx_pkt_hdr : packet header
4243  *
4244  * Return: QDF_STATUS_SUCCESS on success
4245  *	   QDF_STATUS_E_FAILURE on failure
4246  */
4247 #ifdef FEATURE_NAC_RSSI
4248 QDF_STATUS dp_filter_neighbour_peer(struct dp_pdev *pdev,
4249 				    uint8_t *rx_pkt_hdr);
4250 #else
4251 static inline
dp_filter_neighbour_peer(struct dp_pdev * pdev,uint8_t * rx_pkt_hdr)4252 QDF_STATUS dp_filter_neighbour_peer(struct dp_pdev *pdev,
4253 				    uint8_t *rx_pkt_hdr)
4254 {
4255 	return QDF_STATUS_SUCCESS;
4256 }
4257 #endif /* FEATURE_NAC_RSSI */
4258 
4259 /**
4260  * dp_neighbour_peers_detach() - Detach neighbour peers(nac clients)
4261  * @pdev: device object
4262  *
4263  * Return: void
4264  */
4265 void dp_neighbour_peers_detach(struct dp_pdev *pdev);
4266 
4267 /**
4268  * dp_reset_monitor_mode() - Disable monitor mode
4269  * @soc_hdl: Datapath soc handle
4270  * @pdev_id: id of datapath PDEV handle
4271  * @smart_monitor: smart monitor flag
4272  *
4273  * Return: QDF_STATUS
4274  */
4275 QDF_STATUS dp_reset_monitor_mode(struct cdp_soc_t *soc_hdl,
4276 				 uint8_t pdev_id,
4277 				 uint8_t smart_monitor);
4278 
4279 /**
4280  * dp_reset_monitor_mode_unlock() - Disable monitor mode with no locks
4281  * @soc_hdl: Datapath soc handle
4282  * @pdev_id: id of datapath PDEV handle
4283  * @smart_monitor: smart monitor flag
4284  *
4285  * Return: QDF_STATUS
4286  */
4287 #ifdef WIFI_MONITOR_SUPPORT
4288 QDF_STATUS dp_reset_monitor_mode_unlock(struct cdp_soc_t *soc_hdl,
4289 					uint8_t pdev_id,
4290 					uint8_t smart_monitor);
4291 #else
dp_reset_monitor_mode_unlock(struct cdp_soc_t * soc_hdl,uint8_t pdev_id,uint8_t smart_monitor)4292 QDF_STATUS dp_reset_monitor_mode_unlock(struct cdp_soc_t *soc_hdl,
4293 					uint8_t pdev_id,
4294 					uint8_t smart_monitor)
4295 {
4296 	return QDF_STATUS_SUCCESS;
4297 }
4298 #endif
4299 
4300 static inline
dp_mon_ops_get(struct dp_soc * soc)4301 struct dp_mon_ops *dp_mon_ops_get(struct dp_soc *soc)
4302 {
4303 	if (soc && soc->monitor_soc)
4304 		return soc->monitor_soc->mon_ops;
4305 
4306 	return NULL;
4307 }
4308 
4309 static inline
dp_mon_cdp_ops_get(struct dp_soc * soc)4310 struct cdp_mon_ops *dp_mon_cdp_ops_get(struct dp_soc *soc)
4311 {
4312 	struct cdp_ops *ops = soc->cdp_soc.ops;
4313 
4314 	return ops->mon_ops;
4315 }
4316 
4317 /**
4318  * dp_monitor_soc_attach() - Monitor SOC attach
4319  * @soc: DP soc handle
4320  *
4321  * Return: void
4322  */
dp_monitor_soc_attach(struct dp_soc * soc)4323 static inline void dp_monitor_soc_attach(struct dp_soc *soc)
4324 {
4325 	struct dp_mon_ops *mon_ops;
4326 
4327 	mon_ops = dp_mon_ops_get(soc);
4328 
4329 	if (mon_ops && mon_ops->mon_soc_attach[0])
4330 		mon_ops->mon_soc_attach[0](soc);
4331 
4332 	if (mon_ops && mon_ops->mon_soc_attach[1])
4333 		mon_ops->mon_soc_attach[1](soc);
4334 }
4335 
4336 /**
4337  * dp_monitor_soc_detach() - Monitor SOC detach
4338  * @soc: DP soc handle
4339  *
4340  * Return: void
4341  */
dp_monitor_soc_detach(struct dp_soc * soc)4342 static inline void dp_monitor_soc_detach(struct dp_soc *soc)
4343 {
4344 	struct dp_mon_ops *mon_ops;
4345 
4346 	mon_ops = dp_mon_ops_get(soc);
4347 
4348 	if (mon_ops && mon_ops->mon_soc_detach[0])
4349 		mon_ops->mon_soc_detach[0](soc);
4350 
4351 	if (mon_ops && mon_ops->mon_soc_detach[1])
4352 		mon_ops->mon_soc_detach[1](soc);
4353 }
4354 
4355 /**
4356  * dp_monitor_soc_init() - Monitor SOC init
4357  * @soc: DP soc handle
4358  *
4359  * Return: void
4360  */
dp_monitor_soc_init(struct dp_soc * soc)4361 static inline void dp_monitor_soc_init(struct dp_soc *soc)
4362 {
4363 	struct dp_mon_ops *mon_ops;
4364 
4365 	mon_ops = dp_mon_ops_get(soc);
4366 
4367 	if (mon_ops && mon_ops->mon_soc_init[0])
4368 		mon_ops->mon_soc_init[0](soc);
4369 
4370 	if (mon_ops && mon_ops->mon_soc_init[1])
4371 		mon_ops->mon_soc_init[1](soc);
4372 }
4373 
4374 /**
4375  * dp_monitor_soc_deinit() - Monitor SOC deinit
4376  * @soc: DP soc handle
4377  *
4378  * Return: void
4379  */
dp_monitor_soc_deinit(struct dp_soc * soc)4380 static inline void dp_monitor_soc_deinit(struct dp_soc *soc)
4381 {
4382 	struct dp_mon_ops *mon_ops;
4383 
4384 	mon_ops = dp_mon_ops_get(soc);
4385 
4386 	if (mon_ops && mon_ops->mon_soc_deinit[0])
4387 		mon_ops->mon_soc_deinit[0](soc);
4388 
4389 	if (mon_ops && mon_ops->mon_soc_deinit[1])
4390 		mon_ops->mon_soc_deinit[1](soc);
4391 }
4392 
4393 /**
4394  * dp_ppdu_desc_user_stats_update(): Function to update TX user stats
4395  * @pdev: DP pdev handle
4396  * @ppdu_info: per PPDU TLV descriptor
4397  *
4398  * Return: void
4399  */
4400 #ifdef QCA_ENHANCED_STATS_SUPPORT
4401 void
4402 dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev,
4403 			       struct ppdu_info *ppdu_info);
4404 #else
4405 static inline void
dp_ppdu_desc_user_stats_update(struct dp_pdev * pdev,struct ppdu_info * ppdu_info)4406 dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev,
4407 			       struct ppdu_info *ppdu_info)
4408 {
4409 }
4410 #endif /* QCA_ENHANCED_STATS_SUPPORT */
4411 
4412 /**
4413  * dp_mon_ops_register_1_0(): register legacy monitor ops
4414  * @mon_soc: monitor soc handle
4415  *
4416  * return: void
4417  */
4418 void dp_mon_ops_register_1_0(struct dp_mon_soc *mon_soc);
4419 
4420 /**
4421  * dp_mon_cdp_ops_register_1_0(): register legacy monitor cdp ops
4422  * @ops: cdp ops handle
4423  *
4424  * return: void
4425  */
4426 void dp_mon_cdp_ops_register_1_0(struct cdp_ops *ops);
4427 
4428 #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
4429 /**
4430  * dp_cfr_filter_register_1_0(): register cfr filter setting API
4431  * @ops: cdp ops handle
4432  *
4433  * return: void
4434  */
4435 void dp_cfr_filter_register_1_0(struct cdp_ops *ops);
4436 #endif
4437 
4438 QDF_STATUS dp_mon_pdev_htt_srng_setup_2_0(struct dp_soc *soc,
4439 					  struct dp_pdev *pdev,
4440 					  int mac_id,
4441 					  int mac_for_pdev);
4442 QDF_STATUS dp_mon_soc_htt_srng_setup_2_0(struct dp_soc *soc);
4443 QDF_STATUS dp_mon_soc_attach_2_0(struct dp_soc *soc);
4444 QDF_STATUS dp_mon_soc_init_2_0(struct dp_soc *soc);
4445 void dp_mon_soc_deinit_2_0(struct dp_soc *soc);
4446 QDF_STATUS dp_mon_soc_detach_2_0(struct dp_soc *soc);
4447 void dp_pdev_mon_rings_deinit_2_0(struct dp_pdev *pdev);
4448 QDF_STATUS dp_pdev_mon_rings_init_2_0(struct dp_pdev *pdev);
4449 void dp_pdev_mon_rings_free_2_0(struct dp_pdev *pdev);
4450 QDF_STATUS dp_pdev_mon_rings_alloc_2_0(struct dp_pdev *pdev);
4451 
4452 #ifdef WLAN_PKT_CAPTURE_TX_2_0
4453 /**
4454  * dp_mon_ops_register_tx_2_0(): register monitor tx ops 2.0
4455  * @mon_soc: monitor soc handle
4456  *
4457  * return: void
4458  */
4459 void dp_mon_ops_register_tx_2_0(struct dp_mon_soc *mon_soc);
4460 #else
4461 static inline
dp_mon_ops_register_tx_2_0(struct dp_mon_soc * mon_soc)4462 void dp_mon_ops_register_tx_2_0(struct dp_mon_soc *mon_soc)
4463 {
4464 }
4465 #endif /* WLAN_PKT_CAPTURE_TX_2_0 */
4466 
4467 #if defined(WLAN_PKT_CAPTURE_TX_2_0) || \
4468 defined(WLAN_PKT_CAPTURE_RX_2_0)
4469 /**
4470  * dp_mon_ops_register_2_0(): register monitor ops
4471  * @mon_soc: monitor soc handle
4472  *
4473  * return: void
4474  */
4475 void dp_mon_ops_register_2_0(struct dp_mon_soc *mon_soc);
4476 
4477 /**
4478  * dp_mon_cdp_ops_register_2_0(): register monitor cdp ops
4479  * @ops: cdp ops handle
4480  *
4481  * return: void
4482  */
4483 void dp_mon_cdp_ops_register_2_0(struct cdp_ops *ops);
4484 
4485 #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
4486 /**
4487  * dp_cfr_filter_register_2_0(): register cfr filter setting API
4488  * @ops: cdp ops handle
4489  *
4490  * return: void
4491  */
4492 void dp_cfr_filter_register_2_0(struct cdp_ops *ops);
4493 #endif
4494 void dp_mon_ops_register_cmn_2_0(struct dp_mon_soc *mon_soc);
4495 #else
4496 static inline void
dp_mon_ops_register_2_0(struct dp_mon_soc * mon_soc)4497 dp_mon_ops_register_2_0(struct dp_mon_soc *mon_soc)
4498 {
4499 }
4500 
4501 static inline void
dp_mon_cdp_ops_register_2_0(struct cdp_ops * ops)4502 dp_mon_cdp_ops_register_2_0(struct cdp_ops *ops)
4503 {
4504 }
4505 
4506 static inline void
dp_mon_ops_register_cmn_2_0(struct dp_mon_soc * mon_soc)4507 dp_mon_ops_register_cmn_2_0(struct dp_mon_soc *mon_soc)
4508 {
4509 }
4510 #endif /* WLAN_PKT_CAPTURE_TX_2_0 OR WLAN_PKT_CAPTURE_RX_2_0 */
4511 
4512 #ifdef WLAN_PKT_CAPTURE_RX_2_0
4513 /**
4514  * dp_mon_ops_register_rx_2_0(): register monitor rx ops 2.0
4515  * @mon_soc: monitor soc handle
4516  *
4517  * return: void
4518  */
4519 void dp_mon_ops_register_rx_2_0(struct dp_mon_soc *mon_soc);
4520 #else
4521 static inline
dp_mon_ops_register_rx_2_0(struct dp_mon_soc * mon_soc)4522 void dp_mon_ops_register_rx_2_0(struct dp_mon_soc *mon_soc)
4523 {
4524 }
4525 #endif
4526 
4527 /**
4528  * dp_mon_register_feature_ops(): Register mon feature ops
4529  * @soc: Datapath soc context
4530  *
4531  * return: void
4532  */
4533 static inline
dp_mon_register_feature_ops(struct dp_soc * soc)4534 void dp_mon_register_feature_ops(struct dp_soc *soc)
4535 {
4536 	struct dp_mon_ops *mon_ops = NULL;
4537 
4538 	mon_ops = dp_mon_ops_get(soc);
4539 	if (!mon_ops) {
4540 		dp_mon_err("Monitor ops is NULL");
4541 		return;
4542 	}
4543 	if (mon_ops->mon_register_feature_ops)
4544 		mon_ops->mon_register_feature_ops(soc);
4545 }
4546 
4547 /**
4548  * dp_pdev_get_rx_mon_stats(): Get pdev Rx monitor stats
4549  * @soc_hdl: soc handle
4550  * @pdev_id: id of pdev handle
4551  * @stats: User allocated stats buffer
4552  *
4553  * return: status success/failure
4554  */
4555 QDF_STATUS dp_pdev_get_rx_mon_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
4556 				    struct cdp_pdev_mon_stats *stats);
4557 
4558 /**
4559  * dp_enable_mon_reap_timer() - enable/disable reap timer
4560  * @soc_hdl: Datapath soc handle
4561  * @source: trigger source of the timer
4562  * @enable: Enable/Disable reap timer of monitor status ring
4563  *
4564  * Return: true if a timer-start/stop is performed, false otherwise.
4565  */
4566 bool dp_enable_mon_reap_timer(struct cdp_soc_t *soc_hdl,
4567 			      enum cdp_mon_reap_source source, bool enable);
4568 
4569 QDF_STATUS dp_vdev_set_monitor_mode(struct cdp_soc_t *dp_soc,
4570 				    uint8_t vdev_id,
4571 				    uint8_t special_monitor);
4572 
4573 #ifdef QCA_ENHANCED_STATS_SUPPORT
4574 /**
4575  * dp_enable_enhanced_stats() - enable enhanced and MLD Link Peer stats
4576  * @soc: Datapath soc handle
4577  * @pdev_id: Pdev Id on which stats will get enable
4578  *
4579  * Return: status success/failure
4580  */
4581 QDF_STATUS
4582 dp_enable_enhanced_stats(struct cdp_soc_t *soc, uint8_t pdev_id);
4583 
4584 /**
4585  * dp_disable_enhanced_stats() - disable enhanced and MLD Link Peer stats
4586  * @soc: Datapath soc handle
4587  * @pdev_id: Pdev Id on which stats will get disable
4588  *
4589  * Return: status success/failure
4590  */
4591 QDF_STATUS
4592 dp_disable_enhanced_stats(struct cdp_soc_t *soc, uint8_t pdev_id);
4593 #endif /* QCA_ENHANCED_STATS_SUPPORT */
4594 
4595 /*
4596  * dp_monitor_lite_mon_disable_rx() - disables rx lite mon
4597  * @pdev: dp pdev
4598  *
4599  * Return: void
4600  */
4601 static inline void
dp_monitor_lite_mon_disable_rx(struct dp_pdev * pdev)4602 dp_monitor_lite_mon_disable_rx(struct dp_pdev *pdev)
4603 {
4604 	struct dp_mon_ops *monitor_ops;
4605 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
4606 
4607 	if (!mon_soc) {
4608 		dp_mon_debug("monitor soc is NULL");
4609 		return;
4610 }
4611 
4612 	monitor_ops = mon_soc->mon_ops;
4613 	if (!monitor_ops ||
4614 	    !monitor_ops->mon_lite_mon_disable_rx) {
4615 		dp_mon_debug("callback not registered");
4616 		return;
4617 }
4618 
4619 	return monitor_ops->mon_lite_mon_disable_rx(pdev);
4620 }
4621 
4622 /*
4623  * dp_monitor_lite_mon_is_rx_adv_filter_enable()
4624  *   - check if advance mon filter is already applied
4625  * @pdev: dp pdev
4626  *
4627  * Return: bool
4628  */
4629 static inline bool
dp_monitor_lite_mon_is_rx_adv_filter_enable(struct dp_pdev * pdev)4630 dp_monitor_lite_mon_is_rx_adv_filter_enable(struct dp_pdev *pdev)
4631 {
4632 	struct dp_mon_ops *monitor_ops;
4633 	struct dp_mon_soc *mon_soc = pdev->soc->monitor_soc;
4634 
4635 	if (!mon_soc) {
4636 		dp_mon_debug("monitor soc is NULL");
4637 		return false;
4638 	}
4639 
4640 	monitor_ops = mon_soc->mon_ops;
4641 	if (!monitor_ops ||
4642 	    !monitor_ops->mon_lite_mon_disable_rx) {
4643 		dp_mon_debug("callback not registered");
4644 		return false;
4645 	}
4646 
4647 	return monitor_ops->mon_lite_mon_is_rx_adv_filter_enable(pdev);
4648 }
4649 
4650 #ifndef QCA_SUPPORT_LITE_MONITOR
4651 static inline void
dp_lite_mon_disable_rx(struct dp_pdev * pdev)4652 dp_lite_mon_disable_rx(struct dp_pdev *pdev)
4653 {
4654 }
4655 
4656 static inline void
dp_lite_mon_disable_tx(struct dp_pdev * pdev)4657 dp_lite_mon_disable_tx(struct dp_pdev *pdev)
4658 {
4659 }
4660 
4661 static inline bool
dp_lite_mon_is_rx_adv_filter_enable(struct dp_pdev * pdev)4662 dp_lite_mon_is_rx_adv_filter_enable(struct dp_pdev *pdev)
4663 {
4664 	return false;
4665 }
4666 
4667 static inline bool
dp_lite_mon_get_filter_ucast_data(struct cdp_pdev * pdev_handle)4668 dp_lite_mon_get_filter_ucast_data(struct cdp_pdev *pdev_handle)
4669 {
4670 	return false;
4671 }
4672 
4673 static inline bool
dp_lite_mon_get_filter_mcast_data(struct cdp_pdev * pdev_handle)4674 dp_lite_mon_get_filter_mcast_data(struct cdp_pdev *pdev_handle)
4675 {
4676 	return false;
4677 }
4678 
4679 static inline bool
dp_lite_mon_get_filter_non_data(struct cdp_pdev * pdev_handle)4680 dp_lite_mon_get_filter_non_data(struct cdp_pdev *pdev_handle)
4681 {
4682 	return false;
4683 }
4684 
4685 static inline int
dp_lite_mon_is_level_msdu(struct dp_mon_pdev * mon_pdev)4686 dp_lite_mon_is_level_msdu(struct dp_mon_pdev *mon_pdev)
4687 {
4688 	return 0;
4689 }
4690 
4691 static inline int
dp_lite_mon_is_rx_enabled(struct dp_mon_pdev * mon_pdev)4692 dp_lite_mon_is_rx_enabled(struct dp_mon_pdev *mon_pdev)
4693 {
4694 	return 0;
4695 }
4696 
4697 static inline int
dp_lite_mon_is_tx_enabled(struct dp_mon_pdev * mon_pdev)4698 dp_lite_mon_is_tx_enabled(struct dp_mon_pdev *mon_pdev)
4699 {
4700 	return 0;
4701 }
4702 
4703 static inline QDF_STATUS
dp_lite_mon_alloc(struct dp_pdev * pdev)4704 dp_lite_mon_alloc(struct dp_pdev *pdev)
4705 {
4706 	return QDF_STATUS_SUCCESS;
4707 }
4708 
4709 static inline void
dp_lite_mon_dealloc(struct dp_pdev * pdev)4710 dp_lite_mon_dealloc(struct dp_pdev *pdev)
4711 {
4712 }
4713 
4714 static inline void
dp_lite_mon_vdev_delete(struct dp_pdev * pdev,struct dp_vdev * vdev)4715 dp_lite_mon_vdev_delete(struct dp_pdev *pdev, struct dp_vdev *vdev)
4716 {
4717 }
4718 
4719 static inline int
dp_lite_mon_config_nac_peer(struct cdp_soc_t * soc_hdl,uint8_t vdev_id,uint32_t cmd,uint8_t * macaddr)4720 dp_lite_mon_config_nac_peer(struct cdp_soc_t *soc_hdl,
4721 			    uint8_t vdev_id,
4722 			    uint32_t cmd, uint8_t *macaddr)
4723 {
4724 	return 0;
4725 }
4726 
4727 static inline QDF_STATUS
dp_lite_mon_config_nac_rssi_peer(struct cdp_soc_t * soc_hdl,uint8_t vdev_id,enum cdp_nac_param_cmd cmd,char * bssid,char * macaddr,uint8_t chan_num)4728 dp_lite_mon_config_nac_rssi_peer(struct cdp_soc_t *soc_hdl,
4729 				 uint8_t vdev_id,
4730 				 enum cdp_nac_param_cmd cmd,
4731 				 char *bssid, char *macaddr,
4732 				 uint8_t chan_num)
4733 {
4734 	return QDF_STATUS_E_FAILURE;
4735 }
4736 
4737 static inline QDF_STATUS
dp_lite_mon_get_nac_peer_rssi(struct cdp_soc_t * soc_hdl,uint8_t vdev_id,char * macaddr,uint8_t * rssi)4738 dp_lite_mon_get_nac_peer_rssi(struct cdp_soc_t *soc_hdl,
4739 			      uint8_t vdev_id, char *macaddr,
4740 			      uint8_t *rssi)
4741 {
4742 	return QDF_STATUS_E_FAILURE;
4743 }
4744 
4745 static inline QDF_STATUS
dp_lite_mon_rx_mpdu_process(struct dp_pdev * pdev,struct hal_rx_ppdu_info * ppdu_info,qdf_nbuf_t mon_mpdu,uint16_t mpdu_id,uint8_t user)4746 dp_lite_mon_rx_mpdu_process(struct dp_pdev *pdev,
4747 			    struct hal_rx_ppdu_info *ppdu_info,
4748 			    qdf_nbuf_t mon_mpdu, uint16_t mpdu_id,
4749 			    uint8_t user)
4750 {
4751 	return QDF_STATUS_E_FAILURE;
4752 }
4753 
4754 static inline int
dp_lite_mon_get_legacy_feature_enabled(struct cdp_soc_t * soc,uint8_t pdev_id,uint8_t direction)4755 dp_lite_mon_get_legacy_feature_enabled(struct cdp_soc_t *soc,
4756 				       uint8_t pdev_id,
4757 				       uint8_t direction)
4758 {
4759 	return 0;
4760 }
4761 #endif
4762 
4763 #ifdef WLAN_CONFIG_TELEMETRY_AGENT
4764 static inline
dp_monitor_peer_telemetry_stats(struct dp_peer * peer,struct cdp_peer_telemetry_stats * stats)4765 void dp_monitor_peer_telemetry_stats(struct dp_peer *peer,
4766 				     struct cdp_peer_telemetry_stats *stats)
4767 {
4768 	struct dp_mon_peer_stats *mon_peer_stats = NULL;
4769 	uint8_t ac;
4770 
4771 	if (qdf_unlikely(!peer->monitor_peer))
4772 		return;
4773 
4774 	mon_peer_stats = &peer->monitor_peer->stats;
4775 	for (ac = 0; ac < WME_AC_MAX; ac++) {
4776 		stats->tx_airtime_consumption[ac] =
4777 			mon_peer_stats->airtime_stats.tx_airtime_consumption[ac].avg_consumption_per_sec;
4778 		stats->rx_airtime_consumption[ac] =
4779 			mon_peer_stats->airtime_stats.rx_airtime_consumption[ac].avg_consumption_per_sec;
4780 	}
4781 	stats->tx_mpdu_retried = mon_peer_stats->tx.retries;
4782 	stats->tx_mpdu_total = mon_peer_stats->tx.tx_mpdus_tried;
4783 	stats->rx_mpdu_retried = mon_peer_stats->rx.mpdu_retry_cnt;
4784 	stats->rx_mpdu_total = mon_peer_stats->rx.rx_mpdus;
4785 	stats->snr = CDP_SNR_OUT(mon_peer_stats->rx.avg_snr);
4786 }
4787 
4788 static inline
dp_monitor_peer_deter_stats(struct dp_peer * peer,struct cdp_peer_deter_stats * stats)4789 void dp_monitor_peer_deter_stats(struct dp_peer *peer,
4790 				 struct cdp_peer_deter_stats *stats)
4791 {
4792 	struct dp_mon_peer_stats *mon_peer_stats = NULL;
4793 	struct cdp_peer_deter_stats *deter_stats;
4794 
4795 	if (qdf_unlikely(!peer->monitor_peer))
4796 		return;
4797 
4798 	mon_peer_stats = &peer->monitor_peer->stats;
4799 	deter_stats = &mon_peer_stats->deter_stats.deter[0];
4800 	qdf_mem_copy(stats, deter_stats, sizeof(*stats) * CDP_DATA_TID_MAX);
4801 }
4802 #endif
4803 
4804 /**
4805  * dp_monitor_is_tx_cap_enabled() - get tx-cature enabled/disabled
4806  * @peer: DP peer handle
4807  *
4808  * Return: true if tx-capture is enabled
4809  */
dp_monitor_is_tx_cap_enabled(struct dp_peer * peer)4810 static inline bool dp_monitor_is_tx_cap_enabled(struct dp_peer *peer)
4811 {
4812 	return peer->monitor_peer ? peer->monitor_peer->tx_cap_enabled : 0;
4813 }
4814 
4815 /**
4816  * dp_monitor_is_rx_cap_enabled() - get rx-cature enabled/disabled
4817  * @peer: DP peer handle
4818  *
4819  * Return: true if rx-capture is enabled
4820  */
dp_monitor_is_rx_cap_enabled(struct dp_peer * peer)4821 static inline bool dp_monitor_is_rx_cap_enabled(struct dp_peer *peer)
4822 {
4823 	return peer->monitor_peer ? peer->monitor_peer->rx_cap_enabled : 0;
4824 }
4825 
4826 #if !(!defined(DISABLE_MON_CONFIG) && (defined(WLAN_PKT_CAPTURE_TX_2_0) || \
4827 	defined(WLAN_PKT_CAPTURE_RX_2_0)))
4828 /**
4829  * dp_mon_get_context_size_be() - get BE specific size for mon pdev/soc
4830  * @context_type: context type for which the size is needed
4831  *
4832  * Return: size in bytes for the context_type
4833  */
4834 static inline
dp_mon_get_context_size_be(enum dp_context_type context_type)4835 qdf_size_t dp_mon_get_context_size_be(enum dp_context_type context_type)
4836 {
4837 	switch (context_type) {
4838 	case DP_CONTEXT_TYPE_MON_SOC:
4839 		return sizeof(struct dp_mon_soc);
4840 	case DP_CONTEXT_TYPE_MON_PDEV:
4841 		return sizeof(struct dp_mon_pdev);
4842 	default:
4843 		return 0;
4844 	}
4845 }
4846 #endif
4847 
4848 /**
4849  * dp_mon_rx_print_advanced_stats() - print advanced monitor stats
4850  * @soc: DP soc handle
4851  * @pdev: DP pdev handle
4852  *
4853  * Return: void
4854  */
4855 static inline void
dp_mon_rx_print_advanced_stats(struct dp_soc * soc,struct dp_pdev * pdev)4856 dp_mon_rx_print_advanced_stats(struct dp_soc *soc,
4857 			       struct dp_pdev *pdev)
4858 {
4859 	struct dp_mon_soc *mon_soc = soc->monitor_soc;
4860 	struct dp_mon_ops *monitor_ops;
4861 
4862 	if (!mon_soc) {
4863 		dp_mon_debug("mon soc is NULL");
4864 		return;
4865 	}
4866 
4867 	monitor_ops = mon_soc->mon_ops;
4868 	if (!monitor_ops ||
4869 	    !monitor_ops->mon_rx_print_advanced_stats) {
4870 		dp_mon_debug("callback not registered");
4871 		return;
4872 	}
4873 	return monitor_ops->mon_rx_print_advanced_stats(soc, pdev);
4874 }
4875 
4876 #ifdef WLAN_CONFIG_TELEMETRY_AGENT
4877 /*
4878  * dp_update_pdev_mon_telemetry_airtime_stats() - update telemetry airtime
4879  * stats in monitor pdev
4880  *
4881  *@soc: dp soc handle
4882  *@pdev_id: pdev id
4883  *
4884  * This API is used to update telemetry airtime stats in monitor pdev
4885  *
4886  * Return: Success if stats are updated, else failure
4887  */
4888 
4889 QDF_STATUS dp_pdev_update_telemetry_airtime_stats(struct cdp_soc_t *soc,
4890 						  uint8_t pdev_id);
4891 #endif
4892 
4893 /*
4894  * dp_mon_register_lpc_ops_1_0() - set local packet capture 1_0 mon ops
4895  * @mon_ops: monitor ops
4896  *
4897  * This function initializes the mon_ops callbacks.
4898  * index [0] is for Monitor 1.0 and index [1] is for Monitor 2.0
4899  * based on the @WLAN_FEATURE_LOCAL_PKT_CAPTURE macro, it sets the
4900  * appropriate callbacks
4901  *
4902  * Return: None
4903  */
4904 void dp_mon_register_lpc_ops_1_0(struct dp_mon_ops *mon_ops);
4905 
4906 /*
4907  * dp_mon_register_tx_pkt_enh_ops_1_0() - set tx pkt enh mon ops
4908  * @mon_ops: monitor ops
4909  *
4910  * Return: None
4911  */
4912 void dp_mon_register_tx_pkt_enh_ops_1_0(struct dp_mon_ops *mon_ops);
4913 
4914 #ifdef WLAN_FEATURE_LOCAL_PKT_CAPTURE
4915 /*
4916  * dp_local_pkt_capture_tx_config() - local packet capture tx config
4917  * @pdev: physical device handle
4918  *
4919  * Return: QDF_STATUS
4920  */
4921 QDF_STATUS dp_local_pkt_capture_tx_config(struct dp_pdev *pdev);
4922 
4923 /*
4924  * dp_mon_mode_local_pkt_capture() - Check if in LPC mode
4925  * @soc: DP SOC handle
4926  *
4927  * Return: True in case of LPC mode else false
4928  *
4929  */
4930 static inline bool
dp_mon_mode_local_pkt_capture(struct dp_soc * soc)4931 dp_mon_mode_local_pkt_capture(struct dp_soc *soc)
4932 {
4933 	/* Currently there is no way to distinguish between
4934 	 * Local Packet Capture and STA+Mon mode as both mode
4935 	 * uses same monitor interface. So to distinguish between
4936 	 * two mode in local_packet_capture enable case use
4937 	 * mon_flags which can be passed during monitor interface
4938 	 * add time. If "flags otherbss" is passed during
4939 	 * monitor interface add driver will consider current mode
4940 	 * as STA+MON mode, LPC otherwise.
4941 	 */
4942 	if (wlan_cfg_get_local_pkt_capture(soc->wlan_cfg_ctx) &&
4943 	    !(soc->mon_flags & QDF_MONITOR_FLAG_OTHER_BSS))
4944 		return true;
4945 
4946 	return false;
4947 }
4948 #else
4949 static inline
dp_local_pkt_capture_tx_config(struct dp_pdev * pdev)4950 QDF_STATUS dp_local_pkt_capture_tx_config(struct dp_pdev *pdev)
4951 {
4952 	return QDF_STATUS_SUCCESS;
4953 }
4954 
4955 static inline bool
dp_mon_mode_local_pkt_capture(struct dp_soc * soc)4956 dp_mon_mode_local_pkt_capture(struct dp_soc *soc)
4957 {
4958 	return false;
4959 }
4960 #endif
4961 
4962 #ifdef WIFI_MONITOR_SUPPORT
4963 void
4964 dp_check_and_dump_full_mon_info(struct dp_soc *soc, struct dp_pdev *pdev,
4965 				int mac_id, int war);
4966 
4967 /**
4968  * dp_mon_rx_ppdu_status_reset() - reset and clear ppdu rx status
4969  * @mon_pdev: monitor pdev
4970  *
4971  * Return: none
4972  */
4973 static inline void
dp_mon_rx_ppdu_status_reset(struct dp_mon_pdev * mon_pdev)4974 dp_mon_rx_ppdu_status_reset(struct dp_mon_pdev *mon_pdev)
4975 {
4976 	mon_pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
4977 	mon_pdev->ppdu_info.com_info.num_users = 0;
4978 	qdf_mem_zero(&mon_pdev->ppdu_info.rx_status,
4979 		     sizeof(mon_pdev->ppdu_info.rx_status));
4980 }
4981 #else
4982 void
4983 dp_check_and_dump_full_mon_info(struct dp_soc *soc, struct dp_pdev *pdev,
4984 				int mac_id, int war);
4985 
4986 {
4987 }
4988 
4989 static inline void
dp_mon_rx_ppdu_status_reset(struct dp_mon_pdev * mon_pdev)4990 dp_mon_rx_ppdu_status_reset(struct dp_mon_pdev *mon_pdev)
4991 {
4992 }
4993 #endif
4994 
4995 static inline void
dp_mon_pdev_filter_init(struct dp_mon_pdev * mon_pdev)4996 dp_mon_pdev_filter_init(struct dp_mon_pdev *mon_pdev)
4997 {
4998 	if (!mon_pdev)
4999 		return;
5000 
5001 	mon_pdev->mon_filter_mode = MON_FILTER_ALL;
5002 	mon_pdev->fp_mgmt_filter = FILTER_MGMT_ALL;
5003 	mon_pdev->fp_ctrl_filter = FILTER_CTRL_ALL;
5004 	mon_pdev->fp_data_filter = FILTER_DATA_ALL;
5005 	mon_pdev->mo_mgmt_filter = FILTER_MGMT_ALL;
5006 	mon_pdev->mo_ctrl_filter = FILTER_CTRL_ALL;
5007 	mon_pdev->mo_data_filter = FILTER_DATA_ALL;
5008 }
5009 #endif /* _DP_MON_H_ */
5010