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