blob: 4fc80c9d6d02b528e43ce30fa3e5a8f5e88dd264 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Nirav Shaheb017be2018-02-15 11:20:58 +05302 * Copyright (c) 2012-2018 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,
Krishna Kumaar Natarajanc7e2bb72017-03-10 10:38:46 -0800153 tpSirWifiInterfaceInfo info);
154
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
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700355/**
356 * wlan_hdd_get_rssi() - Get the current RSSI
357 * @adapter: adapter upon which the measurement is requested
358 * @rssi_value: pointer to where the RSSI should be returned
359 *
360 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
361 */
362QDF_STATUS wlan_hdd_get_rssi(struct hdd_adapter *adapter, int8_t *rssi_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700364/**
365 * wlan_hdd_get_snr() - Get the current SNR
366 * @adapter: adapter upon which the measurement is requested
367 * @snr: pointer to where the SNR should be returned
368 *
369 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
370 */
371QDF_STATUS wlan_hdd_get_snr(struct hdd_adapter *adapter, int8_t *snr);
372
373/**
374 * wlan_hdd_get_linkspeed_for_peermac() - Get link speed for a peer
375 * @adapter: adapter upon which the peer is active
376 * @mac_address: MAC address of the peer
377 * @linkspeed: pointer to memory where returned link speed is to be placed
378 *
379 * This function will send a query to SME for the linkspeed of the
380 * given peer, and then wait for the callback to be invoked.
381 *
382 * Return: 0 if linkspeed data is available, negative errno otherwise
383 */
384int wlan_hdd_get_linkspeed_for_peermac(struct hdd_adapter *adapter,
385 struct qdf_mac_addr *mac_address,
386 uint32_t *linkspeed);
387
388/**
389 * wlan_hdd_get_link_speed() - get link speed
390 * @adapter: pointer to the adapter
391 * @link_speed: pointer to link speed
392 *
393 * This function fetches per bssid link speed.
394 *
395 * Return: if associated, link speed shall be returned.
396 * if not associated, link speed of 0 is returned.
397 * On error, error number will be returned.
398 */
399int wlan_hdd_get_link_speed(struct hdd_adapter *adapter, uint32_t *link_speed);
400
401/**
402 * wlan_hdd_get_peer_rssi() - get station's rssi
403 * @adapter: hostapd interface
404 * @macaddress: peer sta mac address or ff:ff:ff:ff:ff:ff to query all peer
405 * @peer_sta_info: output pointer which will fill by peer sta info
406 *
407 * This function will call sme_get_peer_info to get rssi
408 *
409 * Return: 0 on success, otherwise error value
410 */
411int wlan_hdd_get_peer_rssi(struct hdd_adapter *adapter,
412 struct qdf_mac_addr *macaddress,
413 struct sir_peer_sta_info *peer_sta_info);
414
415/**
416 * wlan_hdd_get_peer_info() - get peer info
417 * @adapter: hostapd interface
418 * @macaddress: request peer mac address
419 * @peer_info_ext: one peer extended info retrieved
420 *
421 * This function will call sme_get_peer_info_ext to get peer info
422 *
423 * Return: 0 on success, otherwise error value
424 */
425int wlan_hdd_get_peer_info(struct hdd_adapter *adapter,
426 struct qdf_mac_addr macaddress,
427 struct sir_peer_info_ext *peer_info_ext);
428
Naveen Rawate8b1b822018-01-30 09:46:16 -0800429#ifndef QCA_SUPPORT_CP_STATS
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700430/**
431 * wlan_hdd_get_class_astats() - Get Class A statistics
432 * @adapter: adapter for which statistics are desired
433 *
434 * Return: QDF_STATUS_SUCCESS if adapter's Class A statistics were updated
435 */
436QDF_STATUS wlan_hdd_get_class_astats(struct hdd_adapter *adapter);
Naveen Rawate8b1b822018-01-30 09:46:16 -0800437#endif
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700438
439/**
440 * wlan_hdd_get_station_stats() - Get station statistics
441 * @adapter: adapter for which statistics are desired
442 *
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700443 * Return: status of operation
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700444 */
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700445int wlan_hdd_get_station_stats(struct hdd_adapter *adapter);
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700446
447/**
448 * wlan_hdd_get_temperature() - get current device temperature
449 * @adapter: device upon which the request was made
450 * @temperature: pointer to where the temperature is to be returned
451 *
452 * Return: 0 if a temperature value (either current or cached) was
453 * returned, otherwise a negative errno is returned.
454 *
455 */
456int wlan_hdd_get_temperature(struct hdd_adapter *adapter, int *temperature);
457
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700458/**
459 * wlan_hdd_request_station_stats() - Get station statistics
460 * @adapter: adapter for which statistics are desired
461 *
462 * Return: QDF_STATUS_SUCCESS if adapter's statistics were updated
463 */
464int wlan_hdd_request_station_stats(struct hdd_adapter *adapter);
Mohit Khanna70322002018-05-15 19:21:32 -0700465
466/**
467 * wlan_hdd_display_txrx_stats() - display HDD txrx stats summary
468 * @hdd_ctx: hdd context
469 *
470 * Display TXRX Stats for all adapters
471 *
472 * Return: none
473 */
474void wlan_hdd_display_txrx_stats(struct hdd_context *hdd_ctx);
Jeff Johnson5fe539b2018-03-23 13:53:30 -0700475#endif /* end #if !defined(WLAN_HDD_STATS_H) */