Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 1 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 2 | /* |
| 3 | * mac80211 debugfs for wireless PHYs |
| 4 | * |
| 5 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> |
| 6 | * |
| 7 | * GPLv2 |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | #include <linux/debugfs.h> |
| 12 | #include <linux/rtnetlink.h> |
| 13 | #include "ieee80211_i.h" |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 14 | #include "driver-ops.h" |
Johannes Berg | 2c8dccc | 2008-04-08 15:14:40 -0400 | [diff] [blame] | 15 | #include "rate.h" |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 16 | #include "debugfs.h" |
| 17 | |
| 18 | int mac80211_open_file_generic(struct inode *inode, struct file *file) |
| 19 | { |
| 20 | file->private_data = inode->i_private; |
| 21 | return 0; |
| 22 | } |
| 23 | |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 24 | #define DEBUGFS_FORMAT_BUFFER_SIZE 100 |
| 25 | |
| 26 | int mac80211_format_buffer(char __user *userbuf, size_t count, |
| 27 | loff_t *ppos, char *fmt, ...) |
| 28 | { |
| 29 | va_list args; |
| 30 | char buf[DEBUGFS_FORMAT_BUFFER_SIZE]; |
| 31 | int res; |
| 32 | |
| 33 | va_start(args, fmt); |
| 34 | res = vscnprintf(buf, sizeof(buf), fmt, args); |
| 35 | va_end(args); |
| 36 | |
| 37 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); |
| 38 | } |
| 39 | |
Ben Greear | 279daf6 | 2011-03-23 14:04:31 -0700 | [diff] [blame] | 40 | #define DEBUGFS_READONLY_FILE_FN(name, fmt, value...) \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 41 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ |
| 42 | size_t count, loff_t *ppos) \ |
| 43 | { \ |
| 44 | struct ieee80211_local *local = file->private_data; \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 45 | \ |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 46 | return mac80211_format_buffer(userbuf, count, ppos, \ |
| 47 | fmt "\n", ##value); \ |
Ben Greear | 279daf6 | 2011-03-23 14:04:31 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | #define DEBUGFS_READONLY_FILE_OPS(name) \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 51 | static const struct file_operations name## _ops = { \ |
| 52 | .read = name## _read, \ |
| 53 | .open = mac80211_open_file_generic, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 54 | .llseek = generic_file_llseek, \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
Ben Greear | 279daf6 | 2011-03-23 14:04:31 -0700 | [diff] [blame] | 57 | #define DEBUGFS_READONLY_FILE(name, fmt, value...) \ |
| 58 | DEBUGFS_READONLY_FILE_FN(name, fmt, value) \ |
| 59 | DEBUGFS_READONLY_FILE_OPS(name) |
| 60 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 61 | #define DEBUGFS_ADD(name) \ |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 62 | debugfs_create_file(#name, 0400, phyd, local, &name## _ops); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 63 | |
Johannes Berg | 827b1fb | 2009-03-13 11:44:18 +0100 | [diff] [blame] | 64 | #define DEBUGFS_ADD_MODE(name, mode) \ |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 65 | debugfs_create_file(#name, mode, phyd, local, &name## _ops); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 66 | |
| 67 | |
Ben Greear | 83bdf2a | 2011-02-15 13:11:22 -0800 | [diff] [blame] | 68 | DEBUGFS_READONLY_FILE(user_power, "%d", |
| 69 | local->user_power_level); |
| 70 | DEBUGFS_READONLY_FILE(power, "%d", |
| 71 | local->hw.conf.power_level); |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 72 | DEBUGFS_READONLY_FILE(frequency, "%d", |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 73 | local->hw.conf.channel->center_freq); |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 74 | DEBUGFS_READONLY_FILE(total_ps_buffered, "%d", |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 75 | local->total_ps_buffered); |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 76 | DEBUGFS_READONLY_FILE(wep_iv, "%#08x", |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 77 | local->wep_iv & 0xffffff); |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 78 | DEBUGFS_READONLY_FILE(rate_ctrl_alg, "%s", |
Johannes Berg | af65cd96 | 2009-11-17 18:18:36 +0100 | [diff] [blame] | 79 | local->rate_ctrl ? local->rate_ctrl->ops->name : "hw/driver"); |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 80 | |
Johannes Berg | 827b1fb | 2009-03-13 11:44:18 +0100 | [diff] [blame] | 81 | static ssize_t reset_write(struct file *file, const char __user *user_buf, |
| 82 | size_t count, loff_t *ppos) |
| 83 | { |
| 84 | struct ieee80211_local *local = file->private_data; |
| 85 | |
| 86 | rtnl_lock(); |
Johannes Berg | eecc480 | 2011-05-04 15:37:29 +0200 | [diff] [blame] | 87 | __ieee80211_suspend(&local->hw, NULL); |
Johannes Berg | 827b1fb | 2009-03-13 11:44:18 +0100 | [diff] [blame] | 88 | __ieee80211_resume(&local->hw); |
| 89 | rtnl_unlock(); |
| 90 | |
| 91 | return count; |
| 92 | } |
| 93 | |
| 94 | static const struct file_operations reset_ops = { |
| 95 | .write = reset_write, |
| 96 | .open = mac80211_open_file_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 97 | .llseek = noop_llseek, |
Johannes Berg | 827b1fb | 2009-03-13 11:44:18 +0100 | [diff] [blame] | 98 | }; |
| 99 | |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 100 | static ssize_t uapsd_queues_read(struct file *file, char __user *user_buf, |
| 101 | size_t count, loff_t *ppos) |
| 102 | { |
| 103 | struct ieee80211_local *local = file->private_data; |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 104 | return mac80211_format_buffer(user_buf, count, ppos, "0x%x\n", |
| 105 | local->uapsd_queues); |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | static ssize_t uapsd_queues_write(struct file *file, |
| 109 | const char __user *user_buf, |
| 110 | size_t count, loff_t *ppos) |
| 111 | { |
| 112 | struct ieee80211_local *local = file->private_data; |
Peter Huewe | b38de31 | 2011-06-07 22:36:14 +0200 | [diff] [blame] | 113 | u8 val; |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 114 | int ret; |
| 115 | |
Peter Huewe | b38de31 | 2011-06-07 22:36:14 +0200 | [diff] [blame] | 116 | ret = kstrtou8_from_user(user_buf, count, 0, &val); |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 117 | if (ret) |
Peter Huewe | b38de31 | 2011-06-07 22:36:14 +0200 | [diff] [blame] | 118 | return ret; |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 119 | |
| 120 | if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) |
| 121 | return -ERANGE; |
| 122 | |
| 123 | local->uapsd_queues = val; |
| 124 | |
| 125 | return count; |
| 126 | } |
| 127 | |
| 128 | static const struct file_operations uapsd_queues_ops = { |
| 129 | .read = uapsd_queues_read, |
| 130 | .write = uapsd_queues_write, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 131 | .open = mac80211_open_file_generic, |
| 132 | .llseek = default_llseek, |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 133 | }; |
| 134 | |
| 135 | static ssize_t uapsd_max_sp_len_read(struct file *file, char __user *user_buf, |
| 136 | size_t count, loff_t *ppos) |
| 137 | { |
| 138 | struct ieee80211_local *local = file->private_data; |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 139 | |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 140 | return mac80211_format_buffer(user_buf, count, ppos, "0x%x\n", |
| 141 | local->uapsd_max_sp_len); |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | static ssize_t uapsd_max_sp_len_write(struct file *file, |
| 145 | const char __user *user_buf, |
| 146 | size_t count, loff_t *ppos) |
| 147 | { |
| 148 | struct ieee80211_local *local = file->private_data; |
| 149 | unsigned long val; |
| 150 | char buf[10]; |
| 151 | size_t len; |
| 152 | int ret; |
| 153 | |
| 154 | len = min(count, sizeof(buf) - 1); |
| 155 | if (copy_from_user(buf, user_buf, len)) |
| 156 | return -EFAULT; |
| 157 | buf[len] = '\0'; |
| 158 | |
Julia Lawall | 61e3f32 | 2011-11-06 14:26:48 +0100 | [diff] [blame] | 159 | ret = kstrtoul(buf, 0, &val); |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 160 | |
| 161 | if (ret) |
| 162 | return -EINVAL; |
| 163 | |
| 164 | if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK) |
| 165 | return -ERANGE; |
| 166 | |
| 167 | local->uapsd_max_sp_len = val; |
| 168 | |
| 169 | return count; |
| 170 | } |
| 171 | |
| 172 | static const struct file_operations uapsd_max_sp_len_ops = { |
| 173 | .read = uapsd_max_sp_len_read, |
| 174 | .write = uapsd_max_sp_len_write, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 175 | .open = mac80211_open_file_generic, |
| 176 | .llseek = default_llseek, |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 177 | }; |
| 178 | |
Benoit Papillault | 199d69f | 2010-02-04 22:00:20 +0100 | [diff] [blame] | 179 | static ssize_t channel_type_read(struct file *file, char __user *user_buf, |
| 180 | size_t count, loff_t *ppos) |
| 181 | { |
| 182 | struct ieee80211_local *local = file->private_data; |
| 183 | const char *buf; |
| 184 | |
| 185 | switch (local->hw.conf.channel_type) { |
| 186 | case NL80211_CHAN_NO_HT: |
| 187 | buf = "no ht\n"; |
| 188 | break; |
| 189 | case NL80211_CHAN_HT20: |
| 190 | buf = "ht20\n"; |
| 191 | break; |
| 192 | case NL80211_CHAN_HT40MINUS: |
| 193 | buf = "ht40-\n"; |
| 194 | break; |
| 195 | case NL80211_CHAN_HT40PLUS: |
| 196 | buf = "ht40+\n"; |
| 197 | break; |
| 198 | default: |
| 199 | buf = "???"; |
| 200 | break; |
| 201 | } |
| 202 | |
| 203 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
| 204 | } |
| 205 | |
Ben Greear | 279daf6 | 2011-03-23 14:04:31 -0700 | [diff] [blame] | 206 | static ssize_t hwflags_read(struct file *file, char __user *user_buf, |
| 207 | size_t count, loff_t *ppos) |
| 208 | { |
| 209 | struct ieee80211_local *local = file->private_data; |
| 210 | int mxln = 500; |
| 211 | ssize_t rv; |
| 212 | char *buf = kzalloc(mxln, GFP_KERNEL); |
| 213 | int sf = 0; /* how many written so far */ |
| 214 | |
Joe Perches | d15b845 | 2011-08-29 14:17:31 -0700 | [diff] [blame] | 215 | if (!buf) |
| 216 | return 0; |
| 217 | |
Ben Greear | 279daf6 | 2011-03-23 14:04:31 -0700 | [diff] [blame] | 218 | sf += snprintf(buf, mxln - sf, "0x%x\n", local->hw.flags); |
| 219 | if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) |
| 220 | sf += snprintf(buf + sf, mxln - sf, "HAS_RATE_CONTROL\n"); |
| 221 | if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) |
| 222 | sf += snprintf(buf + sf, mxln - sf, "RX_INCLUDES_FCS\n"); |
| 223 | if (local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING) |
| 224 | sf += snprintf(buf + sf, mxln - sf, |
| 225 | "HOST_BCAST_PS_BUFFERING\n"); |
| 226 | if (local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE) |
| 227 | sf += snprintf(buf + sf, mxln - sf, |
| 228 | "2GHZ_SHORT_SLOT_INCAPABLE\n"); |
| 229 | if (local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE) |
| 230 | sf += snprintf(buf + sf, mxln - sf, |
| 231 | "2GHZ_SHORT_PREAMBLE_INCAPABLE\n"); |
| 232 | if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) |
| 233 | sf += snprintf(buf + sf, mxln - sf, "SIGNAL_UNSPEC\n"); |
| 234 | if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) |
| 235 | sf += snprintf(buf + sf, mxln - sf, "SIGNAL_DBM\n"); |
| 236 | if (local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) |
| 237 | sf += snprintf(buf + sf, mxln - sf, "NEED_DTIM_PERIOD\n"); |
| 238 | if (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT) |
| 239 | sf += snprintf(buf + sf, mxln - sf, "SPECTRUM_MGMT\n"); |
| 240 | if (local->hw.flags & IEEE80211_HW_AMPDU_AGGREGATION) |
| 241 | sf += snprintf(buf + sf, mxln - sf, "AMPDU_AGGREGATION\n"); |
| 242 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_PS) |
| 243 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_PS\n"); |
| 244 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) |
| 245 | sf += snprintf(buf + sf, mxln - sf, "PS_NULLFUNC_STACK\n"); |
| 246 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) |
| 247 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_PS\n"); |
| 248 | if (local->hw.flags & IEEE80211_HW_MFP_CAPABLE) |
| 249 | sf += snprintf(buf + sf, mxln - sf, "MFP_CAPABLE\n"); |
Ben Greear | 279daf6 | 2011-03-23 14:04:31 -0700 | [diff] [blame] | 250 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_STATIC_SMPS) |
| 251 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_STATIC_SMPS\n"); |
| 252 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS) |
| 253 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_SMPS\n"); |
| 254 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD) |
| 255 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_UAPSD\n"); |
| 256 | if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) |
| 257 | sf += snprintf(buf + sf, mxln - sf, "REPORTS_TX_ACK_STATUS\n"); |
| 258 | if (local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR) |
| 259 | sf += snprintf(buf + sf, mxln - sf, "CONNECTION_MONITOR\n"); |
Ben Greear | 279daf6 | 2011-03-23 14:04:31 -0700 | [diff] [blame] | 260 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK) |
| 261 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_PER_STA_GTK\n"); |
| 262 | if (local->hw.flags & IEEE80211_HW_AP_LINK_PS) |
| 263 | sf += snprintf(buf + sf, mxln - sf, "AP_LINK_PS\n"); |
Arik Nemtsov | edf6b78 | 2011-08-30 09:32:38 +0300 | [diff] [blame] | 264 | if (local->hw.flags & IEEE80211_HW_TX_AMPDU_SETUP_IN_HW) |
| 265 | sf += snprintf(buf + sf, mxln - sf, "TX_AMPDU_SETUP_IN_HW\n"); |
Ben Greear | 279daf6 | 2011-03-23 14:04:31 -0700 | [diff] [blame] | 266 | |
| 267 | rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
| 268 | kfree(buf); |
| 269 | return rv; |
| 270 | } |
Benoit Papillault | 199d69f | 2010-02-04 22:00:20 +0100 | [diff] [blame] | 271 | |
Johannes Berg | db2e6bd | 2009-06-14 17:37:39 +0200 | [diff] [blame] | 272 | static ssize_t queues_read(struct file *file, char __user *user_buf, |
| 273 | size_t count, loff_t *ppos) |
| 274 | { |
| 275 | struct ieee80211_local *local = file->private_data; |
| 276 | unsigned long flags; |
| 277 | char buf[IEEE80211_MAX_QUEUES * 20]; |
| 278 | int q, res = 0; |
| 279 | |
| 280 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
| 281 | for (q = 0; q < local->hw.queues; q++) |
| 282 | res += sprintf(buf + res, "%02d: %#.8lx/%d\n", q, |
| 283 | local->queue_stop_reasons[q], |
Johannes Berg | 3b8d81e0 | 2009-06-17 17:43:56 +0200 | [diff] [blame] | 284 | skb_queue_len(&local->pending[q])); |
Johannes Berg | db2e6bd | 2009-06-14 17:37:39 +0200 | [diff] [blame] | 285 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); |
| 286 | |
| 287 | return simple_read_from_buffer(user_buf, count, ppos, buf, res); |
| 288 | } |
| 289 | |
Ben Greear | 279daf6 | 2011-03-23 14:04:31 -0700 | [diff] [blame] | 290 | DEBUGFS_READONLY_FILE_OPS(hwflags); |
| 291 | DEBUGFS_READONLY_FILE_OPS(channel_type); |
| 292 | DEBUGFS_READONLY_FILE_OPS(queues); |
Johannes Berg | db2e6bd | 2009-06-14 17:37:39 +0200 | [diff] [blame] | 293 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 294 | /* statistics stuff */ |
| 295 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 296 | static ssize_t format_devstat_counter(struct ieee80211_local *local, |
| 297 | char __user *userbuf, |
| 298 | size_t count, loff_t *ppos, |
| 299 | int (*printvalue)(struct ieee80211_low_level_stats *stats, char *buf, |
| 300 | int buflen)) |
| 301 | { |
| 302 | struct ieee80211_low_level_stats stats; |
| 303 | char buf[20]; |
| 304 | int res; |
| 305 | |
Johannes Berg | 7563652 | 2008-07-09 14:40:35 +0200 | [diff] [blame] | 306 | rtnl_lock(); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 307 | res = drv_get_stats(local, &stats); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 308 | rtnl_unlock(); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 309 | if (res) |
| 310 | return res; |
| 311 | res = printvalue(&stats, buf, sizeof(buf)); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 312 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); |
| 313 | } |
| 314 | |
| 315 | #define DEBUGFS_DEVSTATS_FILE(name) \ |
| 316 | static int print_devstats_##name(struct ieee80211_low_level_stats *stats,\ |
| 317 | char *buf, int buflen) \ |
| 318 | { \ |
| 319 | return scnprintf(buf, buflen, "%u\n", stats->name); \ |
| 320 | } \ |
| 321 | static ssize_t stats_ ##name## _read(struct file *file, \ |
| 322 | char __user *userbuf, \ |
| 323 | size_t count, loff_t *ppos) \ |
| 324 | { \ |
| 325 | return format_devstat_counter(file->private_data, \ |
| 326 | userbuf, \ |
| 327 | count, \ |
| 328 | ppos, \ |
| 329 | print_devstats_##name); \ |
| 330 | } \ |
| 331 | \ |
| 332 | static const struct file_operations stats_ ##name## _ops = { \ |
| 333 | .read = stats_ ##name## _read, \ |
| 334 | .open = mac80211_open_file_generic, \ |
Arnd Bergmann | 2b18ab36 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 335 | .llseek = generic_file_llseek, \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 336 | }; |
| 337 | |
Felix Fietkau | 2826bcd | 2010-06-02 02:57:34 +0200 | [diff] [blame] | 338 | #define DEBUGFS_STATS_ADD(name, field) \ |
| 339 | debugfs_create_u32(#name, 0400, statsd, (u32 *) &field); |
| 340 | #define DEBUGFS_DEVSTATS_ADD(name) \ |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 341 | debugfs_create_file(#name, 0400, statsd, local, &stats_ ##name## _ops); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 342 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 343 | DEBUGFS_DEVSTATS_FILE(dot11ACKFailureCount); |
| 344 | DEBUGFS_DEVSTATS_FILE(dot11RTSFailureCount); |
| 345 | DEBUGFS_DEVSTATS_FILE(dot11FCSErrorCount); |
| 346 | DEBUGFS_DEVSTATS_FILE(dot11RTSSuccessCount); |
| 347 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 348 | void debugfs_hw_add(struct ieee80211_local *local) |
| 349 | { |
| 350 | struct dentry *phyd = local->hw.wiphy->debugfsdir; |
| 351 | struct dentry *statsd; |
| 352 | |
| 353 | if (!phyd) |
| 354 | return; |
| 355 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 356 | local->debugfs.keys = debugfs_create_dir("keys", phyd); |
| 357 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 358 | DEBUGFS_ADD(frequency); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 359 | DEBUGFS_ADD(total_ps_buffered); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 360 | DEBUGFS_ADD(wep_iv); |
Johannes Berg | db2e6bd | 2009-06-14 17:37:39 +0200 | [diff] [blame] | 361 | DEBUGFS_ADD(queues); |
Johannes Berg | 827b1fb | 2009-03-13 11:44:18 +0100 | [diff] [blame] | 362 | DEBUGFS_ADD_MODE(reset, 0200); |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 363 | DEBUGFS_ADD(uapsd_queues); |
| 364 | DEBUGFS_ADD(uapsd_max_sp_len); |
Benoit Papillault | 199d69f | 2010-02-04 22:00:20 +0100 | [diff] [blame] | 365 | DEBUGFS_ADD(channel_type); |
Ben Greear | 279daf6 | 2011-03-23 14:04:31 -0700 | [diff] [blame] | 366 | DEBUGFS_ADD(hwflags); |
Ben Greear | 83bdf2a | 2011-02-15 13:11:22 -0800 | [diff] [blame] | 367 | DEBUGFS_ADD(user_power); |
| 368 | DEBUGFS_ADD(power); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 369 | |
| 370 | statsd = debugfs_create_dir("statistics", phyd); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 371 | |
| 372 | /* if the dir failed, don't put all the other things into the root! */ |
| 373 | if (!statsd) |
| 374 | return; |
| 375 | |
Felix Fietkau | 2826bcd | 2010-06-02 02:57:34 +0200 | [diff] [blame] | 376 | DEBUGFS_STATS_ADD(transmitted_fragment_count, |
| 377 | local->dot11TransmittedFragmentCount); |
| 378 | DEBUGFS_STATS_ADD(multicast_transmitted_frame_count, |
| 379 | local->dot11MulticastTransmittedFrameCount); |
| 380 | DEBUGFS_STATS_ADD(failed_count, local->dot11FailedCount); |
| 381 | DEBUGFS_STATS_ADD(retry_count, local->dot11RetryCount); |
| 382 | DEBUGFS_STATS_ADD(multiple_retry_count, |
| 383 | local->dot11MultipleRetryCount); |
| 384 | DEBUGFS_STATS_ADD(frame_duplicate_count, |
| 385 | local->dot11FrameDuplicateCount); |
| 386 | DEBUGFS_STATS_ADD(received_fragment_count, |
| 387 | local->dot11ReceivedFragmentCount); |
| 388 | DEBUGFS_STATS_ADD(multicast_received_frame_count, |
| 389 | local->dot11MulticastReceivedFrameCount); |
| 390 | DEBUGFS_STATS_ADD(transmitted_frame_count, |
| 391 | local->dot11TransmittedFrameCount); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 392 | #ifdef CONFIG_MAC80211_DEBUG_COUNTERS |
Felix Fietkau | 2826bcd | 2010-06-02 02:57:34 +0200 | [diff] [blame] | 393 | DEBUGFS_STATS_ADD(tx_handlers_drop, local->tx_handlers_drop); |
| 394 | DEBUGFS_STATS_ADD(tx_handlers_queued, local->tx_handlers_queued); |
| 395 | DEBUGFS_STATS_ADD(tx_handlers_drop_unencrypted, |
| 396 | local->tx_handlers_drop_unencrypted); |
| 397 | DEBUGFS_STATS_ADD(tx_handlers_drop_fragment, |
| 398 | local->tx_handlers_drop_fragment); |
| 399 | DEBUGFS_STATS_ADD(tx_handlers_drop_wep, |
| 400 | local->tx_handlers_drop_wep); |
| 401 | DEBUGFS_STATS_ADD(tx_handlers_drop_not_assoc, |
| 402 | local->tx_handlers_drop_not_assoc); |
| 403 | DEBUGFS_STATS_ADD(tx_handlers_drop_unauth_port, |
| 404 | local->tx_handlers_drop_unauth_port); |
| 405 | DEBUGFS_STATS_ADD(rx_handlers_drop, local->rx_handlers_drop); |
| 406 | DEBUGFS_STATS_ADD(rx_handlers_queued, local->rx_handlers_queued); |
| 407 | DEBUGFS_STATS_ADD(rx_handlers_drop_nullfunc, |
| 408 | local->rx_handlers_drop_nullfunc); |
| 409 | DEBUGFS_STATS_ADD(rx_handlers_drop_defrag, |
| 410 | local->rx_handlers_drop_defrag); |
| 411 | DEBUGFS_STATS_ADD(rx_handlers_drop_short, |
| 412 | local->rx_handlers_drop_short); |
| 413 | DEBUGFS_STATS_ADD(rx_handlers_drop_passive_scan, |
| 414 | local->rx_handlers_drop_passive_scan); |
| 415 | DEBUGFS_STATS_ADD(tx_expand_skb_head, |
| 416 | local->tx_expand_skb_head); |
| 417 | DEBUGFS_STATS_ADD(tx_expand_skb_head_cloned, |
| 418 | local->tx_expand_skb_head_cloned); |
| 419 | DEBUGFS_STATS_ADD(rx_expand_skb_head, |
| 420 | local->rx_expand_skb_head); |
| 421 | DEBUGFS_STATS_ADD(rx_expand_skb_head2, |
| 422 | local->rx_expand_skb_head2); |
| 423 | DEBUGFS_STATS_ADD(rx_handlers_fragments, |
| 424 | local->rx_handlers_fragments); |
| 425 | DEBUGFS_STATS_ADD(tx_status_drop, |
| 426 | local->tx_status_drop); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 427 | #endif |
Felix Fietkau | 2826bcd | 2010-06-02 02:57:34 +0200 | [diff] [blame] | 428 | DEBUGFS_DEVSTATS_ADD(dot11ACKFailureCount); |
| 429 | DEBUGFS_DEVSTATS_ADD(dot11RTSFailureCount); |
| 430 | DEBUGFS_DEVSTATS_ADD(dot11FCSErrorCount); |
| 431 | DEBUGFS_DEVSTATS_ADD(dot11RTSSuccessCount); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 432 | } |