1 /*
2  * Copyright (c) 2012-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
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_hdd_stats.h
22  *
23  * WLAN Host Device Driver statistics related implementation
24  *
25  */
26 
27 #if !defined(WLAN_HDD_STATS_H)
28 #define WLAN_HDD_STATS_H
29 
30 #include "wlan_hdd_main.h"
31 #ifdef WLAN_FEATURE_11BE_MLO
32 #include "wlan_mlo_mgr_cmn.h"
33 #endif
34 #include <wlan_cp_stats_chipset_stats.h>
35 
36 #define INVALID_MCS_IDX 255
37 
38 #define DATA_RATE_11AC_MCS_MASK    0x03
39 
40 #ifdef FEATURE_CLUB_LL_STATS_AND_GET_STATION
41 /* LL stats get request time out value */
42 #define WLAN_WAIT_TIME_LL_STATS 3300
43 #else
44 #define WLAN_WAIT_TIME_LL_STATS 800
45 #endif
46 
47 #define WLAN_HDD_TGT_NOISE_FLOOR_DBM     (-128)
48 
49 #ifdef WLAN_FEATURE_LINK_LAYER_STATS
50 extern const struct nla_policy qca_wlan_vendor_ll_ext_policy[
51 			QCA_WLAN_VENDOR_ATTR_LL_STATS_EXT_MAX + 1];
52 
53 /* QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR */
54 extern const struct nla_policy qca_wlan_vendor_ll_clr_policy[
55 			QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
56 
57 /* QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET */
58 extern const struct nla_policy qca_wlan_vendor_ll_set_policy[
59 			QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
60 
61 /* QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET */
62 extern const struct nla_policy qca_wlan_vendor_ll_get_policy[
63 			QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
64 
65 #define FEATURE_LL_STATS_VENDOR_COMMANDS                                \
66 {                                                                       \
67 	.info.vendor_id = QCA_NL80211_VENDOR_ID,                        \
68 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,          \
69 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |                           \
70 		WIPHY_VENDOR_CMD_NEED_NETDEV |                          \
71 		WIPHY_VENDOR_CMD_NEED_RUNNING,                          \
72 	.doit = wlan_hdd_cfg80211_ll_stats_clear,                       \
73 	vendor_command_policy(qca_wlan_vendor_ll_clr_policy,            \
74 			      QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX)    \
75 },                                                                      \
76 									\
77 {                                                                       \
78 	.info.vendor_id = QCA_NL80211_VENDOR_ID,                        \
79 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,          \
80 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |                           \
81 		 WIPHY_VENDOR_CMD_NEED_NETDEV |                         \
82 		 WIPHY_VENDOR_CMD_NEED_RUNNING,                         \
83 	.doit = wlan_hdd_cfg80211_ll_stats_set,                         \
84 	vendor_command_policy(qca_wlan_vendor_ll_set_policy,            \
85 			      QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX)    \
86 },                                                                      \
87                                                                         \
88 {                                                                       \
89 	.info.vendor_id = QCA_NL80211_VENDOR_ID,                        \
90 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,          \
91 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |                           \
92 		 WIPHY_VENDOR_CMD_NEED_NETDEV |                         \
93 		 WIPHY_VENDOR_CMD_NEED_RUNNING,                         \
94 	.doit = wlan_hdd_cfg80211_ll_stats_get,                         \
95 	vendor_command_policy(qca_wlan_vendor_ll_get_policy,            \
96 			      QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX)    \
97 },
98 #else
99 #define FEATURE_LL_STATS_VENDOR_COMMANDS
100 #endif
101 
102 /**
103  * struct index_vht_data_rate_type - vht data rate type
104  * @beacon_rate_index: Beacon rate index
105  * @supported_VHT80_rate: VHT80 rate
106  * @supported_VHT40_rate: VHT40 rate
107  * @supported_VHT20_rate: VHT20 rate
108  */
109 struct index_vht_data_rate_type {
110 	uint8_t beacon_rate_index;
111 	uint16_t supported_VHT80_rate[2];
112 	uint16_t supported_VHT40_rate[2];
113 	uint16_t supported_VHT20_rate[2];
114 };
115 
116 /**
117  * enum data_rate_11ac_max_mcs - possible VHT max MCS values
118  * @DATA_RATE_11AC_MAX_MCS_7: MCS7 rate
119  * @DATA_RATE_11AC_MAX_MCS_8: MCS8 rate
120  * @DATA_RATE_11AC_MAX_MCS_9: MCS9 rate
121  * @DATA_RATE_11AC_MAX_MCS_NA: Not applicable
122  */
123 enum data_rate_11ac_max_mcs {
124 	DATA_RATE_11AC_MAX_MCS_7,
125 	DATA_RATE_11AC_MAX_MCS_8,
126 	DATA_RATE_11AC_MAX_MCS_9,
127 	DATA_RATE_11AC_MAX_MCS_NA
128 };
129 
130 /**
131  * struct index_data_rate_type - non vht data rate type
132  * @beacon_rate_index: Beacon rate index
133  * @supported_rate: Supported rate table
134  */
135 struct index_data_rate_type {
136 	uint8_t beacon_rate_index;
137 	uint16_t supported_rate[4];
138 };
139 
140 #ifdef WLAN_FEATURE_LINK_LAYER_STATS
141 
142 /**
143  * wlan_hdd_cfg80211_ll_stats_set() - set link layer stats
144  * @wiphy: Pointer to wiphy
145  * @wdev: Pointer to wdev
146  * @data: Pointer to data
147  * @data_len: Data length
148  *
149  * Return: int
150  */
151 int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
152 				   struct wireless_dev *wdev,
153 				   const void *data,
154 				   int data_len);
155 
156 /**
157  * wlan_hdd_cfg80211_ll_stats_get() - get link layer stats
158  * @wiphy: Pointer to wiphy
159  * @wdev: Pointer to wdev
160  * @data: Pointer to data
161  * @data_len: Data length
162  *
163  * Return: int
164  */
165 int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
166 				   struct wireless_dev *wdev,
167 				   const void *data,
168 				   int data_len);
169 
170 
171 /**
172  * wlan_hdd_cfg80211_ll_stats_clear() - clear link layer stats
173  * @wiphy: Pointer to wiphy
174  * @wdev: Pointer to wdev
175  * @data: Pointer to data
176  * @data_len: Data length
177  *
178  * Return: int
179  */
180 int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
181 				     struct wireless_dev *wdev,
182 				     const void *data,
183 				     int data_len);
184 
185 void wlan_hdd_clear_link_layer_stats(struct hdd_adapter *adapter);
186 
hdd_link_layer_stats_supported(void)187 static inline bool hdd_link_layer_stats_supported(void)
188 {
189 	return true;
190 }
191 
192 /**
193  * wlan_hdd_cfg80211_ll_stats_ext_set_param() - config monitor parameters
194  * @wiphy: wiphy handle
195  * @wdev: wdev handle
196  * @data: user layer input
197  * @data_len: length of user layer input
198  *
199  * return: 0 success, einval failure
200  */
201 int wlan_hdd_cfg80211_ll_stats_ext_set_param(struct wiphy *wiphy,
202 					     struct wireless_dev *wdev,
203 					     const void *data,
204 					     int data_len);
205 /**
206  * hdd_get_interface_info() - get interface info
207  * @link_info: Link info pointer in HDD adapter
208  * @info: Pointer to interface info
209  *
210  * Return: bool
211  */
212 bool hdd_get_interface_info(struct wlan_hdd_link_info *link_info,
213 			    struct wifi_interface_info *info);
214 
215 /**
216  * wlan_hdd_ll_stats_get() - Get Link Layer statistics from FW
217  * @link_info: Link info pointer in HDD adapter
218  * @req_id: request id
219  * @req_mask: bitmask used by FW for the request
220  *
221  * Return: 0 on success and error code otherwise
222  */
223 int wlan_hdd_ll_stats_get(struct wlan_hdd_link_info *link_info,
224 			  uint32_t req_id, uint32_t req_mask);
225 
226 /**
227  * wlan_hdd_cfg80211_link_layer_stats_callback() - This function is called
228  * @hdd_handle: Handle to HDD context
229  * @indication_type: Indication type
230  * @results: Pointer to results
231  * @cookie: Callback context
232  *
233  * After receiving Link Layer indications from FW.This callback converts the
234  * firmware data to the NL data and send the same to the kernel/upper layers.
235  *
236  * Return: None
237  */
238 void wlan_hdd_cfg80211_link_layer_stats_callback(hdd_handle_t hdd_handle,
239 						 int indication_type,
240 						 tSirLLStatsResults *results,
241 						 void *cookie);
242 
243 /**
244  * wlan_hdd_cfg80211_link_layer_stats_ext_callback() - Callback for LL ext
245  * @ctx: HDD context
246  * @rsp: msg from FW
247  *
248  * This function is an extension of
249  * wlan_hdd_cfg80211_link_layer_stats_callback. It converts
250  * monitoring parameters offloaded to NL data and send the same to the
251  * kernel/upper layers.
252  *
253  * Return: None.
254  */
255 void wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx,
256 						     tSirLLStatsResults *rsp);
257 
258 /**
259  * hdd_lost_link_info_cb() - callback function to get lost link information
260  * @hdd_handle: Opaque handle for the HDD context
261  * @lost_link_info: lost link information
262  *
263  * Return: none
264  */
265 void hdd_lost_link_info_cb(hdd_handle_t hdd_handle,
266 			   struct sir_lost_link_info *lost_link_info);
267 
268 #else /* WLAN_FEATURE_LINK_LAYER_STATS */
269 
hdd_link_layer_stats_supported(void)270 static inline bool hdd_link_layer_stats_supported(void)
271 {
272 	return false;
273 }
274 
275 static inline int
wlan_hdd_cfg80211_ll_stats_ext_set_param(struct wiphy * wiphy,struct wireless_dev * wdev,const void * data,int data_len)276 wlan_hdd_cfg80211_ll_stats_ext_set_param(struct wiphy *wiphy,
277 					 struct wireless_dev *wdev,
278 					 const void *data,
279 					 int data_len)
280 {
281 	return -EINVAL;
282 }
283 
284 static inline int
wlan_hdd_ll_stats_get(struct wlan_hdd_link_info * link_info,uint32_t req_id,uint32_t req_mask)285 wlan_hdd_ll_stats_get(struct wlan_hdd_link_info *link_info,
286 		      uint32_t req_id, uint32_t req_mask)
287 {
288 	return -EINVAL;
289 }
290 
291 static inline void
wlan_hdd_clear_link_layer_stats(struct hdd_adapter * adapter)292 wlan_hdd_clear_link_layer_stats(struct hdd_adapter *adapter)
293 {
294 }
295 
296 static inline void
wlan_hdd_cfg80211_link_layer_stats_callback(hdd_handle_t hdd_handle,int indication_type,tSirLLStatsResults * results,void * cookie)297 wlan_hdd_cfg80211_link_layer_stats_callback(hdd_handle_t hdd_handle,
298 					    int indication_type,
299 					    tSirLLStatsResults *results,
300 					    void *cookie)
301 {
302 }
303 
304 static inline void
wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx,tSirLLStatsResults * rsp)305 wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx,
306 						tSirLLStatsResults *rsp)
307 {
308 }
309 
310 static inline void
hdd_lost_link_info_cb(hdd_handle_t hdd_handle,struct sir_lost_link_info * lost_link_info)311 hdd_lost_link_info_cb(hdd_handle_t hdd_handle,
312 		      struct sir_lost_link_info *lost_link_info)
313 {
314 }
315 
316 #endif /* End of WLAN_FEATURE_LINK_LAYER_STATS */
317 
318 #ifdef WLAN_FEATURE_STATS_EXT
319 /**
320  * wlan_hdd_cfg80211_stats_ext_request() - ext stats request
321  * @wiphy: Pointer to wiphy
322  * @wdev: Pointer to wdev
323  * @data: Pointer to data
324  * @data_len: Data length
325  *
326  * Return: int
327  */
328 int wlan_hdd_cfg80211_stats_ext_request(struct wiphy *wiphy,
329 					struct wireless_dev *wdev,
330 					const void *data,
331 					int data_len);
332 
333 #endif /* End of WLAN_FEATURE_STATS_EXT */
334 
335 /**
336  * wlan_hdd_cfg80211_connected_chan_stats_req() - get currently connected
337  * channel statistics from driver/firmware
338  * @wiphy: Pointer to wiphy
339  * @wdev: Pointer to wdev
340  * @data: Pointer to data
341  * @data_len: Data length
342  *
343  * Return: int
344  */
345 int wlan_hdd_cfg80211_connected_chan_stats_req(struct wiphy *wiphy,
346 					       struct wireless_dev *wdev,
347 					       const void *data,
348 					       int data_len);
349 
350 /**
351  * wlan_hdd_cfg80211_get_station() - get station statistics
352  * @wiphy: Pointer to wiphy
353  * @dev: Pointer to network device
354  * @mac: Pointer to mac
355  * @sinfo: Pointer to station info
356  *
357  * Return: 0 for success, non-zero for failure
358  */
359 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
360 int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy,
361 				  struct net_device *dev, const uint8_t *mac,
362 				  struct station_info *sinfo);
363 #else
364 int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy,
365 				  struct net_device *dev, uint8_t *mac,
366 				  struct station_info *sinfo);
367 #endif
368 
369 /**
370  * wlan_hdd_cfg80211_dump_station() - dump station statistics
371  * @wiphy: Pointer to wiphy
372  * @dev: Pointer to network device
373  * @idx: variable to determine whether to get stats or not
374  * @mac: Pointer to mac
375  * @sinfo: Pointer to station info
376  *
377  * Return: 0 for success, non-zero for failure
378  */
379 int wlan_hdd_cfg80211_dump_station(struct wiphy *wiphy,
380 				struct net_device *dev,
381 				int idx, u8 *mac,
382 				struct station_info *sinfo);
383 
384 struct net_device_stats *hdd_get_stats(struct net_device *dev);
385 
386 int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
387 				  struct net_device *dev,
388 				  int idx, struct survey_info *survey);
389 
390 void hdd_display_hif_stats(void);
391 void hdd_clear_hif_stats(void);
392 
393 /**
394  * wlan_hdd_cfg80211_stats_ext_callback() - ext stats callback
395  * @hdd_handle: Opaque handle to HDD context
396  * @data: ext stats payload
397  *
398  * Return: nothing
399  */
400 void wlan_hdd_cfg80211_stats_ext_callback(hdd_handle_t hdd_handle,
401 					  struct stats_ext_event *data);
402 
403 /**
404  * wlan_hdd_cfg80211_stats_ext2_callback() - stats_ext2_callback
405  * @hdd_handle: opaque handle to the hdd context
406  * @pmsg: sir_sme_rx_aggr_hole_ind
407  *
408  * Return: void
409  */
410 void
411 wlan_hdd_cfg80211_stats_ext2_callback(hdd_handle_t hdd_handle,
412 				      struct sir_sme_rx_aggr_hole_ind *pmsg);
413 
414 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
415 /**
416  * wlan_hdd_cfg80211_roam_events_callback() - roam_events_callback
417  * @roam_stats: roam events stats
418  * @idx: TLV index in roam stats event
419  *
420  * Return: void
421  */
422 void
423 wlan_hdd_cfg80211_roam_events_callback(struct roam_stats_event *roam_stats,
424 				       uint8_t idx);
425 #endif /* End of WLAN_FEATURE_ROAM_OFFLOAD */
426 
427 /**
428  * wlan_hdd_get_rcpi() - Wrapper to get current RCPI
429  * @adapter: adapter upon which the measurement is requested
430  * @mac: peer addr for which measurement is requested
431  * @rcpi_value: pointer to where the RCPI should be returned
432  * @measurement_type: type of rcpi measurement
433  *
434  * This is a wrapper function for getting RCPI, invoke this function only
435  * when rcpi support is enabled in firmware
436  *
437  * Return: 0 for success, non-zero for failure
438  */
439 int wlan_hdd_get_rcpi(struct hdd_adapter *adapter, uint8_t *mac,
440 		      int32_t *rcpi_value,
441 		      enum rcpi_measurement_type measurement_type);
442 
443 #ifdef WLAN_FEATURE_MIB_STATS
444 /**
445  * wlan_hdd_get_mib_stats() - Get the mib statistics
446  * @adapter: adapter upon which the measurement is requested
447  *
448  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
449  */
450 QDF_STATUS wlan_hdd_get_mib_stats(struct hdd_adapter *adapter);
451 #endif
452 
453 /**
454  * wlan_hdd_get_rssi() - Get the current RSSI
455  * @link_info: Link info pointer in HDD adapter
456  * @rssi_value: pointer to where the RSSI should be returned
457  *
458  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
459  */
460 QDF_STATUS wlan_hdd_get_rssi(struct wlan_hdd_link_info *link_info,
461 			     int8_t *rssi_value);
462 
463 /**
464  * wlan_hdd_get_snr() - Get the current SNR
465  * @link_info: Link info pointer in HDD adapter
466  * @snr: pointer to where the SNR should be returned
467  *
468  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
469  */
470 QDF_STATUS wlan_hdd_get_snr(struct wlan_hdd_link_info *link_info, int8_t *snr);
471 
472 /**
473  * wlan_hdd_get_linkspeed_for_peermac() - Get link speed for a peer
474  * @link_info: Link info pointer in adapter
475  * @mac_address: MAC address of the peer
476  * @linkspeed: pointer to memory where returned link speed is to be placed
477  *
478  * This function will send a query to SME for the linkspeed of the
479  * given peer, and then wait for the callback to be invoked.
480  *
481  * Return: 0 if linkspeed data is available, negative errno otherwise
482  */
483 int wlan_hdd_get_linkspeed_for_peermac(struct wlan_hdd_link_info *link_info,
484 				       struct qdf_mac_addr *mac_address,
485 				       uint32_t *linkspeed);
486 
487 /**
488  * wlan_hdd_get_link_speed() - get link speed
489  * @link_info: Link info pointer in HDD adapter
490  * @link_speed:   pointer to link speed
491  *
492  * This function fetches per bssid link speed.
493  *
494  * Return: if associated, link speed shall be returned.
495  *         if not associated, link speed of 0 is returned.
496  *         On error, error number will be returned.
497  */
498 int wlan_hdd_get_link_speed(struct wlan_hdd_link_info *link_info,
499 			    uint32_t *link_speed);
500 
501 /**
502  * wlan_hdd_get_sap_go_peer_linkspeed() - Get SAP/GO peer link speed
503  * @link_info:   Link info pointer in HDD adapter
504  * @link_speed:  Pointer to link speed
505  * @command:     Driver command string
506  * @command_len: Driver command string length
507  *
508  * Return: 0 if linkspeed data is available, negative errno otherwise
509  */
510 int wlan_hdd_get_sap_go_peer_linkspeed(struct wlan_hdd_link_info *link_info,
511 				       uint32_t *link_speed,
512 				       uint8_t *command,
513 				       uint8_t command_len);
514 #ifdef FEATURE_RX_LINKSPEED_ROAM_TRIGGER
515 /**
516  * wlan_hdd_get_peer_rx_rate_stats() - STA gets rx rate stats
517  * @link_info: Link info pointer in HDD adapter
518  *
519  * STA gets rx rate stats through using the existed API
520  * cdp_host_get_peer_stats. The reason that we make this
521  * function is to avoid being disrupted by the flag
522  * "get_station_fw_request_needed"
523  *
524  * Return: void
525  */
526 void wlan_hdd_get_peer_rx_rate_stats(struct wlan_hdd_link_info *link_info);
527 #else
528 static inline void
wlan_hdd_get_peer_rx_rate_stats(struct wlan_hdd_link_info * link_info)529 wlan_hdd_get_peer_rx_rate_stats(struct wlan_hdd_link_info *link_info)
530 {
531 }
532 #endif
533 
534 /**
535  * wlan_hdd_get_station_stats() - Get station statistics
536  * @link_info: Link info pointer in HDD adapter.
537  *
538  * Return: status of operation
539  */
540 int wlan_hdd_get_station_stats(struct wlan_hdd_link_info *link_info);
541 
542 int wlan_hdd_qmi_get_sync_resume(void);
543 int wlan_hdd_qmi_put_suspend(void);
544 
545 #ifdef WLAN_FEATURE_BIG_DATA_STATS
546 /**
547  * wlan_hdd_get_big_data_station_stats() - Get big data station statistics
548  * @link_info: Link info pointer in HDD adapter
549  *
550  * Return: status of operation
551  */
552 int wlan_hdd_get_big_data_station_stats(struct wlan_hdd_link_info *link_info);
553 
554 /**
555  * wlan_cfg80211_mc_cp_get_big_data_stats() - API to get big data
556  * statistics from firmware
557  * @vdev:    Pointer to vdev
558  * @errno:   error type in case of failure
559  *
560  * Return: big data stats buffer on success, Null on failure
561  */
562 struct big_data_stats_event *
563 wlan_cfg80211_mc_cp_get_big_data_stats(struct wlan_objmgr_vdev *vdev,
564 				       int *errno);
565 
566 /**
567  * wlan_cfg80211_mc_cp_stats_free_big_data_stats_event() - API to release big
568  * data statistics buffer
569  * @info:    pointer to object to populate with big data stats
570  *
571  * Return: None
572  */
573 void wlan_cfg80211_mc_cp_stats_free_big_data_stats_event(
574 					struct big_data_stats_event *info);
575 #else
576 static inline int
wlan_hdd_get_big_data_station_stats(struct wlan_hdd_link_info * link_info)577 wlan_hdd_get_big_data_station_stats(struct wlan_hdd_link_info *link_info)
578 {
579 	return 0;
580 }
581 
582 static inline struct big_data_stats_event *
wlan_cfg80211_mc_cp_get_big_data_stats(struct wlan_objmgr_vdev * vdev,int * errno)583 wlan_cfg80211_mc_cp_get_big_data_stats(struct wlan_objmgr_vdev *vdev,
584 				       int *errno)
585 {
586 	return 0;
587 }
588 
589 static inline
wlan_cfg80211_mc_cp_stats_free_big_data_stats_event(struct big_data_stats_event * info)590 void wlan_cfg80211_mc_cp_stats_free_big_data_stats_event(
591 					struct big_data_stats_event *info)
592 {
593 }
594 #endif
595 
596 /**
597  * wlan_hdd_get_temperature() - get current device temperature
598  * @adapter: device upon which the request was made
599  * @temperature: pointer to where the temperature is to be returned
600  *
601  * Return: 0 if a temperature value (either current or cached) was
602  * returned, otherwise a negative errno is returned.
603  *
604  */
605 int wlan_hdd_get_temperature(struct hdd_adapter *adapter, int *temperature);
606 
607 /**
608  * hdd_get_max_tx_bitrate() - Get the max tx bitrate of the AP
609  * @link_info: pointer to link_info struct in adapter
610  *
611  * This function gets the MAX supported rate by AP and cache
612  * it into connection info structure
613  *
614  * Return: None
615  */
616 void hdd_get_max_tx_bitrate(struct wlan_hdd_link_info *link_info);
617 
618 #ifdef TX_MULTIQ_PER_AC
619 /**
620  * wlan_hdd_display_tx_multiq_stats() - display Tx multi queue stats
621  * @context: hdd context
622  * @netdev: netdev
623  *
624  * Return: none
625  */
626 void wlan_hdd_display_tx_multiq_stats(hdd_cb_handle context,
627 				      qdf_netdev_t netdev);
628 #else
629 static inline
wlan_hdd_display_tx_multiq_stats(hdd_cb_handle context,qdf_netdev_t netdev)630 void wlan_hdd_display_tx_multiq_stats(hdd_cb_handle context,
631 				      qdf_netdev_t netdev)
632 {
633 }
634 #endif
635 
636 /**
637  * hdd_report_max_rate() - Fill the max rate stats in the station info structure
638  * to be sent to the userspace.
639  * @link_info: pointer to link_info struct in adapter
640  * @mac_handle: The mac handle
641  * @rate: The station_info tx/rx rate to be filled
642  * @signal: signal from station_info
643  * @rate_flags: TX/RX rate flags computed from tx/rx rate
644  * @mcs_index: The TX/RX mcs index computed from tx/rx rate
645  * @fw_rate: The tx/rx rate from fw stats
646  * @nss: The TX/RX NSS from fw stats
647  *
648  * Return: True if fill is successful
649  */
650 bool hdd_report_max_rate(struct wlan_hdd_link_info *link_info,
651 			 mac_handle_t mac_handle,
652 			 struct rate_info *rate,
653 			 int8_t signal,
654 			 enum tx_rate_info rate_flags,
655 			 uint8_t mcs_index,
656 			 uint16_t fw_rate, uint8_t nss);
657 
658 /**
659  * hdd_check_and_update_nss() - Check and update NSS as per DBS capability
660  * @hdd_ctx: HDD Context pointer
661  * @tx_nss: pointer to variable storing the tx_nss
662  * @rx_nss: pointer to variable storing the rx_nss
663  *
664  * The parameters include the NSS obtained from the FW or static NSS. This NSS
665  * could be invalid in the case the current HW mode is DBS where the connection
666  * are 1x1. Rectify these NSS values as per the current HW mode.
667  *
668  * Return: none
669  */
670 void hdd_check_and_update_nss(struct hdd_context *hdd_ctx,
671 			      uint8_t *tx_nss, uint8_t *rx_nss);
672 #ifdef QCA_SUPPORT_CP_STATS
673 /**
674  * wlan_hdd_register_cp_stats_cb() - Register hdd stats specific
675  * callbacks to the cp stats component
676  * @hdd_ctx: hdd context
677  *
678  * Return: none
679  */
680 
681 void wlan_hdd_register_cp_stats_cb(struct hdd_context *hdd_ctx);
682 #else
wlan_hdd_register_cp_stats_cb(struct hdd_context * hdd_ctx)683 static inline void wlan_hdd_register_cp_stats_cb(struct hdd_context *hdd_ctx) {}
684 #endif
685 
686 #if defined(WLAN_FEATURE_ROAM_OFFLOAD) && defined(WLAN_FEATURE_ROAM_INFO_STATS)
687 #define FEATURE_ROAM_STATS_COMMANDS	\
688 	{	\
689 	.info.vendor_id = QCA_NL80211_VENDOR_ID,	\
690 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAM_STATS,	\
691 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |	\
692 		 WIPHY_VENDOR_CMD_NEED_NETDEV |	\
693 		 WIPHY_VENDOR_CMD_NEED_RUNNING,	\
694 	.doit = wlan_hdd_cfg80211_get_roam_stats,	\
695 	vendor_command_policy(VENDOR_CMD_RAW_DATA, 0)	\
696 	},	\
697 
698 #define FEATURE_ROAM_STATS_EVENTS	\
699 	[QCA_NL80211_VENDOR_SUBCMD_ROAM_STATS_INDEX] = {	\
700 		.vendor_id = QCA_NL80211_VENDOR_ID,	\
701 		.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAM_STATS,	\
702 	},	\
703 
704 /**
705  * wlan_hdd_cfg80211_get_roam_stats() - get roam statstics information
706  * @wiphy: wiphy pointer
707  * @wdev: pointer to struct wireless_dev
708  * @data: pointer to incoming NL vendor data
709  * @data_len: length of @data
710  *
711  * Return: 0 on success; error number otherwise.
712  */
713 int wlan_hdd_cfg80211_get_roam_stats(struct wiphy *wiphy,
714 				     struct wireless_dev *wdev,
715 				     const void *data,
716 				     int data_len);
717 #else
718 #define FEATURE_ROAM_STATS_COMMANDS
719 #define FEATURE_ROAM_STATS_EVENTS
720 #endif
721 
722 #ifdef WLAN_FEATURE_TX_LATENCY_STATS
723 /**
724  * hdd_tx_latency_register_cb() - register callback function for transmit
725  * latency stats
726  * @soc: pointer to soc context
727  *
728  * Return: QDF_STATUS
729  */
730 QDF_STATUS hdd_tx_latency_register_cb(void *soc);
731 
732 /**
733  * hdd_tx_latency_restore_config() - restore tx latency stats config for a link
734  * @link_info: link specific information
735  *
736  * Return: QDF_STATUS
737  */
738 QDF_STATUS
739 hdd_tx_latency_restore_config(struct wlan_hdd_link_info *link_info);
740 
741 /**
742  * wlan_hdd_cfg80211_tx_latency - configure/retrieve per-link transmit latency
743  * statistics
744  * @wiphy: wiphy handle
745  * @wdev: wdev handle
746  * @data: user layer input
747  * @data_len: length of user layer input
748  *
749  * return: 0 success, einval failure
750  */
751 int wlan_hdd_cfg80211_tx_latency(struct wiphy *wiphy,
752 				 struct wireless_dev *wdev,
753 				 const void *data, int data_len);
754 
755 /**
756  * hdd_tx_latency_record_ingress_ts() - Record driver ingress timestamp in CB
757  * @adapter: pointer to hdd vdev/net_device context
758  * @skb: sk buff
759  *
760  * Return: None
761  */
762 static inline void
hdd_tx_latency_record_ingress_ts(struct hdd_adapter * adapter,struct sk_buff * skb)763 hdd_tx_latency_record_ingress_ts(struct hdd_adapter *adapter,
764 				 struct sk_buff *skb)
765 {
766 	if (adapter->tx_latency_cfg.enable)
767 		qdf_nbuf_set_tx_ts(skb);
768 }
769 
770 extern const struct nla_policy
771 	tx_latency_policy[QCA_WLAN_VENDOR_ATTR_TX_LATENCY_MAX + 1];
772 
773 #define FEATURE_TX_LATENCY_STATS_COMMANDS	\
774 	{	\
775 	.info.vendor_id = QCA_NL80211_VENDOR_ID,	\
776 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TX_LATENCY,	\
777 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |	\
778 		 WIPHY_VENDOR_CMD_NEED_NETDEV |	\
779 		 WIPHY_VENDOR_CMD_NEED_RUNNING,	\
780 	.doit = wlan_hdd_cfg80211_tx_latency,	\
781 	vendor_command_policy(tx_latency_policy,	\
782 			      QCA_WLAN_VENDOR_ATTR_TX_LATENCY_MAX)	\
783 	},	\
784 
785 #define FEATURE_TX_LATENCY_STATS_EVENTS	\
786 	[QCA_NL80211_VENDOR_SUBCMD_TX_LATENCY_INDEX] = {	\
787 		.vendor_id = QCA_NL80211_VENDOR_ID,	\
788 		.subcmd = QCA_NL80211_VENDOR_SUBCMD_TX_LATENCY,	\
789 	},	\
790 
791 #else
hdd_tx_latency_register_cb(void * soc)792 static inline QDF_STATUS hdd_tx_latency_register_cb(void *soc)
793 {
794 	return QDF_STATUS_SUCCESS;
795 }
796 
797 static inline QDF_STATUS
hdd_tx_latency_restore_config(struct wlan_hdd_link_info * link_info)798 hdd_tx_latency_restore_config(struct wlan_hdd_link_info *link_info)
799 {
800 	return QDF_STATUS_SUCCESS;
801 }
802 
803 static inline void
hdd_tx_latency_record_ingress_ts(struct hdd_adapter * adapter,struct sk_buff * skb)804 hdd_tx_latency_record_ingress_ts(struct hdd_adapter *adapter,
805 				 struct sk_buff *skb)
806 {
807 }
808 
809 #define FEATURE_TX_LATENCY_STATS_COMMANDS
810 #define FEATURE_TX_LATENCY_STATS_EVENTS
811 #endif
812 
813 #ifdef WLAN_CHIPSET_STATS
814 /**
815  * hdd_cstats_send_data_to_userspace() - Send chipsset stats to userspace
816  *
817  * @buff: Buffer to be sent
818  * @len: length of the buffer
819  * @type: Chipset stats type
820  *
821  * Return: 0 on success -ve value on error
822  */
823 int hdd_cstats_send_data_to_userspace(char *buff, unsigned int len,
824 				      enum cstats_types type);
825 
826 /**
827  * hdd_register_cstats_ops() - Register chipset stats ops
828  *
829  * Return: void
830  */
831 void hdd_register_cstats_ops(void);
832 
833 /**
834  * hdd_cstats_log_ndi_delete_req_evt() - Chipset stats for ndi delete
835  *
836  * @vdev: pointer to vdev object
837  * @transaction_id: transaction ID
838  *
839  * Return : void
840  */
841 void hdd_cstats_log_ndi_delete_req_evt(struct wlan_objmgr_vdev *vdev,
842 				       uint16_t transaction_id);
843 
844 /**
845  * hdd_cstats_log_ndi_create_resp_evt() - Chipset stats for ndi create
846  * response
847  * @li: pointer link_info object
848  * @ndi_rsp: pointer to nan_datapath_inf_create_rsp object
849  *
850  * Return : void
851  */
852 void
853 hdd_cstats_log_ndi_create_resp_evt(struct wlan_hdd_link_info *li,
854 				   struct nan_datapath_inf_create_rsp *ndi_rsp);
855 
856 /**
857  * hdd_cstats_log_ndi_create_req_evt() - Chipset stats for ndi create
858  * request
859  *
860  * @vdev: pointer vdve object
861  * @transaction_id : Transaction ID
862  *
863  * Return : void
864  */
865 void hdd_cstats_log_ndi_create_req_evt(struct wlan_objmgr_vdev *vdev,
866 				       uint16_t transaction_id);
867 #else
hdd_register_cstats_ops(void)868 static inline void hdd_register_cstats_ops(void)
869 {
870 }
871 
872 static inline int
hdd_cstats_send_data_to_userspace(char * buff,unsigned int len,enum cstats_types type)873 hdd_cstats_send_data_to_userspace(char *buff, unsigned int len,
874 				  enum cstats_types type)
875 {
876 	return 0;
877 }
878 
879 static inline void
hdd_cstats_log_ndi_delete_req_evt(struct wlan_objmgr_vdev * vdev,uint16_t transaction_id)880 hdd_cstats_log_ndi_delete_req_evt(struct wlan_objmgr_vdev *vdev,
881 				  uint16_t transaction_id)
882 {
883 }
884 
885 static inline void
hdd_cstats_log_ndi_create_resp_evt(struct wlan_hdd_link_info * li,struct nan_datapath_inf_create_rsp * ndi_rsp)886 hdd_cstats_log_ndi_create_resp_evt(struct wlan_hdd_link_info *li,
887 				   struct nan_datapath_inf_create_rsp *ndi_rsp)
888 {
889 }
890 
891 static inline void
hdd_cstats_log_ndi_create_req_evt(struct wlan_objmgr_vdev * vdev,uint16_t transaction_id)892 hdd_cstats_log_ndi_create_req_evt(struct wlan_objmgr_vdev *vdev,
893 				  uint16_t transaction_id)
894 {
895 }
896 #endif /* WLAN_CHIPSET_STATS */
897 #endif /* end #if !defined(WLAN_HDD_STATS_H) */
898