zd1211rw: move under zydas vendor directory
[linux-2.6-block.git] / drivers / net / wireless / hostap / hostap_proc.c
CommitLineData
ff1d2767
JM
1/* /proc routines for Host AP driver */
2
5fad5a2e
AB
3#include <linux/types.h>
4#include <linux/proc_fs.h>
ee40fa06 5#include <linux/export.h>
274bfb8d 6#include <net/lib80211.h>
5fad5a2e
AB
7
8#include "hostap_wlan.h"
9#include "hostap.h"
10
ff1d2767
JM
11#define PROC_LIMIT (PAGE_SIZE - 80)
12
13
14#ifndef PRISM2_NO_PROCFS_DEBUG
6bbefe86 15static int prism2_debug_proc_show(struct seq_file *m, void *v)
ff1d2767 16{
6bbefe86 17 local_info_t *local = m->private;
ff1d2767
JM
18 int i;
19
6bbefe86
DH
20 seq_printf(m, "next_txfid=%d next_alloc=%d\n",
21 local->next_txfid, local->next_alloc);
ff1d2767 22 for (i = 0; i < PRISM2_TXFID_COUNT; i++)
6bbefe86
DH
23 seq_printf(m, "FID: tx=%04X intransmit=%04X\n",
24 local->txfid[i], local->intransmitfid[i]);
25 seq_printf(m, "FW TX rate control: %d\n", local->fw_tx_rate_control);
26 seq_printf(m, "beacon_int=%d\n", local->beacon_int);
27 seq_printf(m, "dtim_period=%d\n", local->dtim_period);
28 seq_printf(m, "wds_max_connections=%d\n", local->wds_max_connections);
29 seq_printf(m, "dev_enabled=%d\n", local->dev_enabled);
30 seq_printf(m, "sw_tick_stuck=%d\n", local->sw_tick_stuck);
ff1d2767 31 for (i = 0; i < WEP_KEYS; i++) {
274bfb8d
JL
32 if (local->crypt_info.crypt[i] &&
33 local->crypt_info.crypt[i]->ops) {
6bbefe86
DH
34 seq_printf(m, "crypt[%d]=%s\n", i,
35 local->crypt_info.crypt[i]->ops->name);
ff1d2767
JM
36 }
37 }
6bbefe86
DH
38 seq_printf(m, "pri_only=%d\n", local->pri_only);
39 seq_printf(m, "pci=%d\n", local->func->hw_type == HOSTAP_HW_PCI);
40 seq_printf(m, "sram_type=%d\n", local->sram_type);
41 seq_printf(m, "no_pri=%d\n", local->no_pri);
42
43 return 0;
44}
ff1d2767 45
6bbefe86
DH
46static int prism2_debug_proc_open(struct inode *inode, struct file *file)
47{
48 return single_open(file, prism2_debug_proc_show, PDE_DATA(inode));
ff1d2767 49}
6bbefe86
DH
50
51static const struct file_operations prism2_debug_proc_fops = {
52 .open = prism2_debug_proc_open,
53 .read = seq_read,
54 .llseek = seq_lseek,
bc3041f0 55 .release = single_release,
6bbefe86 56};
ff1d2767
JM
57#endif /* PRISM2_NO_PROCFS_DEBUG */
58
59
6bbefe86 60static int prism2_stats_proc_show(struct seq_file *m, void *v)
ff1d2767 61{
6bbefe86 62 local_info_t *local = m->private;
2c208890 63 struct comm_tallies_sums *sums = &local->comm_tallies;
ff1d2767 64
6bbefe86
DH
65 seq_printf(m, "TxUnicastFrames=%u\n", sums->tx_unicast_frames);
66 seq_printf(m, "TxMulticastframes=%u\n", sums->tx_multicast_frames);
67 seq_printf(m, "TxFragments=%u\n", sums->tx_fragments);
68 seq_printf(m, "TxUnicastOctets=%u\n", sums->tx_unicast_octets);
69 seq_printf(m, "TxMulticastOctets=%u\n", sums->tx_multicast_octets);
70 seq_printf(m, "TxDeferredTransmissions=%u\n",
71 sums->tx_deferred_transmissions);
72 seq_printf(m, "TxSingleRetryFrames=%u\n", sums->tx_single_retry_frames);
73 seq_printf(m, "TxMultipleRetryFrames=%u\n",
74 sums->tx_multiple_retry_frames);
75 seq_printf(m, "TxRetryLimitExceeded=%u\n",
76 sums->tx_retry_limit_exceeded);
77 seq_printf(m, "TxDiscards=%u\n", sums->tx_discards);
78 seq_printf(m, "RxUnicastFrames=%u\n", sums->rx_unicast_frames);
79 seq_printf(m, "RxMulticastFrames=%u\n", sums->rx_multicast_frames);
80 seq_printf(m, "RxFragments=%u\n", sums->rx_fragments);
81 seq_printf(m, "RxUnicastOctets=%u\n", sums->rx_unicast_octets);
82 seq_printf(m, "RxMulticastOctets=%u\n", sums->rx_multicast_octets);
83 seq_printf(m, "RxFCSErrors=%u\n", sums->rx_fcs_errors);
84 seq_printf(m, "RxDiscardsNoBuffer=%u\n", sums->rx_discards_no_buffer);
85 seq_printf(m, "TxDiscardsWrongSA=%u\n", sums->tx_discards_wrong_sa);
86 seq_printf(m, "RxDiscardsWEPUndecryptable=%u\n",
87 sums->rx_discards_wep_undecryptable);
88 seq_printf(m, "RxMessageInMsgFragments=%u\n",
89 sums->rx_message_in_msg_fragments);
90 seq_printf(m, "RxMessageInBadMsgFragments=%u\n",
91 sums->rx_message_in_bad_msg_fragments);
ff1d2767
JM
92 /* FIX: this may grow too long for one page(?) */
93
6bbefe86
DH
94 return 0;
95}
96
97static int prism2_stats_proc_open(struct inode *inode, struct file *file)
98{
99 return single_open(file, prism2_stats_proc_show, PDE_DATA(inode));
ff1d2767
JM
100}
101
6bbefe86
DH
102static const struct file_operations prism2_stats_proc_fops = {
103 .open = prism2_stats_proc_open,
104 .read = seq_read,
105 .llseek = seq_lseek,
bc3041f0 106 .release = single_release,
6bbefe86
DH
107};
108
ff1d2767 109
6bbefe86 110static int prism2_wds_proc_show(struct seq_file *m, void *v)
ff1d2767 111{
6bbefe86 112 struct list_head *ptr = v;
ff1d2767
JM
113 struct hostap_interface *iface;
114
6bbefe86
DH
115 iface = list_entry(ptr, struct hostap_interface, list);
116 if (iface->type == HOSTAP_INTERFACE_WDS)
117 seq_printf(m, "%s\t%pM\n",
118 iface->dev->name, iface->u.wds.remote_addr);
119 return 0;
120}
ff1d2767 121
6bbefe86
DH
122static void *prism2_wds_proc_start(struct seq_file *m, loff_t *_pos)
123{
124 local_info_t *local = m->private;
ff1d2767 125 read_lock_bh(&local->iface_lock);
6bbefe86
DH
126 return seq_list_start(&local->hostap_interfaces, *_pos);
127}
ff1d2767 128
6bbefe86
DH
129static void *prism2_wds_proc_next(struct seq_file *m, void *v, loff_t *_pos)
130{
131 local_info_t *local = m->private;
132 return seq_list_next(v, &local->hostap_interfaces, _pos);
133}
134
135static void prism2_wds_proc_stop(struct seq_file *m, void *v)
136{
137 local_info_t *local = m->private;
138 read_unlock_bh(&local->iface_lock);
139}
ff1d2767 140
6bbefe86
DH
141static const struct seq_operations prism2_wds_proc_seqops = {
142 .start = prism2_wds_proc_start,
143 .next = prism2_wds_proc_next,
144 .stop = prism2_wds_proc_stop,
145 .show = prism2_wds_proc_show,
146};
ff1d2767 147
6bbefe86
DH
148static int prism2_wds_proc_open(struct inode *inode, struct file *file)
149{
150 int ret = seq_open(file, &prism2_wds_proc_seqops);
151 if (ret == 0) {
152 struct seq_file *m = file->private_data;
153 m->private = PDE_DATA(inode);
154 }
155 return ret;
ff1d2767
JM
156}
157
6bbefe86
DH
158static const struct file_operations prism2_wds_proc_fops = {
159 .open = prism2_wds_proc_open,
160 .read = seq_read,
161 .llseek = seq_lseek,
162 .release = seq_release,
163};
ff1d2767 164
6bbefe86
DH
165
166static int prism2_bss_list_proc_show(struct seq_file *m, void *v)
ff1d2767 167{
6bbefe86
DH
168 local_info_t *local = m->private;
169 struct list_head *ptr = v;
ff1d2767 170 struct hostap_bss_info *bss;
ff1d2767 171
6bbefe86
DH
172 if (ptr == &local->bss_list) {
173 seq_printf(m, "#BSSID\tlast_update\tcount\tcapab_info\tSSID(txt)\t"
174 "SSID(hex)\tWPA IE\n");
ff1d2767
JM
175 return 0;
176 }
177
6bbefe86
DH
178 bss = list_entry(ptr, struct hostap_bss_info, list);
179 seq_printf(m, "%pM\t%lu\t%u\t0x%x\t",
180 bss->bssid, bss->last_update,
181 bss->count, bss->capab_info);
182
e5ead669 183 seq_printf(m, "%*pE", (int)bss->ssid_len, bss->ssid);
6bbefe86
DH
184
185 seq_putc(m, '\t');
62c5afb8 186 seq_printf(m, "%*phN", (int)bss->ssid_len, bss->ssid);
6bbefe86 187 seq_putc(m, '\t');
62c5afb8 188 seq_printf(m, "%*phN", (int)bss->wpa_ie_len, bss->wpa_ie);
6bbefe86
DH
189 seq_putc(m, '\n');
190 return 0;
191}
192
193static void *prism2_bss_list_proc_start(struct seq_file *m, loff_t *_pos)
194{
195 local_info_t *local = m->private;
ff1d2767 196 spin_lock_bh(&local->lock);
6bbefe86
DH
197 return seq_list_start_head(&local->bss_list, *_pos);
198}
ff1d2767 199
6bbefe86
DH
200static void *prism2_bss_list_proc_next(struct seq_file *m, void *v, loff_t *_pos)
201{
202 local_info_t *local = m->private;
203 return seq_list_next(v, &local->bss_list, _pos);
204}
205
206static void prism2_bss_list_proc_stop(struct seq_file *m, void *v)
207{
208 local_info_t *local = m->private;
209 spin_unlock_bh(&local->lock);
210}
ff1d2767 211
6bbefe86
DH
212static const struct seq_operations prism2_bss_list_proc_seqops = {
213 .start = prism2_bss_list_proc_start,
214 .next = prism2_bss_list_proc_next,
215 .stop = prism2_bss_list_proc_stop,
216 .show = prism2_bss_list_proc_show,
217};
ff1d2767 218
6bbefe86
DH
219static int prism2_bss_list_proc_open(struct inode *inode, struct file *file)
220{
221 int ret = seq_open(file, &prism2_bss_list_proc_seqops);
222 if (ret == 0) {
223 struct seq_file *m = file->private_data;
224 m->private = PDE_DATA(inode);
225 }
226 return ret;
ff1d2767
JM
227}
228
6bbefe86
DH
229static const struct file_operations prism2_bss_list_proc_fops = {
230 .open = prism2_bss_list_proc_open,
231 .read = seq_read,
232 .llseek = seq_lseek,
233 .release = seq_release,
234};
ff1d2767 235
6bbefe86
DH
236
237static int prism2_crypt_proc_show(struct seq_file *m, void *v)
ff1d2767 238{
6bbefe86 239 local_info_t *local = m->private;
ff1d2767
JM
240 int i;
241
6bbefe86 242 seq_printf(m, "tx_keyidx=%d\n", local->crypt_info.tx_keyidx);
ff1d2767 243 for (i = 0; i < WEP_KEYS; i++) {
274bfb8d
JL
244 if (local->crypt_info.crypt[i] &&
245 local->crypt_info.crypt[i]->ops &&
246 local->crypt_info.crypt[i]->ops->print_stats) {
6bbefe86
DH
247 local->crypt_info.crypt[i]->ops->print_stats(
248 m, local->crypt_info.crypt[i]->priv);
ff1d2767
JM
249 }
250 }
6bbefe86
DH
251 return 0;
252}
ff1d2767 253
6bbefe86
DH
254static int prism2_crypt_proc_open(struct inode *inode, struct file *file)
255{
256 return single_open(file, prism2_crypt_proc_show, PDE_DATA(inode));
ff1d2767
JM
257}
258
6bbefe86
DH
259static const struct file_operations prism2_crypt_proc_fops = {
260 .open = prism2_crypt_proc_open,
261 .read = seq_read,
262 .llseek = seq_lseek,
bc3041f0 263 .release = single_release,
6bbefe86
DH
264};
265
ff1d2767 266
6bbefe86
DH
267static ssize_t prism2_pda_proc_read(struct file *file, char __user *buf,
268 size_t count, loff_t *_pos)
ff1d2767 269{
6bbefe86
DH
270 local_info_t *local = PDE_DATA(file_inode(file));
271 size_t off;
ff1d2767 272
6bbefe86 273 if (local->pda == NULL || *_pos >= PRISM2_PDA_SIZE)
ff1d2767 274 return 0;
ff1d2767 275
6bbefe86
DH
276 off = *_pos;
277 if (count > PRISM2_PDA_SIZE - off)
ff1d2767 278 count = PRISM2_PDA_SIZE - off;
6bbefe86
DH
279 if (copy_to_user(buf, local->pda + off, count) != 0)
280 return -EFAULT;
281 *_pos += count;
ff1d2767
JM
282 return count;
283}
284
6bbefe86
DH
285static const struct file_operations prism2_pda_proc_fops = {
286 .read = prism2_pda_proc_read,
287 .llseek = generic_file_llseek,
288};
ff1d2767 289
ff1d2767 290
6bbefe86
DH
291static ssize_t prism2_aux_dump_proc_no_read(struct file *file, char __user *buf,
292 size_t bufsize, loff_t *_pos)
293{
294 return 0;
ff1d2767
JM
295}
296
6bbefe86
DH
297static const struct file_operations prism2_aux_dump_proc_fops = {
298 .read = prism2_aux_dump_proc_no_read,
299};
300
ff1d2767
JM
301
302#ifdef PRISM2_IO_DEBUG
303static int prism2_io_debug_proc_read(char *page, char **start, off_t off,
304 int count, int *eof, void *data)
305{
306 local_info_t *local = (local_info_t *) data;
307 int head = local->io_debug_head;
308 int start_bytes, left, copy, copied;
309
310 if (off + count > PRISM2_IO_DEBUG_SIZE * 4) {
311 *eof = 1;
312 if (off >= PRISM2_IO_DEBUG_SIZE * 4)
313 return 0;
314 count = PRISM2_IO_DEBUG_SIZE * 4 - off;
315 }
316
317 copied = 0;
318 start_bytes = (PRISM2_IO_DEBUG_SIZE - head) * 4;
319 left = count;
320
321 if (off < start_bytes) {
322 copy = start_bytes - off;
323 if (copy > count)
324 copy = count;
325 memcpy(page, ((u8 *) &local->io_debug[head]) + off, copy);
326 left -= copy;
327 if (left > 0)
328 memcpy(&page[copy], local->io_debug, left);
329 } else {
330 memcpy(page, ((u8 *) local->io_debug) + (off - start_bytes),
331 left);
332 }
333
334 *start = page;
335
336 return count;
337}
338#endif /* PRISM2_IO_DEBUG */
339
340
341#ifndef PRISM2_NO_STATION_MODES
6bbefe86 342static int prism2_scan_results_proc_show(struct seq_file *m, void *v)
ff1d2767 343{
6bbefe86
DH
344 local_info_t *local = m->private;
345 unsigned long entry;
346 int i, len;
2e4fd068 347 struct hfa384x_hostscan_result *scanres;
6bbefe86 348 u8 *p;
ff1d2767 349
6bbefe86
DH
350 if (v == SEQ_START_TOKEN) {
351 seq_printf(m,
352 "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates SSID\n");
353 return 0;
354 }
355
356 entry = (unsigned long)v - 2;
357 scanres = &local->last_scan_results[entry];
358
359 seq_printf(m, "%d %d %d %d 0x%02x %d %pM %d ",
360 le16_to_cpu(scanres->chid),
361 (s16) le16_to_cpu(scanres->anl),
362 (s16) le16_to_cpu(scanres->sl),
363 le16_to_cpu(scanres->beacon_interval),
364 le16_to_cpu(scanres->capability),
365 le16_to_cpu(scanres->rate),
366 scanres->bssid,
367 le16_to_cpu(scanres->atim));
368
369 p = scanres->sup_rates;
370 for (i = 0; i < sizeof(scanres->sup_rates); i++) {
371 if (p[i] == 0)
372 break;
373 seq_printf(m, "<%02x>", p[i]);
374 }
375 seq_putc(m, ' ');
376
377 p = scanres->ssid;
378 len = le16_to_cpu(scanres->ssid_len);
379 if (len > 32)
380 len = 32;
381 for (i = 0; i < len; i++) {
382 unsigned char c = p[i];
383 if (c >= 32 && c < 127)
384 seq_putc(m, c);
385 else
386 seq_printf(m, "<%02x>", c);
387 }
388 seq_putc(m, '\n');
389 return 0;
390}
ff1d2767 391
6bbefe86
DH
392static void *prism2_scan_results_proc_start(struct seq_file *m, loff_t *_pos)
393{
394 local_info_t *local = m->private;
ff1d2767 395 spin_lock_bh(&local->lock);
ff1d2767 396
6bbefe86
DH
397 /* We have a header (pos 0) + N results to show (pos 1...N) */
398 if (*_pos > local->last_scan_results_count)
399 return NULL;
400 return (void *)(unsigned long)(*_pos + 1); /* 0 would be EOF */
401}
ff1d2767 402
6bbefe86
DH
403static void *prism2_scan_results_proc_next(struct seq_file *m, void *v, loff_t *_pos)
404{
405 local_info_t *local = m->private;
406
407 ++*_pos;
408 if (*_pos > local->last_scan_results_count)
409 return NULL;
410 return (void *)(unsigned long)(*_pos + 1); /* 0 would be EOF */
411}
412
413static void prism2_scan_results_proc_stop(struct seq_file *m, void *v)
414{
415 local_info_t *local = m->private;
ff1d2767 416 spin_unlock_bh(&local->lock);
6bbefe86 417}
ff1d2767 418
6bbefe86
DH
419static const struct seq_operations prism2_scan_results_proc_seqops = {
420 .start = prism2_scan_results_proc_start,
421 .next = prism2_scan_results_proc_next,
422 .stop = prism2_scan_results_proc_stop,
423 .show = prism2_scan_results_proc_show,
424};
ff1d2767 425
6bbefe86
DH
426static int prism2_scan_results_proc_open(struct inode *inode, struct file *file)
427{
428 int ret = seq_open(file, &prism2_scan_results_proc_seqops);
429 if (ret == 0) {
430 struct seq_file *m = file->private_data;
431 m->private = PDE_DATA(inode);
ff1d2767 432 }
6bbefe86
DH
433 return ret;
434}
435
436static const struct file_operations prism2_scan_results_proc_fops = {
437 .open = prism2_scan_results_proc_open,
438 .read = seq_read,
439 .llseek = seq_lseek,
440 .release = seq_release,
441};
ff1d2767 442
ff1d2767 443
ff1d2767
JM
444#endif /* PRISM2_NO_STATION_MODES */
445
446
447void hostap_init_proc(local_info_t *local)
448{
449 local->proc = NULL;
450
451 if (hostap_proc == NULL) {
452 printk(KERN_WARNING "%s: hostap proc directory not created\n",
453 local->dev->name);
454 return;
455 }
456
457 local->proc = proc_mkdir(local->ddev->name, hostap_proc);
458 if (local->proc == NULL) {
459 printk(KERN_INFO "/proc/net/hostap/%s creation failed\n",
460 local->ddev->name);
461 return;
462 }
463
464#ifndef PRISM2_NO_PROCFS_DEBUG
6bbefe86
DH
465 proc_create_data("debug", 0, local->proc,
466 &prism2_debug_proc_fops, local);
ff1d2767 467#endif /* PRISM2_NO_PROCFS_DEBUG */
6bbefe86
DH
468 proc_create_data("stats", 0, local->proc,
469 &prism2_stats_proc_fops, local);
470 proc_create_data("wds", 0, local->proc,
471 &prism2_wds_proc_fops, local);
472 proc_create_data("pda", 0, local->proc,
473 &prism2_pda_proc_fops, local);
474 proc_create_data("aux_dump", 0, local->proc,
475 local->func->read_aux_fops ?: &prism2_aux_dump_proc_fops,
476 local);
477 proc_create_data("bss_list", 0, local->proc,
478 &prism2_bss_list_proc_fops, local);
479 proc_create_data("crypt", 0, local->proc,
480 &prism2_crypt_proc_fops, local);
ff1d2767 481#ifdef PRISM2_IO_DEBUG
6bbefe86
DH
482 proc_create_data("io_debug", 0, local->proc,
483 &prism2_io_debug_proc_fops, local);
ff1d2767
JM
484#endif /* PRISM2_IO_DEBUG */
485#ifndef PRISM2_NO_STATION_MODES
6bbefe86
DH
486 proc_create_data("scan_results", 0, local->proc,
487 &prism2_scan_results_proc_fops, local);
ff1d2767
JM
488#endif /* PRISM2_NO_STATION_MODES */
489}
490
491
492void hostap_remove_proc(local_info_t *local)
493{
4885c873 494 proc_remove(local->proc);
ff1d2767
JM
495}
496
497
498EXPORT_SYMBOL(hostap_init_proc);
499EXPORT_SYMBOL(hostap_remove_proc);