Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of wl1271 |
| 3 | * |
| 4 | * Copyright (C) 2009 Nokia Corporation |
| 5 | * |
| 6 | * Contact: Luciano Coelho <luciano.coelho@nokia.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License |
| 10 | * version 2 as published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 20 | * 02110-1301 USA |
| 21 | * |
| 22 | */ |
| 23 | |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 24 | #include "debugfs.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 25 | |
| 26 | #include <linux/skbuff.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 27 | #include <linux/slab.h> |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 28 | |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 29 | #include "wl12xx.h" |
| 30 | #include "acx.h" |
| 31 | #include "ps.h" |
| 32 | #include "io.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 33 | |
| 34 | /* ms */ |
| 35 | #define WL1271_DEBUGFS_STATS_LIFETIME 1000 |
| 36 | |
| 37 | /* debugfs macros idea from mac80211 */ |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 38 | #define DEBUGFS_FORMAT_BUFFER_SIZE 100 |
| 39 | static int wl1271_format_buffer(char __user *userbuf, size_t count, |
| 40 | loff_t *ppos, char *fmt, ...) |
| 41 | { |
| 42 | va_list args; |
| 43 | char buf[DEBUGFS_FORMAT_BUFFER_SIZE]; |
| 44 | int res; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 45 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 46 | va_start(args, fmt); |
| 47 | res = vscnprintf(buf, sizeof(buf), fmt, args); |
| 48 | va_end(args); |
| 49 | |
| 50 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); |
| 51 | } |
| 52 | |
| 53 | #define DEBUGFS_READONLY_FILE(name, fmt, value...) \ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 54 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ |
| 55 | size_t count, loff_t *ppos) \ |
| 56 | { \ |
| 57 | struct wl1271 *wl = file->private_data; \ |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 58 | return wl1271_format_buffer(userbuf, count, ppos, \ |
| 59 | fmt "\n", ##value); \ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 60 | } \ |
| 61 | \ |
| 62 | static const struct file_operations name## _ops = { \ |
| 63 | .read = name## _read, \ |
| 64 | .open = wl1271_open_file_generic, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 65 | .llseek = generic_file_llseek, \ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | #define DEBUGFS_ADD(name, parent) \ |
| 69 | wl->debugfs.name = debugfs_create_file(#name, 0400, parent, \ |
| 70 | wl, &name## _ops); \ |
| 71 | if (IS_ERR(wl->debugfs.name)) { \ |
| 72 | ret = PTR_ERR(wl->debugfs.name); \ |
| 73 | wl->debugfs.name = NULL; \ |
| 74 | goto out; \ |
| 75 | } |
| 76 | |
| 77 | #define DEBUGFS_DEL(name) \ |
| 78 | do { \ |
| 79 | debugfs_remove(wl->debugfs.name); \ |
| 80 | wl->debugfs.name = NULL; \ |
| 81 | } while (0) |
| 82 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 83 | #define DEBUGFS_FWSTATS_FILE(sub, name, fmt) \ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 84 | static ssize_t sub## _ ##name## _read(struct file *file, \ |
| 85 | char __user *userbuf, \ |
| 86 | size_t count, loff_t *ppos) \ |
| 87 | { \ |
| 88 | struct wl1271 *wl = file->private_data; \ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 89 | \ |
| 90 | wl1271_debugfs_update_stats(wl); \ |
| 91 | \ |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 92 | return wl1271_format_buffer(userbuf, count, ppos, fmt "\n", \ |
| 93 | wl->stats.fw_stats->sub.name); \ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 94 | } \ |
| 95 | \ |
| 96 | static const struct file_operations sub## _ ##name## _ops = { \ |
| 97 | .read = sub## _ ##name## _read, \ |
| 98 | .open = wl1271_open_file_generic, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 99 | .llseek = generic_file_llseek, \ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | #define DEBUGFS_FWSTATS_ADD(sub, name) \ |
| 103 | DEBUGFS_ADD(sub## _ ##name, wl->debugfs.fw_statistics) |
| 104 | |
| 105 | #define DEBUGFS_FWSTATS_DEL(sub, name) \ |
| 106 | DEBUGFS_DEL(sub## _ ##name) |
| 107 | |
| 108 | static void wl1271_debugfs_update_stats(struct wl1271 *wl) |
| 109 | { |
| 110 | int ret; |
| 111 | |
| 112 | mutex_lock(&wl->mutex); |
| 113 | |
| 114 | ret = wl1271_ps_elp_wakeup(wl, false); |
| 115 | if (ret < 0) |
| 116 | goto out; |
| 117 | |
| 118 | if (wl->state == WL1271_STATE_ON && |
| 119 | time_after(jiffies, wl->stats.fw_stats_update + |
| 120 | msecs_to_jiffies(WL1271_DEBUGFS_STATS_LIFETIME))) { |
| 121 | wl1271_acx_statistics(wl, wl->stats.fw_stats); |
| 122 | wl->stats.fw_stats_update = jiffies; |
| 123 | } |
| 124 | |
| 125 | wl1271_ps_elp_sleep(wl); |
| 126 | |
| 127 | out: |
| 128 | mutex_unlock(&wl->mutex); |
| 129 | } |
| 130 | |
| 131 | static int wl1271_open_file_generic(struct inode *inode, struct file *file) |
| 132 | { |
| 133 | file->private_data = inode->i_private; |
| 134 | return 0; |
| 135 | } |
| 136 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 137 | DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 138 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 139 | DEBUGFS_FWSTATS_FILE(rx, out_of_mem, "%u"); |
| 140 | DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, "%u"); |
| 141 | DEBUGFS_FWSTATS_FILE(rx, hw_stuck, "%u"); |
| 142 | DEBUGFS_FWSTATS_FILE(rx, dropped, "%u"); |
| 143 | DEBUGFS_FWSTATS_FILE(rx, fcs_err, "%u"); |
| 144 | DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, "%u"); |
| 145 | DEBUGFS_FWSTATS_FILE(rx, path_reset, "%u"); |
| 146 | DEBUGFS_FWSTATS_FILE(rx, reset_counter, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 147 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 148 | DEBUGFS_FWSTATS_FILE(dma, rx_requested, "%u"); |
| 149 | DEBUGFS_FWSTATS_FILE(dma, rx_errors, "%u"); |
| 150 | DEBUGFS_FWSTATS_FILE(dma, tx_requested, "%u"); |
| 151 | DEBUGFS_FWSTATS_FILE(dma, tx_errors, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 152 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 153 | DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, "%u"); |
| 154 | DEBUGFS_FWSTATS_FILE(isr, fiqs, "%u"); |
| 155 | DEBUGFS_FWSTATS_FILE(isr, rx_headers, "%u"); |
| 156 | DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, "%u"); |
| 157 | DEBUGFS_FWSTATS_FILE(isr, rx_rdys, "%u"); |
| 158 | DEBUGFS_FWSTATS_FILE(isr, irqs, "%u"); |
| 159 | DEBUGFS_FWSTATS_FILE(isr, tx_procs, "%u"); |
| 160 | DEBUGFS_FWSTATS_FILE(isr, decrypt_done, "%u"); |
| 161 | DEBUGFS_FWSTATS_FILE(isr, dma0_done, "%u"); |
| 162 | DEBUGFS_FWSTATS_FILE(isr, dma1_done, "%u"); |
| 163 | DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, "%u"); |
| 164 | DEBUGFS_FWSTATS_FILE(isr, commands, "%u"); |
| 165 | DEBUGFS_FWSTATS_FILE(isr, rx_procs, "%u"); |
| 166 | DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, "%u"); |
| 167 | DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, "%u"); |
| 168 | DEBUGFS_FWSTATS_FILE(isr, pci_pm, "%u"); |
| 169 | DEBUGFS_FWSTATS_FILE(isr, wakeups, "%u"); |
| 170 | DEBUGFS_FWSTATS_FILE(isr, low_rssi, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 171 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 172 | DEBUGFS_FWSTATS_FILE(wep, addr_key_count, "%u"); |
| 173 | DEBUGFS_FWSTATS_FILE(wep, default_key_count, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 174 | /* skipping wep.reserved */ |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 175 | DEBUGFS_FWSTATS_FILE(wep, key_not_found, "%u"); |
| 176 | DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, "%u"); |
| 177 | DEBUGFS_FWSTATS_FILE(wep, packets, "%u"); |
| 178 | DEBUGFS_FWSTATS_FILE(wep, interrupt, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 179 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 180 | DEBUGFS_FWSTATS_FILE(pwr, ps_enter, "%u"); |
| 181 | DEBUGFS_FWSTATS_FILE(pwr, elp_enter, "%u"); |
| 182 | DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, "%u"); |
| 183 | DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, "%u"); |
| 184 | DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, "%u"); |
| 185 | DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, "%u"); |
| 186 | DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, "%u"); |
| 187 | DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, "%u"); |
| 188 | DEBUGFS_FWSTATS_FILE(pwr, power_save_off, "%u"); |
| 189 | DEBUGFS_FWSTATS_FILE(pwr, enable_ps, "%u"); |
| 190 | DEBUGFS_FWSTATS_FILE(pwr, disable_ps, "%u"); |
| 191 | DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 192 | /* skipping cont_miss_bcns_spread for now */ |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 193 | DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 194 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 195 | DEBUGFS_FWSTATS_FILE(mic, rx_pkts, "%u"); |
| 196 | DEBUGFS_FWSTATS_FILE(mic, calc_failure, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 197 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 198 | DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, "%u"); |
| 199 | DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, "%u"); |
| 200 | DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, "%u"); |
| 201 | DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, "%u"); |
| 202 | DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, "%u"); |
| 203 | DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 204 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 205 | DEBUGFS_FWSTATS_FILE(event, heart_beat, "%u"); |
| 206 | DEBUGFS_FWSTATS_FILE(event, calibration, "%u"); |
| 207 | DEBUGFS_FWSTATS_FILE(event, rx_mismatch, "%u"); |
| 208 | DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, "%u"); |
| 209 | DEBUGFS_FWSTATS_FILE(event, rx_pool, "%u"); |
| 210 | DEBUGFS_FWSTATS_FILE(event, oom_late, "%u"); |
| 211 | DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, "%u"); |
| 212 | DEBUGFS_FWSTATS_FILE(event, tx_stuck, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 213 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 214 | DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, "%u"); |
| 215 | DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, "%u"); |
| 216 | DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, "%u"); |
| 217 | DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, "%u"); |
| 218 | DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, "%u"); |
| 219 | DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, "%u"); |
| 220 | DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 221 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 222 | DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, "%u"); |
| 223 | DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, "%u"); |
| 224 | DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data, "%u"); |
| 225 | DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, "%u"); |
| 226 | DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 227 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 228 | DEBUGFS_READONLY_FILE(retry_count, "%u", wl->stats.retry_count); |
| 229 | DEBUGFS_READONLY_FILE(excessive_retries, "%u", |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 230 | wl->stats.excessive_retries); |
| 231 | |
| 232 | static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf, |
| 233 | size_t count, loff_t *ppos) |
| 234 | { |
| 235 | struct wl1271 *wl = file->private_data; |
| 236 | u32 queue_len; |
| 237 | char buf[20]; |
| 238 | int res; |
| 239 | |
| 240 | queue_len = skb_queue_len(&wl->tx_queue); |
| 241 | |
| 242 | res = scnprintf(buf, sizeof(buf), "%u\n", queue_len); |
| 243 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); |
| 244 | } |
| 245 | |
| 246 | static const struct file_operations tx_queue_len_ops = { |
| 247 | .read = tx_queue_len_read, |
| 248 | .open = wl1271_open_file_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 249 | .llseek = default_llseek, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 250 | }; |
| 251 | |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 252 | static ssize_t gpio_power_read(struct file *file, char __user *user_buf, |
| 253 | size_t count, loff_t *ppos) |
| 254 | { |
| 255 | struct wl1271 *wl = file->private_data; |
Juuso Oikarinen | 71449f8 | 2009-12-11 15:41:07 +0200 | [diff] [blame] | 256 | bool state = test_bit(WL1271_FLAG_GPIO_POWER, &wl->flags); |
| 257 | |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 258 | int res; |
| 259 | char buf[10]; |
| 260 | |
Juuso Oikarinen | 71449f8 | 2009-12-11 15:41:07 +0200 | [diff] [blame] | 261 | res = scnprintf(buf, sizeof(buf), "%d\n", state); |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 262 | |
| 263 | return simple_read_from_buffer(user_buf, count, ppos, buf, res); |
| 264 | } |
| 265 | |
| 266 | static ssize_t gpio_power_write(struct file *file, |
| 267 | const char __user *user_buf, |
| 268 | size_t count, loff_t *ppos) |
| 269 | { |
| 270 | struct wl1271 *wl = file->private_data; |
| 271 | char buf[10]; |
| 272 | size_t len; |
| 273 | unsigned long value; |
| 274 | int ret; |
| 275 | |
| 276 | mutex_lock(&wl->mutex); |
| 277 | |
| 278 | len = min(count, sizeof(buf) - 1); |
| 279 | if (copy_from_user(buf, user_buf, len)) { |
| 280 | ret = -EFAULT; |
| 281 | goto out; |
| 282 | } |
| 283 | buf[len] = '\0'; |
| 284 | |
| 285 | ret = strict_strtoul(buf, 0, &value); |
| 286 | if (ret < 0) { |
| 287 | wl1271_warning("illegal value in gpio_power"); |
| 288 | goto out; |
| 289 | } |
| 290 | |
Teemu Paasikivi | becd551 | 2010-03-18 12:26:27 +0200 | [diff] [blame] | 291 | if (value) |
| 292 | wl1271_power_on(wl); |
| 293 | else |
| 294 | wl1271_power_off(wl); |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 295 | |
| 296 | out: |
| 297 | mutex_unlock(&wl->mutex); |
| 298 | return count; |
| 299 | } |
| 300 | |
| 301 | static const struct file_operations gpio_power_ops = { |
| 302 | .read = gpio_power_read, |
| 303 | .write = gpio_power_write, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 304 | .open = wl1271_open_file_generic, |
| 305 | .llseek = default_llseek, |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 306 | }; |
| 307 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 308 | static void wl1271_debugfs_delete_files(struct wl1271 *wl) |
| 309 | { |
| 310 | DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow); |
| 311 | |
| 312 | DEBUGFS_FWSTATS_DEL(rx, out_of_mem); |
| 313 | DEBUGFS_FWSTATS_DEL(rx, hdr_overflow); |
| 314 | DEBUGFS_FWSTATS_DEL(rx, hw_stuck); |
| 315 | DEBUGFS_FWSTATS_DEL(rx, dropped); |
| 316 | DEBUGFS_FWSTATS_DEL(rx, fcs_err); |
| 317 | DEBUGFS_FWSTATS_DEL(rx, xfr_hint_trig); |
| 318 | DEBUGFS_FWSTATS_DEL(rx, path_reset); |
| 319 | DEBUGFS_FWSTATS_DEL(rx, reset_counter); |
| 320 | |
| 321 | DEBUGFS_FWSTATS_DEL(dma, rx_requested); |
| 322 | DEBUGFS_FWSTATS_DEL(dma, rx_errors); |
| 323 | DEBUGFS_FWSTATS_DEL(dma, tx_requested); |
| 324 | DEBUGFS_FWSTATS_DEL(dma, tx_errors); |
| 325 | |
| 326 | DEBUGFS_FWSTATS_DEL(isr, cmd_cmplt); |
| 327 | DEBUGFS_FWSTATS_DEL(isr, fiqs); |
| 328 | DEBUGFS_FWSTATS_DEL(isr, rx_headers); |
| 329 | DEBUGFS_FWSTATS_DEL(isr, rx_mem_overflow); |
| 330 | DEBUGFS_FWSTATS_DEL(isr, rx_rdys); |
| 331 | DEBUGFS_FWSTATS_DEL(isr, irqs); |
| 332 | DEBUGFS_FWSTATS_DEL(isr, tx_procs); |
| 333 | DEBUGFS_FWSTATS_DEL(isr, decrypt_done); |
| 334 | DEBUGFS_FWSTATS_DEL(isr, dma0_done); |
| 335 | DEBUGFS_FWSTATS_DEL(isr, dma1_done); |
| 336 | DEBUGFS_FWSTATS_DEL(isr, tx_exch_complete); |
| 337 | DEBUGFS_FWSTATS_DEL(isr, commands); |
| 338 | DEBUGFS_FWSTATS_DEL(isr, rx_procs); |
| 339 | DEBUGFS_FWSTATS_DEL(isr, hw_pm_mode_changes); |
| 340 | DEBUGFS_FWSTATS_DEL(isr, host_acknowledges); |
| 341 | DEBUGFS_FWSTATS_DEL(isr, pci_pm); |
| 342 | DEBUGFS_FWSTATS_DEL(isr, wakeups); |
| 343 | DEBUGFS_FWSTATS_DEL(isr, low_rssi); |
| 344 | |
| 345 | DEBUGFS_FWSTATS_DEL(wep, addr_key_count); |
| 346 | DEBUGFS_FWSTATS_DEL(wep, default_key_count); |
| 347 | /* skipping wep.reserved */ |
| 348 | DEBUGFS_FWSTATS_DEL(wep, key_not_found); |
| 349 | DEBUGFS_FWSTATS_DEL(wep, decrypt_fail); |
| 350 | DEBUGFS_FWSTATS_DEL(wep, packets); |
| 351 | DEBUGFS_FWSTATS_DEL(wep, interrupt); |
| 352 | |
| 353 | DEBUGFS_FWSTATS_DEL(pwr, ps_enter); |
| 354 | DEBUGFS_FWSTATS_DEL(pwr, elp_enter); |
| 355 | DEBUGFS_FWSTATS_DEL(pwr, missing_bcns); |
| 356 | DEBUGFS_FWSTATS_DEL(pwr, wake_on_host); |
| 357 | DEBUGFS_FWSTATS_DEL(pwr, wake_on_timer_exp); |
| 358 | DEBUGFS_FWSTATS_DEL(pwr, tx_with_ps); |
| 359 | DEBUGFS_FWSTATS_DEL(pwr, tx_without_ps); |
| 360 | DEBUGFS_FWSTATS_DEL(pwr, rcvd_beacons); |
| 361 | DEBUGFS_FWSTATS_DEL(pwr, power_save_off); |
| 362 | DEBUGFS_FWSTATS_DEL(pwr, enable_ps); |
| 363 | DEBUGFS_FWSTATS_DEL(pwr, disable_ps); |
| 364 | DEBUGFS_FWSTATS_DEL(pwr, fix_tsf_ps); |
| 365 | /* skipping cont_miss_bcns_spread for now */ |
| 366 | DEBUGFS_FWSTATS_DEL(pwr, rcvd_awake_beacons); |
| 367 | |
| 368 | DEBUGFS_FWSTATS_DEL(mic, rx_pkts); |
| 369 | DEBUGFS_FWSTATS_DEL(mic, calc_failure); |
| 370 | |
| 371 | DEBUGFS_FWSTATS_DEL(aes, encrypt_fail); |
| 372 | DEBUGFS_FWSTATS_DEL(aes, decrypt_fail); |
| 373 | DEBUGFS_FWSTATS_DEL(aes, encrypt_packets); |
| 374 | DEBUGFS_FWSTATS_DEL(aes, decrypt_packets); |
| 375 | DEBUGFS_FWSTATS_DEL(aes, encrypt_interrupt); |
| 376 | DEBUGFS_FWSTATS_DEL(aes, decrypt_interrupt); |
| 377 | |
| 378 | DEBUGFS_FWSTATS_DEL(event, heart_beat); |
| 379 | DEBUGFS_FWSTATS_DEL(event, calibration); |
| 380 | DEBUGFS_FWSTATS_DEL(event, rx_mismatch); |
| 381 | DEBUGFS_FWSTATS_DEL(event, rx_mem_empty); |
| 382 | DEBUGFS_FWSTATS_DEL(event, rx_pool); |
| 383 | DEBUGFS_FWSTATS_DEL(event, oom_late); |
| 384 | DEBUGFS_FWSTATS_DEL(event, phy_transmit_error); |
| 385 | DEBUGFS_FWSTATS_DEL(event, tx_stuck); |
| 386 | |
| 387 | DEBUGFS_FWSTATS_DEL(ps, pspoll_timeouts); |
| 388 | DEBUGFS_FWSTATS_DEL(ps, upsd_timeouts); |
| 389 | DEBUGFS_FWSTATS_DEL(ps, upsd_max_sptime); |
| 390 | DEBUGFS_FWSTATS_DEL(ps, upsd_max_apturn); |
| 391 | DEBUGFS_FWSTATS_DEL(ps, pspoll_max_apturn); |
| 392 | DEBUGFS_FWSTATS_DEL(ps, pspoll_utilization); |
| 393 | DEBUGFS_FWSTATS_DEL(ps, upsd_utilization); |
| 394 | |
| 395 | DEBUGFS_FWSTATS_DEL(rxpipe, rx_prep_beacon_drop); |
| 396 | DEBUGFS_FWSTATS_DEL(rxpipe, descr_host_int_trig_rx_data); |
| 397 | DEBUGFS_FWSTATS_DEL(rxpipe, beacon_buffer_thres_host_int_trig_rx_data); |
| 398 | DEBUGFS_FWSTATS_DEL(rxpipe, missed_beacon_host_int_trig_rx_data); |
| 399 | DEBUGFS_FWSTATS_DEL(rxpipe, tx_xfr_host_int_trig_rx_data); |
| 400 | |
| 401 | DEBUGFS_DEL(tx_queue_len); |
| 402 | DEBUGFS_DEL(retry_count); |
| 403 | DEBUGFS_DEL(excessive_retries); |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 404 | |
| 405 | DEBUGFS_DEL(gpio_power); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | static int wl1271_debugfs_add_files(struct wl1271 *wl) |
| 409 | { |
| 410 | int ret = 0; |
| 411 | |
| 412 | DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow); |
| 413 | |
| 414 | DEBUGFS_FWSTATS_ADD(rx, out_of_mem); |
| 415 | DEBUGFS_FWSTATS_ADD(rx, hdr_overflow); |
| 416 | DEBUGFS_FWSTATS_ADD(rx, hw_stuck); |
| 417 | DEBUGFS_FWSTATS_ADD(rx, dropped); |
| 418 | DEBUGFS_FWSTATS_ADD(rx, fcs_err); |
| 419 | DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig); |
| 420 | DEBUGFS_FWSTATS_ADD(rx, path_reset); |
| 421 | DEBUGFS_FWSTATS_ADD(rx, reset_counter); |
| 422 | |
| 423 | DEBUGFS_FWSTATS_ADD(dma, rx_requested); |
| 424 | DEBUGFS_FWSTATS_ADD(dma, rx_errors); |
| 425 | DEBUGFS_FWSTATS_ADD(dma, tx_requested); |
| 426 | DEBUGFS_FWSTATS_ADD(dma, tx_errors); |
| 427 | |
| 428 | DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt); |
| 429 | DEBUGFS_FWSTATS_ADD(isr, fiqs); |
| 430 | DEBUGFS_FWSTATS_ADD(isr, rx_headers); |
| 431 | DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow); |
| 432 | DEBUGFS_FWSTATS_ADD(isr, rx_rdys); |
| 433 | DEBUGFS_FWSTATS_ADD(isr, irqs); |
| 434 | DEBUGFS_FWSTATS_ADD(isr, tx_procs); |
| 435 | DEBUGFS_FWSTATS_ADD(isr, decrypt_done); |
| 436 | DEBUGFS_FWSTATS_ADD(isr, dma0_done); |
| 437 | DEBUGFS_FWSTATS_ADD(isr, dma1_done); |
| 438 | DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete); |
| 439 | DEBUGFS_FWSTATS_ADD(isr, commands); |
| 440 | DEBUGFS_FWSTATS_ADD(isr, rx_procs); |
| 441 | DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes); |
| 442 | DEBUGFS_FWSTATS_ADD(isr, host_acknowledges); |
| 443 | DEBUGFS_FWSTATS_ADD(isr, pci_pm); |
| 444 | DEBUGFS_FWSTATS_ADD(isr, wakeups); |
| 445 | DEBUGFS_FWSTATS_ADD(isr, low_rssi); |
| 446 | |
| 447 | DEBUGFS_FWSTATS_ADD(wep, addr_key_count); |
| 448 | DEBUGFS_FWSTATS_ADD(wep, default_key_count); |
| 449 | /* skipping wep.reserved */ |
| 450 | DEBUGFS_FWSTATS_ADD(wep, key_not_found); |
| 451 | DEBUGFS_FWSTATS_ADD(wep, decrypt_fail); |
| 452 | DEBUGFS_FWSTATS_ADD(wep, packets); |
| 453 | DEBUGFS_FWSTATS_ADD(wep, interrupt); |
| 454 | |
| 455 | DEBUGFS_FWSTATS_ADD(pwr, ps_enter); |
| 456 | DEBUGFS_FWSTATS_ADD(pwr, elp_enter); |
| 457 | DEBUGFS_FWSTATS_ADD(pwr, missing_bcns); |
| 458 | DEBUGFS_FWSTATS_ADD(pwr, wake_on_host); |
| 459 | DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp); |
| 460 | DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps); |
| 461 | DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps); |
| 462 | DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons); |
| 463 | DEBUGFS_FWSTATS_ADD(pwr, power_save_off); |
| 464 | DEBUGFS_FWSTATS_ADD(pwr, enable_ps); |
| 465 | DEBUGFS_FWSTATS_ADD(pwr, disable_ps); |
| 466 | DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps); |
| 467 | /* skipping cont_miss_bcns_spread for now */ |
| 468 | DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons); |
| 469 | |
| 470 | DEBUGFS_FWSTATS_ADD(mic, rx_pkts); |
| 471 | DEBUGFS_FWSTATS_ADD(mic, calc_failure); |
| 472 | |
| 473 | DEBUGFS_FWSTATS_ADD(aes, encrypt_fail); |
| 474 | DEBUGFS_FWSTATS_ADD(aes, decrypt_fail); |
| 475 | DEBUGFS_FWSTATS_ADD(aes, encrypt_packets); |
| 476 | DEBUGFS_FWSTATS_ADD(aes, decrypt_packets); |
| 477 | DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt); |
| 478 | DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt); |
| 479 | |
| 480 | DEBUGFS_FWSTATS_ADD(event, heart_beat); |
| 481 | DEBUGFS_FWSTATS_ADD(event, calibration); |
| 482 | DEBUGFS_FWSTATS_ADD(event, rx_mismatch); |
| 483 | DEBUGFS_FWSTATS_ADD(event, rx_mem_empty); |
| 484 | DEBUGFS_FWSTATS_ADD(event, rx_pool); |
| 485 | DEBUGFS_FWSTATS_ADD(event, oom_late); |
| 486 | DEBUGFS_FWSTATS_ADD(event, phy_transmit_error); |
| 487 | DEBUGFS_FWSTATS_ADD(event, tx_stuck); |
| 488 | |
| 489 | DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts); |
| 490 | DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts); |
| 491 | DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime); |
| 492 | DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn); |
| 493 | DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn); |
| 494 | DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization); |
| 495 | DEBUGFS_FWSTATS_ADD(ps, upsd_utilization); |
| 496 | |
| 497 | DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop); |
| 498 | DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data); |
| 499 | DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data); |
| 500 | DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data); |
| 501 | DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data); |
| 502 | |
| 503 | DEBUGFS_ADD(tx_queue_len, wl->debugfs.rootdir); |
| 504 | DEBUGFS_ADD(retry_count, wl->debugfs.rootdir); |
| 505 | DEBUGFS_ADD(excessive_retries, wl->debugfs.rootdir); |
| 506 | |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 507 | DEBUGFS_ADD(gpio_power, wl->debugfs.rootdir); |
| 508 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 509 | out: |
| 510 | if (ret < 0) |
| 511 | wl1271_debugfs_delete_files(wl); |
| 512 | |
| 513 | return ret; |
| 514 | } |
| 515 | |
| 516 | void wl1271_debugfs_reset(struct wl1271 *wl) |
| 517 | { |
| 518 | memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats)); |
| 519 | wl->stats.retry_count = 0; |
| 520 | wl->stats.excessive_retries = 0; |
| 521 | } |
| 522 | |
| 523 | int wl1271_debugfs_init(struct wl1271 *wl) |
| 524 | { |
| 525 | int ret; |
| 526 | |
| 527 | wl->debugfs.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL); |
| 528 | |
| 529 | if (IS_ERR(wl->debugfs.rootdir)) { |
| 530 | ret = PTR_ERR(wl->debugfs.rootdir); |
| 531 | wl->debugfs.rootdir = NULL; |
| 532 | goto err; |
| 533 | } |
| 534 | |
| 535 | wl->debugfs.fw_statistics = debugfs_create_dir("fw-statistics", |
| 536 | wl->debugfs.rootdir); |
| 537 | |
| 538 | if (IS_ERR(wl->debugfs.fw_statistics)) { |
| 539 | ret = PTR_ERR(wl->debugfs.fw_statistics); |
| 540 | wl->debugfs.fw_statistics = NULL; |
| 541 | goto err_root; |
| 542 | } |
| 543 | |
| 544 | wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats), |
| 545 | GFP_KERNEL); |
| 546 | |
| 547 | if (!wl->stats.fw_stats) { |
| 548 | ret = -ENOMEM; |
| 549 | goto err_fw; |
| 550 | } |
| 551 | |
| 552 | wl->stats.fw_stats_update = jiffies; |
| 553 | |
| 554 | ret = wl1271_debugfs_add_files(wl); |
| 555 | |
| 556 | if (ret < 0) |
| 557 | goto err_file; |
| 558 | |
| 559 | return 0; |
| 560 | |
| 561 | err_file: |
| 562 | kfree(wl->stats.fw_stats); |
| 563 | wl->stats.fw_stats = NULL; |
| 564 | |
| 565 | err_fw: |
| 566 | debugfs_remove(wl->debugfs.fw_statistics); |
| 567 | wl->debugfs.fw_statistics = NULL; |
| 568 | |
| 569 | err_root: |
| 570 | debugfs_remove(wl->debugfs.rootdir); |
| 571 | wl->debugfs.rootdir = NULL; |
| 572 | |
| 573 | err: |
| 574 | return ret; |
| 575 | } |
| 576 | |
| 577 | void wl1271_debugfs_exit(struct wl1271 *wl) |
| 578 | { |
| 579 | wl1271_debugfs_delete_files(wl); |
| 580 | |
| 581 | kfree(wl->stats.fw_stats); |
| 582 | wl->stats.fw_stats = NULL; |
| 583 | |
| 584 | debugfs_remove(wl->debugfs.fw_statistics); |
| 585 | wl->debugfs.fw_statistics = NULL; |
| 586 | |
| 587 | debugfs_remove(wl->debugfs.rootdir); |
| 588 | wl->debugfs.rootdir = NULL; |
| 589 | |
| 590 | } |