xref: /wlan-driver/qcacld-3.0/components/cp_stats/dispatcher/inc/wlan_cp_stats_mc_ucfg_api.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2018-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
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: wlan_cp_stats_mc_ucfg_api.h
22  *
23  * This header file maintain API declaration required for northbound interaction
24  */
25 
26 #ifndef __WLAN_CP_STATS_MC_UCFG_API_H__
27 #define __WLAN_CP_STATS_MC_UCFG_API_H__
28 
29 #ifdef QCA_SUPPORT_CP_STATS
30 
31 #include <wlan_objmgr_psoc_obj.h>
32 #include <wlan_objmgr_vdev_obj.h>
33 #include <wlan_cp_stats_mc_defs.h>
34 
35 #ifdef WLAN_SUPPORT_TWT
36 
37 #include <wlan_objmgr_peer_obj.h>
38 #include "../../core/src/wlan_cp_stats_defs.h"
39 #include <qdf_event.h>
40 
41 /* Max TWT sessions supported */
42 #define TWT_PSOC_MAX_SESSIONS TWT_PEER_MAX_SESSIONS
43 
44 /**
45  * ucfg_twt_get_peer_session_params() - Retrieves peer twt session parameters
46  * corresponding to a peer by using mac_addr and dialog id
47  * If dialog_id is TWT_GET_ALL_PEER_PARAMS_DIALOG_ID retrieves twt session
48  * parameters of all peers with valid twt session
49  * @psoc_obj: psoc object
50  * @param: array pointer to store peer twt session parameters, should contain
51  * mac_addr and dialog id of a peer for which twt session stats to be retrieved
52  *
53  * Return: total number of valid twt session
54  */
55 int
56 ucfg_twt_get_peer_session_params(struct wlan_objmgr_psoc *psoc_obj,
57 				 struct wmi_host_twt_session_stats_info *param);
58 #endif /* WLAN_SUPPORT_TWT */
59 
60 struct psoc_cp_stats;
61 struct vdev_cp_stats;
62 
63 /**
64  * ucfg_mc_cp_stats_get_psoc_wake_lock_stats() : API to get wake lock stats from
65  * psoc
66  * @psoc: pointer to psoc object
67  * @stats: stats object to populate
68  *
69  * Return : status of operation
70  */
71 QDF_STATUS ucfg_mc_cp_stats_get_psoc_wake_lock_stats(
72 						struct wlan_objmgr_psoc *psoc,
73 						struct wake_lock_stats *stats);
74 
75 /**
76  * ucfg_mc_cp_stats_get_vdev_wake_lock_stats() : API to get wake lock stats from
77  * vdev
78  * @vdev: pointer to vdev object
79  * @stats: stats object to populate
80  *
81  * Return : status of operation
82  */
83 QDF_STATUS ucfg_mc_cp_stats_get_vdev_wake_lock_stats(
84 						struct wlan_objmgr_vdev *vdev,
85 						struct wake_lock_stats *stats);
86 
87 /**
88  * ucfg_mc_cp_stats_inc_wake_lock_stats_by_protocol() : API to increment wake
89  * lock stats given the protocol of the packet that was received.
90  * @psoc: pointer to psoc object
91  * @vdev_id: vdev_id for which the packet was received
92  * @protocol: protocol of the packet that was received
93  *
94  * Return : status of operation
95  */
96 QDF_STATUS ucfg_mc_cp_stats_inc_wake_lock_stats_by_protocol(
97 					struct wlan_objmgr_psoc *psoc,
98 					uint8_t vdev_id,
99 					enum qdf_proto_subtype protocol);
100 
101 /**
102  * ucfg_mc_cp_stats_inc_wake_lock_stats_by_dst_addr() : API to increment wake
103  * lock stats given destination of packet that was received.
104  * @psoc: pointer to psoc object
105  * @vdev_id: vdev_id for which the packet was received
106  * @dest_mac: destination mac address of packet that was received
107  *
108  * Return : status of operation
109  */
110 QDF_STATUS ucfg_mc_cp_stats_inc_wake_lock_stats_by_dst_addr(
111 					struct wlan_objmgr_psoc *psoc,
112 					uint8_t vdev_id, uint8_t *dest_mac);
113 
114 /**
115  * ucfg_mc_cp_stats_inc_wake_lock_stats() : API to increment wake lock stats
116  * given wake reason.
117  * @psoc: pointer to psoc object
118  * @vdev_id: vdev_id on with WOW was received
119  * @reason: reason of WOW
120  *
121  * Return : status of operation
122  */
123 QDF_STATUS ucfg_mc_cp_stats_inc_wake_lock_stats(struct wlan_objmgr_psoc *psoc,
124 						uint8_t vdev_id,
125 						uint32_t reason);
126 
127 /**
128  * ucfg_mc_cp_stats_write_wow_stats() - Writes WOW stats to buffer
129  * @psoc: pointer to psoc object
130  * @buffer: The char buffer to write to
131  * @max_len: The maximum number of chars to write
132  * @ret: number of bytes written
133  *
134  * Return: status of operation
135  */
136 QDF_STATUS ucfg_mc_cp_stats_write_wow_stats(
137 				struct wlan_objmgr_psoc *psoc,
138 				char *buffer, uint16_t max_len, int *ret);
139 
140 /**
141  * ucfg_mc_cp_stats_send_stats_request() - API to send stats request to lmac
142  * @vdev: pointer to vdev object
143  * @type: request type
144  * @info: specific request information
145  *
146  * Return: status of operation
147  */
148 QDF_STATUS ucfg_mc_cp_stats_send_stats_request(struct wlan_objmgr_vdev *vdev,
149 					       enum stats_req_type type,
150 					       struct request_info *info);
151 
152 /**
153  * wlan_cfg80211_mc_twt_clear_infra_cp_stats() - send request to reset
154  * control path statistics
155  * @vdev: pointer to vdev object
156  * @dialog_id: dialod id of the twt session
157  * @twt_peer_mac: mac address of the peer
158  *
159  * Return: 0 for success or error code for failure
160  */
161 int
162 wlan_cfg80211_mc_twt_clear_infra_cp_stats(
163 				struct wlan_objmgr_vdev *vdev,
164 				uint32_t dialog_id,
165 				uint8_t twt_peer_mac[QDF_MAC_ADDR_SIZE]);
166 
167 /**
168  * wlan_cfg80211_mc_twt_get_infra_cp_stats() - send twt get statistic request
169  * @vdev: pointer to vdev object
170  * @dialog_id: TWT session dialog id
171  * @twt_peer_mac: mac address of the peer
172  * @errno: error code
173  *
174  * Return: pointer to infra cp stats event for success or NULL for failure
175  */
176 struct infra_cp_stats_event *
177 wlan_cfg80211_mc_twt_get_infra_cp_stats(struct wlan_objmgr_vdev *vdev,
178 					uint32_t dialog_id,
179 					uint8_t twt_peer_mac[QDF_MAC_ADDR_SIZE],
180 					int *errno);
181 /**
182  * ucfg_mc_cp_stats_get_tx_power() - API to fetch tx_power
183  * @vdev: pointer to vdev object
184  * @dbm: pointer to tx power in dbm
185  *
186  * Return: status of operation
187  */
188 QDF_STATUS ucfg_mc_cp_stats_get_tx_power(struct wlan_objmgr_vdev *vdev,
189 					 int *dbm);
190 
191 /**
192  * ucfg_mc_cp_stats_is_req_pending() - API to tell if given request is pending
193  * @psoc: pointer to psoc object
194  * @type: request type to check
195  *
196  * Return: true of request is pending, false otherwise
197  */
198 bool ucfg_mc_cp_stats_is_req_pending(struct wlan_objmgr_psoc *psoc,
199 				     enum stats_req_type type);
200 
201 /**
202  * ucfg_mc_cp_stats_set_pending_req() - API to set pending request
203  * @psoc: pointer to psoc object
204  * @type: request to update
205  * @req: value to update
206  *
207  * Return: status of operation
208  */
209 QDF_STATUS ucfg_mc_cp_stats_set_pending_req(struct wlan_objmgr_psoc *psoc,
210 					    enum stats_req_type type,
211 					    struct request_info *req);
212 /**
213  * ucfg_mc_cp_stats_reset_pending_req() - API to reset pending request
214  * @psoc: pointer to psoc object
215  * @type: request to update
216  * @last_req: last request
217  * @pending: pending request present
218  *
219  * The function is an atomic operation of "reset" and "get" last request.
220  *
221  * Return: status of operation
222  */
223 QDF_STATUS ucfg_mc_cp_stats_reset_pending_req(struct wlan_objmgr_psoc *psoc,
224 					      enum stats_req_type type,
225 					      struct request_info *last_req,
226 					      bool *pending);
227 
228 /**
229  * ucfg_mc_cp_stats_get_pending_req() - API to get pending request
230  * @psoc: pointer to psoc object
231  * @type: request to update
232  * @info: buffer to populate
233  *
234  * Return: status of operation
235  */
236 QDF_STATUS ucfg_mc_cp_stats_get_pending_req(struct wlan_objmgr_psoc *psoc,
237 					    enum stats_req_type type,
238 					    struct request_info *info);
239 
240 /**
241  * ucfg_mc_infra_cp_stats_free_stats_resources() - API to free buffers within
242  * infra cp stats_event structure
243  * @ev: structure whose buffer are to freed
244  *
245  * Return: none
246  */
247 void
248 ucfg_mc_infra_cp_stats_free_stats_resources(struct infra_cp_stats_event *ev);
249 
250 /**
251  * ucfg_mc_cp_stats_free_stats_resources() - API to free buffers within stats_event
252  * structure
253  * @ev: structure whose buffer are to freed
254  *
255  * Return: none
256  */
257 void ucfg_mc_cp_stats_free_stats_resources(struct stats_event *ev);
258 
259 /**
260  * ucfg_mc_cp_stats_cca_stats_get() - API to fetch cca stats
261  * @vdev: pointer to vdev object
262  * @cca_stats: pointer to cca info
263  *
264  * Return: status of operation
265  */
266 QDF_STATUS ucfg_mc_cp_stats_cca_stats_get(struct wlan_objmgr_vdev *vdev,
267 					  struct cca_stats *cca_stats);
268 
269 /**
270  * ucfg_mc_cp_stats_set_rate_flags() - API to set rate flags
271  * @vdev: pointer to vdev object
272  * @flags: value to set
273  *
274  * Return: status of operation
275  */
276 QDF_STATUS ucfg_mc_cp_stats_set_rate_flags(struct wlan_objmgr_vdev *vdev,
277 					   uint32_t flags);
278 
279 /**
280  * ucfg_mc_cp_stats_register_lost_link_info_cb() - API to register lost link
281  * info callback
282  * @psoc: pointer to psoc object
283  * @lost_link_cp_stats_info_cb: Lost link info callback to be registered
284  *
285  */
286 void ucfg_mc_cp_stats_register_lost_link_info_cb(
287 		struct wlan_objmgr_psoc *psoc,
288 		void (*lost_link_cp_stats_info_cb)(void *stats_ev));
289 
290 #ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
291 /**
292  * ucfg_mc_cp_stats_register_pmo_handler() - API to register pmo handler
293  *
294  * Return: none
295  */
296 void ucfg_mc_cp_stats_register_pmo_handler(void);
297 #else
ucfg_mc_cp_stats_register_pmo_handler(void)298 void static inline ucfg_mc_cp_stats_register_pmo_handler(void) { };
299 #endif /* WLAN_POWER_MANAGEMENT_OFFLOAD */
300 
301 #ifdef WLAN_FEATURE_BIG_DATA_STATS
302 /**
303  * ucfg_send_big_data_stats_request() - API to send big data stats
304  * request
305  * @vdev: pointer to vdev object
306  * @type: request type
307  * @info: request info
308  *
309  * Return: status of operation
310  */
311 QDF_STATUS ucfg_send_big_data_stats_request(struct wlan_objmgr_vdev *vdev,
312 					    enum stats_req_type type,
313 					    struct request_info *info);
314 
315 /**
316  * ucfg_mc_cp_set_big_data_fw_support() - set big data fw support
317  * @psoc: PSOC object
318  * @enable: Set true if firmware supports big data, otherwise false
319  *
320  * API to set fw supports big data feature or not
321  *
322  * Return: void
323  */
324 void
325 ucfg_mc_cp_set_big_data_fw_support(struct wlan_objmgr_psoc *psoc,
326 				   bool enable);
327 
328 /**
329  * ucfg_mc_cp_get_big_data_fw_support() - get big data fw support
330  * @psoc: PSOC object
331  * @enable: Set true if firmware supports big data, otherwise false
332  *
333  * API to get fw supports big data feature or not
334  *
335  * Return: void
336  */
337 void
338 ucfg_mc_cp_get_big_data_fw_support(struct wlan_objmgr_psoc *psoc,
339 				   bool *enable);
340 #else
341 static inline
ucfg_send_big_data_stats_request(struct wlan_objmgr_vdev * vdev,enum stats_req_type type,struct request_info * info)342 QDF_STATUS ucfg_send_big_data_stats_request(struct wlan_objmgr_vdev *vdev,
343 					    enum stats_req_type type,
344 					    struct request_info *info)
345 {
346 	return QDF_STATUS_SUCCESS;
347 }
348 
349 static inline void
ucfg_mc_cp_set_big_data_fw_support(struct wlan_objmgr_psoc * psoc,bool enable)350 ucfg_mc_cp_set_big_data_fw_support(struct wlan_objmgr_psoc *psoc,
351 				   bool enable)
352 {}
353 
354 static inline void
ucfg_mc_cp_get_big_data_fw_support(struct wlan_objmgr_psoc * psoc,bool * enable)355 ucfg_mc_cp_get_big_data_fw_support(struct wlan_objmgr_psoc *psoc,
356 				   bool *enable)
357 {}
358 #endif
359 
360 #ifdef CONFIG_WLAN_BMISS
361 /**
362  * wlan_cfg80211_mc_bmiss_get_infra_cp_stats() - API to get bmiss stats
363  * @vdev: pointer to vdev object
364  * @bmiss_peer_mac: mac address of the peer
365  * @errno: error code
366  *
367  * Return: pointer to infra cp stats event for success or NULL for failure
368  */
369 struct infra_cp_stats_event*
370 wlan_cfg80211_mc_bmiss_get_infra_cp_stats(
371 				struct wlan_objmgr_vdev *vdev,
372 				uint8_t bmiss_peer_mac[QDF_MAC_ADDR_SIZE],
373 				int *errno);
374 #else /* CONFIG_WLAN_BMISS */
375 static inline struct infra_cp_stats_event*
wlan_cfg80211_mc_bmiss_get_infra_cp_stats(struct wlan_objmgr_vdev * vdev,uint8_t bmiss_peer_mac[QDF_MAC_ADDR_SIZE],int * errno)376 wlan_cfg80211_mc_bmiss_get_infra_cp_stats(
377 				struct wlan_objmgr_vdev *vdev,
378 				uint8_t bmiss_peer_mac[QDF_MAC_ADDR_SIZE],
379 				int *errno)
380 {
381 	return NULL;
382 }
383 #endif /* CONFIG_WLAN_BMISS */
384 
385 /**
386  * wlan_cp_stats_update_chan_info() - API to update chan stats
387  * @psoc: pointer to psoc
388  * @chan_stat: channel stats
389  * @vdev_id: vdev id
390  *
391  * Return: None
392  */
393 void wlan_cp_stats_update_chan_info(struct wlan_objmgr_psoc *psoc,
394 				    struct channel_status *chan_stat,
395 				    uint8_t vdev_id);
396 
397 /**
398  * wlan_cp_stats_get_rx_clear_count() - API to get rx clear count for a channel
399  * @psoc: pointer to psoc
400  * @vdev_id: vdev id
401  * @req_freq: freq for which rx clear count require
402  *
403  * Return: channel load
404  */
405 uint8_t wlan_cp_stats_get_rx_clear_count(struct wlan_objmgr_psoc *psoc,
406 					 uint8_t vdev_id, qdf_freq_t req_freq);
407 
408 /**
409  * ucfg_mc_cp_stats_clear_channel_status() - API to clear chan stats
410  * @pdev: pointer to pdev object
411  *
412  * Return: None
413  */
414 void ucfg_mc_cp_stats_clear_channel_status(struct wlan_objmgr_pdev *pdev);
415 
416 /**
417  * ucfg_mc_cp_stats_get_channel_status() - API to get chan stats
418  * @pdev: pointer to pdev object
419  * @chan_freq: channel freq of which stats are needed
420  *
421  * Return: channel status
422  */
423 struct channel_status *
424 ucfg_mc_cp_stats_get_channel_status(struct wlan_objmgr_pdev *pdev,
425 				    uint32_t chan_freq);
426 #else /* QCA_SUPPORT_CP_STATS */
427 
ucfg_mc_cp_stats_register_pmo_handler(void)428 void static inline ucfg_mc_cp_stats_register_pmo_handler(void) { };
ucfg_mc_cp_stats_send_stats_request(struct wlan_objmgr_vdev * vdev,enum stats_req_type type,struct request_info * info)429 static inline QDF_STATUS ucfg_mc_cp_stats_send_stats_request(
430 				struct wlan_objmgr_vdev *vdev,
431 				enum stats_req_type type,
432 				struct request_info *info)
433 {
434 	return QDF_STATUS_SUCCESS;
435 }
436 
ucfg_mc_cp_stats_set_rate_flags(struct wlan_objmgr_vdev * vdev,uint32_t flags)437 static inline QDF_STATUS ucfg_mc_cp_stats_set_rate_flags(
438 				struct wlan_objmgr_vdev *vdev,
439 				uint32_t flags)
440 {
441 	return QDF_STATUS_SUCCESS;
442 }
443 
ucfg_mc_cp_stats_get_psoc_wake_lock_stats(struct wlan_objmgr_psoc * psoc,struct wake_lock_stats * stats)444 static inline QDF_STATUS ucfg_mc_cp_stats_get_psoc_wake_lock_stats(
445 						struct wlan_objmgr_psoc *psoc,
446 						struct wake_lock_stats *stats)
447 {
448 	return QDF_STATUS_SUCCESS;
449 }
450 
ucfg_mc_cp_stats_inc_wake_lock_stats_by_protocol(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,enum qdf_proto_subtype protocol)451 static inline QDF_STATUS ucfg_mc_cp_stats_inc_wake_lock_stats_by_protocol(
452 					struct wlan_objmgr_psoc *psoc,
453 					uint8_t vdev_id,
454 					enum qdf_proto_subtype protocol)
455 {
456 	return QDF_STATUS_SUCCESS;
457 }
458 
ucfg_mc_cp_stats_inc_wake_lock_stats(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,uint32_t reason)459 static inline QDF_STATUS ucfg_mc_cp_stats_inc_wake_lock_stats(
460 				struct wlan_objmgr_psoc *psoc,
461 				uint8_t vdev_id,
462 				uint32_t reason)
463 {
464 	return QDF_STATUS_SUCCESS;
465 }
466 
ucfg_mc_cp_stats_inc_wake_lock_stats_by_dst_addr(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,uint8_t * dest_mac)467 static inline QDF_STATUS ucfg_mc_cp_stats_inc_wake_lock_stats_by_dst_addr(
468 					struct wlan_objmgr_psoc *psoc,
469 					uint8_t vdev_id, uint8_t *dest_mac)
470 {
471 	return QDF_STATUS_SUCCESS;
472 }
473 
ucfg_mc_cp_stats_get_vdev_wake_lock_stats(struct wlan_objmgr_vdev * vdev,struct wake_lock_stats * stats)474 static inline QDF_STATUS ucfg_mc_cp_stats_get_vdev_wake_lock_stats(
475 						struct wlan_objmgr_vdev *vdev,
476 						struct wake_lock_stats *stats)
477 {
478 	return QDF_STATUS_SUCCESS;
479 }
480 
481 static inline
ucfg_send_big_data_stats_request(struct wlan_objmgr_vdev * vdev,enum stats_req_type type,struct request_info * info)482 QDF_STATUS ucfg_send_big_data_stats_request(struct wlan_objmgr_vdev *vdev,
483 					    enum stats_req_type type,
484 					    struct request_info *info)
485 {
486 	return QDF_STATUS_SUCCESS;
487 }
488 
489 static inline void
ucfg_mc_cp_set_big_data_fw_support(struct wlan_objmgr_psoc * psoc,bool enable)490 ucfg_mc_cp_set_big_data_fw_support(struct wlan_objmgr_psoc *psoc,
491 				   bool enable)
492 {}
493 
494 static inline void
ucfg_mc_cp_big_data_fw_support(struct wlan_objmgr_psoc * psoc,bool * enable)495 ucfg_mc_cp_big_data_fw_support(struct wlan_objmgr_psoc *psoc,
496 			       bool *enable)
497 {}
498 
499 static inline struct infra_cp_stats_event*
wlan_cfg80211_mc_bmiss_get_infra_cp_stats(struct wlan_objmgr_vdev * vdev,uint8_t bmiss_peer_mac[QDF_MAC_ADDR_SIZE],int * errno)500 wlan_cfg80211_mc_bmiss_get_infra_cp_stats(
501 				struct wlan_objmgr_vdev *vdev,
502 				uint8_t bmiss_peer_mac[QDF_MAC_ADDR_SIZE],
503 				int *errno)
504 {
505 	return NULL;
506 }
507 
508 static inline void
ucfg_mc_cp_stats_get_tx_power(struct wlan_objmgr_vdev * vdev,int * dbm)509 ucfg_mc_cp_stats_get_tx_power(struct wlan_objmgr_vdev *vdev,
510 			      int *dbm)
511 {}
512 
513 static inline
wlan_cp_stats_update_chan_info(struct wlan_objmgr_psoc * psoc,struct channel_status * chan_stat,uint8_t vdev_id)514 void wlan_cp_stats_update_chan_info(struct wlan_objmgr_psoc *psoc,
515 				    struct channel_status *chan_stat,
516 				    uint8_t vdev_id)
517 {
518 }
519 
520 static inline
wlan_cp_stats_get_rx_clear_count(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,qdf_freq_t req_freq)521 uint8_t wlan_cp_stats_get_rx_clear_count(struct wlan_objmgr_psoc *psoc,
522 					 uint8_t vdev_id, qdf_freq_t req_freq)
523 {
524 }
525 
526 static inline
ucfg_mc_cp_stats_clear_channel_status(struct wlan_objmgr_pdev * pdev)527 void ucfg_mc_cp_stats_clear_channel_status(struct wlan_objmgr_pdev *pdev)
528 {
529 }
530 
531 static inline struct channel_status *
ucfg_mc_cp_stats_get_channel_status(struct wlan_objmgr_pdev * pdev,uint32_t chan_freq)532 ucfg_mc_cp_stats_get_channel_status(struct wlan_objmgr_pdev *pdev,
533 				    uint32_t chan_freq)
534 {
535 	return NULL;
536 }
537 #endif /* QCA_SUPPORT_CP_STATS */
538 #endif /* __WLAN_CP_STATS_MC_UCFG_API_H__ */
539