blob: bad56e54097fa1332f61e847446fc01b518cf733 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Srinivas Girigowdafa48ab82017-03-24 23:32:55 -07002 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/**
23 * DOC : wlan_hdd_stats.h
24 *
25 * WLAN Host Device Driver statistics related implementation
26 *
27 */
28
29#if !defined(WLAN_HDD_STATS_H)
30#define WLAN_HDD_STATS_H
31
32#include "wlan_hdd_main.h"
33
34#define INVALID_MCS_IDX 255
35#define MAX_HT_MCS_IDX 8
36#define MAX_VHT_MCS_IDX 10
37
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080038#define DATA_RATE_11AC_MCS_MASK 0x03
39
40/* LL stats get request time out value */
Mukul Sharma71d0c572016-09-03 15:35:30 +053041#define WLAN_WAIT_TIME_LL_STATS 800
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042
Himanshu Agarwal37e42412016-07-21 14:35:09 +053043#define WLAN_HDD_TGT_NOISE_FLOOR_DBM (-96)
44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045/**
46 * struct index_vht_data_rate_type - vht data rate type
47 * @beacon_rate_index: Beacon rate index
48 * @supported_VHT80_rate: VHT80 rate
49 * @supported_VHT40_rate: VHT40 rate
50 * @supported_VHT20_rate: VHT20 rate
51 */
52struct index_vht_data_rate_type {
53 uint8_t beacon_rate_index;
54 uint16_t supported_VHT80_rate[2];
55 uint16_t supported_VHT40_rate[2];
56 uint16_t supported_VHT20_rate[2];
57};
58
59/**
60 * enum - eDataRate11ACMaxMcs
61 * @DATA_RATE_11AC_MAX_MCS_7: MCS7 rate
62 * @DATA_RATE_11AC_MAX_MCS_8: MCS8 rate
63 * @DATA_RATE_11AC_MAX_MCS_9: MCS9 rate
64 * @DATA_RATE_11AC_MAX_MCS_NA:i Not applicable
65 */
Srinivas Girigowdafa48ab82017-03-24 23:32:55 -070066enum eDataRate11ACMaxMcs {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067 DATA_RATE_11AC_MAX_MCS_7,
68 DATA_RATE_11AC_MAX_MCS_8,
69 DATA_RATE_11AC_MAX_MCS_9,
70 DATA_RATE_11AC_MAX_MCS_NA
71};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072
73/**
74 * struct index_data_rate_type - non vht data rate type
75 * @beacon_rate_index: Beacon rate index
76 * @supported_rate: Supported rate table
77 */
78struct index_data_rate_type {
79 uint8_t beacon_rate_index;
80 uint16_t supported_rate[4];
81};
82
83#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Krishna Kumaar Natarajanc7e2bb72017-03-10 10:38:46 -080084
85/**
86 * struct hdd_ll_stats_context - hdd link layer stats context
87 *
88 * @request_id: userspace-assigned link layer stats request id
89 * @request_bitmap: userspace-assigned link layer stats request bitmap
90 * @response_event: LL stats request wait event
91 */
92struct hdd_ll_stats_context {
93 uint32_t request_id;
94 uint32_t request_bitmap;
95 struct completion response_event;
96 spinlock_t context_lock;
97};
98
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099/*
100 * Used to allocate the size of 4096 for the link layer stats.
101 * The size of 4096 is considered assuming that all data per
102 * respective event fit with in the limit.Please take a call
103 * on the limit based on the data requirements on link layer
104 * statistics.
105 */
106#define LL_STATS_EVENT_BUF_SIZE 4096
107
108/**
109 * wlan_hdd_cfg80211_ll_stats_set() - set link layer stats
110 * @wiphy: Pointer to wiphy
111 * @wdev: Pointer to wdev
112 * @data: Pointer to data
113 * @data_len: Data length
114 *
115 * Return: int
116 */
117int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
118 struct wireless_dev *wdev,
119 const void *data,
120 int data_len);
121
122/**
123 * wlan_hdd_cfg80211_ll_stats_get() - get link layer stats
124 * @wiphy: Pointer to wiphy
125 * @wdev: Pointer to wdev
126 * @data: Pointer to data
127 * @data_len: Data length
128 *
129 * Return: int
130 */
131int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
132 struct wireless_dev *wdev,
133 const void *data,
134 int data_len);
135
136
137/**
138 * wlan_hdd_cfg80211_ll_stats_clear() - clear link layer stats
139 * @wiphy: Pointer to wiphy
140 * @wdev: Pointer to wdev
141 * @data: Pointer to data
142 * @data_len: Data length
143 *
144 * Return: int
145 */
146int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
147 struct wireless_dev *wdev,
148 const void *data,
149 int data_len);
150
151void hdd_init_ll_stats_ctx(void);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -0800152
153static inline bool hdd_link_layer_stats_supported(void)
154{
155 return true;
156}
157
Zhang Qian4ead8f02017-03-27 14:21:47 +0800158/**
159 * __wlan_hdd_cfg80211_ll_stats_ext_set_param - config monitor parameters
160 * @wiphy: wiphy handle
161 * @wdev: wdev handle
162 * @data: user layer input
163 * @data_len: length of user layer input
164 *
165 * return: 0 success, einval failure
166 */
167int wlan_hdd_cfg80211_ll_stats_ext_set_param(struct wiphy *wiphy,
168 struct wireless_dev *wdev,
169 const void *data,
170 int data_len);
Krishna Kumaar Natarajanc7e2bb72017-03-10 10:38:46 -0800171/**
172 * hdd_get_interface_info() - get interface info
173 * @adapter: Pointer to device adapter
174 * @info: Pointer to interface info
175 *
176 * Return: bool
177 */
178bool hdd_get_interface_info(hdd_adapter_t *adapter,
179 tpSirWifiInterfaceInfo info);
180
181/**
182 * wlan_hdd_ll_stats_get() - Get Link Layer statistics from FW
183 * @adapter: Pointer to device adapter
184 * @req_id: request id
185 * @req_mask: bitmask used by FW for the request
186 *
187 * Return: 0 on success and error code otherwise
188 */
189int wlan_hdd_ll_stats_get(hdd_adapter_t *adapter, uint32_t req_id,
190 uint32_t req_mask);
191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800192#else
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -0800193
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194static inline void hdd_init_ll_stats_ctx(void)
195{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800196}
197
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -0800198static inline bool hdd_link_layer_stats_supported(void)
199{
200 return false;
201}
202
Zhang Qian4ead8f02017-03-27 14:21:47 +0800203static inline int
204wlan_hdd_cfg80211_ll_stats_ext_set_param(struct wiphy *wiphy,
205 struct wireless_dev *wdev,
206 const void *data,
207 int data_len)
208{
209 return -EINVAL;
210}
211
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212#endif /* End of WLAN_FEATURE_LINK_LAYER_STATS */
213
214#ifdef WLAN_FEATURE_STATS_EXT
215/**
216 * wlan_hdd_cfg80211_stats_ext_request() - ext stats request
217 * @wiphy: Pointer to wiphy
218 * @wdev: Pointer to wdev
219 * @data: Pointer to data
220 * @data_len: Data length
221 *
222 * Return: int
223 */
224int wlan_hdd_cfg80211_stats_ext_request(struct wiphy *wiphy,
225 struct wireless_dev *wdev,
226 const void *data,
227 int data_len);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -0800228
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -0800229#else
230static inline void wlan_hdd_cfg80211_stats_ext_init(hdd_context_t *pHddCtx) {}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231#endif /* End of WLAN_FEATURE_STATS_EXT */
232
233/**
234 * wlan_hdd_cfg80211_get_station() - get station statistics
235 * @wiphy: Pointer to wiphy
236 * @dev: Pointer to network device
237 * @mac: Pointer to mac
238 * @sinfo: Pointer to station info
239 *
240 * Return: 0 for success, non-zero for failure
241 */
242#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
243int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy,
244 struct net_device *dev, const uint8_t *mac,
245 struct station_info *sinfo);
246#else
247int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy,
248 struct net_device *dev, uint8_t *mac,
249 struct station_info *sinfo);
250#endif
251
Himanshu Agarwal37e42412016-07-21 14:35:09 +0530252/**
253 * wlan_hdd_cfg80211_dump_station() - dump station statistics
254 * @wiphy: Pointer to wiphy
255 * @dev: Pointer to network device
256 * @idx: variable to determine whether to get stats or not
257 * @mac: Pointer to mac
258 * @sinfo: Pointer to station info
259 *
260 * Return: 0 for success, non-zero for failure
261 */
262int wlan_hdd_cfg80211_dump_station(struct wiphy *wiphy,
263 struct net_device *dev,
264 int idx, u8 *mac,
265 struct station_info *sinfo);
266
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267struct net_device_stats *hdd_get_stats(struct net_device *dev);
268
269int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
270 struct net_device *dev,
271 int idx, struct survey_info *survey);
Nirav Shahbf1b0332016-05-25 14:27:39 +0530272
273void hdd_display_hif_stats(void);
274void hdd_clear_hif_stats(void);
275
Arun Khandavalli4b55da72016-07-19 19:55:01 +0530276void wlan_hdd_cfg80211_stats_ext_callback(void *ctx,
277 tStatsExtEvent *msg);
278
279void wlan_hdd_cfg80211_link_layer_stats_callback(void *ctx,
280 int indType, void *pRsp);
Zhang Qianca38fb12016-12-23 11:10:48 +0800281/**
282 * wlan_hdd_cfg80211_link_layer_stats_ext_callback() - Callback for LL ext
283 * @ctx: HDD context
284 * @rsp: msg from FW
285 *
286 * This function is an extension of
287 * wlan_hdd_cfg80211_link_layer_stats_callback. It converts
288 * monitoring parameters offloaded to NL data and send the same to the
289 * kernel/upper layers.
290 *
291 * Return: None.
292 */
293void wlan_hdd_cfg80211_link_layer_stats_ext_callback(tHddHandle ctx,
294 tSirLLStatsResults *rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295#endif /* end #if !defined(WLAN_HDD_STATS_H) */
296