Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2005-2011 Atheros Communications Inc. |
| 3 | * Copyright (c) 2011-2013 Qualcomm Atheros, Inc. |
| 4 | * |
| 5 | * Permission to use, copy, modify, and/or distribute this software for any |
| 6 | * purpose with or without fee is hereby granted, provided that the above |
| 7 | * copyright notice and this permission notice appear in all copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | */ |
| 17 | |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/debugfs.h> |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 20 | #include <linux/vmalloc.h> |
Johannes Berg | 12c2715 | 2014-11-21 18:58:49 +0200 | [diff] [blame] | 21 | #include <linux/utsname.h> |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 22 | |
| 23 | #include "core.h" |
| 24 | #include "debug.h" |
Kalle Valo | 7869b4f | 2014-09-24 14:16:58 +0300 | [diff] [blame] | 25 | #include "hif.h" |
Michal Kazior | d7579d1 | 2014-12-03 10:10:54 +0200 | [diff] [blame] | 26 | #include "wmi-ops.h" |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 27 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 28 | /* ms */ |
| 29 | #define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000 |
| 30 | |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 31 | #define ATH10K_FW_CRASH_DUMP_VERSION 1 |
| 32 | |
| 33 | /** |
| 34 | * enum ath10k_fw_crash_dump_type - types of data in the dump file |
| 35 | * @ATH10K_FW_CRASH_DUMP_REGDUMP: Register crash dump in binary format |
| 36 | */ |
| 37 | enum ath10k_fw_crash_dump_type { |
| 38 | ATH10K_FW_CRASH_DUMP_REGISTERS = 0, |
| 39 | |
| 40 | ATH10K_FW_CRASH_DUMP_MAX, |
| 41 | }; |
| 42 | |
| 43 | struct ath10k_tlv_dump_data { |
| 44 | /* see ath10k_fw_crash_dump_type above */ |
| 45 | __le32 type; |
| 46 | |
| 47 | /* in bytes */ |
| 48 | __le32 tlv_len; |
| 49 | |
| 50 | /* pad to 32-bit boundaries as needed */ |
| 51 | u8 tlv_data[]; |
| 52 | } __packed; |
| 53 | |
| 54 | struct ath10k_dump_file_data { |
| 55 | /* dump file information */ |
| 56 | |
| 57 | /* "ATH10K-FW-DUMP" */ |
| 58 | char df_magic[16]; |
| 59 | |
| 60 | __le32 len; |
| 61 | |
| 62 | /* file dump version */ |
| 63 | __le32 version; |
| 64 | |
| 65 | /* some info we can get from ath10k struct that might help */ |
| 66 | |
| 67 | u8 uuid[16]; |
| 68 | |
| 69 | __le32 chip_id; |
| 70 | |
| 71 | /* 0 for now, in place for later hardware */ |
| 72 | __le32 bus_type; |
| 73 | |
| 74 | __le32 target_version; |
| 75 | __le32 fw_version_major; |
| 76 | __le32 fw_version_minor; |
| 77 | __le32 fw_version_release; |
| 78 | __le32 fw_version_build; |
| 79 | __le32 phy_capability; |
| 80 | __le32 hw_min_tx_power; |
| 81 | __le32 hw_max_tx_power; |
| 82 | __le32 ht_cap_info; |
| 83 | __le32 vht_cap_info; |
| 84 | __le32 num_rf_chains; |
| 85 | |
| 86 | /* firmware version string */ |
| 87 | char fw_ver[ETHTOOL_FWVERS_LEN]; |
| 88 | |
| 89 | /* Kernel related information */ |
| 90 | |
| 91 | /* time-of-day stamp */ |
| 92 | __le64 tv_sec; |
| 93 | |
| 94 | /* time-of-day stamp, nano-seconds */ |
| 95 | __le64 tv_nsec; |
| 96 | |
| 97 | /* LINUX_VERSION_CODE */ |
| 98 | __le32 kernel_ver_code; |
| 99 | |
| 100 | /* VERMAGIC_STRING */ |
| 101 | char kernel_ver[64]; |
| 102 | |
| 103 | /* room for growth w/out changing binary format */ |
| 104 | u8 unused[128]; |
| 105 | |
| 106 | /* struct ath10k_tlv_dump_data + more */ |
| 107 | u8 data[0]; |
| 108 | } __packed; |
| 109 | |
Joe Perches | babcb3e | 2014-09-22 10:35:34 -0700 | [diff] [blame] | 110 | void ath10k_info(struct ath10k *ar, const char *fmt, ...) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 111 | { |
| 112 | struct va_format vaf = { |
| 113 | .fmt = fmt, |
| 114 | }; |
| 115 | va_list args; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 116 | |
| 117 | va_start(args, fmt); |
| 118 | vaf.va = &args; |
Joe Perches | babcb3e | 2014-09-22 10:35:34 -0700 | [diff] [blame] | 119 | dev_info(ar->dev, "%pV", &vaf); |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 120 | trace_ath10k_log_info(ar, &vaf); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 121 | va_end(args); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 122 | } |
| 123 | EXPORT_SYMBOL(ath10k_info); |
| 124 | |
Kalle Valo | 8a0c797 | 2014-08-25 08:37:45 +0300 | [diff] [blame] | 125 | void ath10k_print_driver_info(struct ath10k *ar) |
| 126 | { |
Kalle Valo | ffdd075 | 2014-12-17 12:21:03 +0200 | [diff] [blame] | 127 | ath10k_info(ar, "%s (0x%08x, 0x%08x) fw %s api %d htt %d.%d wmi %d cal %s max_sta %d\n", |
Kalle Valo | 8a0c797 | 2014-08-25 08:37:45 +0300 | [diff] [blame] | 128 | ar->hw_params.name, |
| 129 | ar->target_version, |
| 130 | ar->chip_id, |
| 131 | ar->hw->wiphy->fw_version, |
| 132 | ar->fw_api, |
| 133 | ar->htt.target_version_major, |
Michal Kazior | 34b28b6 | 2014-09-23 10:22:52 +0200 | [diff] [blame] | 134 | ar->htt.target_version_minor, |
Kalle Valo | ffdd075 | 2014-12-17 12:21:03 +0200 | [diff] [blame] | 135 | ar->wmi.op_version, |
Michal Kazior | cfd1061 | 2014-11-25 15:16:05 +0100 | [diff] [blame] | 136 | ath10k_cal_mode_str(ar->cal_mode), |
| 137 | ar->max_num_stations); |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 138 | ath10k_info(ar, "debug %d debugfs %d tracing %d dfs %d testmode %d\n", |
Kalle Valo | 8a0c797 | 2014-08-25 08:37:45 +0300 | [diff] [blame] | 139 | config_enabled(CONFIG_ATH10K_DEBUG), |
| 140 | config_enabled(CONFIG_ATH10K_DEBUGFS), |
| 141 | config_enabled(CONFIG_ATH10K_TRACING), |
Kalle Valo | 43d2a30 | 2014-09-10 18:23:30 +0300 | [diff] [blame] | 142 | config_enabled(CONFIG_ATH10K_DFS_CERTIFIED), |
| 143 | config_enabled(CONFIG_NL80211_TESTMODE)); |
Kalle Valo | 8a0c797 | 2014-08-25 08:37:45 +0300 | [diff] [blame] | 144 | } |
| 145 | EXPORT_SYMBOL(ath10k_print_driver_info); |
| 146 | |
Joe Perches | babcb3e | 2014-09-22 10:35:34 -0700 | [diff] [blame] | 147 | void ath10k_err(struct ath10k *ar, const char *fmt, ...) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 148 | { |
| 149 | struct va_format vaf = { |
| 150 | .fmt = fmt, |
| 151 | }; |
| 152 | va_list args; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 153 | |
| 154 | va_start(args, fmt); |
| 155 | vaf.va = &args; |
Joe Perches | babcb3e | 2014-09-22 10:35:34 -0700 | [diff] [blame] | 156 | dev_err(ar->dev, "%pV", &vaf); |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 157 | trace_ath10k_log_err(ar, &vaf); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 158 | va_end(args); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 159 | } |
| 160 | EXPORT_SYMBOL(ath10k_err); |
| 161 | |
Joe Perches | babcb3e | 2014-09-22 10:35:34 -0700 | [diff] [blame] | 162 | void ath10k_warn(struct ath10k *ar, const char *fmt, ...) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 163 | { |
| 164 | struct va_format vaf = { |
| 165 | .fmt = fmt, |
| 166 | }; |
| 167 | va_list args; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 168 | |
| 169 | va_start(args, fmt); |
| 170 | vaf.va = &args; |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 171 | dev_warn_ratelimited(ar->dev, "%pV", &vaf); |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 172 | trace_ath10k_log_warn(ar, &vaf); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 173 | |
| 174 | va_end(args); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 175 | } |
| 176 | EXPORT_SYMBOL(ath10k_warn); |
| 177 | |
| 178 | #ifdef CONFIG_ATH10K_DEBUGFS |
| 179 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 180 | static ssize_t ath10k_read_wmi_services(struct file *file, |
| 181 | char __user *user_buf, |
| 182 | size_t count, loff_t *ppos) |
| 183 | { |
| 184 | struct ath10k *ar = file->private_data; |
| 185 | char *buf; |
Michal Kazior | cff990c | 2014-08-04 09:18:33 +0300 | [diff] [blame] | 186 | unsigned int len = 0, buf_len = 4096; |
| 187 | const char *name; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 188 | ssize_t ret_cnt; |
Michal Kazior | cff990c | 2014-08-04 09:18:33 +0300 | [diff] [blame] | 189 | bool enabled; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 190 | int i; |
| 191 | |
| 192 | buf = kzalloc(buf_len, GFP_KERNEL); |
| 193 | if (!buf) |
| 194 | return -ENOMEM; |
| 195 | |
| 196 | mutex_lock(&ar->conf_mutex); |
| 197 | |
| 198 | if (len > buf_len) |
| 199 | len = buf_len; |
| 200 | |
Michal Kazior | acfe7ec | 2014-11-27 10:11:17 +0100 | [diff] [blame] | 201 | spin_lock_bh(&ar->data_lock); |
Michal Kazior | c4f8c83 | 2014-09-04 10:18:32 +0200 | [diff] [blame] | 202 | for (i = 0; i < WMI_SERVICE_MAX; i++) { |
Michal Kazior | acfe7ec | 2014-11-27 10:11:17 +0100 | [diff] [blame] | 203 | enabled = test_bit(i, ar->wmi.svc_map); |
Michal Kazior | cff990c | 2014-08-04 09:18:33 +0300 | [diff] [blame] | 204 | name = wmi_service_name(i); |
| 205 | |
| 206 | if (!name) { |
| 207 | if (enabled) |
| 208 | len += scnprintf(buf + len, buf_len - len, |
| 209 | "%-40s %s (bit %d)\n", |
| 210 | "unknown", "enabled", i); |
| 211 | |
| 212 | continue; |
| 213 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 214 | |
| 215 | len += scnprintf(buf + len, buf_len - len, |
Michal Kazior | cff990c | 2014-08-04 09:18:33 +0300 | [diff] [blame] | 216 | "%-40s %s\n", |
| 217 | name, enabled ? "enabled" : "-"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 218 | } |
Michal Kazior | acfe7ec | 2014-11-27 10:11:17 +0100 | [diff] [blame] | 219 | spin_unlock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 220 | |
| 221 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 222 | |
| 223 | mutex_unlock(&ar->conf_mutex); |
| 224 | |
| 225 | kfree(buf); |
| 226 | return ret_cnt; |
| 227 | } |
| 228 | |
| 229 | static const struct file_operations fops_wmi_services = { |
| 230 | .read = ath10k_read_wmi_services, |
| 231 | .open = simple_open, |
| 232 | .owner = THIS_MODULE, |
| 233 | .llseek = default_llseek, |
| 234 | }; |
| 235 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 236 | static void ath10k_debug_fw_stats_pdevs_free(struct list_head *head) |
| 237 | { |
| 238 | struct ath10k_fw_stats_pdev *i, *tmp; |
| 239 | |
| 240 | list_for_each_entry_safe(i, tmp, head, list) { |
| 241 | list_del(&i->list); |
| 242 | kfree(i); |
| 243 | } |
| 244 | } |
| 245 | |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 246 | static void ath10k_debug_fw_stats_vdevs_free(struct list_head *head) |
| 247 | { |
| 248 | struct ath10k_fw_stats_vdev *i, *tmp; |
| 249 | |
| 250 | list_for_each_entry_safe(i, tmp, head, list) { |
| 251 | list_del(&i->list); |
| 252 | kfree(i); |
| 253 | } |
| 254 | } |
| 255 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 256 | static void ath10k_debug_fw_stats_peers_free(struct list_head *head) |
| 257 | { |
| 258 | struct ath10k_fw_stats_peer *i, *tmp; |
| 259 | |
| 260 | list_for_each_entry_safe(i, tmp, head, list) { |
| 261 | list_del(&i->list); |
| 262 | kfree(i); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | static void ath10k_debug_fw_stats_reset(struct ath10k *ar) |
| 267 | { |
| 268 | spin_lock_bh(&ar->data_lock); |
| 269 | ar->debug.fw_stats_done = false; |
| 270 | ath10k_debug_fw_stats_pdevs_free(&ar->debug.fw_stats.pdevs); |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 271 | ath10k_debug_fw_stats_vdevs_free(&ar->debug.fw_stats.vdevs); |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 272 | ath10k_debug_fw_stats_peers_free(&ar->debug.fw_stats.peers); |
| 273 | spin_unlock_bh(&ar->data_lock); |
| 274 | } |
| 275 | |
| 276 | static size_t ath10k_debug_fw_stats_num_peers(struct list_head *head) |
| 277 | { |
| 278 | struct ath10k_fw_stats_peer *i; |
| 279 | size_t num = 0; |
| 280 | |
| 281 | list_for_each_entry(i, head, list) |
| 282 | ++num; |
| 283 | |
| 284 | return num; |
| 285 | } |
| 286 | |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 287 | static size_t ath10k_debug_fw_stats_num_vdevs(struct list_head *head) |
| 288 | { |
| 289 | struct ath10k_fw_stats_vdev *i; |
| 290 | size_t num = 0; |
| 291 | |
| 292 | list_for_each_entry(i, head, list) |
| 293 | ++num; |
| 294 | |
| 295 | return num; |
| 296 | } |
| 297 | |
Michal Kazior | 60ef401 | 2014-09-25 12:33:48 +0200 | [diff] [blame] | 298 | void ath10k_debug_fw_stats_process(struct ath10k *ar, struct sk_buff *skb) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 299 | { |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 300 | struct ath10k_fw_stats stats = {}; |
| 301 | bool is_start, is_started, is_end; |
| 302 | size_t num_peers; |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 303 | size_t num_vdevs; |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 304 | int ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 305 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 306 | INIT_LIST_HEAD(&stats.pdevs); |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 307 | INIT_LIST_HEAD(&stats.vdevs); |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 308 | INIT_LIST_HEAD(&stats.peers); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 309 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 310 | spin_lock_bh(&ar->data_lock); |
| 311 | ret = ath10k_wmi_pull_fw_stats(ar, skb, &stats); |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 312 | if (ret) { |
| 313 | ath10k_warn(ar, "failed to pull fw stats: %d\n", ret); |
| 314 | goto unlock; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 315 | } |
| 316 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 317 | /* Stat data may exceed htc-wmi buffer limit. In such case firmware |
| 318 | * splits the stats data and delivers it in a ping-pong fashion of |
| 319 | * request cmd-update event. |
| 320 | * |
| 321 | * However there is no explicit end-of-data. Instead start-of-data is |
| 322 | * used as an implicit one. This works as follows: |
| 323 | * a) discard stat update events until one with pdev stats is |
| 324 | * delivered - this skips session started at end of (b) |
| 325 | * b) consume stat update events until another one with pdev stats is |
| 326 | * delivered which is treated as end-of-data and is itself discarded |
| 327 | */ |
| 328 | |
| 329 | if (ar->debug.fw_stats_done) { |
| 330 | ath10k_warn(ar, "received unsolicited stats update event\n"); |
| 331 | goto free; |
| 332 | } |
| 333 | |
| 334 | num_peers = ath10k_debug_fw_stats_num_peers(&ar->debug.fw_stats.peers); |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 335 | num_vdevs = ath10k_debug_fw_stats_num_vdevs(&ar->debug.fw_stats.vdevs); |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 336 | is_start = (list_empty(&ar->debug.fw_stats.pdevs) && |
| 337 | !list_empty(&stats.pdevs)); |
| 338 | is_end = (!list_empty(&ar->debug.fw_stats.pdevs) && |
| 339 | !list_empty(&stats.pdevs)); |
| 340 | |
| 341 | if (is_start) |
| 342 | list_splice_tail_init(&stats.pdevs, &ar->debug.fw_stats.pdevs); |
| 343 | |
| 344 | if (is_end) |
| 345 | ar->debug.fw_stats_done = true; |
| 346 | |
| 347 | is_started = !list_empty(&ar->debug.fw_stats.pdevs); |
| 348 | |
| 349 | if (is_started && !is_end) { |
| 350 | if (num_peers >= ATH10K_MAX_NUM_PEER_IDS) { |
| 351 | /* Although this is unlikely impose a sane limit to |
| 352 | * prevent firmware from DoS-ing the host. |
| 353 | */ |
| 354 | ath10k_warn(ar, "dropping fw peer stats\n"); |
| 355 | goto free; |
| 356 | } |
| 357 | |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 358 | if (num_vdevs >= BITS_PER_LONG) { |
| 359 | ath10k_warn(ar, "dropping fw vdev stats\n"); |
| 360 | goto free; |
| 361 | } |
| 362 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 363 | list_splice_tail_init(&stats.peers, &ar->debug.fw_stats.peers); |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 364 | list_splice_tail_init(&stats.vdevs, &ar->debug.fw_stats.vdevs); |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 365 | } |
| 366 | |
Michal Kazior | 60ef401 | 2014-09-25 12:33:48 +0200 | [diff] [blame] | 367 | complete(&ar->debug.fw_stats_complete); |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 368 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 369 | free: |
| 370 | /* In some cases lists have been spliced and cleared. Free up |
| 371 | * resources if that is not the case. |
| 372 | */ |
| 373 | ath10k_debug_fw_stats_pdevs_free(&stats.pdevs); |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 374 | ath10k_debug_fw_stats_vdevs_free(&stats.vdevs); |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 375 | ath10k_debug_fw_stats_peers_free(&stats.peers); |
| 376 | |
Michal Kazior | d15fb52 | 2014-09-25 12:33:47 +0200 | [diff] [blame] | 377 | unlock: |
| 378 | spin_unlock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 379 | } |
| 380 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 381 | static int ath10k_debug_fw_stats_request(struct ath10k *ar) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 382 | { |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 383 | unsigned long timeout; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 384 | int ret; |
| 385 | |
Michal Kazior | fb2e9c0 | 2014-09-25 12:33:49 +0200 | [diff] [blame] | 386 | lockdep_assert_held(&ar->conf_mutex); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 387 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 388 | timeout = jiffies + msecs_to_jiffies(1*HZ); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 389 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 390 | ath10k_debug_fw_stats_reset(ar); |
| 391 | |
| 392 | for (;;) { |
| 393 | if (time_after(jiffies, timeout)) |
| 394 | return -ETIMEDOUT; |
| 395 | |
| 396 | reinit_completion(&ar->debug.fw_stats_complete); |
| 397 | |
Michal Kazior | 7777d8c | 2015-02-15 16:50:41 +0200 | [diff] [blame] | 398 | ret = ath10k_wmi_request_stats(ar, |
| 399 | WMI_STAT_PDEV | |
| 400 | WMI_STAT_VDEV | |
| 401 | WMI_STAT_PEER); |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 402 | if (ret) { |
| 403 | ath10k_warn(ar, "could not request stats (%d)\n", ret); |
| 404 | return ret; |
| 405 | } |
| 406 | |
| 407 | ret = wait_for_completion_timeout(&ar->debug.fw_stats_complete, |
| 408 | 1*HZ); |
Nicholas Mc Guire | 38e2a64 | 2015-01-08 13:27:34 +0100 | [diff] [blame] | 409 | if (ret == 0) |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 410 | return -ETIMEDOUT; |
| 411 | |
| 412 | spin_lock_bh(&ar->data_lock); |
| 413 | if (ar->debug.fw_stats_done) { |
| 414 | spin_unlock_bh(&ar->data_lock); |
| 415 | break; |
| 416 | } |
| 417 | spin_unlock_bh(&ar->data_lock); |
| 418 | } |
Michal Kazior | fb2e9c0 | 2014-09-25 12:33:49 +0200 | [diff] [blame] | 419 | |
| 420 | return 0; |
| 421 | } |
| 422 | |
| 423 | /* FIXME: How to calculate the buffer size sanely? */ |
| 424 | #define ATH10K_FW_STATS_BUF_SIZE (1024*1024) |
| 425 | |
| 426 | static void ath10k_fw_stats_fill(struct ath10k *ar, |
| 427 | struct ath10k_fw_stats *fw_stats, |
| 428 | char *buf) |
| 429 | { |
| 430 | unsigned int len = 0; |
| 431 | unsigned int buf_len = ATH10K_FW_STATS_BUF_SIZE; |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 432 | const struct ath10k_fw_stats_pdev *pdev; |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 433 | const struct ath10k_fw_stats_vdev *vdev; |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 434 | const struct ath10k_fw_stats_peer *peer; |
| 435 | size_t num_peers; |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 436 | size_t num_vdevs; |
| 437 | int i; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 438 | |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 439 | spin_lock_bh(&ar->data_lock); |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 440 | |
| 441 | pdev = list_first_entry_or_null(&fw_stats->pdevs, |
| 442 | struct ath10k_fw_stats_pdev, list); |
| 443 | if (!pdev) { |
| 444 | ath10k_warn(ar, "failed to get pdev stats\n"); |
| 445 | goto unlock; |
| 446 | } |
| 447 | |
| 448 | num_peers = ath10k_debug_fw_stats_num_peers(&fw_stats->peers); |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 449 | num_vdevs = ath10k_debug_fw_stats_num_vdevs(&fw_stats->vdevs); |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 450 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 451 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 452 | len += scnprintf(buf + len, buf_len - len, "%30s\n", |
| 453 | "ath10k PDEV stats"); |
| 454 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 455 | "================="); |
| 456 | |
| 457 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 458 | "Channel noise floor", pdev->ch_noise_floor); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 459 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 460 | "Channel TX power", pdev->chan_tx_power); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 461 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 462 | "TX frame count", pdev->tx_frame_count); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 463 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 464 | "RX frame count", pdev->rx_frame_count); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 465 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 466 | "RX clear count", pdev->rx_clear_count); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 467 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 468 | "Cycle count", pdev->cycle_count); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 469 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 470 | "PHY error count", pdev->phy_err_count); |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 471 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 472 | "RTS bad count", pdev->rts_bad); |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 473 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 474 | "RTS good count", pdev->rts_good); |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 475 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 476 | "FCS bad count", pdev->fcs_bad); |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 477 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 478 | "No beacon count", pdev->no_beacons); |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 479 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 480 | "MIB int count", pdev->mib_int_count); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 481 | |
| 482 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 483 | len += scnprintf(buf + len, buf_len - len, "%30s\n", |
| 484 | "ath10k PDEV TX stats"); |
| 485 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 486 | "================="); |
| 487 | |
| 488 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 489 | "HTT cookies queued", pdev->comp_queued); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 490 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 491 | "HTT cookies disp.", pdev->comp_delivered); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 492 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 493 | "MSDU queued", pdev->msdu_enqued); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 494 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 495 | "MPDU queued", pdev->mpdu_enqued); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 496 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 497 | "MSDUs dropped", pdev->wmm_drop); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 498 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 499 | "Local enqued", pdev->local_enqued); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 500 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 501 | "Local freed", pdev->local_freed); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 502 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 503 | "HW queued", pdev->hw_queued); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 504 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 505 | "PPDUs reaped", pdev->hw_reaped); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 506 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 507 | "Num underruns", pdev->underrun); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 508 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 509 | "PPDUs cleaned", pdev->tx_abort); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 510 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 511 | "MPDUs requed", pdev->mpdus_requed); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 512 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 513 | "Excessive retries", pdev->tx_ko); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 514 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 515 | "HW rate", pdev->data_rc); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 516 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 517 | "Sched self tiggers", pdev->self_triggers); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 518 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 519 | "Dropped due to SW retries", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 520 | pdev->sw_retry_failure); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 521 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 522 | "Illegal rate phy errors", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 523 | pdev->illgl_rate_phy_err); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 524 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 525 | "Pdev continous xretry", pdev->pdev_cont_xretry); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 526 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 527 | "TX timeout", pdev->pdev_tx_timeout); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 528 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 529 | "PDEV resets", pdev->pdev_resets); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 530 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 531 | "PHY underrun", pdev->phy_underrun); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 532 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 533 | "MPDU is more than txop limit", pdev->txop_ovf); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 534 | |
| 535 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 536 | len += scnprintf(buf + len, buf_len - len, "%30s\n", |
| 537 | "ath10k PDEV RX stats"); |
| 538 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 539 | "================="); |
| 540 | |
| 541 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 542 | "Mid PPDU route change", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 543 | pdev->mid_ppdu_route_change); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 544 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 545 | "Tot. number of statuses", pdev->status_rcvd); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 546 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 547 | "Extra frags on rings 0", pdev->r0_frags); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 548 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 549 | "Extra frags on rings 1", pdev->r1_frags); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 550 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 551 | "Extra frags on rings 2", pdev->r2_frags); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 552 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 553 | "Extra frags on rings 3", pdev->r3_frags); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 554 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 555 | "MSDUs delivered to HTT", pdev->htt_msdus); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 556 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 557 | "MPDUs delivered to HTT", pdev->htt_mpdus); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 558 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 559 | "MSDUs delivered to stack", pdev->loc_msdus); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 560 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 561 | "MPDUs delivered to stack", pdev->loc_mpdus); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 562 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 563 | "Oversized AMSUs", pdev->oversize_amsdu); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 564 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 565 | "PHY errors", pdev->phy_errs); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 566 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 567 | "PHY errors drops", pdev->phy_err_drop); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 568 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 569 | "MPDU errors (FCS, MIC, ENC)", pdev->mpdu_errs); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 570 | |
| 571 | len += scnprintf(buf + len, buf_len - len, "\n"); |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 572 | len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n", |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 573 | "ath10k VDEV stats", num_vdevs); |
| 574 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 575 | "================="); |
| 576 | |
| 577 | list_for_each_entry(vdev, &fw_stats->vdevs, list) { |
| 578 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 579 | "vdev id", vdev->vdev_id); |
| 580 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 581 | "beacon snr", vdev->beacon_snr); |
| 582 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 583 | "data snr", vdev->data_snr); |
| 584 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 585 | "num rx frames", vdev->num_rx_frames); |
| 586 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 587 | "num rts fail", vdev->num_rts_fail); |
| 588 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 589 | "num rts success", vdev->num_rts_success); |
| 590 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 591 | "num rx err", vdev->num_rx_err); |
| 592 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 593 | "num rx discard", vdev->num_rx_discard); |
| 594 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 595 | "num tx not acked", vdev->num_tx_not_acked); |
| 596 | |
| 597 | for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames); i++) |
| 598 | len += scnprintf(buf + len, buf_len - len, |
| 599 | "%25s [%02d] %u\n", |
| 600 | "num tx frames", i, |
| 601 | vdev->num_tx_frames[i]); |
| 602 | |
| 603 | for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_retries); i++) |
| 604 | len += scnprintf(buf + len, buf_len - len, |
| 605 | "%25s [%02d] %u\n", |
| 606 | "num tx frames retries", i, |
| 607 | vdev->num_tx_frames_retries[i]); |
| 608 | |
| 609 | for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_failures); i++) |
| 610 | len += scnprintf(buf + len, buf_len - len, |
| 611 | "%25s [%02d] %u\n", |
| 612 | "num tx frames failures", i, |
| 613 | vdev->num_tx_frames_failures[i]); |
| 614 | |
| 615 | for (i = 0 ; i < ARRAY_SIZE(vdev->tx_rate_history); i++) |
| 616 | len += scnprintf(buf + len, buf_len - len, |
| 617 | "%25s [%02d] 0x%08x\n", |
| 618 | "tx rate history", i, |
| 619 | vdev->tx_rate_history[i]); |
| 620 | |
| 621 | for (i = 0 ; i < ARRAY_SIZE(vdev->beacon_rssi_history); i++) |
| 622 | len += scnprintf(buf + len, buf_len - len, |
| 623 | "%25s [%02d] %u\n", |
| 624 | "beacon rssi history", i, |
| 625 | vdev->beacon_rssi_history[i]); |
| 626 | |
| 627 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 628 | } |
| 629 | |
| 630 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 631 | len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 632 | "ath10k PEER stats", num_peers); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 633 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 634 | "================="); |
| 635 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 636 | list_for_each_entry(peer, &fw_stats->peers, list) { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 637 | len += scnprintf(buf + len, buf_len - len, "%30s %pM\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 638 | "Peer MAC address", peer->peer_macaddr); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 639 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 640 | "Peer RSSI", peer->peer_rssi); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 641 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 642 | "Peer TX rate", peer->peer_tx_rate); |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 643 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 644 | "Peer RX rate", peer->peer_rx_rate); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 645 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 646 | } |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 647 | |
| 648 | unlock: |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 649 | spin_unlock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 650 | |
Michal Kazior | fb2e9c0 | 2014-09-25 12:33:49 +0200 | [diff] [blame] | 651 | if (len >= buf_len) |
| 652 | buf[len - 1] = 0; |
| 653 | else |
| 654 | buf[len] = 0; |
| 655 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 656 | |
Michal Kazior | fb2e9c0 | 2014-09-25 12:33:49 +0200 | [diff] [blame] | 657 | static int ath10k_fw_stats_open(struct inode *inode, struct file *file) |
| 658 | { |
| 659 | struct ath10k *ar = inode->i_private; |
| 660 | void *buf = NULL; |
| 661 | int ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 662 | |
Michal Kazior | fb2e9c0 | 2014-09-25 12:33:49 +0200 | [diff] [blame] | 663 | mutex_lock(&ar->conf_mutex); |
| 664 | |
| 665 | if (ar->state != ATH10K_STATE_ON) { |
| 666 | ret = -ENETDOWN; |
| 667 | goto err_unlock; |
| 668 | } |
| 669 | |
| 670 | buf = vmalloc(ATH10K_FW_STATS_BUF_SIZE); |
| 671 | if (!buf) { |
| 672 | ret = -ENOMEM; |
| 673 | goto err_unlock; |
| 674 | } |
| 675 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 676 | ret = ath10k_debug_fw_stats_request(ar); |
Michal Kazior | fb2e9c0 | 2014-09-25 12:33:49 +0200 | [diff] [blame] | 677 | if (ret) { |
| 678 | ath10k_warn(ar, "failed to request fw stats: %d\n", ret); |
| 679 | goto err_free; |
| 680 | } |
| 681 | |
| 682 | ath10k_fw_stats_fill(ar, &ar->debug.fw_stats, buf); |
| 683 | file->private_data = buf; |
| 684 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 685 | mutex_unlock(&ar->conf_mutex); |
Michal Kazior | fb2e9c0 | 2014-09-25 12:33:49 +0200 | [diff] [blame] | 686 | return 0; |
| 687 | |
| 688 | err_free: |
| 689 | vfree(buf); |
| 690 | |
| 691 | err_unlock: |
| 692 | mutex_unlock(&ar->conf_mutex); |
| 693 | return ret; |
| 694 | } |
| 695 | |
| 696 | static int ath10k_fw_stats_release(struct inode *inode, struct file *file) |
| 697 | { |
| 698 | vfree(file->private_data); |
| 699 | |
| 700 | return 0; |
| 701 | } |
| 702 | |
| 703 | static ssize_t ath10k_fw_stats_read(struct file *file, char __user *user_buf, |
| 704 | size_t count, loff_t *ppos) |
| 705 | { |
| 706 | const char *buf = file->private_data; |
| 707 | unsigned int len = strlen(buf); |
| 708 | |
| 709 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | static const struct file_operations fops_fw_stats = { |
Michal Kazior | fb2e9c0 | 2014-09-25 12:33:49 +0200 | [diff] [blame] | 713 | .open = ath10k_fw_stats_open, |
| 714 | .release = ath10k_fw_stats_release, |
Michal Kazior | 60ef401 | 2014-09-25 12:33:48 +0200 | [diff] [blame] | 715 | .read = ath10k_fw_stats_read, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 716 | .owner = THIS_MODULE, |
| 717 | .llseek = default_llseek, |
| 718 | }; |
| 719 | |
Ben Greear | f51dbe7 | 2014-09-29 14:41:46 +0300 | [diff] [blame] | 720 | static ssize_t ath10k_debug_fw_reset_stats_read(struct file *file, |
| 721 | char __user *user_buf, |
| 722 | size_t count, loff_t *ppos) |
| 723 | { |
| 724 | struct ath10k *ar = file->private_data; |
| 725 | int ret, len, buf_len; |
| 726 | char *buf; |
| 727 | |
| 728 | buf_len = 500; |
| 729 | buf = kmalloc(buf_len, GFP_KERNEL); |
| 730 | if (!buf) |
| 731 | return -ENOMEM; |
| 732 | |
| 733 | spin_lock_bh(&ar->data_lock); |
| 734 | |
| 735 | len = 0; |
| 736 | len += scnprintf(buf + len, buf_len - len, |
| 737 | "fw_crash_counter\t\t%d\n", ar->stats.fw_crash_counter); |
| 738 | len += scnprintf(buf + len, buf_len - len, |
| 739 | "fw_warm_reset_counter\t\t%d\n", |
| 740 | ar->stats.fw_warm_reset_counter); |
| 741 | len += scnprintf(buf + len, buf_len - len, |
| 742 | "fw_cold_reset_counter\t\t%d\n", |
| 743 | ar->stats.fw_cold_reset_counter); |
| 744 | |
| 745 | spin_unlock_bh(&ar->data_lock); |
| 746 | |
| 747 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 748 | |
| 749 | kfree(buf); |
| 750 | |
| 751 | return ret; |
| 752 | } |
| 753 | |
| 754 | static const struct file_operations fops_fw_reset_stats = { |
| 755 | .open = simple_open, |
| 756 | .read = ath10k_debug_fw_reset_stats_read, |
| 757 | .owner = THIS_MODULE, |
| 758 | .llseek = default_llseek, |
| 759 | }; |
| 760 | |
Ben Greear | d5aebc7 | 2014-09-10 18:59:28 +0300 | [diff] [blame] | 761 | /* This is a clean assert crash in firmware. */ |
| 762 | static int ath10k_debug_fw_assert(struct ath10k *ar) |
| 763 | { |
| 764 | struct wmi_vdev_install_key_cmd *cmd; |
| 765 | struct sk_buff *skb; |
| 766 | |
| 767 | skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + 16); |
| 768 | if (!skb) |
| 769 | return -ENOMEM; |
| 770 | |
| 771 | cmd = (struct wmi_vdev_install_key_cmd *)skb->data; |
| 772 | memset(cmd, 0, sizeof(*cmd)); |
| 773 | |
| 774 | /* big enough number so that firmware asserts */ |
| 775 | cmd->vdev_id = __cpu_to_le32(0x7ffe); |
| 776 | |
| 777 | return ath10k_wmi_cmd_send(ar, skb, |
| 778 | ar->wmi.cmd->vdev_install_key_cmdid); |
| 779 | } |
| 780 | |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 781 | static ssize_t ath10k_read_simulate_fw_crash(struct file *file, |
| 782 | char __user *user_buf, |
| 783 | size_t count, loff_t *ppos) |
| 784 | { |
Kalle Valo | 75cb96d | 2014-09-14 12:50:44 +0300 | [diff] [blame] | 785 | const char buf[] = |
| 786 | "To simulate firmware crash write one of the keywords to this file:\n" |
| 787 | "`soft` - this will send WMI_FORCE_FW_HANG_ASSERT to firmware if FW supports that command.\n" |
| 788 | "`hard` - this will send to firmware command with illegal parameters causing firmware crash.\n" |
Michal Kazior | 605cdba | 2014-10-28 10:34:37 +0100 | [diff] [blame] | 789 | "`assert` - this will send special illegal parameter to firmware to cause assert failure and crash.\n" |
| 790 | "`hw-restart` - this will simply queue hw restart without fw/hw actually crashing.\n"; |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 791 | |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 792 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
| 793 | } |
| 794 | |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 795 | /* Simulate firmware crash: |
| 796 | * 'soft': Call wmi command causing firmware hang. This firmware hang is |
| 797 | * recoverable by warm firmware reset. |
| 798 | * 'hard': Force firmware crash by setting any vdev parameter for not allowed |
| 799 | * vdev id. This is hard firmware crash because it is recoverable only by cold |
| 800 | * firmware reset. |
| 801 | */ |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 802 | static ssize_t ath10k_write_simulate_fw_crash(struct file *file, |
| 803 | const char __user *user_buf, |
| 804 | size_t count, loff_t *ppos) |
| 805 | { |
| 806 | struct ath10k *ar = file->private_data; |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 807 | char buf[32]; |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 808 | int ret; |
| 809 | |
| 810 | mutex_lock(&ar->conf_mutex); |
| 811 | |
| 812 | simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 813 | |
| 814 | /* make sure that buf is null terminated */ |
| 815 | buf[sizeof(buf) - 1] = 0; |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 816 | |
| 817 | if (ar->state != ATH10K_STATE_ON && |
| 818 | ar->state != ATH10K_STATE_RESTARTED) { |
| 819 | ret = -ENETDOWN; |
| 820 | goto exit; |
| 821 | } |
| 822 | |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 823 | /* drop the possible '\n' from the end */ |
| 824 | if (buf[count - 1] == '\n') { |
| 825 | buf[count - 1] = 0; |
| 826 | count--; |
| 827 | } |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 828 | |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 829 | if (!strcmp(buf, "soft")) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 830 | ath10k_info(ar, "simulating soft firmware crash\n"); |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 831 | ret = ath10k_wmi_force_fw_hang(ar, WMI_FORCE_FW_HANG_ASSERT, 0); |
| 832 | } else if (!strcmp(buf, "hard")) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 833 | ath10k_info(ar, "simulating hard firmware crash\n"); |
Ben Greear | 611b368 | 2014-07-25 11:56:40 +0300 | [diff] [blame] | 834 | /* 0x7fff is vdev id, and it is always out of range for all |
| 835 | * firmware variants in order to force a firmware crash. |
| 836 | */ |
| 837 | ret = ath10k_wmi_vdev_set_param(ar, 0x7fff, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 838 | ar->wmi.vdev_param->rts_threshold, |
| 839 | 0); |
Ben Greear | d5aebc7 | 2014-09-10 18:59:28 +0300 | [diff] [blame] | 840 | } else if (!strcmp(buf, "assert")) { |
| 841 | ath10k_info(ar, "simulating firmware assert crash\n"); |
| 842 | ret = ath10k_debug_fw_assert(ar); |
Michal Kazior | 605cdba | 2014-10-28 10:34:37 +0100 | [diff] [blame] | 843 | } else if (!strcmp(buf, "hw-restart")) { |
| 844 | ath10k_info(ar, "user requested hw restart\n"); |
| 845 | queue_work(ar->workqueue, &ar->restart_work); |
| 846 | ret = 0; |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 847 | } else { |
| 848 | ret = -EINVAL; |
| 849 | goto exit; |
| 850 | } |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 851 | |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 852 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 853 | ath10k_warn(ar, "failed to simulate firmware crash: %d\n", ret); |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 854 | goto exit; |
| 855 | } |
| 856 | |
| 857 | ret = count; |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 858 | |
| 859 | exit: |
| 860 | mutex_unlock(&ar->conf_mutex); |
| 861 | return ret; |
| 862 | } |
| 863 | |
| 864 | static const struct file_operations fops_simulate_fw_crash = { |
| 865 | .read = ath10k_read_simulate_fw_crash, |
| 866 | .write = ath10k_write_simulate_fw_crash, |
| 867 | .open = simple_open, |
| 868 | .owner = THIS_MODULE, |
| 869 | .llseek = default_llseek, |
| 870 | }; |
| 871 | |
Kalle Valo | 763b8cd | 2013-09-01 11:22:21 +0300 | [diff] [blame] | 872 | static ssize_t ath10k_read_chip_id(struct file *file, char __user *user_buf, |
| 873 | size_t count, loff_t *ppos) |
| 874 | { |
| 875 | struct ath10k *ar = file->private_data; |
| 876 | unsigned int len; |
| 877 | char buf[50]; |
| 878 | |
| 879 | len = scnprintf(buf, sizeof(buf), "0x%08x\n", ar->chip_id); |
| 880 | |
| 881 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 882 | } |
| 883 | |
| 884 | static const struct file_operations fops_chip_id = { |
| 885 | .read = ath10k_read_chip_id, |
| 886 | .open = simple_open, |
| 887 | .owner = THIS_MODULE, |
| 888 | .llseek = default_llseek, |
| 889 | }; |
| 890 | |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 891 | struct ath10k_fw_crash_data * |
| 892 | ath10k_debug_get_new_fw_crash_data(struct ath10k *ar) |
| 893 | { |
| 894 | struct ath10k_fw_crash_data *crash_data = ar->debug.fw_crash_data; |
| 895 | |
| 896 | lockdep_assert_held(&ar->data_lock); |
| 897 | |
| 898 | crash_data->crashed_since_read = true; |
| 899 | uuid_le_gen(&crash_data->uuid); |
| 900 | getnstimeofday(&crash_data->timestamp); |
| 901 | |
| 902 | return crash_data; |
| 903 | } |
| 904 | EXPORT_SYMBOL(ath10k_debug_get_new_fw_crash_data); |
| 905 | |
| 906 | static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar) |
| 907 | { |
| 908 | struct ath10k_fw_crash_data *crash_data = ar->debug.fw_crash_data; |
| 909 | struct ath10k_dump_file_data *dump_data; |
| 910 | struct ath10k_tlv_dump_data *dump_tlv; |
| 911 | int hdr_len = sizeof(*dump_data); |
| 912 | unsigned int len, sofar = 0; |
| 913 | unsigned char *buf; |
| 914 | |
| 915 | len = hdr_len; |
| 916 | len += sizeof(*dump_tlv) + sizeof(crash_data->registers); |
| 917 | |
| 918 | sofar += hdr_len; |
| 919 | |
| 920 | /* This is going to get big when we start dumping FW RAM and such, |
| 921 | * so go ahead and use vmalloc. |
| 922 | */ |
| 923 | buf = vzalloc(len); |
| 924 | if (!buf) |
| 925 | return NULL; |
| 926 | |
| 927 | spin_lock_bh(&ar->data_lock); |
| 928 | |
| 929 | if (!crash_data->crashed_since_read) { |
| 930 | spin_unlock_bh(&ar->data_lock); |
| 931 | vfree(buf); |
| 932 | return NULL; |
| 933 | } |
| 934 | |
| 935 | dump_data = (struct ath10k_dump_file_data *)(buf); |
| 936 | strlcpy(dump_data->df_magic, "ATH10K-FW-DUMP", |
| 937 | sizeof(dump_data->df_magic)); |
| 938 | dump_data->len = cpu_to_le32(len); |
| 939 | |
| 940 | dump_data->version = cpu_to_le32(ATH10K_FW_CRASH_DUMP_VERSION); |
| 941 | |
| 942 | memcpy(dump_data->uuid, &crash_data->uuid, sizeof(dump_data->uuid)); |
| 943 | dump_data->chip_id = cpu_to_le32(ar->chip_id); |
| 944 | dump_data->bus_type = cpu_to_le32(0); |
| 945 | dump_data->target_version = cpu_to_le32(ar->target_version); |
| 946 | dump_data->fw_version_major = cpu_to_le32(ar->fw_version_major); |
| 947 | dump_data->fw_version_minor = cpu_to_le32(ar->fw_version_minor); |
| 948 | dump_data->fw_version_release = cpu_to_le32(ar->fw_version_release); |
| 949 | dump_data->fw_version_build = cpu_to_le32(ar->fw_version_build); |
| 950 | dump_data->phy_capability = cpu_to_le32(ar->phy_capability); |
| 951 | dump_data->hw_min_tx_power = cpu_to_le32(ar->hw_min_tx_power); |
| 952 | dump_data->hw_max_tx_power = cpu_to_le32(ar->hw_max_tx_power); |
| 953 | dump_data->ht_cap_info = cpu_to_le32(ar->ht_cap_info); |
| 954 | dump_data->vht_cap_info = cpu_to_le32(ar->vht_cap_info); |
| 955 | dump_data->num_rf_chains = cpu_to_le32(ar->num_rf_chains); |
| 956 | |
| 957 | strlcpy(dump_data->fw_ver, ar->hw->wiphy->fw_version, |
| 958 | sizeof(dump_data->fw_ver)); |
| 959 | |
Johannes Berg | 12c2715 | 2014-11-21 18:58:49 +0200 | [diff] [blame] | 960 | dump_data->kernel_ver_code = 0; |
| 961 | strlcpy(dump_data->kernel_ver, init_utsname()->release, |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 962 | sizeof(dump_data->kernel_ver)); |
| 963 | |
| 964 | dump_data->tv_sec = cpu_to_le64(crash_data->timestamp.tv_sec); |
| 965 | dump_data->tv_nsec = cpu_to_le64(crash_data->timestamp.tv_nsec); |
| 966 | |
| 967 | /* Gather crash-dump */ |
| 968 | dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar); |
| 969 | dump_tlv->type = cpu_to_le32(ATH10K_FW_CRASH_DUMP_REGISTERS); |
| 970 | dump_tlv->tlv_len = cpu_to_le32(sizeof(crash_data->registers)); |
| 971 | memcpy(dump_tlv->tlv_data, &crash_data->registers, |
| 972 | sizeof(crash_data->registers)); |
| 973 | sofar += sizeof(*dump_tlv) + sizeof(crash_data->registers); |
| 974 | |
| 975 | ar->debug.fw_crash_data->crashed_since_read = false; |
| 976 | |
| 977 | spin_unlock_bh(&ar->data_lock); |
| 978 | |
| 979 | return dump_data; |
| 980 | } |
| 981 | |
| 982 | static int ath10k_fw_crash_dump_open(struct inode *inode, struct file *file) |
| 983 | { |
| 984 | struct ath10k *ar = inode->i_private; |
| 985 | struct ath10k_dump_file_data *dump; |
| 986 | |
| 987 | dump = ath10k_build_dump_file(ar); |
| 988 | if (!dump) |
| 989 | return -ENODATA; |
| 990 | |
| 991 | file->private_data = dump; |
| 992 | |
| 993 | return 0; |
| 994 | } |
| 995 | |
| 996 | static ssize_t ath10k_fw_crash_dump_read(struct file *file, |
| 997 | char __user *user_buf, |
| 998 | size_t count, loff_t *ppos) |
| 999 | { |
| 1000 | struct ath10k_dump_file_data *dump_file = file->private_data; |
| 1001 | |
| 1002 | return simple_read_from_buffer(user_buf, count, ppos, |
| 1003 | dump_file, |
| 1004 | le32_to_cpu(dump_file->len)); |
| 1005 | } |
| 1006 | |
| 1007 | static int ath10k_fw_crash_dump_release(struct inode *inode, |
| 1008 | struct file *file) |
| 1009 | { |
| 1010 | vfree(file->private_data); |
| 1011 | |
| 1012 | return 0; |
| 1013 | } |
| 1014 | |
| 1015 | static const struct file_operations fops_fw_crash_dump = { |
| 1016 | .open = ath10k_fw_crash_dump_open, |
| 1017 | .read = ath10k_fw_crash_dump_read, |
| 1018 | .release = ath10k_fw_crash_dump_release, |
| 1019 | .owner = THIS_MODULE, |
| 1020 | .llseek = default_llseek, |
| 1021 | }; |
| 1022 | |
Yanbo Li | 077a380 | 2014-11-25 12:24:33 +0200 | [diff] [blame] | 1023 | static ssize_t ath10k_reg_addr_read(struct file *file, |
| 1024 | char __user *user_buf, |
| 1025 | size_t count, loff_t *ppos) |
| 1026 | { |
| 1027 | struct ath10k *ar = file->private_data; |
| 1028 | u8 buf[32]; |
| 1029 | unsigned int len = 0; |
| 1030 | u32 reg_addr; |
| 1031 | |
| 1032 | mutex_lock(&ar->conf_mutex); |
| 1033 | reg_addr = ar->debug.reg_addr; |
| 1034 | mutex_unlock(&ar->conf_mutex); |
| 1035 | |
| 1036 | len += scnprintf(buf + len, sizeof(buf) - len, "0x%x\n", reg_addr); |
| 1037 | |
| 1038 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1039 | } |
| 1040 | |
| 1041 | static ssize_t ath10k_reg_addr_write(struct file *file, |
| 1042 | const char __user *user_buf, |
| 1043 | size_t count, loff_t *ppos) |
| 1044 | { |
| 1045 | struct ath10k *ar = file->private_data; |
| 1046 | u32 reg_addr; |
| 1047 | int ret; |
| 1048 | |
| 1049 | ret = kstrtou32_from_user(user_buf, count, 0, ®_addr); |
| 1050 | if (ret) |
| 1051 | return ret; |
| 1052 | |
| 1053 | if (!IS_ALIGNED(reg_addr, 4)) |
| 1054 | return -EFAULT; |
| 1055 | |
| 1056 | mutex_lock(&ar->conf_mutex); |
| 1057 | ar->debug.reg_addr = reg_addr; |
| 1058 | mutex_unlock(&ar->conf_mutex); |
| 1059 | |
| 1060 | return count; |
| 1061 | } |
| 1062 | |
| 1063 | static const struct file_operations fops_reg_addr = { |
| 1064 | .read = ath10k_reg_addr_read, |
| 1065 | .write = ath10k_reg_addr_write, |
| 1066 | .open = simple_open, |
| 1067 | .owner = THIS_MODULE, |
| 1068 | .llseek = default_llseek, |
| 1069 | }; |
| 1070 | |
| 1071 | static ssize_t ath10k_reg_value_read(struct file *file, |
| 1072 | char __user *user_buf, |
| 1073 | size_t count, loff_t *ppos) |
| 1074 | { |
| 1075 | struct ath10k *ar = file->private_data; |
| 1076 | u8 buf[48]; |
| 1077 | unsigned int len; |
| 1078 | u32 reg_addr, reg_val; |
| 1079 | int ret; |
| 1080 | |
| 1081 | mutex_lock(&ar->conf_mutex); |
| 1082 | |
| 1083 | if (ar->state != ATH10K_STATE_ON && |
| 1084 | ar->state != ATH10K_STATE_UTF) { |
| 1085 | ret = -ENETDOWN; |
| 1086 | goto exit; |
| 1087 | } |
| 1088 | |
| 1089 | reg_addr = ar->debug.reg_addr; |
| 1090 | |
| 1091 | reg_val = ath10k_hif_read32(ar, reg_addr); |
| 1092 | len = scnprintf(buf, sizeof(buf), "0x%08x:0x%08x\n", reg_addr, reg_val); |
| 1093 | |
| 1094 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1095 | |
| 1096 | exit: |
| 1097 | mutex_unlock(&ar->conf_mutex); |
| 1098 | |
| 1099 | return ret; |
| 1100 | } |
| 1101 | |
| 1102 | static ssize_t ath10k_reg_value_write(struct file *file, |
| 1103 | const char __user *user_buf, |
| 1104 | size_t count, loff_t *ppos) |
| 1105 | { |
| 1106 | struct ath10k *ar = file->private_data; |
| 1107 | u32 reg_addr, reg_val; |
| 1108 | int ret; |
| 1109 | |
| 1110 | mutex_lock(&ar->conf_mutex); |
| 1111 | |
| 1112 | if (ar->state != ATH10K_STATE_ON && |
| 1113 | ar->state != ATH10K_STATE_UTF) { |
| 1114 | ret = -ENETDOWN; |
| 1115 | goto exit; |
| 1116 | } |
| 1117 | |
| 1118 | reg_addr = ar->debug.reg_addr; |
| 1119 | |
| 1120 | ret = kstrtou32_from_user(user_buf, count, 0, ®_val); |
| 1121 | if (ret) |
| 1122 | goto exit; |
| 1123 | |
| 1124 | ath10k_hif_write32(ar, reg_addr, reg_val); |
| 1125 | |
| 1126 | ret = count; |
| 1127 | |
| 1128 | exit: |
| 1129 | mutex_unlock(&ar->conf_mutex); |
| 1130 | |
| 1131 | return ret; |
| 1132 | } |
| 1133 | |
| 1134 | static const struct file_operations fops_reg_value = { |
| 1135 | .read = ath10k_reg_value_read, |
| 1136 | .write = ath10k_reg_value_write, |
| 1137 | .open = simple_open, |
| 1138 | .owner = THIS_MODULE, |
| 1139 | .llseek = default_llseek, |
| 1140 | }; |
| 1141 | |
Yanbo Li | 9f65ad2 | 2014-11-25 12:24:48 +0200 | [diff] [blame] | 1142 | static ssize_t ath10k_mem_value_read(struct file *file, |
| 1143 | char __user *user_buf, |
| 1144 | size_t count, loff_t *ppos) |
| 1145 | { |
| 1146 | struct ath10k *ar = file->private_data; |
| 1147 | u8 *buf; |
| 1148 | int ret; |
| 1149 | |
| 1150 | if (*ppos < 0) |
| 1151 | return -EINVAL; |
| 1152 | |
| 1153 | if (!count) |
| 1154 | return 0; |
| 1155 | |
| 1156 | mutex_lock(&ar->conf_mutex); |
| 1157 | |
| 1158 | buf = vmalloc(count); |
| 1159 | if (!buf) { |
| 1160 | ret = -ENOMEM; |
| 1161 | goto exit; |
| 1162 | } |
| 1163 | |
| 1164 | if (ar->state != ATH10K_STATE_ON && |
| 1165 | ar->state != ATH10K_STATE_UTF) { |
| 1166 | ret = -ENETDOWN; |
| 1167 | goto exit; |
| 1168 | } |
| 1169 | |
| 1170 | ret = ath10k_hif_diag_read(ar, *ppos, buf, count); |
| 1171 | if (ret) { |
| 1172 | ath10k_warn(ar, "failed to read address 0x%08x via diagnose window fnrom debugfs: %d\n", |
| 1173 | (u32)(*ppos), ret); |
| 1174 | goto exit; |
| 1175 | } |
| 1176 | |
| 1177 | ret = copy_to_user(user_buf, buf, count); |
| 1178 | if (ret) { |
| 1179 | ret = -EFAULT; |
| 1180 | goto exit; |
| 1181 | } |
| 1182 | |
| 1183 | count -= ret; |
| 1184 | *ppos += count; |
| 1185 | ret = count; |
| 1186 | |
| 1187 | exit: |
| 1188 | vfree(buf); |
| 1189 | mutex_unlock(&ar->conf_mutex); |
| 1190 | |
| 1191 | return ret; |
| 1192 | } |
| 1193 | |
| 1194 | static ssize_t ath10k_mem_value_write(struct file *file, |
| 1195 | const char __user *user_buf, |
| 1196 | size_t count, loff_t *ppos) |
| 1197 | { |
| 1198 | struct ath10k *ar = file->private_data; |
| 1199 | u8 *buf; |
| 1200 | int ret; |
| 1201 | |
| 1202 | if (*ppos < 0) |
| 1203 | return -EINVAL; |
| 1204 | |
| 1205 | if (!count) |
| 1206 | return 0; |
| 1207 | |
| 1208 | mutex_lock(&ar->conf_mutex); |
| 1209 | |
| 1210 | buf = vmalloc(count); |
| 1211 | if (!buf) { |
| 1212 | ret = -ENOMEM; |
| 1213 | goto exit; |
| 1214 | } |
| 1215 | |
| 1216 | if (ar->state != ATH10K_STATE_ON && |
| 1217 | ar->state != ATH10K_STATE_UTF) { |
| 1218 | ret = -ENETDOWN; |
| 1219 | goto exit; |
| 1220 | } |
| 1221 | |
| 1222 | ret = copy_from_user(buf, user_buf, count); |
| 1223 | if (ret) { |
| 1224 | ret = -EFAULT; |
| 1225 | goto exit; |
| 1226 | } |
| 1227 | |
| 1228 | ret = ath10k_hif_diag_write(ar, *ppos, buf, count); |
| 1229 | if (ret) { |
| 1230 | ath10k_warn(ar, "failed to write address 0x%08x via diagnose window from debugfs: %d\n", |
| 1231 | (u32)(*ppos), ret); |
| 1232 | goto exit; |
| 1233 | } |
| 1234 | |
| 1235 | *ppos += count; |
| 1236 | ret = count; |
| 1237 | |
| 1238 | exit: |
| 1239 | vfree(buf); |
| 1240 | mutex_unlock(&ar->conf_mutex); |
| 1241 | |
| 1242 | return ret; |
| 1243 | } |
| 1244 | |
| 1245 | static const struct file_operations fops_mem_value = { |
| 1246 | .read = ath10k_mem_value_read, |
| 1247 | .write = ath10k_mem_value_write, |
| 1248 | .open = simple_open, |
| 1249 | .owner = THIS_MODULE, |
| 1250 | .llseek = default_llseek, |
| 1251 | }; |
| 1252 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 1253 | static int ath10k_debug_htt_stats_req(struct ath10k *ar) |
| 1254 | { |
| 1255 | u64 cookie; |
| 1256 | int ret; |
| 1257 | |
| 1258 | lockdep_assert_held(&ar->conf_mutex); |
| 1259 | |
| 1260 | if (ar->debug.htt_stats_mask == 0) |
| 1261 | /* htt stats are disabled */ |
| 1262 | return 0; |
| 1263 | |
| 1264 | if (ar->state != ATH10K_STATE_ON) |
| 1265 | return 0; |
| 1266 | |
| 1267 | cookie = get_jiffies_64(); |
| 1268 | |
| 1269 | ret = ath10k_htt_h2t_stats_req(&ar->htt, ar->debug.htt_stats_mask, |
| 1270 | cookie); |
| 1271 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1272 | ath10k_warn(ar, "failed to send htt stats request: %d\n", ret); |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 1273 | return ret; |
| 1274 | } |
| 1275 | |
| 1276 | queue_delayed_work(ar->workqueue, &ar->debug.htt_stats_dwork, |
| 1277 | msecs_to_jiffies(ATH10K_DEBUG_HTT_STATS_INTERVAL)); |
| 1278 | |
| 1279 | return 0; |
| 1280 | } |
| 1281 | |
| 1282 | static void ath10k_debug_htt_stats_dwork(struct work_struct *work) |
| 1283 | { |
| 1284 | struct ath10k *ar = container_of(work, struct ath10k, |
| 1285 | debug.htt_stats_dwork.work); |
| 1286 | |
| 1287 | mutex_lock(&ar->conf_mutex); |
| 1288 | |
| 1289 | ath10k_debug_htt_stats_req(ar); |
| 1290 | |
| 1291 | mutex_unlock(&ar->conf_mutex); |
| 1292 | } |
| 1293 | |
| 1294 | static ssize_t ath10k_read_htt_stats_mask(struct file *file, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 1295 | char __user *user_buf, |
| 1296 | size_t count, loff_t *ppos) |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 1297 | { |
| 1298 | struct ath10k *ar = file->private_data; |
| 1299 | char buf[32]; |
| 1300 | unsigned int len; |
| 1301 | |
| 1302 | len = scnprintf(buf, sizeof(buf), "%lu\n", ar->debug.htt_stats_mask); |
| 1303 | |
| 1304 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1305 | } |
| 1306 | |
| 1307 | static ssize_t ath10k_write_htt_stats_mask(struct file *file, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 1308 | const char __user *user_buf, |
| 1309 | size_t count, loff_t *ppos) |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 1310 | { |
| 1311 | struct ath10k *ar = file->private_data; |
| 1312 | unsigned long mask; |
| 1313 | int ret; |
| 1314 | |
| 1315 | ret = kstrtoul_from_user(user_buf, count, 0, &mask); |
| 1316 | if (ret) |
| 1317 | return ret; |
| 1318 | |
| 1319 | /* max 8 bit masks (for now) */ |
| 1320 | if (mask > 0xff) |
| 1321 | return -E2BIG; |
| 1322 | |
| 1323 | mutex_lock(&ar->conf_mutex); |
| 1324 | |
| 1325 | ar->debug.htt_stats_mask = mask; |
| 1326 | |
| 1327 | ret = ath10k_debug_htt_stats_req(ar); |
| 1328 | if (ret) |
| 1329 | goto out; |
| 1330 | |
| 1331 | ret = count; |
| 1332 | |
| 1333 | out: |
| 1334 | mutex_unlock(&ar->conf_mutex); |
| 1335 | |
| 1336 | return ret; |
| 1337 | } |
| 1338 | |
| 1339 | static const struct file_operations fops_htt_stats_mask = { |
| 1340 | .read = ath10k_read_htt_stats_mask, |
| 1341 | .write = ath10k_write_htt_stats_mask, |
| 1342 | .open = simple_open, |
| 1343 | .owner = THIS_MODULE, |
| 1344 | .llseek = default_llseek, |
| 1345 | }; |
| 1346 | |
Janusz Dziedzic | d385623 | 2014-06-02 21:19:46 +0300 | [diff] [blame] | 1347 | static ssize_t ath10k_read_htt_max_amsdu_ampdu(struct file *file, |
| 1348 | char __user *user_buf, |
| 1349 | size_t count, loff_t *ppos) |
| 1350 | { |
| 1351 | struct ath10k *ar = file->private_data; |
| 1352 | char buf[64]; |
| 1353 | u8 amsdu = 3, ampdu = 64; |
| 1354 | unsigned int len; |
| 1355 | |
| 1356 | mutex_lock(&ar->conf_mutex); |
| 1357 | |
| 1358 | if (ar->debug.htt_max_amsdu) |
| 1359 | amsdu = ar->debug.htt_max_amsdu; |
| 1360 | |
| 1361 | if (ar->debug.htt_max_ampdu) |
| 1362 | ampdu = ar->debug.htt_max_ampdu; |
| 1363 | |
| 1364 | mutex_unlock(&ar->conf_mutex); |
| 1365 | |
| 1366 | len = scnprintf(buf, sizeof(buf), "%u %u\n", amsdu, ampdu); |
| 1367 | |
| 1368 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1369 | } |
| 1370 | |
| 1371 | static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct file *file, |
| 1372 | const char __user *user_buf, |
| 1373 | size_t count, loff_t *ppos) |
| 1374 | { |
| 1375 | struct ath10k *ar = file->private_data; |
| 1376 | int res; |
| 1377 | char buf[64]; |
| 1378 | unsigned int amsdu, ampdu; |
| 1379 | |
| 1380 | simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); |
| 1381 | |
| 1382 | /* make sure that buf is null terminated */ |
| 1383 | buf[sizeof(buf) - 1] = 0; |
| 1384 | |
| 1385 | res = sscanf(buf, "%u %u", &amsdu, &du); |
| 1386 | |
| 1387 | if (res != 2) |
| 1388 | return -EINVAL; |
| 1389 | |
| 1390 | mutex_lock(&ar->conf_mutex); |
| 1391 | |
| 1392 | res = ath10k_htt_h2t_aggr_cfg_msg(&ar->htt, ampdu, amsdu); |
| 1393 | if (res) |
| 1394 | goto out; |
| 1395 | |
| 1396 | res = count; |
| 1397 | ar->debug.htt_max_amsdu = amsdu; |
| 1398 | ar->debug.htt_max_ampdu = ampdu; |
| 1399 | |
| 1400 | out: |
| 1401 | mutex_unlock(&ar->conf_mutex); |
| 1402 | return res; |
| 1403 | } |
| 1404 | |
| 1405 | static const struct file_operations fops_htt_max_amsdu_ampdu = { |
| 1406 | .read = ath10k_read_htt_max_amsdu_ampdu, |
| 1407 | .write = ath10k_write_htt_max_amsdu_ampdu, |
| 1408 | .open = simple_open, |
| 1409 | .owner = THIS_MODULE, |
| 1410 | .llseek = default_llseek, |
| 1411 | }; |
| 1412 | |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1413 | static ssize_t ath10k_read_fw_dbglog(struct file *file, |
Kalle Valo | 5b07e07 | 2014-09-14 12:50:06 +0300 | [diff] [blame] | 1414 | char __user *user_buf, |
| 1415 | size_t count, loff_t *ppos) |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1416 | { |
| 1417 | struct ath10k *ar = file->private_data; |
| 1418 | unsigned int len; |
SenthilKumar Jegadeesan | 467210a | 2015-01-29 14:36:52 +0530 | [diff] [blame] | 1419 | char buf[64]; |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1420 | |
SenthilKumar Jegadeesan | 467210a | 2015-01-29 14:36:52 +0530 | [diff] [blame] | 1421 | len = scnprintf(buf, sizeof(buf), "0x%08x %u\n", |
| 1422 | ar->debug.fw_dbglog_mask, ar->debug.fw_dbglog_level); |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1423 | |
| 1424 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1425 | } |
| 1426 | |
| 1427 | static ssize_t ath10k_write_fw_dbglog(struct file *file, |
| 1428 | const char __user *user_buf, |
| 1429 | size_t count, loff_t *ppos) |
| 1430 | { |
| 1431 | struct ath10k *ar = file->private_data; |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1432 | int ret; |
SenthilKumar Jegadeesan | 467210a | 2015-01-29 14:36:52 +0530 | [diff] [blame] | 1433 | char buf[64]; |
| 1434 | unsigned int log_level, mask; |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1435 | |
SenthilKumar Jegadeesan | 467210a | 2015-01-29 14:36:52 +0530 | [diff] [blame] | 1436 | simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); |
| 1437 | |
| 1438 | /* make sure that buf is null terminated */ |
| 1439 | buf[sizeof(buf) - 1] = 0; |
| 1440 | |
| 1441 | ret = sscanf(buf, "%x %u", &mask, &log_level); |
| 1442 | |
| 1443 | if (!ret) |
| 1444 | return -EINVAL; |
| 1445 | |
| 1446 | if (ret == 1) |
| 1447 | /* default if user did not specify */ |
| 1448 | log_level = ATH10K_DBGLOG_LEVEL_WARN; |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1449 | |
| 1450 | mutex_lock(&ar->conf_mutex); |
| 1451 | |
| 1452 | ar->debug.fw_dbglog_mask = mask; |
SenthilKumar Jegadeesan | 467210a | 2015-01-29 14:36:52 +0530 | [diff] [blame] | 1453 | ar->debug.fw_dbglog_level = log_level; |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1454 | |
| 1455 | if (ar->state == ATH10K_STATE_ON) { |
SenthilKumar Jegadeesan | 467210a | 2015-01-29 14:36:52 +0530 | [diff] [blame] | 1456 | ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask, |
| 1457 | ar->debug.fw_dbglog_level); |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1458 | if (ret) { |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1459 | ath10k_warn(ar, "dbglog cfg failed from debugfs: %d\n", |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1460 | ret); |
| 1461 | goto exit; |
| 1462 | } |
| 1463 | } |
| 1464 | |
| 1465 | ret = count; |
| 1466 | |
| 1467 | exit: |
| 1468 | mutex_unlock(&ar->conf_mutex); |
| 1469 | |
| 1470 | return ret; |
| 1471 | } |
| 1472 | |
Ben Greear | 6cddcc7 | 2014-09-29 14:41:46 +0300 | [diff] [blame] | 1473 | /* TODO: Would be nice to always support ethtool stats, would need to |
| 1474 | * move the stats storage out of ath10k_debug, or always have ath10k_debug |
| 1475 | * struct available.. |
| 1476 | */ |
| 1477 | |
| 1478 | /* This generally cooresponds to the debugfs fw_stats file */ |
| 1479 | static const char ath10k_gstrings_stats[][ETH_GSTRING_LEN] = { |
| 1480 | "tx_pkts_nic", |
| 1481 | "tx_bytes_nic", |
| 1482 | "rx_pkts_nic", |
| 1483 | "rx_bytes_nic", |
| 1484 | "d_noise_floor", |
| 1485 | "d_cycle_count", |
| 1486 | "d_phy_error", |
| 1487 | "d_rts_bad", |
| 1488 | "d_rts_good", |
| 1489 | "d_tx_power", /* in .5 dbM I think */ |
| 1490 | "d_rx_crc_err", /* fcs_bad */ |
| 1491 | "d_no_beacon", |
| 1492 | "d_tx_mpdus_queued", |
| 1493 | "d_tx_msdu_queued", |
| 1494 | "d_tx_msdu_dropped", |
| 1495 | "d_local_enqued", |
| 1496 | "d_local_freed", |
| 1497 | "d_tx_ppdu_hw_queued", |
| 1498 | "d_tx_ppdu_reaped", |
| 1499 | "d_tx_fifo_underrun", |
| 1500 | "d_tx_ppdu_abort", |
| 1501 | "d_tx_mpdu_requed", |
| 1502 | "d_tx_excessive_retries", |
| 1503 | "d_tx_hw_rate", |
| 1504 | "d_tx_dropped_sw_retries", |
| 1505 | "d_tx_illegal_rate", |
| 1506 | "d_tx_continuous_xretries", |
| 1507 | "d_tx_timeout", |
| 1508 | "d_tx_mpdu_txop_limit", |
| 1509 | "d_pdev_resets", |
| 1510 | "d_rx_mid_ppdu_route_change", |
| 1511 | "d_rx_status", |
| 1512 | "d_rx_extra_frags_ring0", |
| 1513 | "d_rx_extra_frags_ring1", |
| 1514 | "d_rx_extra_frags_ring2", |
| 1515 | "d_rx_extra_frags_ring3", |
| 1516 | "d_rx_msdu_htt", |
| 1517 | "d_rx_mpdu_htt", |
| 1518 | "d_rx_msdu_stack", |
| 1519 | "d_rx_mpdu_stack", |
| 1520 | "d_rx_phy_err", |
| 1521 | "d_rx_phy_err_drops", |
| 1522 | "d_rx_mpdu_errors", /* FCS, MIC, ENC */ |
| 1523 | "d_fw_crash_count", |
| 1524 | "d_fw_warm_reset_count", |
| 1525 | "d_fw_cold_reset_count", |
| 1526 | }; |
| 1527 | |
| 1528 | #define ATH10K_SSTATS_LEN ARRAY_SIZE(ath10k_gstrings_stats) |
| 1529 | |
| 1530 | void ath10k_debug_get_et_strings(struct ieee80211_hw *hw, |
| 1531 | struct ieee80211_vif *vif, |
| 1532 | u32 sset, u8 *data) |
| 1533 | { |
| 1534 | if (sset == ETH_SS_STATS) |
| 1535 | memcpy(data, *ath10k_gstrings_stats, |
| 1536 | sizeof(ath10k_gstrings_stats)); |
| 1537 | } |
| 1538 | |
| 1539 | int ath10k_debug_get_et_sset_count(struct ieee80211_hw *hw, |
| 1540 | struct ieee80211_vif *vif, int sset) |
| 1541 | { |
| 1542 | if (sset == ETH_SS_STATS) |
| 1543 | return ATH10K_SSTATS_LEN; |
| 1544 | |
| 1545 | return 0; |
| 1546 | } |
| 1547 | |
| 1548 | void ath10k_debug_get_et_stats(struct ieee80211_hw *hw, |
| 1549 | struct ieee80211_vif *vif, |
| 1550 | struct ethtool_stats *stats, u64 *data) |
| 1551 | { |
| 1552 | struct ath10k *ar = hw->priv; |
| 1553 | static const struct ath10k_fw_stats_pdev zero_stats = {}; |
| 1554 | const struct ath10k_fw_stats_pdev *pdev_stats; |
| 1555 | int i = 0, ret; |
| 1556 | |
| 1557 | mutex_lock(&ar->conf_mutex); |
| 1558 | |
| 1559 | if (ar->state == ATH10K_STATE_ON) { |
| 1560 | ret = ath10k_debug_fw_stats_request(ar); |
| 1561 | if (ret) { |
| 1562 | /* just print a warning and try to use older results */ |
| 1563 | ath10k_warn(ar, |
| 1564 | "failed to get fw stats for ethtool: %d\n", |
| 1565 | ret); |
| 1566 | } |
| 1567 | } |
| 1568 | |
| 1569 | pdev_stats = list_first_entry_or_null(&ar->debug.fw_stats.pdevs, |
| 1570 | struct ath10k_fw_stats_pdev, |
| 1571 | list); |
| 1572 | if (!pdev_stats) { |
| 1573 | /* no results available so just return zeroes */ |
| 1574 | pdev_stats = &zero_stats; |
| 1575 | } |
| 1576 | |
| 1577 | spin_lock_bh(&ar->data_lock); |
| 1578 | |
| 1579 | data[i++] = pdev_stats->hw_reaped; /* ppdu reaped */ |
| 1580 | data[i++] = 0; /* tx bytes */ |
| 1581 | data[i++] = pdev_stats->htt_mpdus; |
| 1582 | data[i++] = 0; /* rx bytes */ |
| 1583 | data[i++] = pdev_stats->ch_noise_floor; |
| 1584 | data[i++] = pdev_stats->cycle_count; |
| 1585 | data[i++] = pdev_stats->phy_err_count; |
| 1586 | data[i++] = pdev_stats->rts_bad; |
| 1587 | data[i++] = pdev_stats->rts_good; |
| 1588 | data[i++] = pdev_stats->chan_tx_power; |
| 1589 | data[i++] = pdev_stats->fcs_bad; |
| 1590 | data[i++] = pdev_stats->no_beacons; |
| 1591 | data[i++] = pdev_stats->mpdu_enqued; |
| 1592 | data[i++] = pdev_stats->msdu_enqued; |
| 1593 | data[i++] = pdev_stats->wmm_drop; |
| 1594 | data[i++] = pdev_stats->local_enqued; |
| 1595 | data[i++] = pdev_stats->local_freed; |
| 1596 | data[i++] = pdev_stats->hw_queued; |
| 1597 | data[i++] = pdev_stats->hw_reaped; |
| 1598 | data[i++] = pdev_stats->underrun; |
| 1599 | data[i++] = pdev_stats->tx_abort; |
| 1600 | data[i++] = pdev_stats->mpdus_requed; |
| 1601 | data[i++] = pdev_stats->tx_ko; |
| 1602 | data[i++] = pdev_stats->data_rc; |
| 1603 | data[i++] = pdev_stats->sw_retry_failure; |
| 1604 | data[i++] = pdev_stats->illgl_rate_phy_err; |
| 1605 | data[i++] = pdev_stats->pdev_cont_xretry; |
| 1606 | data[i++] = pdev_stats->pdev_tx_timeout; |
| 1607 | data[i++] = pdev_stats->txop_ovf; |
| 1608 | data[i++] = pdev_stats->pdev_resets; |
| 1609 | data[i++] = pdev_stats->mid_ppdu_route_change; |
| 1610 | data[i++] = pdev_stats->status_rcvd; |
| 1611 | data[i++] = pdev_stats->r0_frags; |
| 1612 | data[i++] = pdev_stats->r1_frags; |
| 1613 | data[i++] = pdev_stats->r2_frags; |
| 1614 | data[i++] = pdev_stats->r3_frags; |
| 1615 | data[i++] = pdev_stats->htt_msdus; |
| 1616 | data[i++] = pdev_stats->htt_mpdus; |
| 1617 | data[i++] = pdev_stats->loc_msdus; |
| 1618 | data[i++] = pdev_stats->loc_mpdus; |
| 1619 | data[i++] = pdev_stats->phy_errs; |
| 1620 | data[i++] = pdev_stats->phy_err_drop; |
| 1621 | data[i++] = pdev_stats->mpdu_errs; |
| 1622 | data[i++] = ar->stats.fw_crash_counter; |
| 1623 | data[i++] = ar->stats.fw_warm_reset_counter; |
| 1624 | data[i++] = ar->stats.fw_cold_reset_counter; |
| 1625 | |
| 1626 | spin_unlock_bh(&ar->data_lock); |
| 1627 | |
| 1628 | mutex_unlock(&ar->conf_mutex); |
| 1629 | |
| 1630 | WARN_ON(i != ATH10K_SSTATS_LEN); |
| 1631 | } |
| 1632 | |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1633 | static const struct file_operations fops_fw_dbglog = { |
| 1634 | .read = ath10k_read_fw_dbglog, |
| 1635 | .write = ath10k_write_fw_dbglog, |
| 1636 | .open = simple_open, |
| 1637 | .owner = THIS_MODULE, |
| 1638 | .llseek = default_llseek, |
| 1639 | }; |
| 1640 | |
Kalle Valo | 7869b4f | 2014-09-24 14:16:58 +0300 | [diff] [blame] | 1641 | static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file) |
| 1642 | { |
| 1643 | struct ath10k *ar = inode->i_private; |
| 1644 | void *buf; |
| 1645 | u32 hi_addr; |
| 1646 | __le32 addr; |
| 1647 | int ret; |
| 1648 | |
| 1649 | mutex_lock(&ar->conf_mutex); |
| 1650 | |
| 1651 | if (ar->state != ATH10K_STATE_ON && |
| 1652 | ar->state != ATH10K_STATE_UTF) { |
| 1653 | ret = -ENETDOWN; |
| 1654 | goto err; |
| 1655 | } |
| 1656 | |
| 1657 | buf = vmalloc(QCA988X_CAL_DATA_LEN); |
| 1658 | if (!buf) { |
| 1659 | ret = -ENOMEM; |
| 1660 | goto err; |
| 1661 | } |
| 1662 | |
| 1663 | hi_addr = host_interest_item_address(HI_ITEM(hi_board_data)); |
| 1664 | |
| 1665 | ret = ath10k_hif_diag_read(ar, hi_addr, &addr, sizeof(addr)); |
| 1666 | if (ret) { |
| 1667 | ath10k_warn(ar, "failed to read hi_board_data address: %d\n", ret); |
| 1668 | goto err_vfree; |
| 1669 | } |
| 1670 | |
| 1671 | ret = ath10k_hif_diag_read(ar, le32_to_cpu(addr), buf, |
| 1672 | QCA988X_CAL_DATA_LEN); |
| 1673 | if (ret) { |
| 1674 | ath10k_warn(ar, "failed to read calibration data: %d\n", ret); |
| 1675 | goto err_vfree; |
| 1676 | } |
| 1677 | |
| 1678 | file->private_data = buf; |
| 1679 | |
| 1680 | mutex_unlock(&ar->conf_mutex); |
| 1681 | |
| 1682 | return 0; |
| 1683 | |
| 1684 | err_vfree: |
| 1685 | vfree(buf); |
| 1686 | |
| 1687 | err: |
| 1688 | mutex_unlock(&ar->conf_mutex); |
| 1689 | |
| 1690 | return ret; |
| 1691 | } |
| 1692 | |
| 1693 | static ssize_t ath10k_debug_cal_data_read(struct file *file, |
| 1694 | char __user *user_buf, |
| 1695 | size_t count, loff_t *ppos) |
| 1696 | { |
| 1697 | void *buf = file->private_data; |
| 1698 | |
| 1699 | return simple_read_from_buffer(user_buf, count, ppos, |
| 1700 | buf, QCA988X_CAL_DATA_LEN); |
| 1701 | } |
| 1702 | |
| 1703 | static int ath10k_debug_cal_data_release(struct inode *inode, |
| 1704 | struct file *file) |
| 1705 | { |
| 1706 | vfree(file->private_data); |
| 1707 | |
| 1708 | return 0; |
| 1709 | } |
| 1710 | |
Ashok Raj Nagarajan | b3e71d7 | 2015-03-19 16:38:00 +0530 | [diff] [blame^] | 1711 | static ssize_t ath10k_write_ani_enable(struct file *file, |
| 1712 | const char __user *user_buf, |
| 1713 | size_t count, loff_t *ppos) |
| 1714 | { |
| 1715 | struct ath10k *ar = file->private_data; |
| 1716 | int ret; |
| 1717 | u8 enable; |
| 1718 | |
| 1719 | if (kstrtou8_from_user(user_buf, count, 0, &enable)) |
| 1720 | return -EINVAL; |
| 1721 | |
| 1722 | mutex_lock(&ar->conf_mutex); |
| 1723 | |
| 1724 | if (ar->ani_enabled == enable) { |
| 1725 | ret = count; |
| 1726 | goto exit; |
| 1727 | } |
| 1728 | |
| 1729 | ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->ani_enable, |
| 1730 | enable); |
| 1731 | if (ret) { |
| 1732 | ath10k_warn(ar, "ani_enable failed from debugfs: %d\n", ret); |
| 1733 | goto exit; |
| 1734 | } |
| 1735 | ar->ani_enabled = enable; |
| 1736 | |
| 1737 | ret = count; |
| 1738 | |
| 1739 | exit: |
| 1740 | mutex_unlock(&ar->conf_mutex); |
| 1741 | |
| 1742 | return ret; |
| 1743 | } |
| 1744 | |
| 1745 | static ssize_t ath10k_read_ani_enable(struct file *file, char __user *user_buf, |
| 1746 | size_t count, loff_t *ppos) |
| 1747 | { |
| 1748 | struct ath10k *ar = file->private_data; |
| 1749 | int len = 0; |
| 1750 | char buf[32]; |
| 1751 | |
| 1752 | len = scnprintf(buf, sizeof(buf) - len, "%d\n", |
| 1753 | ar->ani_enabled); |
| 1754 | |
| 1755 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1756 | } |
| 1757 | |
| 1758 | static const struct file_operations fops_ani_enable = { |
| 1759 | .read = ath10k_read_ani_enable, |
| 1760 | .write = ath10k_write_ani_enable, |
| 1761 | .open = simple_open, |
| 1762 | .owner = THIS_MODULE, |
| 1763 | .llseek = default_llseek, |
| 1764 | }; |
| 1765 | |
Kalle Valo | 7869b4f | 2014-09-24 14:16:58 +0300 | [diff] [blame] | 1766 | static const struct file_operations fops_cal_data = { |
| 1767 | .open = ath10k_debug_cal_data_open, |
| 1768 | .read = ath10k_debug_cal_data_read, |
| 1769 | .release = ath10k_debug_cal_data_release, |
| 1770 | .owner = THIS_MODULE, |
| 1771 | .llseek = default_llseek, |
| 1772 | }; |
| 1773 | |
Peter Oh | a7bd3e9 | 2014-12-02 13:07:14 +0200 | [diff] [blame] | 1774 | static ssize_t ath10k_read_nf_cal_period(struct file *file, |
| 1775 | char __user *user_buf, |
| 1776 | size_t count, loff_t *ppos) |
| 1777 | { |
| 1778 | struct ath10k *ar = file->private_data; |
| 1779 | unsigned int len; |
| 1780 | char buf[32]; |
| 1781 | |
| 1782 | len = scnprintf(buf, sizeof(buf), "%d\n", |
| 1783 | ar->debug.nf_cal_period); |
| 1784 | |
| 1785 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1786 | } |
| 1787 | |
| 1788 | static ssize_t ath10k_write_nf_cal_period(struct file *file, |
| 1789 | const char __user *user_buf, |
| 1790 | size_t count, loff_t *ppos) |
| 1791 | { |
| 1792 | struct ath10k *ar = file->private_data; |
| 1793 | unsigned long period; |
| 1794 | int ret; |
| 1795 | |
| 1796 | ret = kstrtoul_from_user(user_buf, count, 0, &period); |
| 1797 | if (ret) |
| 1798 | return ret; |
| 1799 | |
| 1800 | if (period > WMI_PDEV_PARAM_CAL_PERIOD_MAX) |
| 1801 | return -EINVAL; |
| 1802 | |
| 1803 | /* there's no way to switch back to the firmware default */ |
| 1804 | if (period == 0) |
| 1805 | return -EINVAL; |
| 1806 | |
| 1807 | mutex_lock(&ar->conf_mutex); |
| 1808 | |
| 1809 | ar->debug.nf_cal_period = period; |
| 1810 | |
| 1811 | if (ar->state != ATH10K_STATE_ON) { |
| 1812 | /* firmware is not running, nothing else to do */ |
| 1813 | ret = count; |
| 1814 | goto exit; |
| 1815 | } |
| 1816 | |
| 1817 | ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->cal_period, |
| 1818 | ar->debug.nf_cal_period); |
| 1819 | if (ret) { |
| 1820 | ath10k_warn(ar, "cal period cfg failed from debugfs: %d\n", |
| 1821 | ret); |
| 1822 | goto exit; |
| 1823 | } |
| 1824 | |
| 1825 | ret = count; |
| 1826 | |
| 1827 | exit: |
| 1828 | mutex_unlock(&ar->conf_mutex); |
| 1829 | |
| 1830 | return ret; |
| 1831 | } |
| 1832 | |
| 1833 | static const struct file_operations fops_nf_cal_period = { |
| 1834 | .read = ath10k_read_nf_cal_period, |
| 1835 | .write = ath10k_write_nf_cal_period, |
| 1836 | .open = simple_open, |
| 1837 | .owner = THIS_MODULE, |
| 1838 | .llseek = default_llseek, |
| 1839 | }; |
| 1840 | |
Kalle Valo | db66ea0 | 2013-09-03 11:44:03 +0300 | [diff] [blame] | 1841 | int ath10k_debug_start(struct ath10k *ar) |
| 1842 | { |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 1843 | int ret; |
| 1844 | |
Kalle Valo | 60631c5 | 2013-10-08 21:45:25 +0300 | [diff] [blame] | 1845 | lockdep_assert_held(&ar->conf_mutex); |
| 1846 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 1847 | ret = ath10k_debug_htt_stats_req(ar); |
| 1848 | if (ret) |
| 1849 | /* continue normally anyway, this isn't serious */ |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1850 | ath10k_warn(ar, "failed to start htt stats workqueue: %d\n", |
| 1851 | ret); |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 1852 | |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1853 | if (ar->debug.fw_dbglog_mask) { |
SenthilKumar Jegadeesan | 467210a | 2015-01-29 14:36:52 +0530 | [diff] [blame] | 1854 | ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask, |
| 1855 | ATH10K_DBGLOG_LEVEL_WARN); |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1856 | if (ret) |
| 1857 | /* not serious */ |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 1858 | ath10k_warn(ar, "failed to enable dbglog during start: %d", |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1859 | ret); |
| 1860 | } |
| 1861 | |
Rajkumar Manoharan | 9017445 | 2014-10-03 08:02:33 +0300 | [diff] [blame] | 1862 | if (ar->debug.pktlog_filter) { |
| 1863 | ret = ath10k_wmi_pdev_pktlog_enable(ar, |
| 1864 | ar->debug.pktlog_filter); |
| 1865 | if (ret) |
| 1866 | /* not serious */ |
| 1867 | ath10k_warn(ar, |
| 1868 | "failed to enable pktlog filter %x: %d\n", |
| 1869 | ar->debug.pktlog_filter, ret); |
| 1870 | } else { |
| 1871 | ret = ath10k_wmi_pdev_pktlog_disable(ar); |
| 1872 | if (ret) |
| 1873 | /* not serious */ |
| 1874 | ath10k_warn(ar, "failed to disable pktlog: %d\n", ret); |
| 1875 | } |
| 1876 | |
Peter Oh | a7bd3e9 | 2014-12-02 13:07:14 +0200 | [diff] [blame] | 1877 | if (ar->debug.nf_cal_period) { |
| 1878 | ret = ath10k_wmi_pdev_set_param(ar, |
| 1879 | ar->wmi.pdev_param->cal_period, |
| 1880 | ar->debug.nf_cal_period); |
| 1881 | if (ret) |
| 1882 | /* not serious */ |
| 1883 | ath10k_warn(ar, "cal period cfg failed from debug start: %d\n", |
| 1884 | ret); |
| 1885 | } |
| 1886 | |
Rajkumar Manoharan | 9017445 | 2014-10-03 08:02:33 +0300 | [diff] [blame] | 1887 | return ret; |
Kalle Valo | db66ea0 | 2013-09-03 11:44:03 +0300 | [diff] [blame] | 1888 | } |
| 1889 | |
| 1890 | void ath10k_debug_stop(struct ath10k *ar) |
| 1891 | { |
Kalle Valo | 60631c5 | 2013-10-08 21:45:25 +0300 | [diff] [blame] | 1892 | lockdep_assert_held(&ar->conf_mutex); |
| 1893 | |
| 1894 | /* Must not use _sync to avoid deadlock, we do that in |
| 1895 | * ath10k_debug_destroy(). The check for htt_stats_mask is to avoid |
| 1896 | * warning from del_timer(). */ |
| 1897 | if (ar->debug.htt_stats_mask != 0) |
| 1898 | cancel_delayed_work(&ar->debug.htt_stats_dwork); |
Janusz Dziedzic | d385623 | 2014-06-02 21:19:46 +0300 | [diff] [blame] | 1899 | |
| 1900 | ar->debug.htt_max_amsdu = 0; |
| 1901 | ar->debug.htt_max_ampdu = 0; |
Rajkumar Manoharan | 9017445 | 2014-10-03 08:02:33 +0300 | [diff] [blame] | 1902 | |
| 1903 | ath10k_wmi_pdev_pktlog_disable(ar); |
Kalle Valo | db66ea0 | 2013-09-03 11:44:03 +0300 | [diff] [blame] | 1904 | } |
| 1905 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1906 | static ssize_t ath10k_write_simulate_radar(struct file *file, |
| 1907 | const char __user *user_buf, |
| 1908 | size_t count, loff_t *ppos) |
| 1909 | { |
| 1910 | struct ath10k *ar = file->private_data; |
| 1911 | |
| 1912 | ieee80211_radar_detected(ar->hw); |
| 1913 | |
| 1914 | return count; |
| 1915 | } |
| 1916 | |
| 1917 | static const struct file_operations fops_simulate_radar = { |
| 1918 | .write = ath10k_write_simulate_radar, |
| 1919 | .open = simple_open, |
| 1920 | .owner = THIS_MODULE, |
| 1921 | .llseek = default_llseek, |
| 1922 | }; |
| 1923 | |
| 1924 | #define ATH10K_DFS_STAT(s, p) (\ |
| 1925 | len += scnprintf(buf + len, size - len, "%-28s : %10u\n", s, \ |
| 1926 | ar->debug.dfs_stats.p)) |
| 1927 | |
| 1928 | #define ATH10K_DFS_POOL_STAT(s, p) (\ |
| 1929 | len += scnprintf(buf + len, size - len, "%-28s : %10u\n", s, \ |
| 1930 | ar->debug.dfs_pool_stats.p)) |
| 1931 | |
| 1932 | static ssize_t ath10k_read_dfs_stats(struct file *file, char __user *user_buf, |
| 1933 | size_t count, loff_t *ppos) |
| 1934 | { |
| 1935 | int retval = 0, len = 0; |
| 1936 | const int size = 8000; |
| 1937 | struct ath10k *ar = file->private_data; |
| 1938 | char *buf; |
| 1939 | |
| 1940 | buf = kzalloc(size, GFP_KERNEL); |
| 1941 | if (buf == NULL) |
| 1942 | return -ENOMEM; |
| 1943 | |
| 1944 | if (!ar->dfs_detector) { |
| 1945 | len += scnprintf(buf + len, size - len, "DFS not enabled\n"); |
| 1946 | goto exit; |
| 1947 | } |
| 1948 | |
| 1949 | ar->debug.dfs_pool_stats = |
| 1950 | ar->dfs_detector->get_stats(ar->dfs_detector); |
| 1951 | |
| 1952 | len += scnprintf(buf + len, size - len, "Pulse detector statistics:\n"); |
| 1953 | |
| 1954 | ATH10K_DFS_STAT("reported phy errors", phy_errors); |
| 1955 | ATH10K_DFS_STAT("pulse events reported", pulses_total); |
| 1956 | ATH10K_DFS_STAT("DFS pulses detected", pulses_detected); |
| 1957 | ATH10K_DFS_STAT("DFS pulses discarded", pulses_discarded); |
| 1958 | ATH10K_DFS_STAT("Radars detected", radar_detected); |
| 1959 | |
| 1960 | len += scnprintf(buf + len, size - len, "Global Pool statistics:\n"); |
| 1961 | ATH10K_DFS_POOL_STAT("Pool references", pool_reference); |
| 1962 | ATH10K_DFS_POOL_STAT("Pulses allocated", pulse_allocated); |
| 1963 | ATH10K_DFS_POOL_STAT("Pulses alloc error", pulse_alloc_error); |
| 1964 | ATH10K_DFS_POOL_STAT("Pulses in use", pulse_used); |
| 1965 | ATH10K_DFS_POOL_STAT("Seqs. allocated", pseq_allocated); |
| 1966 | ATH10K_DFS_POOL_STAT("Seqs. alloc error", pseq_alloc_error); |
| 1967 | ATH10K_DFS_POOL_STAT("Seqs. in use", pseq_used); |
| 1968 | |
| 1969 | exit: |
| 1970 | if (len > size) |
| 1971 | len = size; |
| 1972 | |
| 1973 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1974 | kfree(buf); |
| 1975 | |
| 1976 | return retval; |
| 1977 | } |
| 1978 | |
| 1979 | static const struct file_operations fops_dfs_stats = { |
| 1980 | .read = ath10k_read_dfs_stats, |
| 1981 | .open = simple_open, |
| 1982 | .owner = THIS_MODULE, |
| 1983 | .llseek = default_llseek, |
| 1984 | }; |
| 1985 | |
Rajkumar Manoharan | 9017445 | 2014-10-03 08:02:33 +0300 | [diff] [blame] | 1986 | static ssize_t ath10k_write_pktlog_filter(struct file *file, |
| 1987 | const char __user *ubuf, |
| 1988 | size_t count, loff_t *ppos) |
| 1989 | { |
| 1990 | struct ath10k *ar = file->private_data; |
| 1991 | u32 filter; |
| 1992 | int ret; |
| 1993 | |
| 1994 | if (kstrtouint_from_user(ubuf, count, 0, &filter)) |
| 1995 | return -EINVAL; |
| 1996 | |
| 1997 | mutex_lock(&ar->conf_mutex); |
| 1998 | |
| 1999 | if (ar->state != ATH10K_STATE_ON) { |
| 2000 | ar->debug.pktlog_filter = filter; |
| 2001 | ret = count; |
| 2002 | goto out; |
| 2003 | } |
| 2004 | |
| 2005 | if (filter && (filter != ar->debug.pktlog_filter)) { |
| 2006 | ret = ath10k_wmi_pdev_pktlog_enable(ar, filter); |
| 2007 | if (ret) { |
| 2008 | ath10k_warn(ar, "failed to enable pktlog filter %x: %d\n", |
| 2009 | ar->debug.pktlog_filter, ret); |
| 2010 | goto out; |
| 2011 | } |
| 2012 | } else { |
| 2013 | ret = ath10k_wmi_pdev_pktlog_disable(ar); |
| 2014 | if (ret) { |
| 2015 | ath10k_warn(ar, "failed to disable pktlog: %d\n", ret); |
| 2016 | goto out; |
| 2017 | } |
| 2018 | } |
| 2019 | |
| 2020 | ar->debug.pktlog_filter = filter; |
| 2021 | ret = count; |
| 2022 | |
| 2023 | out: |
| 2024 | mutex_unlock(&ar->conf_mutex); |
| 2025 | return ret; |
| 2026 | } |
| 2027 | |
| 2028 | static ssize_t ath10k_read_pktlog_filter(struct file *file, char __user *ubuf, |
| 2029 | size_t count, loff_t *ppos) |
| 2030 | { |
| 2031 | char buf[32]; |
| 2032 | struct ath10k *ar = file->private_data; |
| 2033 | int len = 0; |
| 2034 | |
| 2035 | mutex_lock(&ar->conf_mutex); |
| 2036 | len = scnprintf(buf, sizeof(buf) - len, "%08x\n", |
| 2037 | ar->debug.pktlog_filter); |
| 2038 | mutex_unlock(&ar->conf_mutex); |
| 2039 | |
| 2040 | return simple_read_from_buffer(ubuf, count, ppos, buf, len); |
| 2041 | } |
| 2042 | |
| 2043 | static const struct file_operations fops_pktlog_filter = { |
| 2044 | .read = ath10k_read_pktlog_filter, |
| 2045 | .write = ath10k_write_pktlog_filter, |
| 2046 | .open = simple_open |
| 2047 | }; |
| 2048 | |
Rajkumar Manoharan | 63fb32d | 2015-03-15 20:36:20 +0530 | [diff] [blame] | 2049 | static ssize_t ath10k_write_quiet_period(struct file *file, |
| 2050 | const char __user *ubuf, |
| 2051 | size_t count, loff_t *ppos) |
| 2052 | { |
| 2053 | struct ath10k *ar = file->private_data; |
| 2054 | u32 period; |
| 2055 | |
| 2056 | if (kstrtouint_from_user(ubuf, count, 0, &period)) |
| 2057 | return -EINVAL; |
| 2058 | |
| 2059 | if (period < ATH10K_QUIET_PERIOD_MIN) { |
| 2060 | ath10k_warn(ar, "Quiet period %u can not be lesser than 25ms\n", |
| 2061 | period); |
| 2062 | return -EINVAL; |
| 2063 | } |
| 2064 | mutex_lock(&ar->conf_mutex); |
| 2065 | ar->thermal.quiet_period = period; |
Rajkumar Manoharan | 8515b5c | 2015-03-15 20:36:22 +0530 | [diff] [blame] | 2066 | ath10k_thermal_set_throttling(ar); |
Rajkumar Manoharan | 63fb32d | 2015-03-15 20:36:20 +0530 | [diff] [blame] | 2067 | mutex_unlock(&ar->conf_mutex); |
| 2068 | |
| 2069 | return count; |
| 2070 | } |
| 2071 | |
| 2072 | static ssize_t ath10k_read_quiet_period(struct file *file, char __user *ubuf, |
| 2073 | size_t count, loff_t *ppos) |
| 2074 | { |
| 2075 | char buf[32]; |
| 2076 | struct ath10k *ar = file->private_data; |
| 2077 | int len = 0; |
| 2078 | |
| 2079 | mutex_lock(&ar->conf_mutex); |
| 2080 | len = scnprintf(buf, sizeof(buf) - len, "%d\n", |
| 2081 | ar->thermal.quiet_period); |
| 2082 | mutex_unlock(&ar->conf_mutex); |
| 2083 | |
| 2084 | return simple_read_from_buffer(ubuf, count, ppos, buf, len); |
| 2085 | } |
| 2086 | |
| 2087 | static const struct file_operations fops_quiet_period = { |
| 2088 | .read = ath10k_read_quiet_period, |
| 2089 | .write = ath10k_write_quiet_period, |
| 2090 | .open = simple_open |
| 2091 | }; |
| 2092 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2093 | int ath10k_debug_create(struct ath10k *ar) |
| 2094 | { |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 2095 | ar->debug.fw_crash_data = vzalloc(sizeof(*ar->debug.fw_crash_data)); |
Michal Kazior | e13cf7a | 2014-09-04 09:13:08 +0200 | [diff] [blame] | 2096 | if (!ar->debug.fw_crash_data) |
| 2097 | return -ENOMEM; |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 2098 | |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 2099 | INIT_LIST_HEAD(&ar->debug.fw_stats.pdevs); |
Michal Kazior | 7b6b153 | 2015-02-15 16:50:40 +0200 | [diff] [blame] | 2100 | INIT_LIST_HEAD(&ar->debug.fw_stats.vdevs); |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 2101 | INIT_LIST_HEAD(&ar->debug.fw_stats.peers); |
| 2102 | |
Michal Kazior | e13cf7a | 2014-09-04 09:13:08 +0200 | [diff] [blame] | 2103 | return 0; |
| 2104 | } |
| 2105 | |
| 2106 | void ath10k_debug_destroy(struct ath10k *ar) |
| 2107 | { |
| 2108 | vfree(ar->debug.fw_crash_data); |
| 2109 | ar->debug.fw_crash_data = NULL; |
Michal Kazior | 5326849 | 2014-09-25 12:33:50 +0200 | [diff] [blame] | 2110 | |
| 2111 | ath10k_debug_fw_stats_reset(ar); |
Michal Kazior | e13cf7a | 2014-09-04 09:13:08 +0200 | [diff] [blame] | 2112 | } |
| 2113 | |
| 2114 | int ath10k_debug_register(struct ath10k *ar) |
| 2115 | { |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2116 | ar->debug.debugfs_phy = debugfs_create_dir("ath10k", |
| 2117 | ar->hw->wiphy->debugfsdir); |
Michal Kazior | adb43b2 | 2014-09-04 12:36:45 +0200 | [diff] [blame] | 2118 | if (IS_ERR_OR_NULL(ar->debug.debugfs_phy)) { |
| 2119 | if (IS_ERR(ar->debug.debugfs_phy)) |
| 2120 | return PTR_ERR(ar->debug.debugfs_phy); |
Kalle Valo | d8bb26b | 2014-09-14 12:50:33 +0300 | [diff] [blame] | 2121 | |
| 2122 | return -ENOMEM; |
Michal Kazior | adb43b2 | 2014-09-04 12:36:45 +0200 | [diff] [blame] | 2123 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2124 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 2125 | INIT_DELAYED_WORK(&ar->debug.htt_stats_dwork, |
| 2126 | ath10k_debug_htt_stats_dwork); |
| 2127 | |
Michal Kazior | 60ef401 | 2014-09-25 12:33:48 +0200 | [diff] [blame] | 2128 | init_completion(&ar->debug.fw_stats_complete); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2129 | |
| 2130 | debugfs_create_file("fw_stats", S_IRUSR, ar->debug.debugfs_phy, ar, |
| 2131 | &fops_fw_stats); |
| 2132 | |
Ben Greear | f51dbe7 | 2014-09-29 14:41:46 +0300 | [diff] [blame] | 2133 | debugfs_create_file("fw_reset_stats", S_IRUSR, ar->debug.debugfs_phy, |
| 2134 | ar, &fops_fw_reset_stats); |
| 2135 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2136 | debugfs_create_file("wmi_services", S_IRUSR, ar->debug.debugfs_phy, ar, |
| 2137 | &fops_wmi_services); |
| 2138 | |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 2139 | debugfs_create_file("simulate_fw_crash", S_IRUSR, ar->debug.debugfs_phy, |
| 2140 | ar, &fops_simulate_fw_crash); |
| 2141 | |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 2142 | debugfs_create_file("fw_crash_dump", S_IRUSR, ar->debug.debugfs_phy, |
| 2143 | ar, &fops_fw_crash_dump); |
| 2144 | |
Yanbo Li | 077a380 | 2014-11-25 12:24:33 +0200 | [diff] [blame] | 2145 | debugfs_create_file("reg_addr", S_IRUSR | S_IWUSR, |
| 2146 | ar->debug.debugfs_phy, ar, &fops_reg_addr); |
| 2147 | |
| 2148 | debugfs_create_file("reg_value", S_IRUSR | S_IWUSR, |
| 2149 | ar->debug.debugfs_phy, ar, &fops_reg_value); |
| 2150 | |
Yanbo Li | 9f65ad2 | 2014-11-25 12:24:48 +0200 | [diff] [blame] | 2151 | debugfs_create_file("mem_value", S_IRUSR | S_IWUSR, |
| 2152 | ar->debug.debugfs_phy, ar, &fops_mem_value); |
| 2153 | |
Kalle Valo | 763b8cd | 2013-09-01 11:22:21 +0300 | [diff] [blame] | 2154 | debugfs_create_file("chip_id", S_IRUSR, ar->debug.debugfs_phy, |
| 2155 | ar, &fops_chip_id); |
| 2156 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 2157 | debugfs_create_file("htt_stats_mask", S_IRUSR, ar->debug.debugfs_phy, |
| 2158 | ar, &fops_htt_stats_mask); |
| 2159 | |
Janusz Dziedzic | d385623 | 2014-06-02 21:19:46 +0300 | [diff] [blame] | 2160 | debugfs_create_file("htt_max_amsdu_ampdu", S_IRUSR | S_IWUSR, |
| 2161 | ar->debug.debugfs_phy, ar, |
| 2162 | &fops_htt_max_amsdu_ampdu); |
| 2163 | |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 2164 | debugfs_create_file("fw_dbglog", S_IRUSR, ar->debug.debugfs_phy, |
| 2165 | ar, &fops_fw_dbglog); |
| 2166 | |
Kalle Valo | 7869b4f | 2014-09-24 14:16:58 +0300 | [diff] [blame] | 2167 | debugfs_create_file("cal_data", S_IRUSR, ar->debug.debugfs_phy, |
| 2168 | ar, &fops_cal_data); |
| 2169 | |
Ashok Raj Nagarajan | b3e71d7 | 2015-03-19 16:38:00 +0530 | [diff] [blame^] | 2170 | debugfs_create_file("ani_enable", S_IRUSR | S_IWUSR, |
| 2171 | ar->debug.debugfs_phy, ar, &fops_ani_enable); |
| 2172 | |
Peter Oh | a7bd3e9 | 2014-12-02 13:07:14 +0200 | [diff] [blame] | 2173 | debugfs_create_file("nf_cal_period", S_IRUSR | S_IWUSR, |
| 2174 | ar->debug.debugfs_phy, ar, &fops_nf_cal_period); |
| 2175 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2176 | if (config_enabled(CONFIG_ATH10K_DFS_CERTIFIED)) { |
| 2177 | debugfs_create_file("dfs_simulate_radar", S_IWUSR, |
| 2178 | ar->debug.debugfs_phy, ar, |
| 2179 | &fops_simulate_radar); |
| 2180 | |
Marek Puzyniak | 7d9b40b | 2013-11-20 10:00:28 +0200 | [diff] [blame] | 2181 | debugfs_create_bool("dfs_block_radar_events", S_IWUSR, |
| 2182 | ar->debug.debugfs_phy, |
| 2183 | &ar->dfs_block_radar_events); |
| 2184 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 2185 | debugfs_create_file("dfs_stats", S_IRUSR, |
| 2186 | ar->debug.debugfs_phy, ar, |
| 2187 | &fops_dfs_stats); |
| 2188 | } |
| 2189 | |
Rajkumar Manoharan | 9017445 | 2014-10-03 08:02:33 +0300 | [diff] [blame] | 2190 | debugfs_create_file("pktlog_filter", S_IRUGO | S_IWUSR, |
| 2191 | ar->debug.debugfs_phy, ar, &fops_pktlog_filter); |
| 2192 | |
Rajkumar Manoharan | 63fb32d | 2015-03-15 20:36:20 +0530 | [diff] [blame] | 2193 | debugfs_create_file("quiet_period", S_IRUGO | S_IWUSR, |
| 2194 | ar->debug.debugfs_phy, ar, &fops_quiet_period); |
| 2195 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2196 | return 0; |
| 2197 | } |
Kalle Valo | db66ea0 | 2013-09-03 11:44:03 +0300 | [diff] [blame] | 2198 | |
Michal Kazior | e13cf7a | 2014-09-04 09:13:08 +0200 | [diff] [blame] | 2199 | void ath10k_debug_unregister(struct ath10k *ar) |
Kalle Valo | 60631c5 | 2013-10-08 21:45:25 +0300 | [diff] [blame] | 2200 | { |
| 2201 | cancel_delayed_work_sync(&ar->debug.htt_stats_dwork); |
| 2202 | } |
| 2203 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2204 | #endif /* CONFIG_ATH10K_DEBUGFS */ |
| 2205 | |
| 2206 | #ifdef CONFIG_ATH10K_DEBUG |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2207 | void ath10k_dbg(struct ath10k *ar, enum ath10k_debug_mask mask, |
| 2208 | const char *fmt, ...) |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2209 | { |
| 2210 | struct va_format vaf; |
| 2211 | va_list args; |
| 2212 | |
| 2213 | va_start(args, fmt); |
| 2214 | |
| 2215 | vaf.fmt = fmt; |
| 2216 | vaf.va = &args; |
| 2217 | |
| 2218 | if (ath10k_debug_mask & mask) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2219 | dev_printk(KERN_DEBUG, ar->dev, "%pV", &vaf); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2220 | |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 2221 | trace_ath10k_log_dbg(ar, mask, &vaf); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2222 | |
| 2223 | va_end(args); |
| 2224 | } |
| 2225 | EXPORT_SYMBOL(ath10k_dbg); |
| 2226 | |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2227 | void ath10k_dbg_dump(struct ath10k *ar, |
| 2228 | enum ath10k_debug_mask mask, |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2229 | const char *msg, const char *prefix, |
| 2230 | const void *buf, size_t len) |
| 2231 | { |
Michal Kazior | 45724a8 | 2014-09-23 10:22:53 +0200 | [diff] [blame] | 2232 | char linebuf[256]; |
| 2233 | unsigned int linebuflen; |
| 2234 | const void *ptr; |
| 2235 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2236 | if (ath10k_debug_mask & mask) { |
| 2237 | if (msg) |
Michal Kazior | 7aa7a72 | 2014-08-25 12:09:38 +0200 | [diff] [blame] | 2238 | ath10k_dbg(ar, mask, "%s\n", msg); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2239 | |
Michal Kazior | 45724a8 | 2014-09-23 10:22:53 +0200 | [diff] [blame] | 2240 | for (ptr = buf; (ptr - buf) < len; ptr += 16) { |
| 2241 | linebuflen = 0; |
| 2242 | linebuflen += scnprintf(linebuf + linebuflen, |
| 2243 | sizeof(linebuf) - linebuflen, |
| 2244 | "%s%08x: ", |
| 2245 | (prefix ? prefix : ""), |
| 2246 | (unsigned int)(ptr - buf)); |
| 2247 | hex_dump_to_buffer(ptr, len - (ptr - buf), 16, 1, |
| 2248 | linebuf + linebuflen, |
| 2249 | sizeof(linebuf) - linebuflen, true); |
| 2250 | dev_printk(KERN_DEBUG, ar->dev, "%s\n", linebuf); |
| 2251 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2252 | } |
| 2253 | |
| 2254 | /* tracing code doesn't like null strings :/ */ |
Michal Kazior | d35a6c1 | 2014-09-02 11:00:21 +0300 | [diff] [blame] | 2255 | trace_ath10k_log_dbg_dump(ar, msg ? msg : "", prefix ? prefix : "", |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 2256 | buf, len); |
| 2257 | } |
| 2258 | EXPORT_SYMBOL(ath10k_dbg_dump); |
| 2259 | |
| 2260 | #endif /* CONFIG_ATH10K_DEBUG */ |