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 | |
| 40 | #define DEBUGFS_READONLY_FILE(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); \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 48 | } \ |
| 49 | \ |
| 50 | static const struct file_operations name## _ops = { \ |
| 51 | .read = name## _read, \ |
| 52 | .open = mac80211_open_file_generic, \ |
Arnd Bergmann | 2b18ab3 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 53 | .llseek = generic_file_llseek, \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | #define DEBUGFS_ADD(name) \ |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 57 | debugfs_create_file(#name, 0400, phyd, local, &name## _ops); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 58 | |
Johannes Berg | 827b1fb | 2009-03-13 11:44:18 +0100 | [diff] [blame] | 59 | #define DEBUGFS_ADD_MODE(name, mode) \ |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 60 | debugfs_create_file(#name, mode, phyd, local, &name## _ops); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 61 | |
| 62 | |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 63 | DEBUGFS_READONLY_FILE(frequency, "%d", |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 64 | local->hw.conf.channel->center_freq); |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 65 | DEBUGFS_READONLY_FILE(total_ps_buffered, "%d", |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 66 | local->total_ps_buffered); |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 67 | DEBUGFS_READONLY_FILE(wep_iv, "%#08x", |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 68 | local->wep_iv & 0xffffff); |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 69 | DEBUGFS_READONLY_FILE(rate_ctrl_alg, "%s", |
Johannes Berg | af65cd9 | 2009-11-17 18:18:36 +0100 | [diff] [blame] | 70 | local->rate_ctrl ? local->rate_ctrl->ops->name : "hw/driver"); |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 71 | |
| 72 | static ssize_t tsf_read(struct file *file, char __user *user_buf, |
| 73 | size_t count, loff_t *ppos) |
| 74 | { |
| 75 | struct ieee80211_local *local = file->private_data; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 76 | u64 tsf; |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 77 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 78 | tsf = drv_get_tsf(local); |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 79 | |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 80 | return mac80211_format_buffer(user_buf, count, ppos, "0x%016llx\n", |
| 81 | (unsigned long long) tsf); |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | static ssize_t tsf_write(struct file *file, |
| 85 | const char __user *user_buf, |
| 86 | size_t count, loff_t *ppos) |
| 87 | { |
| 88 | struct ieee80211_local *local = file->private_data; |
| 89 | unsigned long long tsf; |
| 90 | char buf[100]; |
| 91 | size_t len; |
| 92 | |
| 93 | len = min(count, sizeof(buf) - 1); |
| 94 | if (copy_from_user(buf, user_buf, len)) |
| 95 | return -EFAULT; |
| 96 | buf[len] = '\0'; |
| 97 | |
| 98 | if (strncmp(buf, "reset", 5) == 0) { |
| 99 | if (local->ops->reset_tsf) { |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 100 | drv_reset_tsf(local); |
Joe Perches | 0fb9a9e | 2010-08-20 16:25:38 -0700 | [diff] [blame] | 101 | wiphy_info(local->hw.wiphy, "debugfs reset TSF\n"); |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 102 | } |
| 103 | } else { |
| 104 | tsf = simple_strtoul(buf, NULL, 0); |
| 105 | if (local->ops->set_tsf) { |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 106 | drv_set_tsf(local, tsf); |
Joe Perches | 0fb9a9e | 2010-08-20 16:25:38 -0700 | [diff] [blame] | 107 | wiphy_info(local->hw.wiphy, |
| 108 | "debugfs set TSF to %#018llx\n", tsf); |
| 109 | |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 110 | } |
| 111 | } |
| 112 | |
| 113 | return count; |
| 114 | } |
| 115 | |
| 116 | static const struct file_operations tsf_ops = { |
| 117 | .read = tsf_read, |
| 118 | .write = tsf_write, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 119 | .open = mac80211_open_file_generic, |
| 120 | .llseek = default_llseek, |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 121 | }; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 122 | |
Johannes Berg | 827b1fb | 2009-03-13 11:44:18 +0100 | [diff] [blame] | 123 | static ssize_t reset_write(struct file *file, const char __user *user_buf, |
| 124 | size_t count, loff_t *ppos) |
| 125 | { |
| 126 | struct ieee80211_local *local = file->private_data; |
| 127 | |
| 128 | rtnl_lock(); |
| 129 | __ieee80211_suspend(&local->hw); |
| 130 | __ieee80211_resume(&local->hw); |
| 131 | rtnl_unlock(); |
| 132 | |
| 133 | return count; |
| 134 | } |
| 135 | |
| 136 | static const struct file_operations reset_ops = { |
| 137 | .write = reset_write, |
| 138 | .open = mac80211_open_file_generic, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 139 | .llseek = noop_llseek, |
Johannes Berg | 827b1fb | 2009-03-13 11:44:18 +0100 | [diff] [blame] | 140 | }; |
| 141 | |
Johannes Berg | d3707d9 | 2009-05-12 22:05:40 +0200 | [diff] [blame] | 142 | static ssize_t noack_read(struct file *file, char __user *user_buf, |
| 143 | size_t count, loff_t *ppos) |
| 144 | { |
| 145 | struct ieee80211_local *local = file->private_data; |
Johannes Berg | d3707d9 | 2009-05-12 22:05:40 +0200 | [diff] [blame] | 146 | |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 147 | return mac80211_format_buffer(user_buf, count, ppos, "%d\n", |
| 148 | local->wifi_wme_noack_test); |
Johannes Berg | d3707d9 | 2009-05-12 22:05:40 +0200 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | static ssize_t noack_write(struct file *file, |
| 152 | const char __user *user_buf, |
| 153 | size_t count, loff_t *ppos) |
| 154 | { |
| 155 | struct ieee80211_local *local = file->private_data; |
| 156 | char buf[10]; |
| 157 | size_t len; |
| 158 | |
| 159 | len = min(count, sizeof(buf) - 1); |
| 160 | if (copy_from_user(buf, user_buf, len)) |
| 161 | return -EFAULT; |
| 162 | buf[len] = '\0'; |
| 163 | |
| 164 | local->wifi_wme_noack_test = !!simple_strtoul(buf, NULL, 0); |
| 165 | |
| 166 | return count; |
| 167 | } |
| 168 | |
| 169 | static const struct file_operations noack_ops = { |
| 170 | .read = noack_read, |
| 171 | .write = noack_write, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 172 | .open = mac80211_open_file_generic, |
| 173 | .llseek = default_llseek, |
Johannes Berg | d3707d9 | 2009-05-12 22:05:40 +0200 | [diff] [blame] | 174 | }; |
| 175 | |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 176 | static ssize_t uapsd_queues_read(struct file *file, char __user *user_buf, |
| 177 | size_t count, loff_t *ppos) |
| 178 | { |
| 179 | struct ieee80211_local *local = file->private_data; |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 180 | return mac80211_format_buffer(user_buf, count, ppos, "0x%x\n", |
| 181 | local->uapsd_queues); |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | static ssize_t uapsd_queues_write(struct file *file, |
| 185 | const char __user *user_buf, |
| 186 | size_t count, loff_t *ppos) |
| 187 | { |
| 188 | struct ieee80211_local *local = file->private_data; |
| 189 | unsigned long val; |
| 190 | char buf[10]; |
| 191 | size_t len; |
| 192 | int ret; |
| 193 | |
| 194 | len = min(count, sizeof(buf) - 1); |
| 195 | if (copy_from_user(buf, user_buf, len)) |
| 196 | return -EFAULT; |
| 197 | buf[len] = '\0'; |
| 198 | |
| 199 | ret = strict_strtoul(buf, 0, &val); |
| 200 | |
| 201 | if (ret) |
| 202 | return -EINVAL; |
| 203 | |
| 204 | if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) |
| 205 | return -ERANGE; |
| 206 | |
| 207 | local->uapsd_queues = val; |
| 208 | |
| 209 | return count; |
| 210 | } |
| 211 | |
| 212 | static const struct file_operations uapsd_queues_ops = { |
| 213 | .read = uapsd_queues_read, |
| 214 | .write = uapsd_queues_write, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 215 | .open = mac80211_open_file_generic, |
| 216 | .llseek = default_llseek, |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 217 | }; |
| 218 | |
| 219 | static ssize_t uapsd_max_sp_len_read(struct file *file, char __user *user_buf, |
| 220 | size_t count, loff_t *ppos) |
| 221 | { |
| 222 | struct ieee80211_local *local = file->private_data; |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 223 | |
Eliad Peller | 07caf9d | 2010-10-27 14:58:29 +0200 | [diff] [blame] | 224 | return mac80211_format_buffer(user_buf, count, ppos, "0x%x\n", |
| 225 | local->uapsd_max_sp_len); |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | static ssize_t uapsd_max_sp_len_write(struct file *file, |
| 229 | const char __user *user_buf, |
| 230 | size_t count, loff_t *ppos) |
| 231 | { |
| 232 | struct ieee80211_local *local = file->private_data; |
| 233 | unsigned long val; |
| 234 | char buf[10]; |
| 235 | size_t len; |
| 236 | int ret; |
| 237 | |
| 238 | len = min(count, sizeof(buf) - 1); |
| 239 | if (copy_from_user(buf, user_buf, len)) |
| 240 | return -EFAULT; |
| 241 | buf[len] = '\0'; |
| 242 | |
| 243 | ret = strict_strtoul(buf, 0, &val); |
| 244 | |
| 245 | if (ret) |
| 246 | return -EINVAL; |
| 247 | |
| 248 | if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK) |
| 249 | return -ERANGE; |
| 250 | |
| 251 | local->uapsd_max_sp_len = val; |
| 252 | |
| 253 | return count; |
| 254 | } |
| 255 | |
| 256 | static const struct file_operations uapsd_max_sp_len_ops = { |
| 257 | .read = uapsd_max_sp_len_read, |
| 258 | .write = uapsd_max_sp_len_write, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 259 | .open = mac80211_open_file_generic, |
| 260 | .llseek = default_llseek, |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 261 | }; |
| 262 | |
Benoit Papillault | 199d69f | 2010-02-04 22:00:20 +0100 | [diff] [blame] | 263 | static ssize_t channel_type_read(struct file *file, char __user *user_buf, |
| 264 | size_t count, loff_t *ppos) |
| 265 | { |
| 266 | struct ieee80211_local *local = file->private_data; |
| 267 | const char *buf; |
| 268 | |
| 269 | switch (local->hw.conf.channel_type) { |
| 270 | case NL80211_CHAN_NO_HT: |
| 271 | buf = "no ht\n"; |
| 272 | break; |
| 273 | case NL80211_CHAN_HT20: |
| 274 | buf = "ht20\n"; |
| 275 | break; |
| 276 | case NL80211_CHAN_HT40MINUS: |
| 277 | buf = "ht40-\n"; |
| 278 | break; |
| 279 | case NL80211_CHAN_HT40PLUS: |
| 280 | buf = "ht40+\n"; |
| 281 | break; |
| 282 | default: |
| 283 | buf = "???"; |
| 284 | break; |
| 285 | } |
| 286 | |
| 287 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
| 288 | } |
| 289 | |
| 290 | static const struct file_operations channel_type_ops = { |
| 291 | .read = channel_type_read, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 292 | .open = mac80211_open_file_generic, |
| 293 | .llseek = default_llseek, |
Benoit Papillault | 199d69f | 2010-02-04 22:00:20 +0100 | [diff] [blame] | 294 | }; |
| 295 | |
Johannes Berg | db2e6bd | 2009-06-14 17:37:39 +0200 | [diff] [blame] | 296 | static ssize_t queues_read(struct file *file, char __user *user_buf, |
| 297 | size_t count, loff_t *ppos) |
| 298 | { |
| 299 | struct ieee80211_local *local = file->private_data; |
| 300 | unsigned long flags; |
| 301 | char buf[IEEE80211_MAX_QUEUES * 20]; |
| 302 | int q, res = 0; |
| 303 | |
| 304 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
| 305 | for (q = 0; q < local->hw.queues; q++) |
| 306 | res += sprintf(buf + res, "%02d: %#.8lx/%d\n", q, |
| 307 | local->queue_stop_reasons[q], |
Johannes Berg | 3b8d81e | 2009-06-17 17:43:56 +0200 | [diff] [blame] | 308 | skb_queue_len(&local->pending[q])); |
Johannes Berg | db2e6bd | 2009-06-14 17:37:39 +0200 | [diff] [blame] | 309 | spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); |
| 310 | |
| 311 | return simple_read_from_buffer(user_buf, count, ppos, buf, res); |
| 312 | } |
| 313 | |
| 314 | static const struct file_operations queues_ops = { |
| 315 | .read = queues_read, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 316 | .open = mac80211_open_file_generic, |
| 317 | .llseek = default_llseek, |
Johannes Berg | db2e6bd | 2009-06-14 17:37:39 +0200 | [diff] [blame] | 318 | }; |
| 319 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 320 | /* statistics stuff */ |
| 321 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 322 | static ssize_t format_devstat_counter(struct ieee80211_local *local, |
| 323 | char __user *userbuf, |
| 324 | size_t count, loff_t *ppos, |
| 325 | int (*printvalue)(struct ieee80211_low_level_stats *stats, char *buf, |
| 326 | int buflen)) |
| 327 | { |
| 328 | struct ieee80211_low_level_stats stats; |
| 329 | char buf[20]; |
| 330 | int res; |
| 331 | |
Johannes Berg | 7563652 | 2008-07-09 14:40:35 +0200 | [diff] [blame] | 332 | rtnl_lock(); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 333 | res = drv_get_stats(local, &stats); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 334 | rtnl_unlock(); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 335 | if (res) |
| 336 | return res; |
| 337 | res = printvalue(&stats, buf, sizeof(buf)); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 338 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); |
| 339 | } |
| 340 | |
| 341 | #define DEBUGFS_DEVSTATS_FILE(name) \ |
| 342 | static int print_devstats_##name(struct ieee80211_low_level_stats *stats,\ |
| 343 | char *buf, int buflen) \ |
| 344 | { \ |
| 345 | return scnprintf(buf, buflen, "%u\n", stats->name); \ |
| 346 | } \ |
| 347 | static ssize_t stats_ ##name## _read(struct file *file, \ |
| 348 | char __user *userbuf, \ |
| 349 | size_t count, loff_t *ppos) \ |
| 350 | { \ |
| 351 | return format_devstat_counter(file->private_data, \ |
| 352 | userbuf, \ |
| 353 | count, \ |
| 354 | ppos, \ |
| 355 | print_devstats_##name); \ |
| 356 | } \ |
| 357 | \ |
| 358 | static const struct file_operations stats_ ##name## _ops = { \ |
| 359 | .read = stats_ ##name## _read, \ |
| 360 | .open = mac80211_open_file_generic, \ |
Arnd Bergmann | 2b18ab3 | 2010-07-06 19:05:31 +0200 | [diff] [blame] | 361 | .llseek = generic_file_llseek, \ |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 362 | }; |
| 363 | |
Felix Fietkau | 2826bcd | 2010-06-02 02:57:34 +0200 | [diff] [blame] | 364 | #define DEBUGFS_STATS_ADD(name, field) \ |
| 365 | debugfs_create_u32(#name, 0400, statsd, (u32 *) &field); |
| 366 | #define DEBUGFS_DEVSTATS_ADD(name) \ |
Johannes Berg | 7bcfaf2 | 2009-10-27 12:59:03 +0100 | [diff] [blame] | 367 | debugfs_create_file(#name, 0400, statsd, local, &stats_ ##name## _ops); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 368 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 369 | DEBUGFS_DEVSTATS_FILE(dot11ACKFailureCount); |
| 370 | DEBUGFS_DEVSTATS_FILE(dot11RTSFailureCount); |
| 371 | DEBUGFS_DEVSTATS_FILE(dot11FCSErrorCount); |
| 372 | DEBUGFS_DEVSTATS_FILE(dot11RTSSuccessCount); |
| 373 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 374 | void debugfs_hw_add(struct ieee80211_local *local) |
| 375 | { |
| 376 | struct dentry *phyd = local->hw.wiphy->debugfsdir; |
| 377 | struct dentry *statsd; |
| 378 | |
| 379 | if (!phyd) |
| 380 | return; |
| 381 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 382 | local->debugfs.keys = debugfs_create_dir("keys", phyd); |
| 383 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 384 | DEBUGFS_ADD(frequency); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 385 | DEBUGFS_ADD(total_ps_buffered); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 386 | DEBUGFS_ADD(wep_iv); |
Alina Friedrichsen | ae54c98 | 2009-01-23 05:33:37 +0100 | [diff] [blame] | 387 | DEBUGFS_ADD(tsf); |
Johannes Berg | db2e6bd | 2009-06-14 17:37:39 +0200 | [diff] [blame] | 388 | DEBUGFS_ADD(queues); |
Johannes Berg | 827b1fb | 2009-03-13 11:44:18 +0100 | [diff] [blame] | 389 | DEBUGFS_ADD_MODE(reset, 0200); |
Johannes Berg | d3707d9 | 2009-05-12 22:05:40 +0200 | [diff] [blame] | 390 | DEBUGFS_ADD(noack); |
Kalle Valo | 50ae0cf | 2010-01-12 10:42:39 +0200 | [diff] [blame] | 391 | DEBUGFS_ADD(uapsd_queues); |
| 392 | DEBUGFS_ADD(uapsd_max_sp_len); |
Benoit Papillault | 199d69f | 2010-02-04 22:00:20 +0100 | [diff] [blame] | 393 | DEBUGFS_ADD(channel_type); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 394 | |
| 395 | statsd = debugfs_create_dir("statistics", phyd); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 396 | |
| 397 | /* if the dir failed, don't put all the other things into the root! */ |
| 398 | if (!statsd) |
| 399 | return; |
| 400 | |
Felix Fietkau | 2826bcd | 2010-06-02 02:57:34 +0200 | [diff] [blame] | 401 | DEBUGFS_STATS_ADD(transmitted_fragment_count, |
| 402 | local->dot11TransmittedFragmentCount); |
| 403 | DEBUGFS_STATS_ADD(multicast_transmitted_frame_count, |
| 404 | local->dot11MulticastTransmittedFrameCount); |
| 405 | DEBUGFS_STATS_ADD(failed_count, local->dot11FailedCount); |
| 406 | DEBUGFS_STATS_ADD(retry_count, local->dot11RetryCount); |
| 407 | DEBUGFS_STATS_ADD(multiple_retry_count, |
| 408 | local->dot11MultipleRetryCount); |
| 409 | DEBUGFS_STATS_ADD(frame_duplicate_count, |
| 410 | local->dot11FrameDuplicateCount); |
| 411 | DEBUGFS_STATS_ADD(received_fragment_count, |
| 412 | local->dot11ReceivedFragmentCount); |
| 413 | DEBUGFS_STATS_ADD(multicast_received_frame_count, |
| 414 | local->dot11MulticastReceivedFrameCount); |
| 415 | DEBUGFS_STATS_ADD(transmitted_frame_count, |
| 416 | local->dot11TransmittedFrameCount); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 417 | #ifdef CONFIG_MAC80211_DEBUG_COUNTERS |
Felix Fietkau | 2826bcd | 2010-06-02 02:57:34 +0200 | [diff] [blame] | 418 | DEBUGFS_STATS_ADD(tx_handlers_drop, local->tx_handlers_drop); |
| 419 | DEBUGFS_STATS_ADD(tx_handlers_queued, local->tx_handlers_queued); |
| 420 | DEBUGFS_STATS_ADD(tx_handlers_drop_unencrypted, |
| 421 | local->tx_handlers_drop_unencrypted); |
| 422 | DEBUGFS_STATS_ADD(tx_handlers_drop_fragment, |
| 423 | local->tx_handlers_drop_fragment); |
| 424 | DEBUGFS_STATS_ADD(tx_handlers_drop_wep, |
| 425 | local->tx_handlers_drop_wep); |
| 426 | DEBUGFS_STATS_ADD(tx_handlers_drop_not_assoc, |
| 427 | local->tx_handlers_drop_not_assoc); |
| 428 | DEBUGFS_STATS_ADD(tx_handlers_drop_unauth_port, |
| 429 | local->tx_handlers_drop_unauth_port); |
| 430 | DEBUGFS_STATS_ADD(rx_handlers_drop, local->rx_handlers_drop); |
| 431 | DEBUGFS_STATS_ADD(rx_handlers_queued, local->rx_handlers_queued); |
| 432 | DEBUGFS_STATS_ADD(rx_handlers_drop_nullfunc, |
| 433 | local->rx_handlers_drop_nullfunc); |
| 434 | DEBUGFS_STATS_ADD(rx_handlers_drop_defrag, |
| 435 | local->rx_handlers_drop_defrag); |
| 436 | DEBUGFS_STATS_ADD(rx_handlers_drop_short, |
| 437 | local->rx_handlers_drop_short); |
| 438 | DEBUGFS_STATS_ADD(rx_handlers_drop_passive_scan, |
| 439 | local->rx_handlers_drop_passive_scan); |
| 440 | DEBUGFS_STATS_ADD(tx_expand_skb_head, |
| 441 | local->tx_expand_skb_head); |
| 442 | DEBUGFS_STATS_ADD(tx_expand_skb_head_cloned, |
| 443 | local->tx_expand_skb_head_cloned); |
| 444 | DEBUGFS_STATS_ADD(rx_expand_skb_head, |
| 445 | local->rx_expand_skb_head); |
| 446 | DEBUGFS_STATS_ADD(rx_expand_skb_head2, |
| 447 | local->rx_expand_skb_head2); |
| 448 | DEBUGFS_STATS_ADD(rx_handlers_fragments, |
| 449 | local->rx_handlers_fragments); |
| 450 | DEBUGFS_STATS_ADD(tx_status_drop, |
| 451 | local->tx_status_drop); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 452 | #endif |
Felix Fietkau | 2826bcd | 2010-06-02 02:57:34 +0200 | [diff] [blame] | 453 | DEBUGFS_DEVSTATS_ADD(dot11ACKFailureCount); |
| 454 | DEBUGFS_DEVSTATS_ADD(dot11RTSFailureCount); |
| 455 | DEBUGFS_DEVSTATS_ADD(dot11FCSErrorCount); |
| 456 | DEBUGFS_DEVSTATS_ADD(dot11RTSSuccessCount); |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 457 | } |