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) \ |
Eliad Peller | 7cb2cea | 2010-11-24 12:53:15 +0200 | [diff] [blame^] | 69 | entry = debugfs_create_file(#name, 0400, parent, \ |
| 70 | wl, &name## _ops); \ |
| 71 | if (!entry || IS_ERR(entry)) \ |
| 72 | goto err; \ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 73 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 74 | #define DEBUGFS_FWSTATS_FILE(sub, name, fmt) \ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 75 | static ssize_t sub## _ ##name## _read(struct file *file, \ |
| 76 | char __user *userbuf, \ |
| 77 | size_t count, loff_t *ppos) \ |
| 78 | { \ |
| 79 | struct wl1271 *wl = file->private_data; \ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 80 | \ |
| 81 | wl1271_debugfs_update_stats(wl); \ |
| 82 | \ |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 83 | return wl1271_format_buffer(userbuf, count, ppos, fmt "\n", \ |
| 84 | wl->stats.fw_stats->sub.name); \ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 85 | } \ |
| 86 | \ |
| 87 | static const struct file_operations sub## _ ##name## _ops = { \ |
| 88 | .read = sub## _ ##name## _read, \ |
| 89 | .open = wl1271_open_file_generic, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 90 | .llseek = generic_file_llseek, \ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | #define DEBUGFS_FWSTATS_ADD(sub, name) \ |
Eliad Peller | 7cb2cea | 2010-11-24 12:53:15 +0200 | [diff] [blame^] | 94 | DEBUGFS_ADD(sub## _ ##name, stats) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 95 | |
| 96 | static void wl1271_debugfs_update_stats(struct wl1271 *wl) |
| 97 | { |
| 98 | int ret; |
| 99 | |
| 100 | mutex_lock(&wl->mutex); |
| 101 | |
| 102 | ret = wl1271_ps_elp_wakeup(wl, false); |
| 103 | if (ret < 0) |
| 104 | goto out; |
| 105 | |
| 106 | if (wl->state == WL1271_STATE_ON && |
| 107 | time_after(jiffies, wl->stats.fw_stats_update + |
| 108 | msecs_to_jiffies(WL1271_DEBUGFS_STATS_LIFETIME))) { |
| 109 | wl1271_acx_statistics(wl, wl->stats.fw_stats); |
| 110 | wl->stats.fw_stats_update = jiffies; |
| 111 | } |
| 112 | |
| 113 | wl1271_ps_elp_sleep(wl); |
| 114 | |
| 115 | out: |
| 116 | mutex_unlock(&wl->mutex); |
| 117 | } |
| 118 | |
| 119 | static int wl1271_open_file_generic(struct inode *inode, struct file *file) |
| 120 | { |
| 121 | file->private_data = inode->i_private; |
| 122 | return 0; |
| 123 | } |
| 124 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 125 | DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 126 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 127 | DEBUGFS_FWSTATS_FILE(rx, out_of_mem, "%u"); |
| 128 | DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, "%u"); |
| 129 | DEBUGFS_FWSTATS_FILE(rx, hw_stuck, "%u"); |
| 130 | DEBUGFS_FWSTATS_FILE(rx, dropped, "%u"); |
| 131 | DEBUGFS_FWSTATS_FILE(rx, fcs_err, "%u"); |
| 132 | DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, "%u"); |
| 133 | DEBUGFS_FWSTATS_FILE(rx, path_reset, "%u"); |
| 134 | DEBUGFS_FWSTATS_FILE(rx, reset_counter, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 135 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 136 | DEBUGFS_FWSTATS_FILE(dma, rx_requested, "%u"); |
| 137 | DEBUGFS_FWSTATS_FILE(dma, rx_errors, "%u"); |
| 138 | DEBUGFS_FWSTATS_FILE(dma, tx_requested, "%u"); |
| 139 | DEBUGFS_FWSTATS_FILE(dma, tx_errors, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 140 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 141 | DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, "%u"); |
| 142 | DEBUGFS_FWSTATS_FILE(isr, fiqs, "%u"); |
| 143 | DEBUGFS_FWSTATS_FILE(isr, rx_headers, "%u"); |
| 144 | DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, "%u"); |
| 145 | DEBUGFS_FWSTATS_FILE(isr, rx_rdys, "%u"); |
| 146 | DEBUGFS_FWSTATS_FILE(isr, irqs, "%u"); |
| 147 | DEBUGFS_FWSTATS_FILE(isr, tx_procs, "%u"); |
| 148 | DEBUGFS_FWSTATS_FILE(isr, decrypt_done, "%u"); |
| 149 | DEBUGFS_FWSTATS_FILE(isr, dma0_done, "%u"); |
| 150 | DEBUGFS_FWSTATS_FILE(isr, dma1_done, "%u"); |
| 151 | DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, "%u"); |
| 152 | DEBUGFS_FWSTATS_FILE(isr, commands, "%u"); |
| 153 | DEBUGFS_FWSTATS_FILE(isr, rx_procs, "%u"); |
| 154 | DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, "%u"); |
| 155 | DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, "%u"); |
| 156 | DEBUGFS_FWSTATS_FILE(isr, pci_pm, "%u"); |
| 157 | DEBUGFS_FWSTATS_FILE(isr, wakeups, "%u"); |
| 158 | DEBUGFS_FWSTATS_FILE(isr, low_rssi, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 159 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 160 | DEBUGFS_FWSTATS_FILE(wep, addr_key_count, "%u"); |
| 161 | DEBUGFS_FWSTATS_FILE(wep, default_key_count, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 162 | /* skipping wep.reserved */ |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 163 | DEBUGFS_FWSTATS_FILE(wep, key_not_found, "%u"); |
| 164 | DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, "%u"); |
| 165 | DEBUGFS_FWSTATS_FILE(wep, packets, "%u"); |
| 166 | DEBUGFS_FWSTATS_FILE(wep, interrupt, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 167 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 168 | DEBUGFS_FWSTATS_FILE(pwr, ps_enter, "%u"); |
| 169 | DEBUGFS_FWSTATS_FILE(pwr, elp_enter, "%u"); |
| 170 | DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, "%u"); |
| 171 | DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, "%u"); |
| 172 | DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, "%u"); |
| 173 | DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, "%u"); |
| 174 | DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, "%u"); |
| 175 | DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, "%u"); |
| 176 | DEBUGFS_FWSTATS_FILE(pwr, power_save_off, "%u"); |
| 177 | DEBUGFS_FWSTATS_FILE(pwr, enable_ps, "%u"); |
| 178 | DEBUGFS_FWSTATS_FILE(pwr, disable_ps, "%u"); |
| 179 | DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 180 | /* skipping cont_miss_bcns_spread for now */ |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 181 | DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 182 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 183 | DEBUGFS_FWSTATS_FILE(mic, rx_pkts, "%u"); |
| 184 | DEBUGFS_FWSTATS_FILE(mic, calc_failure, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 185 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 186 | DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, "%u"); |
| 187 | DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, "%u"); |
| 188 | DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, "%u"); |
| 189 | DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, "%u"); |
| 190 | DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, "%u"); |
| 191 | DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 192 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 193 | DEBUGFS_FWSTATS_FILE(event, heart_beat, "%u"); |
| 194 | DEBUGFS_FWSTATS_FILE(event, calibration, "%u"); |
| 195 | DEBUGFS_FWSTATS_FILE(event, rx_mismatch, "%u"); |
| 196 | DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, "%u"); |
| 197 | DEBUGFS_FWSTATS_FILE(event, rx_pool, "%u"); |
| 198 | DEBUGFS_FWSTATS_FILE(event, oom_late, "%u"); |
| 199 | DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, "%u"); |
| 200 | DEBUGFS_FWSTATS_FILE(event, tx_stuck, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 201 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 202 | DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, "%u"); |
| 203 | DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, "%u"); |
| 204 | DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, "%u"); |
| 205 | DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, "%u"); |
| 206 | DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, "%u"); |
| 207 | DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, "%u"); |
| 208 | DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 209 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 210 | DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, "%u"); |
| 211 | DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, "%u"); |
| 212 | DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data, "%u"); |
| 213 | DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, "%u"); |
| 214 | DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, "%u"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 215 | |
Eliad Peller | 03107a4 | 2010-10-27 14:58:30 +0200 | [diff] [blame] | 216 | DEBUGFS_READONLY_FILE(retry_count, "%u", wl->stats.retry_count); |
| 217 | DEBUGFS_READONLY_FILE(excessive_retries, "%u", |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 218 | wl->stats.excessive_retries); |
| 219 | |
| 220 | static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf, |
| 221 | size_t count, loff_t *ppos) |
| 222 | { |
| 223 | struct wl1271 *wl = file->private_data; |
| 224 | u32 queue_len; |
| 225 | char buf[20]; |
| 226 | int res; |
| 227 | |
| 228 | queue_len = skb_queue_len(&wl->tx_queue); |
| 229 | |
| 230 | res = scnprintf(buf, sizeof(buf), "%u\n", queue_len); |
| 231 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); |
| 232 | } |
| 233 | |
| 234 | static const struct file_operations tx_queue_len_ops = { |
| 235 | .read = tx_queue_len_read, |
| 236 | .open = wl1271_open_file_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 237 | .llseek = default_llseek, |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 238 | }; |
| 239 | |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 240 | static ssize_t gpio_power_read(struct file *file, char __user *user_buf, |
| 241 | size_t count, loff_t *ppos) |
| 242 | { |
| 243 | struct wl1271 *wl = file->private_data; |
Juuso Oikarinen | 71449f8 | 2009-12-11 15:41:07 +0200 | [diff] [blame] | 244 | bool state = test_bit(WL1271_FLAG_GPIO_POWER, &wl->flags); |
| 245 | |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 246 | int res; |
| 247 | char buf[10]; |
| 248 | |
Juuso Oikarinen | 71449f8 | 2009-12-11 15:41:07 +0200 | [diff] [blame] | 249 | res = scnprintf(buf, sizeof(buf), "%d\n", state); |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 250 | |
| 251 | return simple_read_from_buffer(user_buf, count, ppos, buf, res); |
| 252 | } |
| 253 | |
| 254 | static ssize_t gpio_power_write(struct file *file, |
| 255 | const char __user *user_buf, |
| 256 | size_t count, loff_t *ppos) |
| 257 | { |
| 258 | struct wl1271 *wl = file->private_data; |
| 259 | char buf[10]; |
| 260 | size_t len; |
| 261 | unsigned long value; |
| 262 | int ret; |
| 263 | |
| 264 | mutex_lock(&wl->mutex); |
| 265 | |
| 266 | len = min(count, sizeof(buf) - 1); |
| 267 | if (copy_from_user(buf, user_buf, len)) { |
| 268 | ret = -EFAULT; |
| 269 | goto out; |
| 270 | } |
| 271 | buf[len] = '\0'; |
| 272 | |
| 273 | ret = strict_strtoul(buf, 0, &value); |
| 274 | if (ret < 0) { |
| 275 | wl1271_warning("illegal value in gpio_power"); |
| 276 | goto out; |
| 277 | } |
| 278 | |
Teemu Paasikivi | becd551 | 2010-03-18 12:26:27 +0200 | [diff] [blame] | 279 | if (value) |
| 280 | wl1271_power_on(wl); |
| 281 | else |
| 282 | wl1271_power_off(wl); |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 283 | |
| 284 | out: |
| 285 | mutex_unlock(&wl->mutex); |
| 286 | return count; |
| 287 | } |
| 288 | |
| 289 | static const struct file_operations gpio_power_ops = { |
| 290 | .read = gpio_power_read, |
| 291 | .write = gpio_power_write, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 292 | .open = wl1271_open_file_generic, |
| 293 | .llseek = default_llseek, |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 294 | }; |
| 295 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 296 | static int wl1271_debugfs_add_files(struct wl1271 *wl) |
| 297 | { |
| 298 | int ret = 0; |
Eliad Peller | 7cb2cea | 2010-11-24 12:53:15 +0200 | [diff] [blame^] | 299 | struct dentry *entry, *stats; |
| 300 | |
| 301 | stats = debugfs_create_dir("fw-statistics", wl->rootdir); |
| 302 | if (!stats || IS_ERR(stats)) { |
| 303 | entry = stats; |
| 304 | goto err; |
| 305 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 306 | |
| 307 | DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow); |
| 308 | |
| 309 | DEBUGFS_FWSTATS_ADD(rx, out_of_mem); |
| 310 | DEBUGFS_FWSTATS_ADD(rx, hdr_overflow); |
| 311 | DEBUGFS_FWSTATS_ADD(rx, hw_stuck); |
| 312 | DEBUGFS_FWSTATS_ADD(rx, dropped); |
| 313 | DEBUGFS_FWSTATS_ADD(rx, fcs_err); |
| 314 | DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig); |
| 315 | DEBUGFS_FWSTATS_ADD(rx, path_reset); |
| 316 | DEBUGFS_FWSTATS_ADD(rx, reset_counter); |
| 317 | |
| 318 | DEBUGFS_FWSTATS_ADD(dma, rx_requested); |
| 319 | DEBUGFS_FWSTATS_ADD(dma, rx_errors); |
| 320 | DEBUGFS_FWSTATS_ADD(dma, tx_requested); |
| 321 | DEBUGFS_FWSTATS_ADD(dma, tx_errors); |
| 322 | |
| 323 | DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt); |
| 324 | DEBUGFS_FWSTATS_ADD(isr, fiqs); |
| 325 | DEBUGFS_FWSTATS_ADD(isr, rx_headers); |
| 326 | DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow); |
| 327 | DEBUGFS_FWSTATS_ADD(isr, rx_rdys); |
| 328 | DEBUGFS_FWSTATS_ADD(isr, irqs); |
| 329 | DEBUGFS_FWSTATS_ADD(isr, tx_procs); |
| 330 | DEBUGFS_FWSTATS_ADD(isr, decrypt_done); |
| 331 | DEBUGFS_FWSTATS_ADD(isr, dma0_done); |
| 332 | DEBUGFS_FWSTATS_ADD(isr, dma1_done); |
| 333 | DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete); |
| 334 | DEBUGFS_FWSTATS_ADD(isr, commands); |
| 335 | DEBUGFS_FWSTATS_ADD(isr, rx_procs); |
| 336 | DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes); |
| 337 | DEBUGFS_FWSTATS_ADD(isr, host_acknowledges); |
| 338 | DEBUGFS_FWSTATS_ADD(isr, pci_pm); |
| 339 | DEBUGFS_FWSTATS_ADD(isr, wakeups); |
| 340 | DEBUGFS_FWSTATS_ADD(isr, low_rssi); |
| 341 | |
| 342 | DEBUGFS_FWSTATS_ADD(wep, addr_key_count); |
| 343 | DEBUGFS_FWSTATS_ADD(wep, default_key_count); |
| 344 | /* skipping wep.reserved */ |
| 345 | DEBUGFS_FWSTATS_ADD(wep, key_not_found); |
| 346 | DEBUGFS_FWSTATS_ADD(wep, decrypt_fail); |
| 347 | DEBUGFS_FWSTATS_ADD(wep, packets); |
| 348 | DEBUGFS_FWSTATS_ADD(wep, interrupt); |
| 349 | |
| 350 | DEBUGFS_FWSTATS_ADD(pwr, ps_enter); |
| 351 | DEBUGFS_FWSTATS_ADD(pwr, elp_enter); |
| 352 | DEBUGFS_FWSTATS_ADD(pwr, missing_bcns); |
| 353 | DEBUGFS_FWSTATS_ADD(pwr, wake_on_host); |
| 354 | DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp); |
| 355 | DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps); |
| 356 | DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps); |
| 357 | DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons); |
| 358 | DEBUGFS_FWSTATS_ADD(pwr, power_save_off); |
| 359 | DEBUGFS_FWSTATS_ADD(pwr, enable_ps); |
| 360 | DEBUGFS_FWSTATS_ADD(pwr, disable_ps); |
| 361 | DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps); |
| 362 | /* skipping cont_miss_bcns_spread for now */ |
| 363 | DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons); |
| 364 | |
| 365 | DEBUGFS_FWSTATS_ADD(mic, rx_pkts); |
| 366 | DEBUGFS_FWSTATS_ADD(mic, calc_failure); |
| 367 | |
| 368 | DEBUGFS_FWSTATS_ADD(aes, encrypt_fail); |
| 369 | DEBUGFS_FWSTATS_ADD(aes, decrypt_fail); |
| 370 | DEBUGFS_FWSTATS_ADD(aes, encrypt_packets); |
| 371 | DEBUGFS_FWSTATS_ADD(aes, decrypt_packets); |
| 372 | DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt); |
| 373 | DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt); |
| 374 | |
| 375 | DEBUGFS_FWSTATS_ADD(event, heart_beat); |
| 376 | DEBUGFS_FWSTATS_ADD(event, calibration); |
| 377 | DEBUGFS_FWSTATS_ADD(event, rx_mismatch); |
| 378 | DEBUGFS_FWSTATS_ADD(event, rx_mem_empty); |
| 379 | DEBUGFS_FWSTATS_ADD(event, rx_pool); |
| 380 | DEBUGFS_FWSTATS_ADD(event, oom_late); |
| 381 | DEBUGFS_FWSTATS_ADD(event, phy_transmit_error); |
| 382 | DEBUGFS_FWSTATS_ADD(event, tx_stuck); |
| 383 | |
| 384 | DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts); |
| 385 | DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts); |
| 386 | DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime); |
| 387 | DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn); |
| 388 | DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn); |
| 389 | DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization); |
| 390 | DEBUGFS_FWSTATS_ADD(ps, upsd_utilization); |
| 391 | |
| 392 | DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop); |
| 393 | DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data); |
| 394 | DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data); |
| 395 | DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data); |
| 396 | DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data); |
| 397 | |
Eliad Peller | 7cb2cea | 2010-11-24 12:53:15 +0200 | [diff] [blame^] | 398 | DEBUGFS_ADD(tx_queue_len, wl->rootdir); |
| 399 | DEBUGFS_ADD(retry_count, wl->rootdir); |
| 400 | DEBUGFS_ADD(excessive_retries, wl->rootdir); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 401 | |
Eliad Peller | 7cb2cea | 2010-11-24 12:53:15 +0200 | [diff] [blame^] | 402 | DEBUGFS_ADD(gpio_power, wl->rootdir); |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 403 | |
Eliad Peller | 7cb2cea | 2010-11-24 12:53:15 +0200 | [diff] [blame^] | 404 | return 0; |
| 405 | |
| 406 | err: |
| 407 | if (IS_ERR(entry)) |
| 408 | ret = PTR_ERR(entry); |
| 409 | else |
| 410 | ret = -ENOMEM; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 411 | |
| 412 | return ret; |
| 413 | } |
| 414 | |
| 415 | void wl1271_debugfs_reset(struct wl1271 *wl) |
| 416 | { |
| 417 | memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats)); |
| 418 | wl->stats.retry_count = 0; |
| 419 | wl->stats.excessive_retries = 0; |
| 420 | } |
| 421 | |
| 422 | int wl1271_debugfs_init(struct wl1271 *wl) |
| 423 | { |
| 424 | int ret; |
| 425 | |
Eliad Peller | 7cb2cea | 2010-11-24 12:53:15 +0200 | [diff] [blame^] | 426 | wl->rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 427 | |
Eliad Peller | 7cb2cea | 2010-11-24 12:53:15 +0200 | [diff] [blame^] | 428 | if (IS_ERR(wl->rootdir)) { |
| 429 | ret = PTR_ERR(wl->rootdir); |
| 430 | wl->rootdir = NULL; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 431 | goto err; |
| 432 | } |
| 433 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 434 | wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats), |
| 435 | GFP_KERNEL); |
| 436 | |
| 437 | if (!wl->stats.fw_stats) { |
| 438 | ret = -ENOMEM; |
| 439 | goto err_fw; |
| 440 | } |
| 441 | |
| 442 | wl->stats.fw_stats_update = jiffies; |
| 443 | |
| 444 | ret = wl1271_debugfs_add_files(wl); |
| 445 | |
| 446 | if (ret < 0) |
| 447 | goto err_file; |
| 448 | |
| 449 | return 0; |
| 450 | |
| 451 | err_file: |
| 452 | kfree(wl->stats.fw_stats); |
| 453 | wl->stats.fw_stats = NULL; |
| 454 | |
| 455 | err_fw: |
Eliad Peller | 7cb2cea | 2010-11-24 12:53:15 +0200 | [diff] [blame^] | 456 | debugfs_remove_recursive(wl->rootdir); |
| 457 | wl->rootdir = NULL; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 458 | |
| 459 | err: |
| 460 | return ret; |
| 461 | } |
| 462 | |
| 463 | void wl1271_debugfs_exit(struct wl1271 *wl) |
| 464 | { |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 465 | kfree(wl->stats.fw_stats); |
| 466 | wl->stats.fw_stats = NULL; |
| 467 | |
Eliad Peller | 7cb2cea | 2010-11-24 12:53:15 +0200 | [diff] [blame^] | 468 | debugfs_remove_recursive(wl->rootdir); |
| 469 | wl->rootdir = NULL; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 470 | |
| 471 | } |