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/version.h> |
| 21 | #include <linux/vermagic.h> |
| 22 | #include <linux/vmalloc.h> |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 23 | |
| 24 | #include "core.h" |
| 25 | #include "debug.h" |
| 26 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 27 | /* ms */ |
| 28 | #define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000 |
| 29 | |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 30 | #define ATH10K_FW_CRASH_DUMP_VERSION 1 |
| 31 | |
| 32 | /** |
| 33 | * enum ath10k_fw_crash_dump_type - types of data in the dump file |
| 34 | * @ATH10K_FW_CRASH_DUMP_REGDUMP: Register crash dump in binary format |
| 35 | */ |
| 36 | enum ath10k_fw_crash_dump_type { |
| 37 | ATH10K_FW_CRASH_DUMP_REGISTERS = 0, |
| 38 | |
| 39 | ATH10K_FW_CRASH_DUMP_MAX, |
| 40 | }; |
| 41 | |
| 42 | struct ath10k_tlv_dump_data { |
| 43 | /* see ath10k_fw_crash_dump_type above */ |
| 44 | __le32 type; |
| 45 | |
| 46 | /* in bytes */ |
| 47 | __le32 tlv_len; |
| 48 | |
| 49 | /* pad to 32-bit boundaries as needed */ |
| 50 | u8 tlv_data[]; |
| 51 | } __packed; |
| 52 | |
| 53 | struct ath10k_dump_file_data { |
| 54 | /* dump file information */ |
| 55 | |
| 56 | /* "ATH10K-FW-DUMP" */ |
| 57 | char df_magic[16]; |
| 58 | |
| 59 | __le32 len; |
| 60 | |
| 61 | /* file dump version */ |
| 62 | __le32 version; |
| 63 | |
| 64 | /* some info we can get from ath10k struct that might help */ |
| 65 | |
| 66 | u8 uuid[16]; |
| 67 | |
| 68 | __le32 chip_id; |
| 69 | |
| 70 | /* 0 for now, in place for later hardware */ |
| 71 | __le32 bus_type; |
| 72 | |
| 73 | __le32 target_version; |
| 74 | __le32 fw_version_major; |
| 75 | __le32 fw_version_minor; |
| 76 | __le32 fw_version_release; |
| 77 | __le32 fw_version_build; |
| 78 | __le32 phy_capability; |
| 79 | __le32 hw_min_tx_power; |
| 80 | __le32 hw_max_tx_power; |
| 81 | __le32 ht_cap_info; |
| 82 | __le32 vht_cap_info; |
| 83 | __le32 num_rf_chains; |
| 84 | |
| 85 | /* firmware version string */ |
| 86 | char fw_ver[ETHTOOL_FWVERS_LEN]; |
| 87 | |
| 88 | /* Kernel related information */ |
| 89 | |
| 90 | /* time-of-day stamp */ |
| 91 | __le64 tv_sec; |
| 92 | |
| 93 | /* time-of-day stamp, nano-seconds */ |
| 94 | __le64 tv_nsec; |
| 95 | |
| 96 | /* LINUX_VERSION_CODE */ |
| 97 | __le32 kernel_ver_code; |
| 98 | |
| 99 | /* VERMAGIC_STRING */ |
| 100 | char kernel_ver[64]; |
| 101 | |
| 102 | /* room for growth w/out changing binary format */ |
| 103 | u8 unused[128]; |
| 104 | |
| 105 | /* struct ath10k_tlv_dump_data + more */ |
| 106 | u8 data[0]; |
| 107 | } __packed; |
| 108 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 109 | static int ath10k_printk(const char *level, const char *fmt, ...) |
| 110 | { |
| 111 | struct va_format vaf; |
| 112 | va_list args; |
| 113 | int rtn; |
| 114 | |
| 115 | va_start(args, fmt); |
| 116 | |
| 117 | vaf.fmt = fmt; |
| 118 | vaf.va = &args; |
| 119 | |
| 120 | rtn = printk("%sath10k: %pV", level, &vaf); |
| 121 | |
| 122 | va_end(args); |
| 123 | |
| 124 | return rtn; |
| 125 | } |
| 126 | |
| 127 | int ath10k_info(const char *fmt, ...) |
| 128 | { |
| 129 | struct va_format vaf = { |
| 130 | .fmt = fmt, |
| 131 | }; |
| 132 | va_list args; |
| 133 | int ret; |
| 134 | |
| 135 | va_start(args, fmt); |
| 136 | vaf.va = &args; |
| 137 | ret = ath10k_printk(KERN_INFO, "%pV", &vaf); |
| 138 | trace_ath10k_log_info(&vaf); |
| 139 | va_end(args); |
| 140 | |
| 141 | return ret; |
| 142 | } |
| 143 | EXPORT_SYMBOL(ath10k_info); |
| 144 | |
Kalle Valo | 8a0c797 | 2014-08-25 08:37:45 +0300 | [diff] [blame^] | 145 | void ath10k_print_driver_info(struct ath10k *ar) |
| 146 | { |
| 147 | ath10k_info("%s (0x%08x, 0x%08x) fw %s api %d htt %d.%d\n", |
| 148 | ar->hw_params.name, |
| 149 | ar->target_version, |
| 150 | ar->chip_id, |
| 151 | ar->hw->wiphy->fw_version, |
| 152 | ar->fw_api, |
| 153 | ar->htt.target_version_major, |
| 154 | ar->htt.target_version_minor); |
| 155 | ath10k_info("debug %d debugfs %d tracing %d dfs %d\n", |
| 156 | config_enabled(CONFIG_ATH10K_DEBUG), |
| 157 | config_enabled(CONFIG_ATH10K_DEBUGFS), |
| 158 | config_enabled(CONFIG_ATH10K_TRACING), |
| 159 | config_enabled(CONFIG_ATH10K_DFS_CERTIFIED)); |
| 160 | } |
| 161 | EXPORT_SYMBOL(ath10k_print_driver_info); |
| 162 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 163 | int ath10k_err(const char *fmt, ...) |
| 164 | { |
| 165 | struct va_format vaf = { |
| 166 | .fmt = fmt, |
| 167 | }; |
| 168 | va_list args; |
| 169 | int ret; |
| 170 | |
| 171 | va_start(args, fmt); |
| 172 | vaf.va = &args; |
| 173 | ret = ath10k_printk(KERN_ERR, "%pV", &vaf); |
| 174 | trace_ath10k_log_err(&vaf); |
| 175 | va_end(args); |
| 176 | |
| 177 | return ret; |
| 178 | } |
| 179 | EXPORT_SYMBOL(ath10k_err); |
| 180 | |
| 181 | int ath10k_warn(const char *fmt, ...) |
| 182 | { |
| 183 | struct va_format vaf = { |
| 184 | .fmt = fmt, |
| 185 | }; |
| 186 | va_list args; |
| 187 | int ret = 0; |
| 188 | |
| 189 | va_start(args, fmt); |
| 190 | vaf.va = &args; |
| 191 | |
| 192 | if (net_ratelimit()) |
| 193 | ret = ath10k_printk(KERN_WARNING, "%pV", &vaf); |
| 194 | |
| 195 | trace_ath10k_log_warn(&vaf); |
| 196 | |
| 197 | va_end(args); |
| 198 | |
| 199 | return ret; |
| 200 | } |
| 201 | EXPORT_SYMBOL(ath10k_warn); |
| 202 | |
| 203 | #ifdef CONFIG_ATH10K_DEBUGFS |
| 204 | |
| 205 | void ath10k_debug_read_service_map(struct ath10k *ar, |
| 206 | void *service_map, |
| 207 | size_t map_size) |
| 208 | { |
| 209 | memcpy(ar->debug.wmi_service_bitmap, service_map, map_size); |
| 210 | } |
| 211 | |
| 212 | static ssize_t ath10k_read_wmi_services(struct file *file, |
| 213 | char __user *user_buf, |
| 214 | size_t count, loff_t *ppos) |
| 215 | { |
| 216 | struct ath10k *ar = file->private_data; |
| 217 | char *buf; |
Michal Kazior | cff990c | 2014-08-04 09:18:33 +0300 | [diff] [blame] | 218 | unsigned int len = 0, buf_len = 4096; |
| 219 | const char *name; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 220 | ssize_t ret_cnt; |
Michal Kazior | cff990c | 2014-08-04 09:18:33 +0300 | [diff] [blame] | 221 | bool enabled; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 222 | int i; |
| 223 | |
| 224 | buf = kzalloc(buf_len, GFP_KERNEL); |
| 225 | if (!buf) |
| 226 | return -ENOMEM; |
| 227 | |
| 228 | mutex_lock(&ar->conf_mutex); |
| 229 | |
| 230 | if (len > buf_len) |
| 231 | len = buf_len; |
| 232 | |
Michal Kazior | cff990c | 2014-08-04 09:18:33 +0300 | [diff] [blame] | 233 | for (i = 0; i < WMI_MAX_SERVICE; i++) { |
| 234 | enabled = test_bit(i, ar->debug.wmi_service_bitmap); |
| 235 | name = wmi_service_name(i); |
| 236 | |
| 237 | if (!name) { |
| 238 | if (enabled) |
| 239 | len += scnprintf(buf + len, buf_len - len, |
| 240 | "%-40s %s (bit %d)\n", |
| 241 | "unknown", "enabled", i); |
| 242 | |
| 243 | continue; |
| 244 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 245 | |
| 246 | len += scnprintf(buf + len, buf_len - len, |
Michal Kazior | cff990c | 2014-08-04 09:18:33 +0300 | [diff] [blame] | 247 | "%-40s %s\n", |
| 248 | name, enabled ? "enabled" : "-"); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 252 | |
| 253 | mutex_unlock(&ar->conf_mutex); |
| 254 | |
| 255 | kfree(buf); |
| 256 | return ret_cnt; |
| 257 | } |
| 258 | |
| 259 | static const struct file_operations fops_wmi_services = { |
| 260 | .read = ath10k_read_wmi_services, |
| 261 | .open = simple_open, |
| 262 | .owner = THIS_MODULE, |
| 263 | .llseek = default_llseek, |
| 264 | }; |
| 265 | |
| 266 | void ath10k_debug_read_target_stats(struct ath10k *ar, |
| 267 | struct wmi_stats_event *ev) |
| 268 | { |
| 269 | u8 *tmp = ev->data; |
| 270 | struct ath10k_target_stats *stats; |
| 271 | int num_pdev_stats, num_vdev_stats, num_peer_stats; |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 272 | struct wmi_pdev_stats_10x *ps; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 273 | int i; |
| 274 | |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 275 | spin_lock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 276 | |
| 277 | stats = &ar->debug.target_stats; |
| 278 | |
| 279 | num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats); /* 0 or 1 */ |
| 280 | num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats); /* 0 or max vdevs */ |
| 281 | num_peer_stats = __le32_to_cpu(ev->num_peer_stats); /* 0 or max peers */ |
| 282 | |
| 283 | if (num_pdev_stats) { |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 284 | ps = (struct wmi_pdev_stats_10x *)tmp; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 285 | |
| 286 | stats->ch_noise_floor = __le32_to_cpu(ps->chan_nf); |
| 287 | stats->tx_frame_count = __le32_to_cpu(ps->tx_frame_count); |
| 288 | stats->rx_frame_count = __le32_to_cpu(ps->rx_frame_count); |
| 289 | stats->rx_clear_count = __le32_to_cpu(ps->rx_clear_count); |
| 290 | stats->cycle_count = __le32_to_cpu(ps->cycle_count); |
| 291 | stats->phy_err_count = __le32_to_cpu(ps->phy_err_count); |
| 292 | stats->chan_tx_power = __le32_to_cpu(ps->chan_tx_pwr); |
| 293 | |
| 294 | stats->comp_queued = __le32_to_cpu(ps->wal.tx.comp_queued); |
| 295 | stats->comp_delivered = |
| 296 | __le32_to_cpu(ps->wal.tx.comp_delivered); |
| 297 | stats->msdu_enqued = __le32_to_cpu(ps->wal.tx.msdu_enqued); |
| 298 | stats->mpdu_enqued = __le32_to_cpu(ps->wal.tx.mpdu_enqued); |
| 299 | stats->wmm_drop = __le32_to_cpu(ps->wal.tx.wmm_drop); |
| 300 | stats->local_enqued = __le32_to_cpu(ps->wal.tx.local_enqued); |
| 301 | stats->local_freed = __le32_to_cpu(ps->wal.tx.local_freed); |
| 302 | stats->hw_queued = __le32_to_cpu(ps->wal.tx.hw_queued); |
| 303 | stats->hw_reaped = __le32_to_cpu(ps->wal.tx.hw_reaped); |
| 304 | stats->underrun = __le32_to_cpu(ps->wal.tx.underrun); |
| 305 | stats->tx_abort = __le32_to_cpu(ps->wal.tx.tx_abort); |
| 306 | stats->mpdus_requed = __le32_to_cpu(ps->wal.tx.mpdus_requed); |
| 307 | stats->tx_ko = __le32_to_cpu(ps->wal.tx.tx_ko); |
| 308 | stats->data_rc = __le32_to_cpu(ps->wal.tx.data_rc); |
| 309 | stats->self_triggers = __le32_to_cpu(ps->wal.tx.self_triggers); |
| 310 | stats->sw_retry_failure = |
| 311 | __le32_to_cpu(ps->wal.tx.sw_retry_failure); |
| 312 | stats->illgl_rate_phy_err = |
| 313 | __le32_to_cpu(ps->wal.tx.illgl_rate_phy_err); |
| 314 | stats->pdev_cont_xretry = |
| 315 | __le32_to_cpu(ps->wal.tx.pdev_cont_xretry); |
| 316 | stats->pdev_tx_timeout = |
| 317 | __le32_to_cpu(ps->wal.tx.pdev_tx_timeout); |
| 318 | stats->pdev_resets = __le32_to_cpu(ps->wal.tx.pdev_resets); |
| 319 | stats->phy_underrun = __le32_to_cpu(ps->wal.tx.phy_underrun); |
| 320 | stats->txop_ovf = __le32_to_cpu(ps->wal.tx.txop_ovf); |
| 321 | |
| 322 | stats->mid_ppdu_route_change = |
| 323 | __le32_to_cpu(ps->wal.rx.mid_ppdu_route_change); |
| 324 | stats->status_rcvd = __le32_to_cpu(ps->wal.rx.status_rcvd); |
| 325 | stats->r0_frags = __le32_to_cpu(ps->wal.rx.r0_frags); |
| 326 | stats->r1_frags = __le32_to_cpu(ps->wal.rx.r1_frags); |
| 327 | stats->r2_frags = __le32_to_cpu(ps->wal.rx.r2_frags); |
| 328 | stats->r3_frags = __le32_to_cpu(ps->wal.rx.r3_frags); |
| 329 | stats->htt_msdus = __le32_to_cpu(ps->wal.rx.htt_msdus); |
| 330 | stats->htt_mpdus = __le32_to_cpu(ps->wal.rx.htt_mpdus); |
| 331 | stats->loc_msdus = __le32_to_cpu(ps->wal.rx.loc_msdus); |
| 332 | stats->loc_mpdus = __le32_to_cpu(ps->wal.rx.loc_mpdus); |
| 333 | stats->oversize_amsdu = |
| 334 | __le32_to_cpu(ps->wal.rx.oversize_amsdu); |
| 335 | stats->phy_errs = __le32_to_cpu(ps->wal.rx.phy_errs); |
| 336 | stats->phy_err_drop = __le32_to_cpu(ps->wal.rx.phy_err_drop); |
| 337 | stats->mpdu_errs = __le32_to_cpu(ps->wal.rx.mpdu_errs); |
| 338 | |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 339 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, |
| 340 | ar->fw_features)) { |
| 341 | stats->ack_rx_bad = __le32_to_cpu(ps->ack_rx_bad); |
| 342 | stats->rts_bad = __le32_to_cpu(ps->rts_bad); |
| 343 | stats->rts_good = __le32_to_cpu(ps->rts_good); |
| 344 | stats->fcs_bad = __le32_to_cpu(ps->fcs_bad); |
| 345 | stats->no_beacons = __le32_to_cpu(ps->no_beacons); |
| 346 | stats->mib_int_count = __le32_to_cpu(ps->mib_int_count); |
| 347 | tmp += sizeof(struct wmi_pdev_stats_10x); |
| 348 | } else { |
| 349 | tmp += sizeof(struct wmi_pdev_stats_old); |
| 350 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | /* 0 or max vdevs */ |
| 354 | /* Currently firmware does not support VDEV stats */ |
| 355 | if (num_vdev_stats) { |
| 356 | struct wmi_vdev_stats *vdev_stats; |
| 357 | |
| 358 | for (i = 0; i < num_vdev_stats; i++) { |
| 359 | vdev_stats = (struct wmi_vdev_stats *)tmp; |
| 360 | tmp += sizeof(struct wmi_vdev_stats); |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | if (num_peer_stats) { |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 365 | struct wmi_peer_stats_10x *peer_stats; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 366 | struct ath10k_peer_stat *s; |
| 367 | |
| 368 | stats->peers = num_peer_stats; |
| 369 | |
| 370 | for (i = 0; i < num_peer_stats; i++) { |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 371 | peer_stats = (struct wmi_peer_stats_10x *)tmp; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 372 | s = &stats->peer_stat[i]; |
| 373 | |
Chun-Yeow Yeoh | cf0fd56 | 2014-03-21 17:46:58 +0200 | [diff] [blame] | 374 | memcpy(s->peer_macaddr, &peer_stats->peer_macaddr.addr, |
| 375 | ETH_ALEN); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 376 | s->peer_rssi = __le32_to_cpu(peer_stats->peer_rssi); |
| 377 | s->peer_tx_rate = |
| 378 | __le32_to_cpu(peer_stats->peer_tx_rate); |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 379 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, |
| 380 | ar->fw_features)) { |
| 381 | s->peer_rx_rate = |
| 382 | __le32_to_cpu(peer_stats->peer_rx_rate); |
| 383 | tmp += sizeof(struct wmi_peer_stats_10x); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 384 | |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 385 | } else { |
| 386 | tmp += sizeof(struct wmi_peer_stats_old); |
| 387 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 388 | } |
| 389 | } |
| 390 | |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 391 | spin_unlock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 392 | complete(&ar->debug.event_stats_compl); |
| 393 | } |
| 394 | |
| 395 | static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf, |
| 396 | size_t count, loff_t *ppos) |
| 397 | { |
| 398 | struct ath10k *ar = file->private_data; |
| 399 | struct ath10k_target_stats *fw_stats; |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 400 | char *buf = NULL; |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 401 | unsigned int len = 0, buf_len = 8000; |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 402 | ssize_t ret_cnt = 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 403 | long left; |
| 404 | int i; |
| 405 | int ret; |
| 406 | |
| 407 | fw_stats = &ar->debug.target_stats; |
| 408 | |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 409 | mutex_lock(&ar->conf_mutex); |
| 410 | |
| 411 | if (ar->state != ATH10K_STATE_ON) |
| 412 | goto exit; |
| 413 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 414 | buf = kzalloc(buf_len, GFP_KERNEL); |
| 415 | if (!buf) |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 416 | goto exit; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 417 | |
| 418 | ret = ath10k_wmi_request_stats(ar, WMI_REQUEST_PEER_STAT); |
| 419 | if (ret) { |
| 420 | ath10k_warn("could not request stats (%d)\n", ret); |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 421 | goto exit; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | left = wait_for_completion_timeout(&ar->debug.event_stats_compl, 1*HZ); |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 425 | if (left <= 0) |
| 426 | goto exit; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 427 | |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 428 | spin_lock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 429 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 430 | len += scnprintf(buf + len, buf_len - len, "%30s\n", |
| 431 | "ath10k PDEV stats"); |
| 432 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 433 | "================="); |
| 434 | |
| 435 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 436 | "Channel noise floor", fw_stats->ch_noise_floor); |
| 437 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 438 | "Channel TX power", fw_stats->chan_tx_power); |
| 439 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 440 | "TX frame count", fw_stats->tx_frame_count); |
| 441 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 442 | "RX frame count", fw_stats->rx_frame_count); |
| 443 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 444 | "RX clear count", fw_stats->rx_clear_count); |
| 445 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 446 | "Cycle count", fw_stats->cycle_count); |
| 447 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 448 | "PHY error count", fw_stats->phy_err_count); |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 449 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 450 | "RTS bad count", fw_stats->rts_bad); |
| 451 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 452 | "RTS good count", fw_stats->rts_good); |
| 453 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 454 | "FCS bad count", fw_stats->fcs_bad); |
| 455 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 456 | "No beacon count", fw_stats->no_beacons); |
| 457 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 458 | "MIB int count", fw_stats->mib_int_count); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 459 | |
| 460 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 461 | len += scnprintf(buf + len, buf_len - len, "%30s\n", |
| 462 | "ath10k PDEV TX stats"); |
| 463 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 464 | "================="); |
| 465 | |
| 466 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 467 | "HTT cookies queued", fw_stats->comp_queued); |
| 468 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 469 | "HTT cookies disp.", fw_stats->comp_delivered); |
| 470 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 471 | "MSDU queued", fw_stats->msdu_enqued); |
| 472 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 473 | "MPDU queued", fw_stats->mpdu_enqued); |
| 474 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 475 | "MSDUs dropped", fw_stats->wmm_drop); |
| 476 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 477 | "Local enqued", fw_stats->local_enqued); |
| 478 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 479 | "Local freed", fw_stats->local_freed); |
| 480 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 481 | "HW queued", fw_stats->hw_queued); |
| 482 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 483 | "PPDUs reaped", fw_stats->hw_reaped); |
| 484 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 485 | "Num underruns", fw_stats->underrun); |
| 486 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 487 | "PPDUs cleaned", fw_stats->tx_abort); |
| 488 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 489 | "MPDUs requed", fw_stats->mpdus_requed); |
| 490 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 491 | "Excessive retries", fw_stats->tx_ko); |
| 492 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 493 | "HW rate", fw_stats->data_rc); |
| 494 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 495 | "Sched self tiggers", fw_stats->self_triggers); |
| 496 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 497 | "Dropped due to SW retries", |
| 498 | fw_stats->sw_retry_failure); |
| 499 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 500 | "Illegal rate phy errors", |
| 501 | fw_stats->illgl_rate_phy_err); |
| 502 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 503 | "Pdev continous xretry", fw_stats->pdev_cont_xretry); |
| 504 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 505 | "TX timeout", fw_stats->pdev_tx_timeout); |
| 506 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 507 | "PDEV resets", fw_stats->pdev_resets); |
| 508 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 509 | "PHY underrun", fw_stats->phy_underrun); |
| 510 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 511 | "MPDU is more than txop limit", fw_stats->txop_ovf); |
| 512 | |
| 513 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 514 | len += scnprintf(buf + len, buf_len - len, "%30s\n", |
| 515 | "ath10k PDEV RX stats"); |
| 516 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 517 | "================="); |
| 518 | |
| 519 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 520 | "Mid PPDU route change", |
| 521 | fw_stats->mid_ppdu_route_change); |
| 522 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 523 | "Tot. number of statuses", fw_stats->status_rcvd); |
| 524 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 525 | "Extra frags on rings 0", fw_stats->r0_frags); |
| 526 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 527 | "Extra frags on rings 1", fw_stats->r1_frags); |
| 528 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 529 | "Extra frags on rings 2", fw_stats->r2_frags); |
| 530 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 531 | "Extra frags on rings 3", fw_stats->r3_frags); |
| 532 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 533 | "MSDUs delivered to HTT", fw_stats->htt_msdus); |
| 534 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 535 | "MPDUs delivered to HTT", fw_stats->htt_mpdus); |
| 536 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 537 | "MSDUs delivered to stack", fw_stats->loc_msdus); |
| 538 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 539 | "MPDUs delivered to stack", fw_stats->loc_mpdus); |
| 540 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 541 | "Oversized AMSUs", fw_stats->oversize_amsdu); |
| 542 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 543 | "PHY errors", fw_stats->phy_errs); |
| 544 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 545 | "PHY errors drops", fw_stats->phy_err_drop); |
| 546 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 547 | "MPDU errors (FCS, MIC, ENC)", fw_stats->mpdu_errs); |
| 548 | |
| 549 | len += scnprintf(buf + len, buf_len - len, "\n"); |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 550 | len += scnprintf(buf + len, buf_len - len, "%30s (%d)\n", |
| 551 | "ath10k PEER stats", fw_stats->peers); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 552 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 553 | "================="); |
| 554 | |
| 555 | for (i = 0; i < fw_stats->peers; i++) { |
| 556 | len += scnprintf(buf + len, buf_len - len, "%30s %pM\n", |
| 557 | "Peer MAC address", |
| 558 | fw_stats->peer_stat[i].peer_macaddr); |
| 559 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 560 | "Peer RSSI", fw_stats->peer_stat[i].peer_rssi); |
| 561 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 562 | "Peer TX rate", |
| 563 | fw_stats->peer_stat[i].peer_tx_rate); |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 564 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 565 | "Peer RX rate", |
| 566 | fw_stats->peer_stat[i].peer_rx_rate); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 567 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 568 | } |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 569 | spin_unlock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 570 | |
| 571 | if (len > buf_len) |
| 572 | len = buf_len; |
| 573 | |
| 574 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 575 | |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 576 | exit: |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 577 | mutex_unlock(&ar->conf_mutex); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 578 | kfree(buf); |
| 579 | return ret_cnt; |
| 580 | } |
| 581 | |
| 582 | static const struct file_operations fops_fw_stats = { |
| 583 | .read = ath10k_read_fw_stats, |
| 584 | .open = simple_open, |
| 585 | .owner = THIS_MODULE, |
| 586 | .llseek = default_llseek, |
| 587 | }; |
| 588 | |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 589 | static ssize_t ath10k_read_simulate_fw_crash(struct file *file, |
| 590 | char __user *user_buf, |
| 591 | size_t count, loff_t *ppos) |
| 592 | { |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 593 | const char buf[] = "To simulate firmware crash write one of the" |
| 594 | " keywords to this file:\n `soft` - this will send" |
| 595 | " WMI_FORCE_FW_HANG_ASSERT to firmware if FW" |
| 596 | " supports that command.\n `hard` - this will send" |
| 597 | " to firmware command with illegal parameters" |
| 598 | " causing firmware crash.\n"; |
| 599 | |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 600 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
| 601 | } |
| 602 | |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 603 | /* Simulate firmware crash: |
| 604 | * 'soft': Call wmi command causing firmware hang. This firmware hang is |
| 605 | * recoverable by warm firmware reset. |
| 606 | * 'hard': Force firmware crash by setting any vdev parameter for not allowed |
| 607 | * vdev id. This is hard firmware crash because it is recoverable only by cold |
| 608 | * firmware reset. |
| 609 | */ |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 610 | static ssize_t ath10k_write_simulate_fw_crash(struct file *file, |
| 611 | const char __user *user_buf, |
| 612 | size_t count, loff_t *ppos) |
| 613 | { |
| 614 | struct ath10k *ar = file->private_data; |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 615 | char buf[32]; |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 616 | int ret; |
| 617 | |
| 618 | mutex_lock(&ar->conf_mutex); |
| 619 | |
| 620 | simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 621 | |
| 622 | /* make sure that buf is null terminated */ |
| 623 | buf[sizeof(buf) - 1] = 0; |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 624 | |
| 625 | if (ar->state != ATH10K_STATE_ON && |
| 626 | ar->state != ATH10K_STATE_RESTARTED) { |
| 627 | ret = -ENETDOWN; |
| 628 | goto exit; |
| 629 | } |
| 630 | |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 631 | /* drop the possible '\n' from the end */ |
| 632 | if (buf[count - 1] == '\n') { |
| 633 | buf[count - 1] = 0; |
| 634 | count--; |
| 635 | } |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 636 | |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 637 | if (!strcmp(buf, "soft")) { |
| 638 | ath10k_info("simulating soft firmware crash\n"); |
| 639 | ret = ath10k_wmi_force_fw_hang(ar, WMI_FORCE_FW_HANG_ASSERT, 0); |
| 640 | } else if (!strcmp(buf, "hard")) { |
| 641 | ath10k_info("simulating hard firmware crash\n"); |
Ben Greear | 611b368 | 2014-07-25 11:56:40 +0300 | [diff] [blame] | 642 | /* 0x7fff is vdev id, and it is always out of range for all |
| 643 | * firmware variants in order to force a firmware crash. |
| 644 | */ |
| 645 | ret = ath10k_wmi_vdev_set_param(ar, 0x7fff, |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 646 | ar->wmi.vdev_param->rts_threshold, 0); |
| 647 | } else { |
| 648 | ret = -EINVAL; |
| 649 | goto exit; |
| 650 | } |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 651 | |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 652 | if (ret) { |
| 653 | ath10k_warn("failed to simulate firmware crash: %d\n", ret); |
| 654 | goto exit; |
| 655 | } |
| 656 | |
| 657 | ret = count; |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 658 | |
| 659 | exit: |
| 660 | mutex_unlock(&ar->conf_mutex); |
| 661 | return ret; |
| 662 | } |
| 663 | |
| 664 | static const struct file_operations fops_simulate_fw_crash = { |
| 665 | .read = ath10k_read_simulate_fw_crash, |
| 666 | .write = ath10k_write_simulate_fw_crash, |
| 667 | .open = simple_open, |
| 668 | .owner = THIS_MODULE, |
| 669 | .llseek = default_llseek, |
| 670 | }; |
| 671 | |
Kalle Valo | 763b8cd | 2013-09-01 11:22:21 +0300 | [diff] [blame] | 672 | static ssize_t ath10k_read_chip_id(struct file *file, char __user *user_buf, |
| 673 | size_t count, loff_t *ppos) |
| 674 | { |
| 675 | struct ath10k *ar = file->private_data; |
| 676 | unsigned int len; |
| 677 | char buf[50]; |
| 678 | |
| 679 | len = scnprintf(buf, sizeof(buf), "0x%08x\n", ar->chip_id); |
| 680 | |
| 681 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 682 | } |
| 683 | |
| 684 | static const struct file_operations fops_chip_id = { |
| 685 | .read = ath10k_read_chip_id, |
| 686 | .open = simple_open, |
| 687 | .owner = THIS_MODULE, |
| 688 | .llseek = default_llseek, |
| 689 | }; |
| 690 | |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 691 | struct ath10k_fw_crash_data * |
| 692 | ath10k_debug_get_new_fw_crash_data(struct ath10k *ar) |
| 693 | { |
| 694 | struct ath10k_fw_crash_data *crash_data = ar->debug.fw_crash_data; |
| 695 | |
| 696 | lockdep_assert_held(&ar->data_lock); |
| 697 | |
| 698 | crash_data->crashed_since_read = true; |
| 699 | uuid_le_gen(&crash_data->uuid); |
| 700 | getnstimeofday(&crash_data->timestamp); |
| 701 | |
| 702 | return crash_data; |
| 703 | } |
| 704 | EXPORT_SYMBOL(ath10k_debug_get_new_fw_crash_data); |
| 705 | |
| 706 | static struct ath10k_dump_file_data *ath10k_build_dump_file(struct ath10k *ar) |
| 707 | { |
| 708 | struct ath10k_fw_crash_data *crash_data = ar->debug.fw_crash_data; |
| 709 | struct ath10k_dump_file_data *dump_data; |
| 710 | struct ath10k_tlv_dump_data *dump_tlv; |
| 711 | int hdr_len = sizeof(*dump_data); |
| 712 | unsigned int len, sofar = 0; |
| 713 | unsigned char *buf; |
| 714 | |
| 715 | len = hdr_len; |
| 716 | len += sizeof(*dump_tlv) + sizeof(crash_data->registers); |
| 717 | |
| 718 | sofar += hdr_len; |
| 719 | |
| 720 | /* This is going to get big when we start dumping FW RAM and such, |
| 721 | * so go ahead and use vmalloc. |
| 722 | */ |
| 723 | buf = vzalloc(len); |
| 724 | if (!buf) |
| 725 | return NULL; |
| 726 | |
| 727 | spin_lock_bh(&ar->data_lock); |
| 728 | |
| 729 | if (!crash_data->crashed_since_read) { |
| 730 | spin_unlock_bh(&ar->data_lock); |
| 731 | vfree(buf); |
| 732 | return NULL; |
| 733 | } |
| 734 | |
| 735 | dump_data = (struct ath10k_dump_file_data *)(buf); |
| 736 | strlcpy(dump_data->df_magic, "ATH10K-FW-DUMP", |
| 737 | sizeof(dump_data->df_magic)); |
| 738 | dump_data->len = cpu_to_le32(len); |
| 739 | |
| 740 | dump_data->version = cpu_to_le32(ATH10K_FW_CRASH_DUMP_VERSION); |
| 741 | |
| 742 | memcpy(dump_data->uuid, &crash_data->uuid, sizeof(dump_data->uuid)); |
| 743 | dump_data->chip_id = cpu_to_le32(ar->chip_id); |
| 744 | dump_data->bus_type = cpu_to_le32(0); |
| 745 | dump_data->target_version = cpu_to_le32(ar->target_version); |
| 746 | dump_data->fw_version_major = cpu_to_le32(ar->fw_version_major); |
| 747 | dump_data->fw_version_minor = cpu_to_le32(ar->fw_version_minor); |
| 748 | dump_data->fw_version_release = cpu_to_le32(ar->fw_version_release); |
| 749 | dump_data->fw_version_build = cpu_to_le32(ar->fw_version_build); |
| 750 | dump_data->phy_capability = cpu_to_le32(ar->phy_capability); |
| 751 | dump_data->hw_min_tx_power = cpu_to_le32(ar->hw_min_tx_power); |
| 752 | dump_data->hw_max_tx_power = cpu_to_le32(ar->hw_max_tx_power); |
| 753 | dump_data->ht_cap_info = cpu_to_le32(ar->ht_cap_info); |
| 754 | dump_data->vht_cap_info = cpu_to_le32(ar->vht_cap_info); |
| 755 | dump_data->num_rf_chains = cpu_to_le32(ar->num_rf_chains); |
| 756 | |
| 757 | strlcpy(dump_data->fw_ver, ar->hw->wiphy->fw_version, |
| 758 | sizeof(dump_data->fw_ver)); |
| 759 | |
| 760 | dump_data->kernel_ver_code = cpu_to_le32(LINUX_VERSION_CODE); |
| 761 | strlcpy(dump_data->kernel_ver, VERMAGIC_STRING, |
| 762 | sizeof(dump_data->kernel_ver)); |
| 763 | |
| 764 | dump_data->tv_sec = cpu_to_le64(crash_data->timestamp.tv_sec); |
| 765 | dump_data->tv_nsec = cpu_to_le64(crash_data->timestamp.tv_nsec); |
| 766 | |
| 767 | /* Gather crash-dump */ |
| 768 | dump_tlv = (struct ath10k_tlv_dump_data *)(buf + sofar); |
| 769 | dump_tlv->type = cpu_to_le32(ATH10K_FW_CRASH_DUMP_REGISTERS); |
| 770 | dump_tlv->tlv_len = cpu_to_le32(sizeof(crash_data->registers)); |
| 771 | memcpy(dump_tlv->tlv_data, &crash_data->registers, |
| 772 | sizeof(crash_data->registers)); |
| 773 | sofar += sizeof(*dump_tlv) + sizeof(crash_data->registers); |
| 774 | |
| 775 | ar->debug.fw_crash_data->crashed_since_read = false; |
| 776 | |
| 777 | spin_unlock_bh(&ar->data_lock); |
| 778 | |
| 779 | return dump_data; |
| 780 | } |
| 781 | |
| 782 | static int ath10k_fw_crash_dump_open(struct inode *inode, struct file *file) |
| 783 | { |
| 784 | struct ath10k *ar = inode->i_private; |
| 785 | struct ath10k_dump_file_data *dump; |
| 786 | |
| 787 | dump = ath10k_build_dump_file(ar); |
| 788 | if (!dump) |
| 789 | return -ENODATA; |
| 790 | |
| 791 | file->private_data = dump; |
| 792 | |
| 793 | return 0; |
| 794 | } |
| 795 | |
| 796 | static ssize_t ath10k_fw_crash_dump_read(struct file *file, |
| 797 | char __user *user_buf, |
| 798 | size_t count, loff_t *ppos) |
| 799 | { |
| 800 | struct ath10k_dump_file_data *dump_file = file->private_data; |
| 801 | |
| 802 | return simple_read_from_buffer(user_buf, count, ppos, |
| 803 | dump_file, |
| 804 | le32_to_cpu(dump_file->len)); |
| 805 | } |
| 806 | |
| 807 | static int ath10k_fw_crash_dump_release(struct inode *inode, |
| 808 | struct file *file) |
| 809 | { |
| 810 | vfree(file->private_data); |
| 811 | |
| 812 | return 0; |
| 813 | } |
| 814 | |
| 815 | static const struct file_operations fops_fw_crash_dump = { |
| 816 | .open = ath10k_fw_crash_dump_open, |
| 817 | .read = ath10k_fw_crash_dump_read, |
| 818 | .release = ath10k_fw_crash_dump_release, |
| 819 | .owner = THIS_MODULE, |
| 820 | .llseek = default_llseek, |
| 821 | }; |
| 822 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 823 | static int ath10k_debug_htt_stats_req(struct ath10k *ar) |
| 824 | { |
| 825 | u64 cookie; |
| 826 | int ret; |
| 827 | |
| 828 | lockdep_assert_held(&ar->conf_mutex); |
| 829 | |
| 830 | if (ar->debug.htt_stats_mask == 0) |
| 831 | /* htt stats are disabled */ |
| 832 | return 0; |
| 833 | |
| 834 | if (ar->state != ATH10K_STATE_ON) |
| 835 | return 0; |
| 836 | |
| 837 | cookie = get_jiffies_64(); |
| 838 | |
| 839 | ret = ath10k_htt_h2t_stats_req(&ar->htt, ar->debug.htt_stats_mask, |
| 840 | cookie); |
| 841 | if (ret) { |
| 842 | ath10k_warn("failed to send htt stats request: %d\n", ret); |
| 843 | return ret; |
| 844 | } |
| 845 | |
| 846 | queue_delayed_work(ar->workqueue, &ar->debug.htt_stats_dwork, |
| 847 | msecs_to_jiffies(ATH10K_DEBUG_HTT_STATS_INTERVAL)); |
| 848 | |
| 849 | return 0; |
| 850 | } |
| 851 | |
| 852 | static void ath10k_debug_htt_stats_dwork(struct work_struct *work) |
| 853 | { |
| 854 | struct ath10k *ar = container_of(work, struct ath10k, |
| 855 | debug.htt_stats_dwork.work); |
| 856 | |
| 857 | mutex_lock(&ar->conf_mutex); |
| 858 | |
| 859 | ath10k_debug_htt_stats_req(ar); |
| 860 | |
| 861 | mutex_unlock(&ar->conf_mutex); |
| 862 | } |
| 863 | |
| 864 | static ssize_t ath10k_read_htt_stats_mask(struct file *file, |
| 865 | char __user *user_buf, |
| 866 | size_t count, loff_t *ppos) |
| 867 | { |
| 868 | struct ath10k *ar = file->private_data; |
| 869 | char buf[32]; |
| 870 | unsigned int len; |
| 871 | |
| 872 | len = scnprintf(buf, sizeof(buf), "%lu\n", ar->debug.htt_stats_mask); |
| 873 | |
| 874 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 875 | } |
| 876 | |
| 877 | static ssize_t ath10k_write_htt_stats_mask(struct file *file, |
| 878 | const char __user *user_buf, |
| 879 | size_t count, loff_t *ppos) |
| 880 | { |
| 881 | struct ath10k *ar = file->private_data; |
| 882 | unsigned long mask; |
| 883 | int ret; |
| 884 | |
| 885 | ret = kstrtoul_from_user(user_buf, count, 0, &mask); |
| 886 | if (ret) |
| 887 | return ret; |
| 888 | |
| 889 | /* max 8 bit masks (for now) */ |
| 890 | if (mask > 0xff) |
| 891 | return -E2BIG; |
| 892 | |
| 893 | mutex_lock(&ar->conf_mutex); |
| 894 | |
| 895 | ar->debug.htt_stats_mask = mask; |
| 896 | |
| 897 | ret = ath10k_debug_htt_stats_req(ar); |
| 898 | if (ret) |
| 899 | goto out; |
| 900 | |
| 901 | ret = count; |
| 902 | |
| 903 | out: |
| 904 | mutex_unlock(&ar->conf_mutex); |
| 905 | |
| 906 | return ret; |
| 907 | } |
| 908 | |
| 909 | static const struct file_operations fops_htt_stats_mask = { |
| 910 | .read = ath10k_read_htt_stats_mask, |
| 911 | .write = ath10k_write_htt_stats_mask, |
| 912 | .open = simple_open, |
| 913 | .owner = THIS_MODULE, |
| 914 | .llseek = default_llseek, |
| 915 | }; |
| 916 | |
Janusz Dziedzic | d385623 | 2014-06-02 21:19:46 +0300 | [diff] [blame] | 917 | static ssize_t ath10k_read_htt_max_amsdu_ampdu(struct file *file, |
| 918 | char __user *user_buf, |
| 919 | size_t count, loff_t *ppos) |
| 920 | { |
| 921 | struct ath10k *ar = file->private_data; |
| 922 | char buf[64]; |
| 923 | u8 amsdu = 3, ampdu = 64; |
| 924 | unsigned int len; |
| 925 | |
| 926 | mutex_lock(&ar->conf_mutex); |
| 927 | |
| 928 | if (ar->debug.htt_max_amsdu) |
| 929 | amsdu = ar->debug.htt_max_amsdu; |
| 930 | |
| 931 | if (ar->debug.htt_max_ampdu) |
| 932 | ampdu = ar->debug.htt_max_ampdu; |
| 933 | |
| 934 | mutex_unlock(&ar->conf_mutex); |
| 935 | |
| 936 | len = scnprintf(buf, sizeof(buf), "%u %u\n", amsdu, ampdu); |
| 937 | |
| 938 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 939 | } |
| 940 | |
| 941 | static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct file *file, |
| 942 | const char __user *user_buf, |
| 943 | size_t count, loff_t *ppos) |
| 944 | { |
| 945 | struct ath10k *ar = file->private_data; |
| 946 | int res; |
| 947 | char buf[64]; |
| 948 | unsigned int amsdu, ampdu; |
| 949 | |
| 950 | simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); |
| 951 | |
| 952 | /* make sure that buf is null terminated */ |
| 953 | buf[sizeof(buf) - 1] = 0; |
| 954 | |
| 955 | res = sscanf(buf, "%u %u", &amsdu, &du); |
| 956 | |
| 957 | if (res != 2) |
| 958 | return -EINVAL; |
| 959 | |
| 960 | mutex_lock(&ar->conf_mutex); |
| 961 | |
| 962 | res = ath10k_htt_h2t_aggr_cfg_msg(&ar->htt, ampdu, amsdu); |
| 963 | if (res) |
| 964 | goto out; |
| 965 | |
| 966 | res = count; |
| 967 | ar->debug.htt_max_amsdu = amsdu; |
| 968 | ar->debug.htt_max_ampdu = ampdu; |
| 969 | |
| 970 | out: |
| 971 | mutex_unlock(&ar->conf_mutex); |
| 972 | return res; |
| 973 | } |
| 974 | |
| 975 | static const struct file_operations fops_htt_max_amsdu_ampdu = { |
| 976 | .read = ath10k_read_htt_max_amsdu_ampdu, |
| 977 | .write = ath10k_write_htt_max_amsdu_ampdu, |
| 978 | .open = simple_open, |
| 979 | .owner = THIS_MODULE, |
| 980 | .llseek = default_llseek, |
| 981 | }; |
| 982 | |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 983 | static ssize_t ath10k_read_fw_dbglog(struct file *file, |
| 984 | char __user *user_buf, |
| 985 | size_t count, loff_t *ppos) |
| 986 | { |
| 987 | struct ath10k *ar = file->private_data; |
| 988 | unsigned int len; |
| 989 | char buf[32]; |
| 990 | |
| 991 | len = scnprintf(buf, sizeof(buf), "0x%08x\n", |
| 992 | ar->debug.fw_dbglog_mask); |
| 993 | |
| 994 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 995 | } |
| 996 | |
| 997 | static ssize_t ath10k_write_fw_dbglog(struct file *file, |
| 998 | const char __user *user_buf, |
| 999 | size_t count, loff_t *ppos) |
| 1000 | { |
| 1001 | struct ath10k *ar = file->private_data; |
| 1002 | unsigned long mask; |
| 1003 | int ret; |
| 1004 | |
| 1005 | ret = kstrtoul_from_user(user_buf, count, 0, &mask); |
| 1006 | if (ret) |
| 1007 | return ret; |
| 1008 | |
| 1009 | mutex_lock(&ar->conf_mutex); |
| 1010 | |
| 1011 | ar->debug.fw_dbglog_mask = mask; |
| 1012 | |
| 1013 | if (ar->state == ATH10K_STATE_ON) { |
| 1014 | ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask); |
| 1015 | if (ret) { |
| 1016 | ath10k_warn("dbglog cfg failed from debugfs: %d\n", |
| 1017 | ret); |
| 1018 | goto exit; |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | ret = count; |
| 1023 | |
| 1024 | exit: |
| 1025 | mutex_unlock(&ar->conf_mutex); |
| 1026 | |
| 1027 | return ret; |
| 1028 | } |
| 1029 | |
| 1030 | static const struct file_operations fops_fw_dbglog = { |
| 1031 | .read = ath10k_read_fw_dbglog, |
| 1032 | .write = ath10k_write_fw_dbglog, |
| 1033 | .open = simple_open, |
| 1034 | .owner = THIS_MODULE, |
| 1035 | .llseek = default_llseek, |
| 1036 | }; |
| 1037 | |
Kalle Valo | db66ea0 | 2013-09-03 11:44:03 +0300 | [diff] [blame] | 1038 | int ath10k_debug_start(struct ath10k *ar) |
| 1039 | { |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 1040 | int ret; |
| 1041 | |
Kalle Valo | 60631c5 | 2013-10-08 21:45:25 +0300 | [diff] [blame] | 1042 | lockdep_assert_held(&ar->conf_mutex); |
| 1043 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 1044 | ret = ath10k_debug_htt_stats_req(ar); |
| 1045 | if (ret) |
| 1046 | /* continue normally anyway, this isn't serious */ |
| 1047 | ath10k_warn("failed to start htt stats workqueue: %d\n", ret); |
| 1048 | |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1049 | if (ar->debug.fw_dbglog_mask) { |
| 1050 | ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask); |
| 1051 | if (ret) |
| 1052 | /* not serious */ |
| 1053 | ath10k_warn("failed to enable dbglog during start: %d", |
| 1054 | ret); |
| 1055 | } |
| 1056 | |
Kalle Valo | db66ea0 | 2013-09-03 11:44:03 +0300 | [diff] [blame] | 1057 | return 0; |
| 1058 | } |
| 1059 | |
| 1060 | void ath10k_debug_stop(struct ath10k *ar) |
| 1061 | { |
Kalle Valo | 60631c5 | 2013-10-08 21:45:25 +0300 | [diff] [blame] | 1062 | lockdep_assert_held(&ar->conf_mutex); |
| 1063 | |
| 1064 | /* Must not use _sync to avoid deadlock, we do that in |
| 1065 | * ath10k_debug_destroy(). The check for htt_stats_mask is to avoid |
| 1066 | * warning from del_timer(). */ |
| 1067 | if (ar->debug.htt_stats_mask != 0) |
| 1068 | cancel_delayed_work(&ar->debug.htt_stats_dwork); |
Janusz Dziedzic | d385623 | 2014-06-02 21:19:46 +0300 | [diff] [blame] | 1069 | |
| 1070 | ar->debug.htt_max_amsdu = 0; |
| 1071 | ar->debug.htt_max_ampdu = 0; |
Kalle Valo | db66ea0 | 2013-09-03 11:44:03 +0300 | [diff] [blame] | 1072 | } |
| 1073 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1074 | static ssize_t ath10k_write_simulate_radar(struct file *file, |
| 1075 | const char __user *user_buf, |
| 1076 | size_t count, loff_t *ppos) |
| 1077 | { |
| 1078 | struct ath10k *ar = file->private_data; |
| 1079 | |
| 1080 | ieee80211_radar_detected(ar->hw); |
| 1081 | |
| 1082 | return count; |
| 1083 | } |
| 1084 | |
| 1085 | static const struct file_operations fops_simulate_radar = { |
| 1086 | .write = ath10k_write_simulate_radar, |
| 1087 | .open = simple_open, |
| 1088 | .owner = THIS_MODULE, |
| 1089 | .llseek = default_llseek, |
| 1090 | }; |
| 1091 | |
| 1092 | #define ATH10K_DFS_STAT(s, p) (\ |
| 1093 | len += scnprintf(buf + len, size - len, "%-28s : %10u\n", s, \ |
| 1094 | ar->debug.dfs_stats.p)) |
| 1095 | |
| 1096 | #define ATH10K_DFS_POOL_STAT(s, p) (\ |
| 1097 | len += scnprintf(buf + len, size - len, "%-28s : %10u\n", s, \ |
| 1098 | ar->debug.dfs_pool_stats.p)) |
| 1099 | |
| 1100 | static ssize_t ath10k_read_dfs_stats(struct file *file, char __user *user_buf, |
| 1101 | size_t count, loff_t *ppos) |
| 1102 | { |
| 1103 | int retval = 0, len = 0; |
| 1104 | const int size = 8000; |
| 1105 | struct ath10k *ar = file->private_data; |
| 1106 | char *buf; |
| 1107 | |
| 1108 | buf = kzalloc(size, GFP_KERNEL); |
| 1109 | if (buf == NULL) |
| 1110 | return -ENOMEM; |
| 1111 | |
| 1112 | if (!ar->dfs_detector) { |
| 1113 | len += scnprintf(buf + len, size - len, "DFS not enabled\n"); |
| 1114 | goto exit; |
| 1115 | } |
| 1116 | |
| 1117 | ar->debug.dfs_pool_stats = |
| 1118 | ar->dfs_detector->get_stats(ar->dfs_detector); |
| 1119 | |
| 1120 | len += scnprintf(buf + len, size - len, "Pulse detector statistics:\n"); |
| 1121 | |
| 1122 | ATH10K_DFS_STAT("reported phy errors", phy_errors); |
| 1123 | ATH10K_DFS_STAT("pulse events reported", pulses_total); |
| 1124 | ATH10K_DFS_STAT("DFS pulses detected", pulses_detected); |
| 1125 | ATH10K_DFS_STAT("DFS pulses discarded", pulses_discarded); |
| 1126 | ATH10K_DFS_STAT("Radars detected", radar_detected); |
| 1127 | |
| 1128 | len += scnprintf(buf + len, size - len, "Global Pool statistics:\n"); |
| 1129 | ATH10K_DFS_POOL_STAT("Pool references", pool_reference); |
| 1130 | ATH10K_DFS_POOL_STAT("Pulses allocated", pulse_allocated); |
| 1131 | ATH10K_DFS_POOL_STAT("Pulses alloc error", pulse_alloc_error); |
| 1132 | ATH10K_DFS_POOL_STAT("Pulses in use", pulse_used); |
| 1133 | ATH10K_DFS_POOL_STAT("Seqs. allocated", pseq_allocated); |
| 1134 | ATH10K_DFS_POOL_STAT("Seqs. alloc error", pseq_alloc_error); |
| 1135 | ATH10K_DFS_POOL_STAT("Seqs. in use", pseq_used); |
| 1136 | |
| 1137 | exit: |
| 1138 | if (len > size) |
| 1139 | len = size; |
| 1140 | |
| 1141 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 1142 | kfree(buf); |
| 1143 | |
| 1144 | return retval; |
| 1145 | } |
| 1146 | |
| 1147 | static const struct file_operations fops_dfs_stats = { |
| 1148 | .read = ath10k_read_dfs_stats, |
| 1149 | .open = simple_open, |
| 1150 | .owner = THIS_MODULE, |
| 1151 | .llseek = default_llseek, |
| 1152 | }; |
| 1153 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1154 | int ath10k_debug_create(struct ath10k *ar) |
| 1155 | { |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1156 | int ret; |
| 1157 | |
| 1158 | ar->debug.fw_crash_data = vzalloc(sizeof(*ar->debug.fw_crash_data)); |
| 1159 | if (!ar->debug.fw_crash_data) { |
| 1160 | ret = -ENOMEM; |
| 1161 | goto err; |
| 1162 | } |
| 1163 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1164 | ar->debug.debugfs_phy = debugfs_create_dir("ath10k", |
| 1165 | ar->hw->wiphy->debugfsdir); |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1166 | if (!ar->debug.debugfs_phy) { |
| 1167 | ret = -ENOMEM; |
| 1168 | goto err_free_fw_crash_data; |
| 1169 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1170 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 1171 | INIT_DELAYED_WORK(&ar->debug.htt_stats_dwork, |
| 1172 | ath10k_debug_htt_stats_dwork); |
| 1173 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1174 | init_completion(&ar->debug.event_stats_compl); |
| 1175 | |
| 1176 | debugfs_create_file("fw_stats", S_IRUSR, ar->debug.debugfs_phy, ar, |
| 1177 | &fops_fw_stats); |
| 1178 | |
| 1179 | debugfs_create_file("wmi_services", S_IRUSR, ar->debug.debugfs_phy, ar, |
| 1180 | &fops_wmi_services); |
| 1181 | |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 1182 | debugfs_create_file("simulate_fw_crash", S_IRUSR, ar->debug.debugfs_phy, |
| 1183 | ar, &fops_simulate_fw_crash); |
| 1184 | |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1185 | debugfs_create_file("fw_crash_dump", S_IRUSR, ar->debug.debugfs_phy, |
| 1186 | ar, &fops_fw_crash_dump); |
| 1187 | |
Kalle Valo | 763b8cd | 2013-09-01 11:22:21 +0300 | [diff] [blame] | 1188 | debugfs_create_file("chip_id", S_IRUSR, ar->debug.debugfs_phy, |
| 1189 | ar, &fops_chip_id); |
| 1190 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 1191 | debugfs_create_file("htt_stats_mask", S_IRUSR, ar->debug.debugfs_phy, |
| 1192 | ar, &fops_htt_stats_mask); |
| 1193 | |
Janusz Dziedzic | d385623 | 2014-06-02 21:19:46 +0300 | [diff] [blame] | 1194 | debugfs_create_file("htt_max_amsdu_ampdu", S_IRUSR | S_IWUSR, |
| 1195 | ar->debug.debugfs_phy, ar, |
| 1196 | &fops_htt_max_amsdu_ampdu); |
| 1197 | |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 1198 | debugfs_create_file("fw_dbglog", S_IRUSR, ar->debug.debugfs_phy, |
| 1199 | ar, &fops_fw_dbglog); |
| 1200 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1201 | if (config_enabled(CONFIG_ATH10K_DFS_CERTIFIED)) { |
| 1202 | debugfs_create_file("dfs_simulate_radar", S_IWUSR, |
| 1203 | ar->debug.debugfs_phy, ar, |
| 1204 | &fops_simulate_radar); |
| 1205 | |
Marek Puzyniak | 7d9b40b | 2013-11-20 10:00:28 +0200 | [diff] [blame] | 1206 | debugfs_create_bool("dfs_block_radar_events", S_IWUSR, |
| 1207 | ar->debug.debugfs_phy, |
| 1208 | &ar->dfs_block_radar_events); |
| 1209 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 1210 | debugfs_create_file("dfs_stats", S_IRUSR, |
| 1211 | ar->debug.debugfs_phy, ar, |
| 1212 | &fops_dfs_stats); |
| 1213 | } |
| 1214 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1215 | return 0; |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1216 | |
| 1217 | err_free_fw_crash_data: |
| 1218 | vfree(ar->debug.fw_crash_data); |
| 1219 | |
| 1220 | err: |
| 1221 | return ret; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1222 | } |
Kalle Valo | db66ea0 | 2013-09-03 11:44:03 +0300 | [diff] [blame] | 1223 | |
Kalle Valo | 60631c5 | 2013-10-08 21:45:25 +0300 | [diff] [blame] | 1224 | void ath10k_debug_destroy(struct ath10k *ar) |
| 1225 | { |
Ben Greear | 384914b | 2014-08-25 08:37:32 +0300 | [diff] [blame] | 1226 | vfree(ar->debug.fw_crash_data); |
Kalle Valo | 60631c5 | 2013-10-08 21:45:25 +0300 | [diff] [blame] | 1227 | cancel_delayed_work_sync(&ar->debug.htt_stats_dwork); |
| 1228 | } |
| 1229 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 1230 | #endif /* CONFIG_ATH10K_DEBUGFS */ |
| 1231 | |
| 1232 | #ifdef CONFIG_ATH10K_DEBUG |
| 1233 | void ath10k_dbg(enum ath10k_debug_mask mask, const char *fmt, ...) |
| 1234 | { |
| 1235 | struct va_format vaf; |
| 1236 | va_list args; |
| 1237 | |
| 1238 | va_start(args, fmt); |
| 1239 | |
| 1240 | vaf.fmt = fmt; |
| 1241 | vaf.va = &args; |
| 1242 | |
| 1243 | if (ath10k_debug_mask & mask) |
| 1244 | ath10k_printk(KERN_DEBUG, "%pV", &vaf); |
| 1245 | |
| 1246 | trace_ath10k_log_dbg(mask, &vaf); |
| 1247 | |
| 1248 | va_end(args); |
| 1249 | } |
| 1250 | EXPORT_SYMBOL(ath10k_dbg); |
| 1251 | |
| 1252 | void ath10k_dbg_dump(enum ath10k_debug_mask mask, |
| 1253 | const char *msg, const char *prefix, |
| 1254 | const void *buf, size_t len) |
| 1255 | { |
| 1256 | if (ath10k_debug_mask & mask) { |
| 1257 | if (msg) |
| 1258 | ath10k_dbg(mask, "%s\n", msg); |
| 1259 | |
| 1260 | print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, buf, len); |
| 1261 | } |
| 1262 | |
| 1263 | /* tracing code doesn't like null strings :/ */ |
| 1264 | trace_ath10k_log_dbg_dump(msg ? msg : "", prefix ? prefix : "", |
| 1265 | buf, len); |
| 1266 | } |
| 1267 | EXPORT_SYMBOL(ath10k_dbg_dump); |
| 1268 | |
| 1269 | #endif /* CONFIG_ATH10K_DEBUG */ |