blob: 88a9b587e05399d7b3f6e57f867973eadabc324f [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jeff Johnsonbdcf63d2018-12-30 14:16:49 -08002 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/**
20 * DOC : wlan_hdd_stats.h
21 *
22 * WLAN Host Device Driver statistics related implementation
23 *
24 */
25
26#if !defined(WLAN_HDD_STATS_H)
27#define WLAN_HDD_STATS_H
28
29#include "wlan_hdd_main.h"
30
31#define INVALID_MCS_IDX 255
32#define MAX_HT_MCS_IDX 8
33#define MAX_VHT_MCS_IDX 10
34
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080035#define DATA_RATE_11AC_MCS_MASK 0x03
36
37/* LL stats get request time out value */
Mukul Sharma71d0c572016-09-03 15:35:30 +053038#define WLAN_WAIT_TIME_LL_STATS 800
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080039
Himanshu Agarwal37e42412016-07-21 14:35:09 +053040#define WLAN_HDD_TGT_NOISE_FLOOR_DBM (-96)
41
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042/**
43 * struct index_vht_data_rate_type - vht data rate type
44 * @beacon_rate_index: Beacon rate index
45 * @supported_VHT80_rate: VHT80 rate
46 * @supported_VHT40_rate: VHT40 rate
47 * @supported_VHT20_rate: VHT20 rate
48 */
49struct index_vht_data_rate_type {
50 uint8_t beacon_rate_index;
51 uint16_t supported_VHT80_rate[2];
52 uint16_t supported_VHT40_rate[2];
53 uint16_t supported_VHT20_rate[2];
54};
55
56/**
Will Huang496b36c2017-07-11 16:38:50 +080057 * enum - data_rate_11ac_max_mcs
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080058 * @DATA_RATE_11AC_MAX_MCS_7: MCS7 rate
59 * @DATA_RATE_11AC_MAX_MCS_8: MCS8 rate
60 * @DATA_RATE_11AC_MAX_MCS_9: MCS9 rate
61 * @DATA_RATE_11AC_MAX_MCS_NA:i Not applicable
62 */
Will Huang496b36c2017-07-11 16:38:50 +080063enum data_rate_11ac_max_mcs {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064 DATA_RATE_11AC_MAX_MCS_7,
65 DATA_RATE_11AC_MAX_MCS_8,
66 DATA_RATE_11AC_MAX_MCS_9,
67 DATA_RATE_11AC_MAX_MCS_NA
68};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069
70/**
71 * struct index_data_rate_type - non vht data rate type
72 * @beacon_rate_index: Beacon rate index
73 * @supported_rate: Supported rate table
74 */
75struct index_data_rate_type {
76 uint8_t beacon_rate_index;
77 uint16_t supported_rate[4];
78};
79
80#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Krishna Kumaar Natarajanc7e2bb72017-03-10 10:38:46 -080081
82/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083 * wlan_hdd_cfg80211_ll_stats_set() - set link layer stats
84 * @wiphy: Pointer to wiphy
85 * @wdev: Pointer to wdev
86 * @data: Pointer to data
87 * @data_len: Data length
88 *
89 * Return: int
90 */
91int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
92 struct wireless_dev *wdev,
93 const void *data,
94 int data_len);
95
96/**
97 * wlan_hdd_cfg80211_ll_stats_get() - get link layer stats
98 * @wiphy: Pointer to wiphy
99 * @wdev: Pointer to wdev
100 * @data: Pointer to data
101 * @data_len: Data length
102 *
103 * Return: int
104 */
105int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
106 struct wireless_dev *wdev,
107 const void *data,
108 int data_len);
109
110
111/**
112 * wlan_hdd_cfg80211_ll_stats_clear() - clear link layer stats
113 * @wiphy: Pointer to wiphy
114 * @wdev: Pointer to wdev
115 * @data: Pointer to data
116 * @data_len: Data length
117 *
118 * Return: int
119 */
120int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
121 struct wireless_dev *wdev,
122 const void *data,
123 int data_len);
124
Qiwei Cai3719efe2018-06-11 21:09:29 +0800125void wlan_hdd_clear_link_layer_stats(struct hdd_adapter *adapter);
126
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -0800127static inline bool hdd_link_layer_stats_supported(void)
128{
129 return true;
130}
131
Zhang Qian4ead8f02017-03-27 14:21:47 +0800132/**
133 * __wlan_hdd_cfg80211_ll_stats_ext_set_param - config monitor parameters
134 * @wiphy: wiphy handle
135 * @wdev: wdev handle
136 * @data: user layer input
137 * @data_len: length of user layer input
138 *
139 * return: 0 success, einval failure
140 */
141int wlan_hdd_cfg80211_ll_stats_ext_set_param(struct wiphy *wiphy,
142 struct wireless_dev *wdev,
143 const void *data,
144 int data_len);
Krishna Kumaar Natarajanc7e2bb72017-03-10 10:38:46 -0800145/**
146 * hdd_get_interface_info() - get interface info
147 * @adapter: Pointer to device adapter
148 * @info: Pointer to interface info
149 *
150 * Return: bool
151 */
Jeff Johnsona11f94b2017-08-29 14:21:35 -0700152bool hdd_get_interface_info(struct hdd_adapter *adapter,
Jeff Johnsonc9770ee2019-03-08 15:56:52 -0800153 struct wifi_interface_info *info);
Krishna Kumaar Natarajanc7e2bb72017-03-10 10:38:46 -0800154
155/**
156 * wlan_hdd_ll_stats_get() - Get Link Layer statistics from FW
157 * @adapter: Pointer to device adapter
158 * @req_id: request id
159 * @req_mask: bitmask used by FW for the request
160 *
161 * Return: 0 on success and error code otherwise
162 */
Jeff Johnsona11f94b2017-08-29 14:21:35 -0700163int wlan_hdd_ll_stats_get(struct hdd_adapter *adapter, uint32_t req_id,
Krishna Kumaar Natarajanc7e2bb72017-03-10 10:38:46 -0800164 uint32_t req_mask);
165
Jeff Johnson959f3692018-07-03 17:30:40 -0700166/**
167 * wlan_hdd_cfg80211_link_layer_stats_callback() - This function is called
168 * @hdd_handle: Handle to HDD context
169 * @indication_type: Indication type
170 * @results: Pointer to results
Dundi Ravitejae232cf12018-05-16 18:34:34 +0530171 * @cookie: Callback context
Jeff Johnson959f3692018-07-03 17:30:40 -0700172 *
173 * After receiving Link Layer indications from FW.This callback converts the
174 * firmware data to the NL data and send the same to the kernel/upper layers.
175 *
176 * Return: None
177 */
178void wlan_hdd_cfg80211_link_layer_stats_callback(hdd_handle_t hdd_handle,
179 int indication_type,
Dundi Ravitejae232cf12018-05-16 18:34:34 +0530180 tSirLLStatsResults *results,
181 void *cookie);
Jeff Johnson959f3692018-07-03 17:30:40 -0700182
Qiwei Cai3719efe2018-06-11 21:09:29 +0800183/**
184 * wlan_hdd_cfg80211_link_layer_stats_ext_callback() - Callback for LL ext
185 * @ctx: HDD context
186 * @rsp: msg from FW
187 *
188 * This function is an extension of
189 * wlan_hdd_cfg80211_link_layer_stats_callback. It converts
190 * monitoring parameters offloaded to NL data and send the same to the
191 * kernel/upper layers.
192 *
193 * Return: None.
194 */
195void wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx,
196 tSirLLStatsResults *rsp);
197
198/**
199 * hdd_lost_link_info_cb() - callback function to get lost link information
Jeff Johnsondc198ec2018-07-04 17:39:53 -0700200 * @hdd_handle: Opaque handle for the HDD context
Qiwei Cai3719efe2018-06-11 21:09:29 +0800201 * @lost_link_info: lost link information
202 *
203 * Return: none
204 */
Jeff Johnsondc198ec2018-07-04 17:39:53 -0700205void hdd_lost_link_info_cb(hdd_handle_t hdd_handle,
Qiwei Cai3719efe2018-06-11 21:09:29 +0800206 struct sir_lost_link_info *lost_link_info);
207
208#else /* WLAN_FEATURE_LINK_LAYER_STATS */
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -0800209
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -0800210static inline bool hdd_link_layer_stats_supported(void)
211{
212 return false;
213}
214
Zhang Qian4ead8f02017-03-27 14:21:47 +0800215static inline int
216wlan_hdd_cfg80211_ll_stats_ext_set_param(struct wiphy *wiphy,
217 struct wireless_dev *wdev,
218 const void *data,
219 int data_len)
220{
221 return -EINVAL;
222}
223
Qiwei Cai3719efe2018-06-11 21:09:29 +0800224static inline int
225wlan_hdd_ll_stats_get(struct hdd_adapter *adapter, uint32_t req_id,
226 uint32_t req_mask)
Nirav Shaheb017be2018-02-15 11:20:58 +0530227{
228 return -EINVAL;
229}
230
Qiwei Cai3719efe2018-06-11 21:09:29 +0800231static inline void
232wlan_hdd_clear_link_layer_stats(struct hdd_adapter *adapter)
233{
234}
235
236static inline void
Jeff Johnson959f3692018-07-03 17:30:40 -0700237wlan_hdd_cfg80211_link_layer_stats_callback(hdd_handle_t hdd_handle,
238 int indication_type,
Dundi Ravitejae232cf12018-05-16 18:34:34 +0530239 tSirLLStatsResults *results,
240 void *cookie)
Qiwei Cai3719efe2018-06-11 21:09:29 +0800241{
242}
243
244static inline void
245wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx,
246 tSirLLStatsResults *rsp)
247{
248}
249
250static inline void
Jeff Johnsondc198ec2018-07-04 17:39:53 -0700251hdd_lost_link_info_cb(hdd_handle_t hdd_handle,
Qiwei Cai3719efe2018-06-11 21:09:29 +0800252 struct sir_lost_link_info *lost_link_info)
253{
254}
255
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256#endif /* End of WLAN_FEATURE_LINK_LAYER_STATS */
257
258#ifdef WLAN_FEATURE_STATS_EXT
259/**
260 * wlan_hdd_cfg80211_stats_ext_request() - ext stats request
261 * @wiphy: Pointer to wiphy
262 * @wdev: Pointer to wdev
263 * @data: Pointer to data
264 * @data_len: Data length
265 *
266 * Return: int
267 */
268int wlan_hdd_cfg80211_stats_ext_request(struct wiphy *wiphy,
269 struct wireless_dev *wdev,
270 const void *data,
271 int data_len);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -0800272
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800273#endif /* End of WLAN_FEATURE_STATS_EXT */
274
275/**
276 * wlan_hdd_cfg80211_get_station() - get station statistics
277 * @wiphy: Pointer to wiphy
278 * @dev: Pointer to network device
279 * @mac: Pointer to mac
280 * @sinfo: Pointer to station info
281 *
282 * Return: 0 for success, non-zero for failure
283 */
284#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
285int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy,
286 struct net_device *dev, const uint8_t *mac,
287 struct station_info *sinfo);
288#else
289int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy,
290 struct net_device *dev, uint8_t *mac,
291 struct station_info *sinfo);
292#endif
293
Himanshu Agarwal37e42412016-07-21 14:35:09 +0530294/**
295 * wlan_hdd_cfg80211_dump_station() - dump station statistics
296 * @wiphy: Pointer to wiphy
297 * @dev: Pointer to network device
298 * @idx: variable to determine whether to get stats or not
299 * @mac: Pointer to mac
300 * @sinfo: Pointer to station info
301 *
302 * Return: 0 for success, non-zero for failure
303 */
304int wlan_hdd_cfg80211_dump_station(struct wiphy *wiphy,
305 struct net_device *dev,
306 int idx, u8 *mac,
307 struct station_info *sinfo);
308
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309struct net_device_stats *hdd_get_stats(struct net_device *dev);
310
311int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
312 struct net_device *dev,
313 int idx, struct survey_info *survey);
Nirav Shahbf1b0332016-05-25 14:27:39 +0530314
315void hdd_display_hif_stats(void);
316void hdd_clear_hif_stats(void);
317
Jeff Johnson45843652018-07-04 12:47:34 -0700318/**
319 * wlan_hdd_cfg80211_stats_ext_callback() - ext stats callback
320 * @hdd_handle: Opaque handle to HDD context
321 * @data: ext stats payload
322 *
323 * Return: nothing
324 */
325void wlan_hdd_cfg80211_stats_ext_callback(hdd_handle_t hdd_handle,
326 struct stats_ext_event *data);
Arun Khandavalli4b55da72016-07-19 19:55:01 +0530327
lifeng66831662017-05-19 16:01:35 +0800328/**
Jeff Johnson45843652018-07-04 12:47:34 -0700329 * wlan_hdd_cfg80211_stats_ext2_callback() - stats_ext2_callback
330 * @hdd_handle: opaque handle to the hdd context
lifeng66831662017-05-19 16:01:35 +0800331 * @pmsg: sir_sme_rx_aggr_hole_ind
332 *
333 * Return: void
334 */
Jeff Johnson45843652018-07-04 12:47:34 -0700335void
336wlan_hdd_cfg80211_stats_ext2_callback(hdd_handle_t hdd_handle,
337 struct sir_sme_rx_aggr_hole_ind *pmsg);
lifeng66831662017-05-19 16:01:35 +0800338
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +0530339/**
340 * wlan_hdd_get_rcpi() - Wrapper to get current RCPI
341 * @adapter: adapter upon which the measurement is requested
342 * @mac: peer addr for which measurement is requested
343 * @rcpi_value: pointer to where the RCPI should be returned
344 * @measurement_type: type of rcpi measurement
345 *
346 * This is a wrapper function for getting RCPI, invoke this function only
347 * when rcpi support is enabled in firmware
348 *
349 * Return: 0 for success, non-zero for failure
350 */
351int wlan_hdd_get_rcpi(struct hdd_adapter *adapter, uint8_t *mac,
352 int32_t *rcpi_value,
353 enum rcpi_measurement_type measurement_type);
354
tinlin9abd17f2019-08-14 13:29:44 +0800355#ifdef WLAN_FEATURE_MIB_STATS
356/**
357 * wlan_hdd_get_mib_stats() - Get the mib statistics
358 * @adapter: adapter upon which the measurement is requested
359 *
360 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
361 */
362QDF_STATUS wlan_hdd_get_mib_stats(struct hdd_adapter *adapter);
363#endif
364
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700365/**
366 * wlan_hdd_get_rssi() - Get the current RSSI
367 * @adapter: adapter upon which the measurement is requested
368 * @rssi_value: pointer to where the RSSI should be returned
369 *
370 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
371 */
372QDF_STATUS wlan_hdd_get_rssi(struct hdd_adapter *adapter, int8_t *rssi_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700374/**
375 * wlan_hdd_get_snr() - Get the current SNR
376 * @adapter: adapter upon which the measurement is requested
377 * @snr: pointer to where the SNR should be returned
378 *
379 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
380 */
381QDF_STATUS wlan_hdd_get_snr(struct hdd_adapter *adapter, int8_t *snr);
382
383/**
384 * wlan_hdd_get_linkspeed_for_peermac() - Get link speed for a peer
385 * @adapter: adapter upon which the peer is active
386 * @mac_address: MAC address of the peer
387 * @linkspeed: pointer to memory where returned link speed is to be placed
388 *
389 * This function will send a query to SME for the linkspeed of the
390 * given peer, and then wait for the callback to be invoked.
391 *
392 * Return: 0 if linkspeed data is available, negative errno otherwise
393 */
394int wlan_hdd_get_linkspeed_for_peermac(struct hdd_adapter *adapter,
395 struct qdf_mac_addr *mac_address,
396 uint32_t *linkspeed);
397
398/**
399 * wlan_hdd_get_link_speed() - get link speed
400 * @adapter: pointer to the adapter
401 * @link_speed: pointer to link speed
402 *
403 * This function fetches per bssid link speed.
404 *
405 * Return: if associated, link speed shall be returned.
406 * if not associated, link speed of 0 is returned.
407 * On error, error number will be returned.
408 */
409int wlan_hdd_get_link_speed(struct hdd_adapter *adapter, uint32_t *link_speed);
410
411/**
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700412 * wlan_hdd_get_peer_info() - get peer info
413 * @adapter: hostapd interface
414 * @macaddress: request peer mac address
415 * @peer_info_ext: one peer extended info retrieved
416 *
417 * This function will call sme_get_peer_info_ext to get peer info
418 *
419 * Return: 0 on success, otherwise error value
420 */
421int wlan_hdd_get_peer_info(struct hdd_adapter *adapter,
422 struct qdf_mac_addr macaddress,
423 struct sir_peer_info_ext *peer_info_ext);
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700424/**
425 * wlan_hdd_get_station_stats() - Get station statistics
426 * @adapter: adapter for which statistics are desired
427 *
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700428 * Return: status of operation
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700429 */
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700430int wlan_hdd_get_station_stats(struct hdd_adapter *adapter);
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700431
432/**
433 * wlan_hdd_get_temperature() - get current device temperature
434 * @adapter: device upon which the request was made
435 * @temperature: pointer to where the temperature is to be returned
436 *
437 * Return: 0 if a temperature value (either current or cached) was
438 * returned, otherwise a negative errno is returned.
439 *
440 */
441int wlan_hdd_get_temperature(struct hdd_adapter *adapter, int *temperature);
442
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700443/**
Mohit Khanna70322002018-05-15 19:21:32 -0700444 * wlan_hdd_display_txrx_stats() - display HDD txrx stats summary
445 * @hdd_ctx: hdd context
446 *
447 * Display TXRX Stats for all adapters
448 *
449 * Return: none
450 */
451void wlan_hdd_display_txrx_stats(struct hdd_context *hdd_ctx);
Ashish Kumar Dhanotiya4c6f6b62019-04-16 12:59:57 +0530452
453/**
454 * hdd_report_max_rate() - Fill the max rate stats in the station info structure
455 * to be sent to the userspace.
456 *
457 * @mac_handle: The mac handle
Rajeev Kumar Sirasanagandlae709bca2019-04-30 23:36:24 +0530458 * @rate: The station_info tx/rx rate to be filled
459 * @signal: signal from station_info
460 * @rate_flags: TX/RX rate flags computed from tx/rx rate
461 * @mcs_index; The TX/RX mcs index computed from tx/rx rate
462 * @fw_rate: The tx/rx rate from fw stats
463 * @nss: The TX/RX NSS from fw stats
Ashish Kumar Dhanotiya4c6f6b62019-04-16 12:59:57 +0530464 *
Rajeev Kumar Sirasanagandlae709bca2019-04-30 23:36:24 +0530465 * Return: True if fill is successful
Ashish Kumar Dhanotiya4c6f6b62019-04-16 12:59:57 +0530466 */
Rajeev Kumar Sirasanagandlae709bca2019-04-30 23:36:24 +0530467bool hdd_report_max_rate(mac_handle_t mac_handle,
468 struct rate_info *rate,
469 int8_t signal,
Jingxiang Gef1d81592019-10-20 12:03:22 +0800470 enum tx_rate_info rate_flags,
Rajeev Kumar Sirasanagandlae709bca2019-04-30 23:36:24 +0530471 uint8_t mcs_index,
472 uint16_t fw_rate, uint8_t nss);
Ashish Kumar Dhanotiya4c6f6b62019-04-16 12:59:57 +0530473
Hangtian Zhucf89c862019-08-28 10:48:52 +0800474#ifdef QCA_SUPPORT_CP_STATS
Ashish Kumar Dhanotiya017e5022019-07-23 20:58:11 +0530475/**
476 * wlan_hdd_register_cp_stats_cb() - Register hdd stats specific
477 * callbacks to the cp stats component
478 * @hdd_ctx: hdd context
479 *
480 * Return: none
481 */
482
483void wlan_hdd_register_cp_stats_cb(struct hdd_context *hdd_ctx);
Hangtian Zhucf89c862019-08-28 10:48:52 +0800484#else
485static inline void wlan_hdd_register_cp_stats_cb(struct hdd_context *hdd_ctx) {}
486#endif
Ashish Kumar Dhanotiya017e5022019-07-23 20:58:11 +0530487
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700488#endif /* end #if !defined(WLAN_HDD_STATS_H) */