Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Srinivas Girigowda | fa48ab8 | 2017-03-24 23:32:55 -0700 | [diff] [blame] | 2 | * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 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 Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 38 | #define DATA_RATE_11AC_MCS_MASK 0x03 |
| 39 | |
| 40 | /* LL stats get request time out value */ |
Mukul Sharma | 71d0c57 | 2016-09-03 15:35:30 +0530 | [diff] [blame] | 41 | #define WLAN_WAIT_TIME_LL_STATS 800 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 42 | |
Himanshu Agarwal | 37e4241 | 2016-07-21 14:35:09 +0530 | [diff] [blame] | 43 | #define WLAN_HDD_TGT_NOISE_FLOOR_DBM (-96) |
| 44 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 45 | /** |
| 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 | */ |
| 52 | struct 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 Girigowda | fa48ab8 | 2017-03-24 23:32:55 -0700 | [diff] [blame] | 66 | enum eDataRate11ACMaxMcs { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 67 | 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 Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 72 | |
| 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 | */ |
| 78 | struct 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 Natarajan | c7e2bb7 | 2017-03-10 10:38:46 -0800 | [diff] [blame^] | 84 | |
| 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 | */ |
| 92 | struct 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 Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 99 | /* |
| 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 | */ |
| 117 | int 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 | */ |
| 131 | int 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 | */ |
| 146 | int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy, |
| 147 | struct wireless_dev *wdev, |
| 148 | const void *data, |
| 149 | int data_len); |
| 150 | |
| 151 | void hdd_init_ll_stats_ctx(void); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 152 | |
| 153 | static inline bool hdd_link_layer_stats_supported(void) |
| 154 | { |
| 155 | return true; |
| 156 | } |
| 157 | |
Zhang Qian | 4ead8f0 | 2017-03-27 14:21:47 +0800 | [diff] [blame] | 158 | /** |
| 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 | */ |
| 167 | int 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 Natarajan | c7e2bb7 | 2017-03-10 10:38:46 -0800 | [diff] [blame^] | 171 | /** |
| 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 | */ |
| 178 | bool 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 | */ |
| 189 | int wlan_hdd_ll_stats_get(hdd_adapter_t *adapter, uint32_t req_id, |
| 190 | uint32_t req_mask); |
| 191 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 192 | #else |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 193 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 194 | static inline void hdd_init_ll_stats_ctx(void) |
| 195 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 196 | } |
| 197 | |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 198 | static inline bool hdd_link_layer_stats_supported(void) |
| 199 | { |
| 200 | return false; |
| 201 | } |
| 202 | |
Zhang Qian | 4ead8f0 | 2017-03-27 14:21:47 +0800 | [diff] [blame] | 203 | static inline int |
| 204 | wlan_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 Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 212 | #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 | */ |
| 224 | int wlan_hdd_cfg80211_stats_ext_request(struct wiphy *wiphy, |
| 225 | struct wireless_dev *wdev, |
| 226 | const void *data, |
| 227 | int data_len); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 228 | |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 229 | #else |
| 230 | static inline void wlan_hdd_cfg80211_stats_ext_init(hdd_context_t *pHddCtx) {} |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 231 | #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)) |
| 243 | int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, |
| 244 | struct net_device *dev, const uint8_t *mac, |
| 245 | struct station_info *sinfo); |
| 246 | #else |
| 247 | int 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 Agarwal | 37e4241 | 2016-07-21 14:35:09 +0530 | [diff] [blame] | 252 | /** |
| 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 | */ |
| 262 | int 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 Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 267 | struct net_device_stats *hdd_get_stats(struct net_device *dev); |
| 268 | |
| 269 | int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy, |
| 270 | struct net_device *dev, |
| 271 | int idx, struct survey_info *survey); |
Nirav Shah | bf1b033 | 2016-05-25 14:27:39 +0530 | [diff] [blame] | 272 | |
| 273 | void hdd_display_hif_stats(void); |
| 274 | void hdd_clear_hif_stats(void); |
| 275 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 276 | void wlan_hdd_cfg80211_stats_ext_callback(void *ctx, |
| 277 | tStatsExtEvent *msg); |
| 278 | |
| 279 | void wlan_hdd_cfg80211_link_layer_stats_callback(void *ctx, |
| 280 | int indType, void *pRsp); |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 281 | /** |
| 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 | */ |
| 293 | void wlan_hdd_cfg80211_link_layer_stats_ext_callback(tHddHandle ctx, |
| 294 | tSirLLStatsResults *rsp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 295 | #endif /* end #if !defined(WLAN_HDD_STATS_H) */ |
| 296 | |