xref: /wlan-dirver/qca-wifi-host-cmn/dp/wifi3.0/monitor/2.0/dp_rx_mon_2.0.h (revision 3b082b0bf8d2e31f3268608a8140a8dfa0215204)
1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef _DP_RX_MON_2_0_H_
19 #define _DP_RX_MON_2_0_H_
20 
21 #include <qdf_nbuf_frag.h>
22 #include <hal_be_api_mon.h>
23 
24 #define DP_RX_MON_PACKET_OFFSET 8
25 #define DP_RX_MON_RX_HDR_OFFSET 8
26 #define DP_GET_NUM_QWORDS(num)	((num) >> 3)
27 
28 #define DP_RX_MON_TLV_HDR_MARKER 0xFEED
29 #define DP_RX_MON_TLV_HDR_MARKER_LEN 2
30 #define DP_RX_MON_TLV_HDR_LEN 3 /* TLV ID field sz + TLV len field sz */
31 #define DP_RX_MON_TLV_TOTAL_LEN 2
32 
33 #define DP_RX_MON_TLV_PF_ID 1
34 #define DP_RX_MON_TLV_PPDU_ID 2
35 #define DP_RX_MON_MAX_TLVS 2
36 
37 #define DP_RX_MON_TLV_MSDU_CNT 2
38 #define DP_RX_MON_MAX_MSDU 16
39 #define DP_RX_MON_PF_TLV_LEN (((DP_RX_MON_PF_TAG_LEN_PER_FRAG)\
40 			       * (DP_RX_MON_MAX_MSDU) * 2)\
41 			       + (DP_RX_MON_TLV_MSDU_CNT))
42 
43 #define DP_RX_MON_PPDU_ID_LEN 4
44 
45 #define DP_RX_MON_INDIV_TLV_LEN ((DP_RX_MON_PF_TLV_LEN)\
46 				 + (DP_RX_MON_PPDU_ID_LEN))
47 #define DP_RX_MON_TLV_ROOM ((DP_RX_MON_INDIV_TLV_LEN)\
48 			    + ((DP_RX_MON_TLV_HDR_LEN) * (DP_RX_MON_MAX_TLVS))\
49 			    + (DP_RX_MON_TLV_HDR_MARKER_LEN)\
50 			    + (DP_RX_MON_TLV_TOTAL_LEN))
51 
52 #define DP_RX_MON_WQ_THRESHOLD 128
53 
54 #ifdef WLAN_PKT_CAPTURE_RX_2_0
55 QDF_STATUS dp_mon_pdev_ext_init_2_0(struct dp_pdev *pdev);
56 QDF_STATUS dp_mon_pdev_ext_deinit_2_0(struct dp_pdev *pdev);
57 QDF_STATUS dp_rx_mon_ppdu_info_cache_create(struct dp_pdev *pdev);
58 void dp_rx_mon_ppdu_info_cache_destroy(struct dp_pdev *pdev);
59 QDF_STATUS dp_rx_mon_pdev_htt_srng_setup_2_0(struct dp_soc *soc,
60 					    struct dp_pdev *pdev,
61 					    int mac_id,
62 					    int mac_for_pdev);
63 QDF_STATUS dp_rx_mon_soc_htt_srng_setup_2_0(struct dp_soc *soc,
64 					    int mac_id);
65 QDF_STATUS dp_rx_mon_pdev_rings_alloc_2_0(struct dp_pdev *pdev, int lmac_id);
66 void dp_rx_mon_pdev_rings_free_2_0(struct dp_pdev *pdev, int lmac_id);
67 QDF_STATUS dp_rx_mon_pdev_rings_init_2_0(struct dp_pdev *pdev, int lmac_id);
68 void dp_rx_mon_pdev_rings_deinit_2_0(struct dp_pdev *pdev, int lmac_id);
69 QDF_STATUS dp_rx_mon_soc_init_2_0(struct dp_soc *soc);
70 
71 /*
72  * dp_rx_mon_buffers_alloc() - allocate rx monitor buffers
73  * @soc: DP soc handle
74  *
75  * Return: QDF_STATUS_SUCCESS: Success
76  *         QDF_STATUS_E_FAILURE: Error
77  */
78 QDF_STATUS
79 dp_rx_mon_buffers_alloc(struct dp_soc *soc, uint32_t size);
80 
81 /*
82  * dp_rx_mon_buffers_free() - free rx monitor buffers
83  * @soc: dp soc handle
84  *
85  */
86 void
87 dp_rx_mon_buffers_free(struct dp_soc *soc);
88 
89 /*
90  * dp_rx_mon_desc_pool_deinit() - deinit rx monitor descriptor pool
91  * @soc: dp soc handle
92  *
93  */
94 void
95 dp_rx_mon_buf_desc_pool_deinit(struct dp_soc *soc);
96 
97 /*
98  * dp_rx_mon_desc_pool_deinit() - deinit rx monitor descriptor pool
99  * @soc: dp soc handle
100  *
101  * Return: QDF_STATUS_SUCCESS: Success
102  *         QDF_STATUS_E_FAILURE: Error
103  */
104 QDF_STATUS
105 dp_rx_mon_buf_desc_pool_init(struct dp_soc *soc);
106 
107 /*
108  * dp_rx_mon_buf_desc_pool_free() - free rx monitor descriptor pool
109  * @soc: dp soc handle
110  *
111  */
112 void dp_rx_mon_buf_desc_pool_free(struct dp_soc *soc);
113 
114 /*
115  * dp_rx_mon_buf_desc_pool_alloc() - allocate rx monitor descriptor pool
116  * @soc: DP soc handle
117  *
118  * Return: QDF_STATUS_SUCCESS: Success
119  *         QDF_STATUS_E_FAILURE: Error
120  */
121 QDF_STATUS
122 dp_rx_mon_buf_desc_pool_alloc(struct dp_soc *soc);
123 
124 /**
125  * dp_rx_mon_stats_update_2_0() - update rx stats
126  *
127  * @mon_peer: monitor peer handle
128  * @ppdu: Rx PPDU status metadata object
129  * @ppdu_user: Rx PPDU user status metadata object
130  *
131  * Return: Void
132  */
133 void dp_rx_mon_stats_update_2_0(struct dp_mon_peer *mon_peer,
134 				struct cdp_rx_indication_ppdu *ppdu,
135 				struct cdp_rx_stats_ppdu_user *ppdu_user);
136 
137 /**
138  * dp_rx_mon_populate_ppdu_usr_info_2_0() - Populate ppdu user info
139  *
140  * @rx_user_status: Rx user status
141  * @ppdu_user: ppdu user metadata
142  *
143  * Return: void
144  */
145 void
146 dp_rx_mon_populate_ppdu_usr_info_2_0(struct mon_rx_user_status *rx_user_status,
147 				     struct cdp_rx_stats_ppdu_user *ppdu_user);
148 
149 /**
150  * dp_rx_mon_populate_ppdu_info_2_0() --  Populate ppdu info
151  *
152  * @hal_ppdu_info: HAL PPDU info
153  * @ppdu: Rx PPDU status metadata object
154  *
155  * Return: void
156  */
157 void
158 dp_rx_mon_populate_ppdu_info_2_0(struct hal_rx_ppdu_info *hal_ppdu_info,
159 				 struct cdp_rx_indication_ppdu *ppdu);
160 
161 /**
162  * dp_rx_process_pktlog_be() - process pktlog
163  * @soc: dp soc handle
164  * @pdev: dp pdev handle
165  * @ppdu_info: HAL PPDU info
166  * @status_frag: frag pointer which needs to be added to nbuf
167  * @end_offset: Offset in frag to be added to nbuf_frags
168  *
169  * Return: QDF_STATUS_SUCCESS or Failure
170  */
171 QDF_STATUS dp_rx_process_pktlog_be(struct dp_soc *soc, struct dp_pdev *pdev,
172 				   struct hal_rx_ppdu_info *ppdu_info,
173 				   void *status_frag, uint32_t end_offset);
174 
175 QDF_STATUS dp_rx_mon_soc_attach_2_0(struct dp_soc *soc, int lmac_id);
176 void  dp_rx_mon_soc_detach_2_0(struct dp_soc *soc, int lmac_id);
177 void dp_rx_mon_soc_deinit_2_0(struct dp_soc *soc, uint32_t lmac_id);
178 #else
179 static inline QDF_STATUS dp_mon_pdev_ext_init_2_0(struct dp_pdev *pdev)
180 {
181 	return QDF_STATUS_SUCCESS;
182 }
183 
184 static inline QDF_STATUS dp_mon_pdev_ext_deinit_2_0(struct dp_pdev *pdev)
185 {
186 	return QDF_STATUS_SUCCESS;
187 }
188 
189 static inline QDF_STATUS dp_rx_mon_ppdu_info_cache_create(struct dp_pdev *pdev)
190 {
191 	return QDF_STATUS_SUCCESS;
192 }
193 
194 static inline void dp_rx_mon_ppdu_info_cache_destroy(struct dp_pdev *pdev)
195 {
196 }
197 
198 static inline QDF_STATUS
199 dp_rx_mon_buffers_alloc(struct dp_soc *soc, uint32_t size)
200 {
201 	return QDF_STATUS_SUCCESS;
202 }
203 
204 static inline
205 QDF_STATUS dp_rx_mon_soc_init_2_0(struct dp_soc *soc)
206 {
207 	return QDF_STATUS_SUCCESS;
208 }
209 
210 static inline void
211 dp_rx_mon_buffers_free(struct dp_soc *soc)
212 
213 {
214 }
215 
216 static inline void
217 dp_rx_mon_buf_desc_pool_deinit(struct dp_soc *soc)
218 {
219 }
220 
221 static inline QDF_STATUS
222 dp_rx_mon_buf_desc_pool_init(struct dp_soc *soc)
223 {
224 	return QDF_STATUS_SUCCESS;
225 }
226 
227 static inline void dp_rx_mon_buf_desc_pool_free(struct dp_soc *soc)
228 {
229 }
230 
231 static inline QDF_STATUS
232 dp_rx_mon_buf_desc_pool_alloc(struct dp_soc *soc)
233 {
234 	return QDF_STATUS_SUCCESS;
235 }
236 
237 static inline
238 void dp_rx_mon_stats_update_2_0(struct dp_mon_peer *mon_peer,
239 				struct cdp_rx_indication_ppdu *ppdu,
240 				struct cdp_rx_stats_ppdu_user *ppdu_user)
241 {
242 }
243 
244 static inline void
245 dp_rx_mon_populate_ppdu_usr_info_2_0(struct mon_rx_user_status *rx_user_status,
246 				     struct cdp_rx_stats_ppdu_user *ppdu_user)
247 {
248 }
249 
250 static inline void
251 dp_rx_mon_populate_ppdu_info_2_0(struct hal_rx_ppdu_info *hal_ppdu_info,
252 				 struct cdp_rx_indication_ppdu *ppdu)
253 {
254 }
255 
256 static inline
257 QDF_STATUS dp_rx_process_pktlog_be(struct dp_soc *soc, struct dp_pdev *pdev,
258 				   struct hal_rx_ppdu_info *ppdu_info,
259 				   void *status_frag, uint32_t end_offset)
260 {
261 	return QDF_STATUS_SUCCESS;
262 }
263 
264 static inline
265 QDF_STATUS dp_rx_mon_pdev_htt_srng_setup_2_0(struct dp_soc *soc,
266 					    struct dp_pdev *pdev,
267 					    int mac_id,
268 					    int mac_for_pdev)
269 {
270 	return QDF_STATUS_SUCCESS;
271 }
272 
273 static inline
274 QDF_STATUS dp_rx_mon_soc_htt_srng_setup_2_0(struct dp_soc *soc,
275 					    int mac_id)
276 {
277 	return QDF_STATUS_SUCCESS;
278 }
279 
280 static inline
281 QDF_STATUS dp_rx_mon_pdev_rings_alloc_2_0(struct dp_pdev *pdev, int lmac_id)
282 {
283 	return QDF_STATUS_SUCCESS;
284 }
285 
286 static inline
287 void dp_rx_mon_pdev_rings_free_2_0(struct dp_pdev *pdev, int lmac_id)
288 {
289 }
290 
291 static inline
292 QDF_STATUS dp_rx_mon_pdev_rings_init_2_0(struct dp_pdev *pdev, int lmac_id)
293 {
294 	return QDF_STATUS_SUCCESS;
295 }
296 
297 static inline
298 void dp_rx_mon_pdev_rings_deinit_2_0(struct dp_pdev *pdev, int lmac_id)
299 {
300 }
301 
302 static inline
303 QDF_STATUS dp_rx_mon_soc_attach_2_0(struct dp_soc *soc, int lmac_id)
304 {
305 	return QDF_STATUS_SUCCESS;
306 }
307 
308 static inline
309 void dp_rx_mon_soc_detach_2_0(struct dp_soc *soc, int lmac_id)
310 {
311 }
312 
313 static inline
314 void dp_rx_mon_soc_deinit_2_0(struct dp_soc *soc, uint32_t lmac_id)
315 {
316 }
317 #endif
318 
319 #if !defined(DISABLE_MON_CONFIG) && defined(WLAN_PKT_CAPTURE_RX_2_0)
320 /*
321  * dp_rx_mon_process_2_0() - Process Rx monitor interrupt
322  *
323  * @soc: DP soc handle
324  * @int_ctx: Interrupt context
325  * @mac_id: LMAC id
326  * @quota: quota to reap
327  */
328 uint32_t
329 dp_rx_mon_process_2_0(struct dp_soc *soc, struct dp_intr *int_ctx,
330 		      uint32_t mac_id, uint32_t quota);
331 
332 /**
333  * dp_rx_mon_process_ppdu() - RxMON Workqueue processing API
334  *
335  * @context: workqueue context
336  */
337 void dp_rx_mon_process_ppdu(void *context);
338 #else
339 static inline uint32_t
340 dp_rx_mon_process_2_0(struct dp_soc *soc, struct dp_intr *int_ctx,
341 		      uint32_t mac_id, uint32_t quota)
342 {
343 	return 0;
344 }
345 
346 static inline void dp_rx_mon_process_ppdu(void *context)
347 {
348 }
349 #endif /* DISABLE_MON_CONFIG */
350 
351 /**
352  * dp_rx_mon_handle_full_mon() - Handle full monitor MPDU restitch
353  *
354  * @pdev: DP pdev
355  * @ppdu_info: PPDU info
356  * @mpdu: mpdu buf
357  *
358  * Return: SUCCESS or Failure
359  */
360 QDF_STATUS
361 dp_rx_mon_handle_full_mon(struct dp_pdev *pdev,
362 			  struct hal_rx_ppdu_info *ppdu_info,
363 			  qdf_nbuf_t mpdu);
364 
365 /**
366  * dp_rx_mon_drain_wq() - Drain monitor buffers from rxmon workqueue
367  *
368  * @pdev: DP pdev handle
369  *
370  * Return: Void
371  */
372 void dp_rx_mon_drain_wq(struct dp_pdev *pdev);
373 
374 /**
375  * dp_mon_free_parent_nbuf() - Free parent SKB
376  *
377  * @mon_pdev: monitor pdev
378  * @nbuf: SKB to be freed
379  *
380  * Return: void
381  */
382 void dp_mon_free_parent_nbuf(struct dp_mon_pdev *mon_pdev,
383 			qdf_nbuf_t nbuf);
384 
385 #ifdef QCA_ENHANCED_STATS_SUPPORT
386 /**
387  * dp_mon_rx_print_advanced_stats_2_0() - print advanced monitor statistics
388  *
389  * @soc: DP soc handle
390  * @pdev: DP pdev handle
391  *
392  * Return: void
393  */
394 void dp_mon_rx_print_advanced_stats_2_0(struct dp_soc *soc,
395 					struct dp_pdev *pdev);
396 #else
397 static inline
398 void dp_mon_rx_print_advanced_stats_2_0(struct dp_soc *soc,
399 					struct dp_pdev *pdev)
400 {
401 }
402 #endif
403 
404 #endif /* _DP_RX_MON_2_0_H_ */
405