diff options
Diffstat (limited to 'net/mac80211/debugfs.c')
-rw-r--r-- | net/mac80211/debugfs.c | 175 |
1 files changed, 128 insertions, 47 deletions
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index a694c593ff6a..186e02f7cc32 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c | |||
@@ -21,23 +21,43 @@ int mac80211_open_file_generic(struct inode *inode, struct file *file) | |||
21 | return 0; | 21 | return 0; |
22 | } | 22 | } |
23 | 23 | ||
24 | #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \ | 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_FN(name, fmt, value...) \ | ||
25 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ | 41 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ |
26 | size_t count, loff_t *ppos) \ | 42 | size_t count, loff_t *ppos) \ |
27 | { \ | 43 | { \ |
28 | struct ieee80211_local *local = file->private_data; \ | 44 | struct ieee80211_local *local = file->private_data; \ |
29 | char buf[buflen]; \ | ||
30 | int res; \ | ||
31 | \ | ||
32 | res = scnprintf(buf, buflen, fmt "\n", ##value); \ | ||
33 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ | ||
34 | } \ | ||
35 | \ | 45 | \ |
46 | return mac80211_format_buffer(userbuf, count, ppos, \ | ||
47 | fmt "\n", ##value); \ | ||
48 | } | ||
49 | |||
50 | #define DEBUGFS_READONLY_FILE_OPS(name) \ | ||
36 | static const struct file_operations name## _ops = { \ | 51 | static const struct file_operations name## _ops = { \ |
37 | .read = name## _read, \ | 52 | .read = name## _read, \ |
38 | .open = mac80211_open_file_generic, \ | 53 | .open = mac80211_open_file_generic, \ |
54 | .llseek = generic_file_llseek, \ | ||
39 | }; | 55 | }; |
40 | 56 | ||
57 | #define DEBUGFS_READONLY_FILE(name, fmt, value...) \ | ||
58 | DEBUGFS_READONLY_FILE_FN(name, fmt, value) \ | ||
59 | DEBUGFS_READONLY_FILE_OPS(name) | ||
60 | |||
41 | #define DEBUGFS_ADD(name) \ | 61 | #define DEBUGFS_ADD(name) \ |
42 | debugfs_create_file(#name, 0400, phyd, local, &name## _ops); | 62 | debugfs_create_file(#name, 0400, phyd, local, &name## _ops); |
43 | 63 | ||
@@ -45,13 +65,17 @@ static const struct file_operations name## _ops = { \ | |||
45 | debugfs_create_file(#name, mode, phyd, local, &name## _ops); | 65 | debugfs_create_file(#name, mode, phyd, local, &name## _ops); |
46 | 66 | ||
47 | 67 | ||
48 | DEBUGFS_READONLY_FILE(frequency, 20, "%d", | 68 | DEBUGFS_READONLY_FILE(user_power, "%d", |
69 | local->user_power_level); | ||
70 | DEBUGFS_READONLY_FILE(power, "%d", | ||
71 | local->hw.conf.power_level); | ||
72 | DEBUGFS_READONLY_FILE(frequency, "%d", | ||
49 | local->hw.conf.channel->center_freq); | 73 | local->hw.conf.channel->center_freq); |
50 | DEBUGFS_READONLY_FILE(total_ps_buffered, 20, "%d", | 74 | DEBUGFS_READONLY_FILE(total_ps_buffered, "%d", |
51 | local->total_ps_buffered); | 75 | local->total_ps_buffered); |
52 | DEBUGFS_READONLY_FILE(wep_iv, 20, "%#08x", | 76 | DEBUGFS_READONLY_FILE(wep_iv, "%#08x", |
53 | local->wep_iv & 0xffffff); | 77 | local->wep_iv & 0xffffff); |
54 | DEBUGFS_READONLY_FILE(rate_ctrl_alg, 100, "%s", | 78 | DEBUGFS_READONLY_FILE(rate_ctrl_alg, "%s", |
55 | local->rate_ctrl ? local->rate_ctrl->ops->name : "hw/driver"); | 79 | local->rate_ctrl ? local->rate_ctrl->ops->name : "hw/driver"); |
56 | 80 | ||
57 | static ssize_t tsf_read(struct file *file, char __user *user_buf, | 81 | static ssize_t tsf_read(struct file *file, char __user *user_buf, |
@@ -59,13 +83,11 @@ static ssize_t tsf_read(struct file *file, char __user *user_buf, | |||
59 | { | 83 | { |
60 | struct ieee80211_local *local = file->private_data; | 84 | struct ieee80211_local *local = file->private_data; |
61 | u64 tsf; | 85 | u64 tsf; |
62 | char buf[100]; | ||
63 | 86 | ||
64 | tsf = drv_get_tsf(local); | 87 | tsf = drv_get_tsf(local); |
65 | 88 | ||
66 | snprintf(buf, sizeof(buf), "0x%016llx\n", (unsigned long long) tsf); | 89 | return mac80211_format_buffer(user_buf, count, ppos, "0x%016llx\n", |
67 | 90 | (unsigned long long) tsf); | |
68 | return simple_read_from_buffer(user_buf, count, ppos, buf, 19); | ||
69 | } | 91 | } |
70 | 92 | ||
71 | static ssize_t tsf_write(struct file *file, | 93 | static ssize_t tsf_write(struct file *file, |
@@ -85,13 +107,15 @@ static ssize_t tsf_write(struct file *file, | |||
85 | if (strncmp(buf, "reset", 5) == 0) { | 107 | if (strncmp(buf, "reset", 5) == 0) { |
86 | if (local->ops->reset_tsf) { | 108 | if (local->ops->reset_tsf) { |
87 | drv_reset_tsf(local); | 109 | drv_reset_tsf(local); |
88 | printk(KERN_INFO "%s: debugfs reset TSF\n", wiphy_name(local->hw.wiphy)); | 110 | wiphy_info(local->hw.wiphy, "debugfs reset TSF\n"); |
89 | } | 111 | } |
90 | } else { | 112 | } else { |
91 | tsf = simple_strtoul(buf, NULL, 0); | 113 | tsf = simple_strtoul(buf, NULL, 0); |
92 | if (local->ops->set_tsf) { | 114 | if (local->ops->set_tsf) { |
93 | drv_set_tsf(local, tsf); | 115 | drv_set_tsf(local, tsf); |
94 | printk(KERN_INFO "%s: debugfs set TSF to %#018llx\n", wiphy_name(local->hw.wiphy), tsf); | 116 | wiphy_info(local->hw.wiphy, |
117 | "debugfs set TSF to %#018llx\n", tsf); | ||
118 | |||
95 | } | 119 | } |
96 | } | 120 | } |
97 | 121 | ||
@@ -101,7 +125,8 @@ static ssize_t tsf_write(struct file *file, | |||
101 | static const struct file_operations tsf_ops = { | 125 | static const struct file_operations tsf_ops = { |
102 | .read = tsf_read, | 126 | .read = tsf_read, |
103 | .write = tsf_write, | 127 | .write = tsf_write, |
104 | .open = mac80211_open_file_generic | 128 | .open = mac80211_open_file_generic, |
129 | .llseek = default_llseek, | ||
105 | }; | 130 | }; |
106 | 131 | ||
107 | static ssize_t reset_write(struct file *file, const char __user *user_buf, | 132 | static ssize_t reset_write(struct file *file, const char __user *user_buf, |
@@ -110,7 +135,7 @@ static ssize_t reset_write(struct file *file, const char __user *user_buf, | |||
110 | struct ieee80211_local *local = file->private_data; | 135 | struct ieee80211_local *local = file->private_data; |
111 | 136 | ||
112 | rtnl_lock(); | 137 | rtnl_lock(); |
113 | __ieee80211_suspend(&local->hw); | 138 | __ieee80211_suspend(&local->hw, NULL); |
114 | __ieee80211_resume(&local->hw); | 139 | __ieee80211_resume(&local->hw); |
115 | rtnl_unlock(); | 140 | rtnl_unlock(); |
116 | 141 | ||
@@ -120,18 +145,16 @@ static ssize_t reset_write(struct file *file, const char __user *user_buf, | |||
120 | static const struct file_operations reset_ops = { | 145 | static const struct file_operations reset_ops = { |
121 | .write = reset_write, | 146 | .write = reset_write, |
122 | .open = mac80211_open_file_generic, | 147 | .open = mac80211_open_file_generic, |
148 | .llseek = noop_llseek, | ||
123 | }; | 149 | }; |
124 | 150 | ||
125 | static ssize_t noack_read(struct file *file, char __user *user_buf, | 151 | static ssize_t noack_read(struct file *file, char __user *user_buf, |
126 | size_t count, loff_t *ppos) | 152 | size_t count, loff_t *ppos) |
127 | { | 153 | { |
128 | struct ieee80211_local *local = file->private_data; | 154 | struct ieee80211_local *local = file->private_data; |
129 | int res; | ||
130 | char buf[10]; | ||
131 | 155 | ||
132 | res = scnprintf(buf, sizeof(buf), "%d\n", local->wifi_wme_noack_test); | 156 | return mac80211_format_buffer(user_buf, count, ppos, "%d\n", |
133 | 157 | local->wifi_wme_noack_test); | |
134 | return simple_read_from_buffer(user_buf, count, ppos, buf, res); | ||
135 | } | 158 | } |
136 | 159 | ||
137 | static ssize_t noack_write(struct file *file, | 160 | static ssize_t noack_write(struct file *file, |
@@ -155,19 +178,16 @@ static ssize_t noack_write(struct file *file, | |||
155 | static const struct file_operations noack_ops = { | 178 | static const struct file_operations noack_ops = { |
156 | .read = noack_read, | 179 | .read = noack_read, |
157 | .write = noack_write, | 180 | .write = noack_write, |
158 | .open = mac80211_open_file_generic | 181 | .open = mac80211_open_file_generic, |
182 | .llseek = default_llseek, | ||
159 | }; | 183 | }; |
160 | 184 | ||
161 | static ssize_t uapsd_queues_read(struct file *file, char __user *user_buf, | 185 | static ssize_t uapsd_queues_read(struct file *file, char __user *user_buf, |
162 | size_t count, loff_t *ppos) | 186 | size_t count, loff_t *ppos) |
163 | { | 187 | { |
164 | struct ieee80211_local *local = file->private_data; | 188 | struct ieee80211_local *local = file->private_data; |
165 | int res; | 189 | return mac80211_format_buffer(user_buf, count, ppos, "0x%x\n", |
166 | char buf[10]; | 190 | local->uapsd_queues); |
167 | |||
168 | res = scnprintf(buf, sizeof(buf), "0x%x\n", local->uapsd_queues); | ||
169 | |||
170 | return simple_read_from_buffer(user_buf, count, ppos, buf, res); | ||
171 | } | 191 | } |
172 | 192 | ||
173 | static ssize_t uapsd_queues_write(struct file *file, | 193 | static ssize_t uapsd_queues_write(struct file *file, |
@@ -201,19 +221,17 @@ static ssize_t uapsd_queues_write(struct file *file, | |||
201 | static const struct file_operations uapsd_queues_ops = { | 221 | static const struct file_operations uapsd_queues_ops = { |
202 | .read = uapsd_queues_read, | 222 | .read = uapsd_queues_read, |
203 | .write = uapsd_queues_write, | 223 | .write = uapsd_queues_write, |
204 | .open = mac80211_open_file_generic | 224 | .open = mac80211_open_file_generic, |
225 | .llseek = default_llseek, | ||
205 | }; | 226 | }; |
206 | 227 | ||
207 | static ssize_t uapsd_max_sp_len_read(struct file *file, char __user *user_buf, | 228 | static ssize_t uapsd_max_sp_len_read(struct file *file, char __user *user_buf, |
208 | size_t count, loff_t *ppos) | 229 | size_t count, loff_t *ppos) |
209 | { | 230 | { |
210 | struct ieee80211_local *local = file->private_data; | 231 | struct ieee80211_local *local = file->private_data; |
211 | int res; | ||
212 | char buf[10]; | ||
213 | |||
214 | res = scnprintf(buf, sizeof(buf), "0x%x\n", local->uapsd_max_sp_len); | ||
215 | 232 | ||
216 | return simple_read_from_buffer(user_buf, count, ppos, buf, res); | 233 | return mac80211_format_buffer(user_buf, count, ppos, "0x%x\n", |
234 | local->uapsd_max_sp_len); | ||
217 | } | 235 | } |
218 | 236 | ||
219 | static ssize_t uapsd_max_sp_len_write(struct file *file, | 237 | static ssize_t uapsd_max_sp_len_write(struct file *file, |
@@ -247,7 +265,8 @@ static ssize_t uapsd_max_sp_len_write(struct file *file, | |||
247 | static const struct file_operations uapsd_max_sp_len_ops = { | 265 | static const struct file_operations uapsd_max_sp_len_ops = { |
248 | .read = uapsd_max_sp_len_read, | 266 | .read = uapsd_max_sp_len_read, |
249 | .write = uapsd_max_sp_len_write, | 267 | .write = uapsd_max_sp_len_write, |
250 | .open = mac80211_open_file_generic | 268 | .open = mac80211_open_file_generic, |
269 | .llseek = default_llseek, | ||
251 | }; | 270 | }; |
252 | 271 | ||
253 | static ssize_t channel_type_read(struct file *file, char __user *user_buf, | 272 | static ssize_t channel_type_read(struct file *file, char __user *user_buf, |
@@ -277,10 +296,70 @@ static ssize_t channel_type_read(struct file *file, char __user *user_buf, | |||
277 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); | 296 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
278 | } | 297 | } |
279 | 298 | ||
280 | static const struct file_operations channel_type_ops = { | 299 | static ssize_t hwflags_read(struct file *file, char __user *user_buf, |
281 | .read = channel_type_read, | 300 | size_t count, loff_t *ppos) |
282 | .open = mac80211_open_file_generic | 301 | { |
283 | }; | 302 | struct ieee80211_local *local = file->private_data; |
303 | int mxln = 500; | ||
304 | ssize_t rv; | ||
305 | char *buf = kzalloc(mxln, GFP_KERNEL); | ||
306 | int sf = 0; /* how many written so far */ | ||
307 | |||
308 | sf += snprintf(buf, mxln - sf, "0x%x\n", local->hw.flags); | ||
309 | if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) | ||
310 | sf += snprintf(buf + sf, mxln - sf, "HAS_RATE_CONTROL\n"); | ||
311 | if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) | ||
312 | sf += snprintf(buf + sf, mxln - sf, "RX_INCLUDES_FCS\n"); | ||
313 | if (local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING) | ||
314 | sf += snprintf(buf + sf, mxln - sf, | ||
315 | "HOST_BCAST_PS_BUFFERING\n"); | ||
316 | if (local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE) | ||
317 | sf += snprintf(buf + sf, mxln - sf, | ||
318 | "2GHZ_SHORT_SLOT_INCAPABLE\n"); | ||
319 | if (local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE) | ||
320 | sf += snprintf(buf + sf, mxln - sf, | ||
321 | "2GHZ_SHORT_PREAMBLE_INCAPABLE\n"); | ||
322 | if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) | ||
323 | sf += snprintf(buf + sf, mxln - sf, "SIGNAL_UNSPEC\n"); | ||
324 | if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) | ||
325 | sf += snprintf(buf + sf, mxln - sf, "SIGNAL_DBM\n"); | ||
326 | if (local->hw.flags & IEEE80211_HW_NEED_DTIM_PERIOD) | ||
327 | sf += snprintf(buf + sf, mxln - sf, "NEED_DTIM_PERIOD\n"); | ||
328 | if (local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT) | ||
329 | sf += snprintf(buf + sf, mxln - sf, "SPECTRUM_MGMT\n"); | ||
330 | if (local->hw.flags & IEEE80211_HW_AMPDU_AGGREGATION) | ||
331 | sf += snprintf(buf + sf, mxln - sf, "AMPDU_AGGREGATION\n"); | ||
332 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_PS) | ||
333 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_PS\n"); | ||
334 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) | ||
335 | sf += snprintf(buf + sf, mxln - sf, "PS_NULLFUNC_STACK\n"); | ||
336 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) | ||
337 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_PS\n"); | ||
338 | if (local->hw.flags & IEEE80211_HW_MFP_CAPABLE) | ||
339 | sf += snprintf(buf + sf, mxln - sf, "MFP_CAPABLE\n"); | ||
340 | if (local->hw.flags & IEEE80211_HW_BEACON_FILTER) | ||
341 | sf += snprintf(buf + sf, mxln - sf, "BEACON_FILTER\n"); | ||
342 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_STATIC_SMPS) | ||
343 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_STATIC_SMPS\n"); | ||
344 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS) | ||
345 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_SMPS\n"); | ||
346 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_UAPSD) | ||
347 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_UAPSD\n"); | ||
348 | if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS) | ||
349 | sf += snprintf(buf + sf, mxln - sf, "REPORTS_TX_ACK_STATUS\n"); | ||
350 | if (local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR) | ||
351 | sf += snprintf(buf + sf, mxln - sf, "CONNECTION_MONITOR\n"); | ||
352 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI) | ||
353 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_CQM_RSSI\n"); | ||
354 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK) | ||
355 | sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_PER_STA_GTK\n"); | ||
356 | if (local->hw.flags & IEEE80211_HW_AP_LINK_PS) | ||
357 | sf += snprintf(buf + sf, mxln - sf, "AP_LINK_PS\n"); | ||
358 | |||
359 | rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); | ||
360 | kfree(buf); | ||
361 | return rv; | ||
362 | } | ||
284 | 363 | ||
285 | static ssize_t queues_read(struct file *file, char __user *user_buf, | 364 | static ssize_t queues_read(struct file *file, char __user *user_buf, |
286 | size_t count, loff_t *ppos) | 365 | size_t count, loff_t *ppos) |
@@ -300,10 +379,9 @@ static ssize_t queues_read(struct file *file, char __user *user_buf, | |||
300 | return simple_read_from_buffer(user_buf, count, ppos, buf, res); | 379 | return simple_read_from_buffer(user_buf, count, ppos, buf, res); |
301 | } | 380 | } |
302 | 381 | ||
303 | static const struct file_operations queues_ops = { | 382 | DEBUGFS_READONLY_FILE_OPS(hwflags); |
304 | .read = queues_read, | 383 | DEBUGFS_READONLY_FILE_OPS(channel_type); |
305 | .open = mac80211_open_file_generic | 384 | DEBUGFS_READONLY_FILE_OPS(queues); |
306 | }; | ||
307 | 385 | ||
308 | /* statistics stuff */ | 386 | /* statistics stuff */ |
309 | 387 | ||
@@ -346,6 +424,7 @@ static ssize_t stats_ ##name## _read(struct file *file, \ | |||
346 | static const struct file_operations stats_ ##name## _ops = { \ | 424 | static const struct file_operations stats_ ##name## _ops = { \ |
347 | .read = stats_ ##name## _read, \ | 425 | .read = stats_ ##name## _read, \ |
348 | .open = mac80211_open_file_generic, \ | 426 | .open = mac80211_open_file_generic, \ |
427 | .llseek = generic_file_llseek, \ | ||
349 | }; | 428 | }; |
350 | 429 | ||
351 | #define DEBUGFS_STATS_ADD(name, field) \ | 430 | #define DEBUGFS_STATS_ADD(name, field) \ |
@@ -366,7 +445,6 @@ void debugfs_hw_add(struct ieee80211_local *local) | |||
366 | if (!phyd) | 445 | if (!phyd) |
367 | return; | 446 | return; |
368 | 447 | ||
369 | local->debugfs.stations = debugfs_create_dir("stations", phyd); | ||
370 | local->debugfs.keys = debugfs_create_dir("keys", phyd); | 448 | local->debugfs.keys = debugfs_create_dir("keys", phyd); |
371 | 449 | ||
372 | DEBUGFS_ADD(frequency); | 450 | DEBUGFS_ADD(frequency); |
@@ -379,6 +457,9 @@ void debugfs_hw_add(struct ieee80211_local *local) | |||
379 | DEBUGFS_ADD(uapsd_queues); | 457 | DEBUGFS_ADD(uapsd_queues); |
380 | DEBUGFS_ADD(uapsd_max_sp_len); | 458 | DEBUGFS_ADD(uapsd_max_sp_len); |
381 | DEBUGFS_ADD(channel_type); | 459 | DEBUGFS_ADD(channel_type); |
460 | DEBUGFS_ADD(hwflags); | ||
461 | DEBUGFS_ADD(user_power); | ||
462 | DEBUGFS_ADD(power); | ||
382 | 463 | ||
383 | statsd = debugfs_create_dir("statistics", phyd); | 464 | statsd = debugfs_create_dir("statistics", phyd); |
384 | 465 | ||