xref: /wlan-driver/qcacld-3.0/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_ucfg_api.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: Declare public API related to the pkt_capture called by north bound
22  * HDD/OSIF/LIM
23  */
24 
25 #ifndef _WLAN_PKT_CAPTURE_UCFG_API_H_
26 #define _WLAN_PKT_CAPTURE_UCFG_API_H_
27 
28 #include <qdf_status.h>
29 #include <qdf_types.h>
30 #include "wlan_pkt_capture_objmgr.h"
31 #include "wlan_pkt_capture_public_structs.h"
32 #include "wlan_pkt_capture_mon_thread.h"
33 #include <htt_types.h>
34 #include "wlan_pkt_capture_data_txrx.h"
35 #include <ol_htt_api.h>
36 
37 #ifdef WLAN_FEATURE_PKT_CAPTURE
38 /**
39  * ucfg_pkt_capture_init() - Packet capture component initialization.
40  *
41  * This function gets called when packet capture initializing.
42  *
43  * Return: QDF_STATUS
44  */
45 QDF_STATUS ucfg_pkt_capture_init(void);
46 
47 /**
48  * ucfg_pkt_capture_deinit() - Packet capture component de-init.
49  *
50  * This function gets called when packet capture de-init.
51  *
52  * Return: None
53  */
54 void ucfg_pkt_capture_deinit(void);
55 
56 /**
57  * ucfg_pkt_capture_get_mode() - get packet capture mode
58  * @psoc: objmgr psoc handle
59  *
60  * Return: enum pkt_capture_mode
61  */
62 enum pkt_capture_mode
63 ucfg_pkt_capture_get_mode(struct wlan_objmgr_psoc *psoc);
64 
65 /**
66  * ucfg_pkt_capture_suspend_mon_thread() - suspend packet capture mon thread
67  * @vdev: pointer to vdev object manager
68  *
69  * Return: 0 on success, -EINVAL on failure
70  */
71 int ucfg_pkt_capture_suspend_mon_thread(struct wlan_objmgr_vdev *vdev);
72 
73 /**
74  * ucfg_pkt_capture_resume_mon_thread() - resume packet capture mon thread
75  * @vdev: pointer to vdev object manager
76  *
77  * Resume packet capture MON thread by completing RX thread resume event
78  *
79  * Return: None
80  */
81 void ucfg_pkt_capture_resume_mon_thread(struct wlan_objmgr_vdev *vdev);
82 
83 /**
84  * ucfg_pkt_capture_register_callbacks - Register packet capture callbacks
85  * @vdev: pointer to wlan vdev object manager
86  * @mon_cb: callback to call
87  * @context: callback context
88  *
89  * Return: QDF_STATUS
90  */
91 QDF_STATUS
92 ucfg_pkt_capture_register_callbacks(struct wlan_objmgr_vdev *vdev,
93 				    QDF_STATUS (*mon_cb)(void *, qdf_nbuf_t),
94 				    void *context);
95 
96 /**
97  * ucfg_pkt_capture_deregister_callbacks - De-register packet capture callbacks
98  * @vdev: pointer to wlan vdev object manager
99  *
100  * Return: QDF_STATUS
101  */
102 QDF_STATUS
103 ucfg_pkt_capture_deregister_callbacks(struct wlan_objmgr_vdev *vdev);
104 
105 /**
106  * ucfg_pkt_capture_set_pktcap_mode - Set packet capture mode
107  * @psoc: pointer to psoc object
108  * @val: mode to be set
109  *
110  * Return: None
111  */
112 void ucfg_pkt_capture_set_pktcap_mode(struct wlan_objmgr_psoc *psoc,
113 				      enum pkt_capture_mode val);
114 
115 /**
116  * ucfg_pkt_capture_get_pktcap_mode - Get packet capture mode
117  * @psoc: pointer to psoc object
118  *
119  * Return: enum pkt_capture_mode
120  */
121 enum pkt_capture_mode
122 ucfg_pkt_capture_get_pktcap_mode(struct wlan_objmgr_psoc *psoc);
123 
124 /**
125  * ucfg_pkt_capture_set_pktcap_config - Set packet capture config
126  * @vdev: pointer to vdev object
127  * @config: config to be set
128  *
129  * Return: None
130  */
131 void ucfg_pkt_capture_set_pktcap_config(struct wlan_objmgr_vdev *vdev,
132 					enum pkt_capture_config config);
133 
134 /**
135  * ucfg_pkt_capture_get_pktcap_config - Get packet capture config
136  * @vdev: pointer to vdev object
137  *
138  * Return: config value
139  */
140 enum pkt_capture_config
141 ucfg_pkt_capture_get_pktcap_config(struct wlan_objmgr_vdev *vdev);
142 
143 /**
144  * ucfg_pkt_capture_process_mgmt_tx_data() - process management tx packets
145  * @pdev: pointer to pdev object
146  * @params: management offload event params
147  * @nbuf: netbuf
148  * @status: status
149  *
150  * Return: QDF_STATUS
151  */
152 QDF_STATUS
153 ucfg_pkt_capture_process_mgmt_tx_data(struct wlan_objmgr_pdev *pdev,
154 				      struct mgmt_offload_event_params *params,
155 				      qdf_nbuf_t nbuf,
156 				      uint8_t status);
157 
158 /**
159  * ucfg_pkt_capture_mgmt_tx() - process mgmt tx completion
160  * for pkt capture mode
161  * @pdev: pointer to pdev object
162  * @nbuf: netbuf
163  * @chan_freq: channel freq
164  * @preamble_type: preamble_type
165  *
166  * Return: none
167  */
168 void
169 ucfg_pkt_capture_mgmt_tx(struct wlan_objmgr_pdev *pdev,
170 			 qdf_nbuf_t nbuf,
171 			 uint16_t chan_freq,
172 			 uint8_t preamble_type);
173 
174 /**
175  * ucfg_pkt_capture_mgmt_tx_completion() - process mgmt tx completion
176  * for pkt capture mode
177  * @pdev: pointer to pdev object
178  * @desc_id: desc_id
179  * @status: status
180  * @params: management offload event params
181  *
182  * Return: none
183  */
184 void
185 ucfg_pkt_capture_mgmt_tx_completion(
186 				struct wlan_objmgr_pdev *pdev,
187 				uint32_t desc_id,
188 				uint32_t status,
189 				struct mgmt_offload_event_params *params);
190 
191 /**
192  * ucfg_pkt_capture_rx_msdu_process() -  process data rx pkts
193  * @bssid: bssid
194  * @head_msdu: pointer to head msdu
195  * @vdev_id: vdev_id
196  * @pdev: pdev handle
197  *
198  * Return: none
199  */
200 void ucfg_pkt_capture_rx_msdu_process(
201 				uint8_t *bssid,
202 				qdf_nbuf_t head_msdu,
203 				uint8_t vdev_id, htt_pdev_handle pdev);
204 
205 /**
206  * ucfg_pkt_capture_rx_offloaded_pkt() - check offloaded data pkt or not
207  * @rx_ind_msg: rx_ind_msg
208  *
209  * Return: 0 not an offload pkt
210  *         1 offload pkt
211  */
212 bool ucfg_pkt_capture_rx_offloaded_pkt(qdf_nbuf_t rx_ind_msg);
213 
214 /**
215  * ucfg_pkt_capture_rx_drop_offload_pkt() - drop offload packets
216  * @head_msdu: pointer to head msdu
217  *
218  * Return: none
219  */
220 void ucfg_pkt_capture_rx_drop_offload_pkt(qdf_nbuf_t head_msdu);
221 
222 /**
223  * ucfg_pkt_capture_offload_deliver_indication_handler() - Handle offload
224  * data pkts
225  * @msg: offload netbuf msg
226  * @vdev_id: vdev id
227  * @bssid: bssid
228  * @pdev: pdev handle
229  *
230  * Return: none
231  */
232 void ucfg_pkt_capture_offload_deliver_indication_handler(
233 					void *msg, uint8_t vdev_id,
234 					uint8_t *bssid, htt_pdev_handle pdev);
235 
236 /**
237  * ucfg_pkt_capture_tx_get_txcomplete_data_hdr() - extract Tx data hdr from Tx
238  * completion for pkt capture mode
239  * @msg_word: Tx completion htt msg
240  * @num_msdus: number of msdus
241  *
242  * Return: tx data hdr information
243  */
244 struct htt_tx_data_hdr_information *ucfg_pkt_capture_tx_get_txcomplete_data_hdr(
245 		uint32_t *msg_word,
246 		int num_msdus);
247 
248 /**
249  * ucfg_pkt_capture_tx_completion_process() - process data tx packets
250  * @vdev_id: vdev id for which packet is captured
251  * @mon_buf_list: netbuf list
252  * @type: data process type
253  * @tid:  tid number
254  * @status: Tx status
255  * @pkt_format: Frame format
256  * @bssid: bssid
257  * @pdev: pdev handle
258  * @tx_retry_cnt: tx retry count
259  *
260  * Return: none
261  */
262 void ucfg_pkt_capture_tx_completion_process(
263 			uint8_t vdev_id,
264 			qdf_nbuf_t mon_buf_list,
265 			enum pkt_capture_data_process_type type,
266 			uint8_t tid, uint8_t status, bool pkt_format,
267 			uint8_t *bssid, htt_pdev_handle pdev,
268 			uint8_t tx_retry_cnt);
269 
270 /**
271  * ucfg_pkt_capture_record_channel() - Update Channel Information
272  * for packet capture mode
273  * @vdev: pointer to vdev
274  *
275  * Return: None
276  */
277 void ucfg_pkt_capture_record_channel(struct wlan_objmgr_vdev *vdev);
278 
279 /**
280  * ucfg_pkt_capture_register_wma_callbacks - ucfg API to register WMA callbacks
281  * @psoc: pointer to psoc object
282  * @cb_obj: Pointer to packet capture callback structure
283  *
284  * Return: status of operation
285  */
286 int
287 ucfg_pkt_capture_register_wma_callbacks(struct wlan_objmgr_psoc *psoc,
288 					struct pkt_capture_callbacks *cb_obj);
289 
290 /**
291  * ucfg_pkt_capture_set_filter() - ucfg API to set frame filter
292  * @frame_filter: pkt capture frame filter data
293  * @vdev: pointer to vdev
294  *
295  * Return: QDF_STATUS
296  */
297 QDF_STATUS
298 ucfg_pkt_capture_set_filter(struct pkt_capture_frame_filter frame_filter,
299 			    struct wlan_objmgr_vdev *vdev);
300 
301 #else
302 static inline
ucfg_pkt_capture_init(void)303 QDF_STATUS ucfg_pkt_capture_init(void)
304 {
305 	return QDF_STATUS_SUCCESS;
306 }
307 
308 static inline
ucfg_pkt_capture_deinit(void)309 void ucfg_pkt_capture_deinit(void)
310 {
311 }
312 
313 static inline
ucfg_pkt_capture_get_mode(struct wlan_objmgr_psoc * psoc)314 enum pkt_capture_mode ucfg_pkt_capture_get_mode(struct wlan_objmgr_psoc *psoc)
315 {
316 	return PACKET_CAPTURE_MODE_DISABLE;
317 }
318 
319 static inline
ucfg_pkt_capture_resume_mon_thread(struct wlan_objmgr_vdev * vdev)320 void ucfg_pkt_capture_resume_mon_thread(struct wlan_objmgr_vdev *vdev)
321 {
322 }
323 
324 static inline
ucfg_pkt_capture_suspend_mon_thread(struct wlan_objmgr_vdev * vdev)325 int ucfg_pkt_capture_suspend_mon_thread(struct wlan_objmgr_vdev *vdev)
326 {
327 	return 0;
328 }
329 
330 static inline QDF_STATUS
ucfg_pkt_capture_register_callbacks(struct wlan_objmgr_vdev * vdev,QDF_STATUS (* mon_cb)(void *,qdf_nbuf_t),void * context)331 ucfg_pkt_capture_register_callbacks(struct wlan_objmgr_vdev *vdev,
332 				    QDF_STATUS (*mon_cb)(void *, qdf_nbuf_t),
333 				    void *context)
334 {
335 	return QDF_STATUS_SUCCESS;
336 }
337 
338 static inline
ucfg_pkt_capture_deregister_callbacks(struct wlan_objmgr_vdev * vdev)339 QDF_STATUS ucfg_pkt_capture_deregister_callbacks(struct wlan_objmgr_vdev *vdev)
340 {
341 	return QDF_STATUS_SUCCESS;
342 }
343 
344 static inline
ucfg_pkt_capture_set_pktcap_mode(struct wlan_objmgr_psoc * psoc,uint8_t val)345 void ucfg_pkt_capture_set_pktcap_mode(struct wlan_objmgr_psoc *psoc,
346 				      uint8_t val)
347 {
348 }
349 
350 static inline enum pkt_capture_mode
ucfg_pkt_capture_get_pktcap_mode(struct wlan_objmgr_psoc * psoc)351 ucfg_pkt_capture_get_pktcap_mode(struct wlan_objmgr_psoc *psoc)
352 {
353 	return PACKET_CAPTURE_MODE_DISABLE;
354 }
355 
356 static inline
ucfg_pkt_capture_set_pktcap_config(struct wlan_objmgr_vdev * vdev,enum pkt_capture_config config)357 void ucfg_pkt_capture_set_pktcap_config(struct wlan_objmgr_vdev *vdev,
358 					enum pkt_capture_config config)
359 {
360 }
361 
362 static inline enum pkt_capture_config
ucfg_pkt_capture_get_pktcap_config(struct wlan_objmgr_vdev * vdev)363 ucfg_pkt_capture_get_pktcap_config(struct wlan_objmgr_vdev *vdev)
364 {
365 	return 0;
366 }
367 
368 static inline QDF_STATUS
ucfg_pkt_capture_process_mgmt_tx_data(struct mgmt_offload_event_params * params,qdf_nbuf_t nbuf,uint8_t status)369 ucfg_pkt_capture_process_mgmt_tx_data(
370 				struct mgmt_offload_event_params *params,
371 				qdf_nbuf_t nbuf,
372 				uint8_t status)
373 {
374 	return 0;
375 }
376 
377 static inline void
ucfg_pkt_capture_mgmt_tx(struct wlan_objmgr_pdev * pdev,qdf_nbuf_t nbuf,uint16_t chan_freq,uint8_t preamble_type)378 ucfg_pkt_capture_mgmt_tx(struct wlan_objmgr_pdev *pdev,
379 			 qdf_nbuf_t nbuf,
380 			 uint16_t chan_freq,
381 			 uint8_t preamble_type)
382 {
383 }
384 
385 static inline void
ucfg_pkt_capture_mgmt_tx_completion(struct wlan_objmgr_pdev * pdev,uint32_t desc_id,uint32_t status,struct mgmt_offload_event_params * params)386 ucfg_pkt_capture_mgmt_tx_completion(struct wlan_objmgr_pdev *pdev,
387 				    uint32_t desc_id,
388 				    uint32_t status,
389 				    struct mgmt_offload_event_params *params)
390 {
391 }
392 
393 static inline void
ucfg_pkt_capture_offload_deliver_indication_handler(void * msg,uint8_t vdev_id,uint8_t * bssid,htt_pdev_handle pdev)394 ucfg_pkt_capture_offload_deliver_indication_handler(
395 					void *msg, uint8_t vdev_id,
396 					uint8_t *bssid, htt_pdev_handle pdev)
397 {
398 }
399 
400 static inline
ucfg_pkt_capture_tx_get_txcomplete_data_hdr(uint32_t * msg_word,int num_msdus)401 struct htt_tx_data_hdr_information *ucfg_pkt_capture_tx_get_txcomplete_data_hdr(
402 		uint32_t *msg_word,
403 		int num_msdus)
404 {
405 	return NULL;
406 }
407 
408 static inline void
ucfg_pkt_capture_rx_msdu_process(uint8_t * bssid,qdf_nbuf_t head_msdu,uint8_t vdev_id,htt_pdev_handle pdev)409 ucfg_pkt_capture_rx_msdu_process(
410 				uint8_t *bssid,
411 				qdf_nbuf_t head_msdu,
412 				uint8_t vdev_id, htt_pdev_handle pdev)
413 {
414 }
415 
416 static inline bool
ucfg_pkt_capture_rx_offloaded_pkt(qdf_nbuf_t rx_ind_msg)417 ucfg_pkt_capture_rx_offloaded_pkt(qdf_nbuf_t rx_ind_msg)
418 {
419 	return false;
420 }
421 
422 static inline void
ucfg_pkt_capture_rx_drop_offload_pkt(qdf_nbuf_t head_msdu)423 ucfg_pkt_capture_rx_drop_offload_pkt(qdf_nbuf_t head_msdu)
424 {
425 }
426 
427 static inline void
ucfg_pkt_capture_tx_completion_process(uint8_t vdev_id,qdf_nbuf_t mon_buf_list,enum pkt_capture_data_process_type type,uint8_t tid,uint8_t status,bool pkt_format,uint8_t * bssid,htt_pdev_handle pdev,uint8_t tx_retry_cnt)428 ucfg_pkt_capture_tx_completion_process(
429 			uint8_t vdev_id,
430 			qdf_nbuf_t mon_buf_list,
431 			enum pkt_capture_data_process_type type,
432 			uint8_t tid, uint8_t status, bool pkt_format,
433 			uint8_t *bssid, htt_pdev_handle pdev,
434 			uint8_t tx_retry_cnt)
435 {
436 }
437 
438 static inline void
ucfg_pkt_capture_record_channel(struct wlan_objmgr_vdev * vdev)439 ucfg_pkt_capture_record_channel(struct wlan_objmgr_vdev *vdev)
440 {
441 }
442 
443 static inline QDF_STATUS
ucfg_pkt_capture_set_filter(struct pkt_capture_frame_filter frame_filter,struct wlan_objmgr_vdev * vdev)444 ucfg_pkt_capture_set_filter(struct pkt_capture_frame_filter frame_filter,
445 			    struct wlan_objmgr_vdev *vdev)
446 {
447 	return QDF_STATUS_SUCCESS;
448 }
449 
450 #endif /* WLAN_FEATURE_PKT_CAPTURE */
451 #endif /* _WLAN_PKT_CAPTURE_UCFG_API_H_ */
452