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> |
| 20 | |
| 21 | #include "core.h" |
| 22 | #include "debug.h" |
| 23 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 24 | /* ms */ |
| 25 | #define ATH10K_DEBUG_HTT_STATS_INTERVAL 1000 |
| 26 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 27 | static int ath10k_printk(const char *level, const char *fmt, ...) |
| 28 | { |
| 29 | struct va_format vaf; |
| 30 | va_list args; |
| 31 | int rtn; |
| 32 | |
| 33 | va_start(args, fmt); |
| 34 | |
| 35 | vaf.fmt = fmt; |
| 36 | vaf.va = &args; |
| 37 | |
| 38 | rtn = printk("%sath10k: %pV", level, &vaf); |
| 39 | |
| 40 | va_end(args); |
| 41 | |
| 42 | return rtn; |
| 43 | } |
| 44 | |
| 45 | int ath10k_info(const char *fmt, ...) |
| 46 | { |
| 47 | struct va_format vaf = { |
| 48 | .fmt = fmt, |
| 49 | }; |
| 50 | va_list args; |
| 51 | int ret; |
| 52 | |
| 53 | va_start(args, fmt); |
| 54 | vaf.va = &args; |
| 55 | ret = ath10k_printk(KERN_INFO, "%pV", &vaf); |
| 56 | trace_ath10k_log_info(&vaf); |
| 57 | va_end(args); |
| 58 | |
| 59 | return ret; |
| 60 | } |
| 61 | EXPORT_SYMBOL(ath10k_info); |
| 62 | |
| 63 | int ath10k_err(const char *fmt, ...) |
| 64 | { |
| 65 | struct va_format vaf = { |
| 66 | .fmt = fmt, |
| 67 | }; |
| 68 | va_list args; |
| 69 | int ret; |
| 70 | |
| 71 | va_start(args, fmt); |
| 72 | vaf.va = &args; |
| 73 | ret = ath10k_printk(KERN_ERR, "%pV", &vaf); |
| 74 | trace_ath10k_log_err(&vaf); |
| 75 | va_end(args); |
| 76 | |
| 77 | return ret; |
| 78 | } |
| 79 | EXPORT_SYMBOL(ath10k_err); |
| 80 | |
| 81 | int ath10k_warn(const char *fmt, ...) |
| 82 | { |
| 83 | struct va_format vaf = { |
| 84 | .fmt = fmt, |
| 85 | }; |
| 86 | va_list args; |
| 87 | int ret = 0; |
| 88 | |
| 89 | va_start(args, fmt); |
| 90 | vaf.va = &args; |
| 91 | |
| 92 | if (net_ratelimit()) |
| 93 | ret = ath10k_printk(KERN_WARNING, "%pV", &vaf); |
| 94 | |
| 95 | trace_ath10k_log_warn(&vaf); |
| 96 | |
| 97 | va_end(args); |
| 98 | |
| 99 | return ret; |
| 100 | } |
| 101 | EXPORT_SYMBOL(ath10k_warn); |
| 102 | |
| 103 | #ifdef CONFIG_ATH10K_DEBUGFS |
| 104 | |
| 105 | void ath10k_debug_read_service_map(struct ath10k *ar, |
| 106 | void *service_map, |
| 107 | size_t map_size) |
| 108 | { |
| 109 | memcpy(ar->debug.wmi_service_bitmap, service_map, map_size); |
| 110 | } |
| 111 | |
| 112 | static ssize_t ath10k_read_wmi_services(struct file *file, |
| 113 | char __user *user_buf, |
| 114 | size_t count, loff_t *ppos) |
| 115 | { |
| 116 | struct ath10k *ar = file->private_data; |
| 117 | char *buf; |
| 118 | unsigned int len = 0, buf_len = 1500; |
| 119 | const char *status; |
| 120 | ssize_t ret_cnt; |
| 121 | int i; |
| 122 | |
| 123 | buf = kzalloc(buf_len, GFP_KERNEL); |
| 124 | if (!buf) |
| 125 | return -ENOMEM; |
| 126 | |
| 127 | mutex_lock(&ar->conf_mutex); |
| 128 | |
| 129 | if (len > buf_len) |
| 130 | len = buf_len; |
| 131 | |
| 132 | for (i = 0; i < WMI_SERVICE_LAST; i++) { |
| 133 | if (WMI_SERVICE_IS_ENABLED(ar->debug.wmi_service_bitmap, i)) |
| 134 | status = "enabled"; |
| 135 | else |
| 136 | status = "disabled"; |
| 137 | |
| 138 | len += scnprintf(buf + len, buf_len - len, |
| 139 | "0x%02x - %20s - %s\n", |
| 140 | i, wmi_service_name(i), status); |
| 141 | } |
| 142 | |
| 143 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 144 | |
| 145 | mutex_unlock(&ar->conf_mutex); |
| 146 | |
| 147 | kfree(buf); |
| 148 | return ret_cnt; |
| 149 | } |
| 150 | |
| 151 | static const struct file_operations fops_wmi_services = { |
| 152 | .read = ath10k_read_wmi_services, |
| 153 | .open = simple_open, |
| 154 | .owner = THIS_MODULE, |
| 155 | .llseek = default_llseek, |
| 156 | }; |
| 157 | |
| 158 | void ath10k_debug_read_target_stats(struct ath10k *ar, |
| 159 | struct wmi_stats_event *ev) |
| 160 | { |
| 161 | u8 *tmp = ev->data; |
| 162 | struct ath10k_target_stats *stats; |
| 163 | int num_pdev_stats, num_vdev_stats, num_peer_stats; |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 164 | struct wmi_pdev_stats_10x *ps; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 165 | int i; |
| 166 | |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 167 | spin_lock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 168 | |
| 169 | stats = &ar->debug.target_stats; |
| 170 | |
| 171 | num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats); /* 0 or 1 */ |
| 172 | num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats); /* 0 or max vdevs */ |
| 173 | num_peer_stats = __le32_to_cpu(ev->num_peer_stats); /* 0 or max peers */ |
| 174 | |
| 175 | if (num_pdev_stats) { |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 176 | ps = (struct wmi_pdev_stats_10x *)tmp; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 177 | |
| 178 | stats->ch_noise_floor = __le32_to_cpu(ps->chan_nf); |
| 179 | stats->tx_frame_count = __le32_to_cpu(ps->tx_frame_count); |
| 180 | stats->rx_frame_count = __le32_to_cpu(ps->rx_frame_count); |
| 181 | stats->rx_clear_count = __le32_to_cpu(ps->rx_clear_count); |
| 182 | stats->cycle_count = __le32_to_cpu(ps->cycle_count); |
| 183 | stats->phy_err_count = __le32_to_cpu(ps->phy_err_count); |
| 184 | stats->chan_tx_power = __le32_to_cpu(ps->chan_tx_pwr); |
| 185 | |
| 186 | stats->comp_queued = __le32_to_cpu(ps->wal.tx.comp_queued); |
| 187 | stats->comp_delivered = |
| 188 | __le32_to_cpu(ps->wal.tx.comp_delivered); |
| 189 | stats->msdu_enqued = __le32_to_cpu(ps->wal.tx.msdu_enqued); |
| 190 | stats->mpdu_enqued = __le32_to_cpu(ps->wal.tx.mpdu_enqued); |
| 191 | stats->wmm_drop = __le32_to_cpu(ps->wal.tx.wmm_drop); |
| 192 | stats->local_enqued = __le32_to_cpu(ps->wal.tx.local_enqued); |
| 193 | stats->local_freed = __le32_to_cpu(ps->wal.tx.local_freed); |
| 194 | stats->hw_queued = __le32_to_cpu(ps->wal.tx.hw_queued); |
| 195 | stats->hw_reaped = __le32_to_cpu(ps->wal.tx.hw_reaped); |
| 196 | stats->underrun = __le32_to_cpu(ps->wal.tx.underrun); |
| 197 | stats->tx_abort = __le32_to_cpu(ps->wal.tx.tx_abort); |
| 198 | stats->mpdus_requed = __le32_to_cpu(ps->wal.tx.mpdus_requed); |
| 199 | stats->tx_ko = __le32_to_cpu(ps->wal.tx.tx_ko); |
| 200 | stats->data_rc = __le32_to_cpu(ps->wal.tx.data_rc); |
| 201 | stats->self_triggers = __le32_to_cpu(ps->wal.tx.self_triggers); |
| 202 | stats->sw_retry_failure = |
| 203 | __le32_to_cpu(ps->wal.tx.sw_retry_failure); |
| 204 | stats->illgl_rate_phy_err = |
| 205 | __le32_to_cpu(ps->wal.tx.illgl_rate_phy_err); |
| 206 | stats->pdev_cont_xretry = |
| 207 | __le32_to_cpu(ps->wal.tx.pdev_cont_xretry); |
| 208 | stats->pdev_tx_timeout = |
| 209 | __le32_to_cpu(ps->wal.tx.pdev_tx_timeout); |
| 210 | stats->pdev_resets = __le32_to_cpu(ps->wal.tx.pdev_resets); |
| 211 | stats->phy_underrun = __le32_to_cpu(ps->wal.tx.phy_underrun); |
| 212 | stats->txop_ovf = __le32_to_cpu(ps->wal.tx.txop_ovf); |
| 213 | |
| 214 | stats->mid_ppdu_route_change = |
| 215 | __le32_to_cpu(ps->wal.rx.mid_ppdu_route_change); |
| 216 | stats->status_rcvd = __le32_to_cpu(ps->wal.rx.status_rcvd); |
| 217 | stats->r0_frags = __le32_to_cpu(ps->wal.rx.r0_frags); |
| 218 | stats->r1_frags = __le32_to_cpu(ps->wal.rx.r1_frags); |
| 219 | stats->r2_frags = __le32_to_cpu(ps->wal.rx.r2_frags); |
| 220 | stats->r3_frags = __le32_to_cpu(ps->wal.rx.r3_frags); |
| 221 | stats->htt_msdus = __le32_to_cpu(ps->wal.rx.htt_msdus); |
| 222 | stats->htt_mpdus = __le32_to_cpu(ps->wal.rx.htt_mpdus); |
| 223 | stats->loc_msdus = __le32_to_cpu(ps->wal.rx.loc_msdus); |
| 224 | stats->loc_mpdus = __le32_to_cpu(ps->wal.rx.loc_mpdus); |
| 225 | stats->oversize_amsdu = |
| 226 | __le32_to_cpu(ps->wal.rx.oversize_amsdu); |
| 227 | stats->phy_errs = __le32_to_cpu(ps->wal.rx.phy_errs); |
| 228 | stats->phy_err_drop = __le32_to_cpu(ps->wal.rx.phy_err_drop); |
| 229 | stats->mpdu_errs = __le32_to_cpu(ps->wal.rx.mpdu_errs); |
| 230 | |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 231 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, |
| 232 | ar->fw_features)) { |
| 233 | stats->ack_rx_bad = __le32_to_cpu(ps->ack_rx_bad); |
| 234 | stats->rts_bad = __le32_to_cpu(ps->rts_bad); |
| 235 | stats->rts_good = __le32_to_cpu(ps->rts_good); |
| 236 | stats->fcs_bad = __le32_to_cpu(ps->fcs_bad); |
| 237 | stats->no_beacons = __le32_to_cpu(ps->no_beacons); |
| 238 | stats->mib_int_count = __le32_to_cpu(ps->mib_int_count); |
| 239 | tmp += sizeof(struct wmi_pdev_stats_10x); |
| 240 | } else { |
| 241 | tmp += sizeof(struct wmi_pdev_stats_old); |
| 242 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | /* 0 or max vdevs */ |
| 246 | /* Currently firmware does not support VDEV stats */ |
| 247 | if (num_vdev_stats) { |
| 248 | struct wmi_vdev_stats *vdev_stats; |
| 249 | |
| 250 | for (i = 0; i < num_vdev_stats; i++) { |
| 251 | vdev_stats = (struct wmi_vdev_stats *)tmp; |
| 252 | tmp += sizeof(struct wmi_vdev_stats); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | if (num_peer_stats) { |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 257 | struct wmi_peer_stats_10x *peer_stats; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 258 | struct ath10k_peer_stat *s; |
| 259 | |
| 260 | stats->peers = num_peer_stats; |
| 261 | |
| 262 | for (i = 0; i < num_peer_stats; i++) { |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 263 | peer_stats = (struct wmi_peer_stats_10x *)tmp; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 264 | s = &stats->peer_stat[i]; |
| 265 | |
Chun-Yeow Yeoh | cf0fd56 | 2014-03-21 17:46:58 +0200 | [diff] [blame] | 266 | memcpy(s->peer_macaddr, &peer_stats->peer_macaddr.addr, |
| 267 | ETH_ALEN); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 268 | s->peer_rssi = __le32_to_cpu(peer_stats->peer_rssi); |
| 269 | s->peer_tx_rate = |
| 270 | __le32_to_cpu(peer_stats->peer_tx_rate); |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 271 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, |
| 272 | ar->fw_features)) { |
| 273 | s->peer_rx_rate = |
| 274 | __le32_to_cpu(peer_stats->peer_rx_rate); |
| 275 | tmp += sizeof(struct wmi_peer_stats_10x); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 276 | |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 277 | } else { |
| 278 | tmp += sizeof(struct wmi_peer_stats_old); |
| 279 | } |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 283 | spin_unlock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 284 | complete(&ar->debug.event_stats_compl); |
| 285 | } |
| 286 | |
| 287 | static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf, |
| 288 | size_t count, loff_t *ppos) |
| 289 | { |
| 290 | struct ath10k *ar = file->private_data; |
| 291 | struct ath10k_target_stats *fw_stats; |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 292 | char *buf = NULL; |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 293 | unsigned int len = 0, buf_len = 8000; |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 294 | ssize_t ret_cnt = 0; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 295 | long left; |
| 296 | int i; |
| 297 | int ret; |
| 298 | |
| 299 | fw_stats = &ar->debug.target_stats; |
| 300 | |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 301 | mutex_lock(&ar->conf_mutex); |
| 302 | |
| 303 | if (ar->state != ATH10K_STATE_ON) |
| 304 | goto exit; |
| 305 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 306 | buf = kzalloc(buf_len, GFP_KERNEL); |
| 307 | if (!buf) |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 308 | goto exit; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 309 | |
| 310 | ret = ath10k_wmi_request_stats(ar, WMI_REQUEST_PEER_STAT); |
| 311 | if (ret) { |
| 312 | ath10k_warn("could not request stats (%d)\n", ret); |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 313 | goto exit; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | left = wait_for_completion_timeout(&ar->debug.event_stats_compl, 1*HZ); |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 317 | if (left <= 0) |
| 318 | goto exit; |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 319 | |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 320 | spin_lock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 321 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 322 | len += scnprintf(buf + len, buf_len - len, "%30s\n", |
| 323 | "ath10k PDEV stats"); |
| 324 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 325 | "================="); |
| 326 | |
| 327 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 328 | "Channel noise floor", fw_stats->ch_noise_floor); |
| 329 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 330 | "Channel TX power", fw_stats->chan_tx_power); |
| 331 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 332 | "TX frame count", fw_stats->tx_frame_count); |
| 333 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 334 | "RX frame count", fw_stats->rx_frame_count); |
| 335 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 336 | "RX clear count", fw_stats->rx_clear_count); |
| 337 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 338 | "Cycle count", fw_stats->cycle_count); |
| 339 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 340 | "PHY error count", fw_stats->phy_err_count); |
Chun-Yeow Yeoh | 52e346d | 2014-03-28 14:35:16 +0200 | [diff] [blame] | 341 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 342 | "RTS bad count", fw_stats->rts_bad); |
| 343 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 344 | "RTS good count", fw_stats->rts_good); |
| 345 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 346 | "FCS bad count", fw_stats->fcs_bad); |
| 347 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 348 | "No beacon count", fw_stats->no_beacons); |
| 349 | len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", |
| 350 | "MIB int count", fw_stats->mib_int_count); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 351 | |
| 352 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 353 | len += scnprintf(buf + len, buf_len - len, "%30s\n", |
| 354 | "ath10k PDEV TX stats"); |
| 355 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 356 | "================="); |
| 357 | |
| 358 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 359 | "HTT cookies queued", fw_stats->comp_queued); |
| 360 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 361 | "HTT cookies disp.", fw_stats->comp_delivered); |
| 362 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 363 | "MSDU queued", fw_stats->msdu_enqued); |
| 364 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 365 | "MPDU queued", fw_stats->mpdu_enqued); |
| 366 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 367 | "MSDUs dropped", fw_stats->wmm_drop); |
| 368 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 369 | "Local enqued", fw_stats->local_enqued); |
| 370 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 371 | "Local freed", fw_stats->local_freed); |
| 372 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 373 | "HW queued", fw_stats->hw_queued); |
| 374 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 375 | "PPDUs reaped", fw_stats->hw_reaped); |
| 376 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 377 | "Num underruns", fw_stats->underrun); |
| 378 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 379 | "PPDUs cleaned", fw_stats->tx_abort); |
| 380 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 381 | "MPDUs requed", fw_stats->mpdus_requed); |
| 382 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 383 | "Excessive retries", fw_stats->tx_ko); |
| 384 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 385 | "HW rate", fw_stats->data_rc); |
| 386 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 387 | "Sched self tiggers", fw_stats->self_triggers); |
| 388 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 389 | "Dropped due to SW retries", |
| 390 | fw_stats->sw_retry_failure); |
| 391 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 392 | "Illegal rate phy errors", |
| 393 | fw_stats->illgl_rate_phy_err); |
| 394 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 395 | "Pdev continous xretry", fw_stats->pdev_cont_xretry); |
| 396 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 397 | "TX timeout", fw_stats->pdev_tx_timeout); |
| 398 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 399 | "PDEV resets", fw_stats->pdev_resets); |
| 400 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 401 | "PHY underrun", fw_stats->phy_underrun); |
| 402 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 403 | "MPDU is more than txop limit", fw_stats->txop_ovf); |
| 404 | |
| 405 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 406 | len += scnprintf(buf + len, buf_len - len, "%30s\n", |
| 407 | "ath10k PDEV RX stats"); |
| 408 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 409 | "================="); |
| 410 | |
| 411 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 412 | "Mid PPDU route change", |
| 413 | fw_stats->mid_ppdu_route_change); |
| 414 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 415 | "Tot. number of statuses", fw_stats->status_rcvd); |
| 416 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 417 | "Extra frags on rings 0", fw_stats->r0_frags); |
| 418 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 419 | "Extra frags on rings 1", fw_stats->r1_frags); |
| 420 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 421 | "Extra frags on rings 2", fw_stats->r2_frags); |
| 422 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 423 | "Extra frags on rings 3", fw_stats->r3_frags); |
| 424 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 425 | "MSDUs delivered to HTT", fw_stats->htt_msdus); |
| 426 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 427 | "MPDUs delivered to HTT", fw_stats->htt_mpdus); |
| 428 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 429 | "MSDUs delivered to stack", fw_stats->loc_msdus); |
| 430 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 431 | "MPDUs delivered to stack", fw_stats->loc_mpdus); |
| 432 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 433 | "Oversized AMSUs", fw_stats->oversize_amsdu); |
| 434 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 435 | "PHY errors", fw_stats->phy_errs); |
| 436 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 437 | "PHY errors drops", fw_stats->phy_err_drop); |
| 438 | len += scnprintf(buf + len, buf_len - len, "%30s %10d\n", |
| 439 | "MPDU errors (FCS, MIC, ENC)", fw_stats->mpdu_errs); |
| 440 | |
| 441 | len += scnprintf(buf + len, buf_len - len, "\n"); |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 442 | len += scnprintf(buf + len, buf_len - len, "%30s (%d)\n", |
| 443 | "ath10k PEER stats", fw_stats->peers); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 444 | len += scnprintf(buf + len, buf_len - len, "%30s\n\n", |
| 445 | "================="); |
| 446 | |
| 447 | for (i = 0; i < fw_stats->peers; i++) { |
| 448 | len += scnprintf(buf + len, buf_len - len, "%30s %pM\n", |
| 449 | "Peer MAC address", |
| 450 | fw_stats->peer_stat[i].peer_macaddr); |
| 451 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 452 | "Peer RSSI", fw_stats->peer_stat[i].peer_rssi); |
| 453 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 454 | "Peer TX rate", |
| 455 | fw_stats->peer_stat[i].peer_tx_rate); |
Ben Greear | 23c3aae | 2014-03-28 14:35:15 +0200 | [diff] [blame] | 456 | len += scnprintf(buf + len, buf_len - len, "%30s %u\n", |
| 457 | "Peer RX rate", |
| 458 | fw_stats->peer_stat[i].peer_rx_rate); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 459 | len += scnprintf(buf + len, buf_len - len, "\n"); |
| 460 | } |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 461 | spin_unlock_bh(&ar->data_lock); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 462 | |
| 463 | if (len > buf_len) |
| 464 | len = buf_len; |
| 465 | |
| 466 | ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 467 | |
Michal Kazior | 87571bf | 2013-07-16 09:38:59 +0200 | [diff] [blame] | 468 | exit: |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 469 | mutex_unlock(&ar->conf_mutex); |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 470 | kfree(buf); |
| 471 | return ret_cnt; |
| 472 | } |
| 473 | |
| 474 | static const struct file_operations fops_fw_stats = { |
| 475 | .read = ath10k_read_fw_stats, |
| 476 | .open = simple_open, |
| 477 | .owner = THIS_MODULE, |
| 478 | .llseek = default_llseek, |
| 479 | }; |
| 480 | |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 481 | static ssize_t ath10k_read_simulate_fw_crash(struct file *file, |
| 482 | char __user *user_buf, |
| 483 | size_t count, loff_t *ppos) |
| 484 | { |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 485 | const char buf[] = "To simulate firmware crash write one of the" |
| 486 | " keywords to this file:\n `soft` - this will send" |
| 487 | " WMI_FORCE_FW_HANG_ASSERT to firmware if FW" |
| 488 | " supports that command.\n `hard` - this will send" |
| 489 | " to firmware command with illegal parameters" |
| 490 | " causing firmware crash.\n"; |
| 491 | |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 492 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
| 493 | } |
| 494 | |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 495 | /* Simulate firmware crash: |
| 496 | * 'soft': Call wmi command causing firmware hang. This firmware hang is |
| 497 | * recoverable by warm firmware reset. |
| 498 | * 'hard': Force firmware crash by setting any vdev parameter for not allowed |
| 499 | * vdev id. This is hard firmware crash because it is recoverable only by cold |
| 500 | * firmware reset. |
| 501 | */ |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 502 | static ssize_t ath10k_write_simulate_fw_crash(struct file *file, |
| 503 | const char __user *user_buf, |
| 504 | size_t count, loff_t *ppos) |
| 505 | { |
| 506 | struct ath10k *ar = file->private_data; |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 507 | char buf[32]; |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 508 | int ret; |
| 509 | |
| 510 | mutex_lock(&ar->conf_mutex); |
| 511 | |
| 512 | simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 513 | |
| 514 | /* make sure that buf is null terminated */ |
| 515 | buf[sizeof(buf) - 1] = 0; |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 516 | |
| 517 | if (ar->state != ATH10K_STATE_ON && |
| 518 | ar->state != ATH10K_STATE_RESTARTED) { |
| 519 | ret = -ENETDOWN; |
| 520 | goto exit; |
| 521 | } |
| 522 | |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 523 | /* drop the possible '\n' from the end */ |
| 524 | if (buf[count - 1] == '\n') { |
| 525 | buf[count - 1] = 0; |
| 526 | count--; |
| 527 | } |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 528 | |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 529 | if (!strcmp(buf, "soft")) { |
| 530 | ath10k_info("simulating soft firmware crash\n"); |
| 531 | ret = ath10k_wmi_force_fw_hang(ar, WMI_FORCE_FW_HANG_ASSERT, 0); |
| 532 | } else if (!strcmp(buf, "hard")) { |
| 533 | ath10k_info("simulating hard firmware crash\n"); |
Ben Greear | 611b368 | 2014-07-25 11:56:40 +0300 | [diff] [blame] | 534 | /* 0x7fff is vdev id, and it is always out of range for all |
| 535 | * firmware variants in order to force a firmware crash. |
| 536 | */ |
| 537 | ret = ath10k_wmi_vdev_set_param(ar, 0x7fff, |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 538 | ar->wmi.vdev_param->rts_threshold, 0); |
| 539 | } else { |
| 540 | ret = -EINVAL; |
| 541 | goto exit; |
| 542 | } |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 543 | |
Marek Puzyniak | 8c65699 | 2014-03-21 17:46:56 +0200 | [diff] [blame] | 544 | if (ret) { |
| 545 | ath10k_warn("failed to simulate firmware crash: %d\n", ret); |
| 546 | goto exit; |
| 547 | } |
| 548 | |
| 549 | ret = count; |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 550 | |
| 551 | exit: |
| 552 | mutex_unlock(&ar->conf_mutex); |
| 553 | return ret; |
| 554 | } |
| 555 | |
| 556 | static const struct file_operations fops_simulate_fw_crash = { |
| 557 | .read = ath10k_read_simulate_fw_crash, |
| 558 | .write = ath10k_write_simulate_fw_crash, |
| 559 | .open = simple_open, |
| 560 | .owner = THIS_MODULE, |
| 561 | .llseek = default_llseek, |
| 562 | }; |
| 563 | |
Kalle Valo | 763b8cd | 2013-09-01 11:22:21 +0300 | [diff] [blame] | 564 | static ssize_t ath10k_read_chip_id(struct file *file, char __user *user_buf, |
| 565 | size_t count, loff_t *ppos) |
| 566 | { |
| 567 | struct ath10k *ar = file->private_data; |
| 568 | unsigned int len; |
| 569 | char buf[50]; |
| 570 | |
| 571 | len = scnprintf(buf, sizeof(buf), "0x%08x\n", ar->chip_id); |
| 572 | |
| 573 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 574 | } |
| 575 | |
| 576 | static const struct file_operations fops_chip_id = { |
| 577 | .read = ath10k_read_chip_id, |
| 578 | .open = simple_open, |
| 579 | .owner = THIS_MODULE, |
| 580 | .llseek = default_llseek, |
| 581 | }; |
| 582 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 583 | static int ath10k_debug_htt_stats_req(struct ath10k *ar) |
| 584 | { |
| 585 | u64 cookie; |
| 586 | int ret; |
| 587 | |
| 588 | lockdep_assert_held(&ar->conf_mutex); |
| 589 | |
| 590 | if (ar->debug.htt_stats_mask == 0) |
| 591 | /* htt stats are disabled */ |
| 592 | return 0; |
| 593 | |
| 594 | if (ar->state != ATH10K_STATE_ON) |
| 595 | return 0; |
| 596 | |
| 597 | cookie = get_jiffies_64(); |
| 598 | |
| 599 | ret = ath10k_htt_h2t_stats_req(&ar->htt, ar->debug.htt_stats_mask, |
| 600 | cookie); |
| 601 | if (ret) { |
| 602 | ath10k_warn("failed to send htt stats request: %d\n", ret); |
| 603 | return ret; |
| 604 | } |
| 605 | |
| 606 | queue_delayed_work(ar->workqueue, &ar->debug.htt_stats_dwork, |
| 607 | msecs_to_jiffies(ATH10K_DEBUG_HTT_STATS_INTERVAL)); |
| 608 | |
| 609 | return 0; |
| 610 | } |
| 611 | |
| 612 | static void ath10k_debug_htt_stats_dwork(struct work_struct *work) |
| 613 | { |
| 614 | struct ath10k *ar = container_of(work, struct ath10k, |
| 615 | debug.htt_stats_dwork.work); |
| 616 | |
| 617 | mutex_lock(&ar->conf_mutex); |
| 618 | |
| 619 | ath10k_debug_htt_stats_req(ar); |
| 620 | |
| 621 | mutex_unlock(&ar->conf_mutex); |
| 622 | } |
| 623 | |
| 624 | static ssize_t ath10k_read_htt_stats_mask(struct file *file, |
| 625 | char __user *user_buf, |
| 626 | size_t count, loff_t *ppos) |
| 627 | { |
| 628 | struct ath10k *ar = file->private_data; |
| 629 | char buf[32]; |
| 630 | unsigned int len; |
| 631 | |
| 632 | len = scnprintf(buf, sizeof(buf), "%lu\n", ar->debug.htt_stats_mask); |
| 633 | |
| 634 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 635 | } |
| 636 | |
| 637 | static ssize_t ath10k_write_htt_stats_mask(struct file *file, |
| 638 | const char __user *user_buf, |
| 639 | size_t count, loff_t *ppos) |
| 640 | { |
| 641 | struct ath10k *ar = file->private_data; |
| 642 | unsigned long mask; |
| 643 | int ret; |
| 644 | |
| 645 | ret = kstrtoul_from_user(user_buf, count, 0, &mask); |
| 646 | if (ret) |
| 647 | return ret; |
| 648 | |
| 649 | /* max 8 bit masks (for now) */ |
| 650 | if (mask > 0xff) |
| 651 | return -E2BIG; |
| 652 | |
| 653 | mutex_lock(&ar->conf_mutex); |
| 654 | |
| 655 | ar->debug.htt_stats_mask = mask; |
| 656 | |
| 657 | ret = ath10k_debug_htt_stats_req(ar); |
| 658 | if (ret) |
| 659 | goto out; |
| 660 | |
| 661 | ret = count; |
| 662 | |
| 663 | out: |
| 664 | mutex_unlock(&ar->conf_mutex); |
| 665 | |
| 666 | return ret; |
| 667 | } |
| 668 | |
| 669 | static const struct file_operations fops_htt_stats_mask = { |
| 670 | .read = ath10k_read_htt_stats_mask, |
| 671 | .write = ath10k_write_htt_stats_mask, |
| 672 | .open = simple_open, |
| 673 | .owner = THIS_MODULE, |
| 674 | .llseek = default_llseek, |
| 675 | }; |
| 676 | |
Janusz Dziedzic | d385623 | 2014-06-02 21:19:46 +0300 | [diff] [blame] | 677 | static ssize_t ath10k_read_htt_max_amsdu_ampdu(struct file *file, |
| 678 | char __user *user_buf, |
| 679 | size_t count, loff_t *ppos) |
| 680 | { |
| 681 | struct ath10k *ar = file->private_data; |
| 682 | char buf[64]; |
| 683 | u8 amsdu = 3, ampdu = 64; |
| 684 | unsigned int len; |
| 685 | |
| 686 | mutex_lock(&ar->conf_mutex); |
| 687 | |
| 688 | if (ar->debug.htt_max_amsdu) |
| 689 | amsdu = ar->debug.htt_max_amsdu; |
| 690 | |
| 691 | if (ar->debug.htt_max_ampdu) |
| 692 | ampdu = ar->debug.htt_max_ampdu; |
| 693 | |
| 694 | mutex_unlock(&ar->conf_mutex); |
| 695 | |
| 696 | len = scnprintf(buf, sizeof(buf), "%u %u\n", amsdu, ampdu); |
| 697 | |
| 698 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 699 | } |
| 700 | |
| 701 | static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct file *file, |
| 702 | const char __user *user_buf, |
| 703 | size_t count, loff_t *ppos) |
| 704 | { |
| 705 | struct ath10k *ar = file->private_data; |
| 706 | int res; |
| 707 | char buf[64]; |
| 708 | unsigned int amsdu, ampdu; |
| 709 | |
| 710 | simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); |
| 711 | |
| 712 | /* make sure that buf is null terminated */ |
| 713 | buf[sizeof(buf) - 1] = 0; |
| 714 | |
| 715 | res = sscanf(buf, "%u %u", &amsdu, &du); |
| 716 | |
| 717 | if (res != 2) |
| 718 | return -EINVAL; |
| 719 | |
| 720 | mutex_lock(&ar->conf_mutex); |
| 721 | |
| 722 | res = ath10k_htt_h2t_aggr_cfg_msg(&ar->htt, ampdu, amsdu); |
| 723 | if (res) |
| 724 | goto out; |
| 725 | |
| 726 | res = count; |
| 727 | ar->debug.htt_max_amsdu = amsdu; |
| 728 | ar->debug.htt_max_ampdu = ampdu; |
| 729 | |
| 730 | out: |
| 731 | mutex_unlock(&ar->conf_mutex); |
| 732 | return res; |
| 733 | } |
| 734 | |
| 735 | static const struct file_operations fops_htt_max_amsdu_ampdu = { |
| 736 | .read = ath10k_read_htt_max_amsdu_ampdu, |
| 737 | .write = ath10k_write_htt_max_amsdu_ampdu, |
| 738 | .open = simple_open, |
| 739 | .owner = THIS_MODULE, |
| 740 | .llseek = default_llseek, |
| 741 | }; |
| 742 | |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 743 | static ssize_t ath10k_read_fw_dbglog(struct file *file, |
| 744 | char __user *user_buf, |
| 745 | size_t count, loff_t *ppos) |
| 746 | { |
| 747 | struct ath10k *ar = file->private_data; |
| 748 | unsigned int len; |
| 749 | char buf[32]; |
| 750 | |
| 751 | len = scnprintf(buf, sizeof(buf), "0x%08x\n", |
| 752 | ar->debug.fw_dbglog_mask); |
| 753 | |
| 754 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 755 | } |
| 756 | |
| 757 | static ssize_t ath10k_write_fw_dbglog(struct file *file, |
| 758 | const char __user *user_buf, |
| 759 | size_t count, loff_t *ppos) |
| 760 | { |
| 761 | struct ath10k *ar = file->private_data; |
| 762 | unsigned long mask; |
| 763 | int ret; |
| 764 | |
| 765 | ret = kstrtoul_from_user(user_buf, count, 0, &mask); |
| 766 | if (ret) |
| 767 | return ret; |
| 768 | |
| 769 | mutex_lock(&ar->conf_mutex); |
| 770 | |
| 771 | ar->debug.fw_dbglog_mask = mask; |
| 772 | |
| 773 | if (ar->state == ATH10K_STATE_ON) { |
| 774 | ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask); |
| 775 | if (ret) { |
| 776 | ath10k_warn("dbglog cfg failed from debugfs: %d\n", |
| 777 | ret); |
| 778 | goto exit; |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | ret = count; |
| 783 | |
| 784 | exit: |
| 785 | mutex_unlock(&ar->conf_mutex); |
| 786 | |
| 787 | return ret; |
| 788 | } |
| 789 | |
| 790 | static const struct file_operations fops_fw_dbglog = { |
| 791 | .read = ath10k_read_fw_dbglog, |
| 792 | .write = ath10k_write_fw_dbglog, |
| 793 | .open = simple_open, |
| 794 | .owner = THIS_MODULE, |
| 795 | .llseek = default_llseek, |
| 796 | }; |
| 797 | |
Kalle Valo | db66ea0 | 2013-09-03 11:44:03 +0300 | [diff] [blame] | 798 | int ath10k_debug_start(struct ath10k *ar) |
| 799 | { |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 800 | int ret; |
| 801 | |
Kalle Valo | 60631c5 | 2013-10-08 21:45:25 +0300 | [diff] [blame] | 802 | lockdep_assert_held(&ar->conf_mutex); |
| 803 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 804 | ret = ath10k_debug_htt_stats_req(ar); |
| 805 | if (ret) |
| 806 | /* continue normally anyway, this isn't serious */ |
| 807 | ath10k_warn("failed to start htt stats workqueue: %d\n", ret); |
| 808 | |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 809 | if (ar->debug.fw_dbglog_mask) { |
| 810 | ret = ath10k_wmi_dbglog_cfg(ar, ar->debug.fw_dbglog_mask); |
| 811 | if (ret) |
| 812 | /* not serious */ |
| 813 | ath10k_warn("failed to enable dbglog during start: %d", |
| 814 | ret); |
| 815 | } |
| 816 | |
Kalle Valo | db66ea0 | 2013-09-03 11:44:03 +0300 | [diff] [blame] | 817 | return 0; |
| 818 | } |
| 819 | |
| 820 | void ath10k_debug_stop(struct ath10k *ar) |
| 821 | { |
Kalle Valo | 60631c5 | 2013-10-08 21:45:25 +0300 | [diff] [blame] | 822 | lockdep_assert_held(&ar->conf_mutex); |
| 823 | |
| 824 | /* Must not use _sync to avoid deadlock, we do that in |
| 825 | * ath10k_debug_destroy(). The check for htt_stats_mask is to avoid |
| 826 | * warning from del_timer(). */ |
| 827 | if (ar->debug.htt_stats_mask != 0) |
| 828 | cancel_delayed_work(&ar->debug.htt_stats_dwork); |
Janusz Dziedzic | d385623 | 2014-06-02 21:19:46 +0300 | [diff] [blame] | 829 | |
| 830 | ar->debug.htt_max_amsdu = 0; |
| 831 | ar->debug.htt_max_ampdu = 0; |
Kalle Valo | db66ea0 | 2013-09-03 11:44:03 +0300 | [diff] [blame] | 832 | } |
| 833 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 834 | static ssize_t ath10k_write_simulate_radar(struct file *file, |
| 835 | const char __user *user_buf, |
| 836 | size_t count, loff_t *ppos) |
| 837 | { |
| 838 | struct ath10k *ar = file->private_data; |
| 839 | |
| 840 | ieee80211_radar_detected(ar->hw); |
| 841 | |
| 842 | return count; |
| 843 | } |
| 844 | |
| 845 | static const struct file_operations fops_simulate_radar = { |
| 846 | .write = ath10k_write_simulate_radar, |
| 847 | .open = simple_open, |
| 848 | .owner = THIS_MODULE, |
| 849 | .llseek = default_llseek, |
| 850 | }; |
| 851 | |
| 852 | #define ATH10K_DFS_STAT(s, p) (\ |
| 853 | len += scnprintf(buf + len, size - len, "%-28s : %10u\n", s, \ |
| 854 | ar->debug.dfs_stats.p)) |
| 855 | |
| 856 | #define ATH10K_DFS_POOL_STAT(s, p) (\ |
| 857 | len += scnprintf(buf + len, size - len, "%-28s : %10u\n", s, \ |
| 858 | ar->debug.dfs_pool_stats.p)) |
| 859 | |
| 860 | static ssize_t ath10k_read_dfs_stats(struct file *file, char __user *user_buf, |
| 861 | size_t count, loff_t *ppos) |
| 862 | { |
| 863 | int retval = 0, len = 0; |
| 864 | const int size = 8000; |
| 865 | struct ath10k *ar = file->private_data; |
| 866 | char *buf; |
| 867 | |
| 868 | buf = kzalloc(size, GFP_KERNEL); |
| 869 | if (buf == NULL) |
| 870 | return -ENOMEM; |
| 871 | |
| 872 | if (!ar->dfs_detector) { |
| 873 | len += scnprintf(buf + len, size - len, "DFS not enabled\n"); |
| 874 | goto exit; |
| 875 | } |
| 876 | |
| 877 | ar->debug.dfs_pool_stats = |
| 878 | ar->dfs_detector->get_stats(ar->dfs_detector); |
| 879 | |
| 880 | len += scnprintf(buf + len, size - len, "Pulse detector statistics:\n"); |
| 881 | |
| 882 | ATH10K_DFS_STAT("reported phy errors", phy_errors); |
| 883 | ATH10K_DFS_STAT("pulse events reported", pulses_total); |
| 884 | ATH10K_DFS_STAT("DFS pulses detected", pulses_detected); |
| 885 | ATH10K_DFS_STAT("DFS pulses discarded", pulses_discarded); |
| 886 | ATH10K_DFS_STAT("Radars detected", radar_detected); |
| 887 | |
| 888 | len += scnprintf(buf + len, size - len, "Global Pool statistics:\n"); |
| 889 | ATH10K_DFS_POOL_STAT("Pool references", pool_reference); |
| 890 | ATH10K_DFS_POOL_STAT("Pulses allocated", pulse_allocated); |
| 891 | ATH10K_DFS_POOL_STAT("Pulses alloc error", pulse_alloc_error); |
| 892 | ATH10K_DFS_POOL_STAT("Pulses in use", pulse_used); |
| 893 | ATH10K_DFS_POOL_STAT("Seqs. allocated", pseq_allocated); |
| 894 | ATH10K_DFS_POOL_STAT("Seqs. alloc error", pseq_alloc_error); |
| 895 | ATH10K_DFS_POOL_STAT("Seqs. in use", pseq_used); |
| 896 | |
| 897 | exit: |
| 898 | if (len > size) |
| 899 | len = size; |
| 900 | |
| 901 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
| 902 | kfree(buf); |
| 903 | |
| 904 | return retval; |
| 905 | } |
| 906 | |
| 907 | static const struct file_operations fops_dfs_stats = { |
| 908 | .read = ath10k_read_dfs_stats, |
| 909 | .open = simple_open, |
| 910 | .owner = THIS_MODULE, |
| 911 | .llseek = default_llseek, |
| 912 | }; |
| 913 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 914 | int ath10k_debug_create(struct ath10k *ar) |
| 915 | { |
| 916 | ar->debug.debugfs_phy = debugfs_create_dir("ath10k", |
| 917 | ar->hw->wiphy->debugfsdir); |
| 918 | |
| 919 | if (!ar->debug.debugfs_phy) |
| 920 | return -ENOMEM; |
| 921 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 922 | INIT_DELAYED_WORK(&ar->debug.htt_stats_dwork, |
| 923 | ath10k_debug_htt_stats_dwork); |
| 924 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 925 | init_completion(&ar->debug.event_stats_compl); |
| 926 | |
| 927 | debugfs_create_file("fw_stats", S_IRUSR, ar->debug.debugfs_phy, ar, |
| 928 | &fops_fw_stats); |
| 929 | |
| 930 | debugfs_create_file("wmi_services", S_IRUSR, ar->debug.debugfs_phy, ar, |
| 931 | &fops_wmi_services); |
| 932 | |
Michal Kazior | 278c4a8 | 2013-07-22 14:08:51 +0200 | [diff] [blame] | 933 | debugfs_create_file("simulate_fw_crash", S_IRUSR, ar->debug.debugfs_phy, |
| 934 | ar, &fops_simulate_fw_crash); |
| 935 | |
Kalle Valo | 763b8cd | 2013-09-01 11:22:21 +0300 | [diff] [blame] | 936 | debugfs_create_file("chip_id", S_IRUSR, ar->debug.debugfs_phy, |
| 937 | ar, &fops_chip_id); |
| 938 | |
Kalle Valo | a3d135e | 2013-09-03 11:44:10 +0300 | [diff] [blame] | 939 | debugfs_create_file("htt_stats_mask", S_IRUSR, ar->debug.debugfs_phy, |
| 940 | ar, &fops_htt_stats_mask); |
| 941 | |
Janusz Dziedzic | d385623 | 2014-06-02 21:19:46 +0300 | [diff] [blame] | 942 | debugfs_create_file("htt_max_amsdu_ampdu", S_IRUSR | S_IWUSR, |
| 943 | ar->debug.debugfs_phy, ar, |
| 944 | &fops_htt_max_amsdu_ampdu); |
| 945 | |
Kalle Valo | f118a3e | 2014-01-03 12:59:31 +0200 | [diff] [blame] | 946 | debugfs_create_file("fw_dbglog", S_IRUSR, ar->debug.debugfs_phy, |
| 947 | ar, &fops_fw_dbglog); |
| 948 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 949 | if (config_enabled(CONFIG_ATH10K_DFS_CERTIFIED)) { |
| 950 | debugfs_create_file("dfs_simulate_radar", S_IWUSR, |
| 951 | ar->debug.debugfs_phy, ar, |
| 952 | &fops_simulate_radar); |
| 953 | |
Marek Puzyniak | 7d9b40b | 2013-11-20 10:00:28 +0200 | [diff] [blame] | 954 | debugfs_create_bool("dfs_block_radar_events", S_IWUSR, |
| 955 | ar->debug.debugfs_phy, |
| 956 | &ar->dfs_block_radar_events); |
| 957 | |
Janusz Dziedzic | 9702c68 | 2013-11-20 09:59:41 +0200 | [diff] [blame] | 958 | debugfs_create_file("dfs_stats", S_IRUSR, |
| 959 | ar->debug.debugfs_phy, ar, |
| 960 | &fops_dfs_stats); |
| 961 | } |
| 962 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 963 | return 0; |
| 964 | } |
Kalle Valo | db66ea0 | 2013-09-03 11:44:03 +0300 | [diff] [blame] | 965 | |
Kalle Valo | 60631c5 | 2013-10-08 21:45:25 +0300 | [diff] [blame] | 966 | void ath10k_debug_destroy(struct ath10k *ar) |
| 967 | { |
| 968 | cancel_delayed_work_sync(&ar->debug.htt_stats_dwork); |
| 969 | } |
| 970 | |
Kalle Valo | 5e3dd15 | 2013-06-12 20:52:10 +0300 | [diff] [blame] | 971 | #endif /* CONFIG_ATH10K_DEBUGFS */ |
| 972 | |
| 973 | #ifdef CONFIG_ATH10K_DEBUG |
| 974 | void ath10k_dbg(enum ath10k_debug_mask mask, const char *fmt, ...) |
| 975 | { |
| 976 | struct va_format vaf; |
| 977 | va_list args; |
| 978 | |
| 979 | va_start(args, fmt); |
| 980 | |
| 981 | vaf.fmt = fmt; |
| 982 | vaf.va = &args; |
| 983 | |
| 984 | if (ath10k_debug_mask & mask) |
| 985 | ath10k_printk(KERN_DEBUG, "%pV", &vaf); |
| 986 | |
| 987 | trace_ath10k_log_dbg(mask, &vaf); |
| 988 | |
| 989 | va_end(args); |
| 990 | } |
| 991 | EXPORT_SYMBOL(ath10k_dbg); |
| 992 | |
| 993 | void ath10k_dbg_dump(enum ath10k_debug_mask mask, |
| 994 | const char *msg, const char *prefix, |
| 995 | const void *buf, size_t len) |
| 996 | { |
| 997 | if (ath10k_debug_mask & mask) { |
| 998 | if (msg) |
| 999 | ath10k_dbg(mask, "%s\n", msg); |
| 1000 | |
| 1001 | print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, buf, len); |
| 1002 | } |
| 1003 | |
| 1004 | /* tracing code doesn't like null strings :/ */ |
| 1005 | trace_ath10k_log_dbg_dump(msg ? msg : "", prefix ? prefix : "", |
| 1006 | buf, len); |
| 1007 | } |
| 1008 | EXPORT_SYMBOL(ath10k_dbg_dump); |
| 1009 | |
| 1010 | #endif /* CONFIG_ATH10K_DEBUG */ |