1 /* /proc routines for Host AP driver */
3 #include <linux/types.h>
4 #include <linux/proc_fs.h>
5 #include <linux/export.h>
6 #include <net/lib80211.h>
8 #include "hostap_wlan.h"
11 #define PROC_LIMIT (PAGE_SIZE - 80)
14 #ifndef PRISM2_NO_PROCFS_DEBUG
15 static int prism2_debug_proc_read(char *page
, char **start
, off_t off
,
16 int count
, int *eof
, void *data
)
19 local_info_t
*local
= (local_info_t
*) data
;
27 p
+= sprintf(p
, "next_txfid=%d next_alloc=%d\n",
28 local
->next_txfid
, local
->next_alloc
);
29 for (i
= 0; i
< PRISM2_TXFID_COUNT
; i
++)
30 p
+= sprintf(p
, "FID: tx=%04X intransmit=%04X\n",
31 local
->txfid
[i
], local
->intransmitfid
[i
]);
32 p
+= sprintf(p
, "FW TX rate control: %d\n", local
->fw_tx_rate_control
);
33 p
+= sprintf(p
, "beacon_int=%d\n", local
->beacon_int
);
34 p
+= sprintf(p
, "dtim_period=%d\n", local
->dtim_period
);
35 p
+= sprintf(p
, "wds_max_connections=%d\n",
36 local
->wds_max_connections
);
37 p
+= sprintf(p
, "dev_enabled=%d\n", local
->dev_enabled
);
38 p
+= sprintf(p
, "sw_tick_stuck=%d\n", local
->sw_tick_stuck
);
39 for (i
= 0; i
< WEP_KEYS
; i
++) {
40 if (local
->crypt_info
.crypt
[i
] &&
41 local
->crypt_info
.crypt
[i
]->ops
) {
42 p
+= sprintf(p
, "crypt[%d]=%s\n", i
,
43 local
->crypt_info
.crypt
[i
]->ops
->name
);
46 p
+= sprintf(p
, "pri_only=%d\n", local
->pri_only
);
47 p
+= sprintf(p
, "pci=%d\n", local
->func
->hw_type
== HOSTAP_HW_PCI
);
48 p
+= sprintf(p
, "sram_type=%d\n", local
->sram_type
);
49 p
+= sprintf(p
, "no_pri=%d\n", local
->no_pri
);
53 #endif /* PRISM2_NO_PROCFS_DEBUG */
56 static int prism2_stats_proc_read(char *page
, char **start
, off_t off
,
57 int count
, int *eof
, void *data
)
60 local_info_t
*local
= (local_info_t
*) data
;
61 struct comm_tallies_sums
*sums
= (struct comm_tallies_sums
*)
69 p
+= sprintf(p
, "TxUnicastFrames=%u\n", sums
->tx_unicast_frames
);
70 p
+= sprintf(p
, "TxMulticastframes=%u\n", sums
->tx_multicast_frames
);
71 p
+= sprintf(p
, "TxFragments=%u\n", sums
->tx_fragments
);
72 p
+= sprintf(p
, "TxUnicastOctets=%u\n", sums
->tx_unicast_octets
);
73 p
+= sprintf(p
, "TxMulticastOctets=%u\n", sums
->tx_multicast_octets
);
74 p
+= sprintf(p
, "TxDeferredTransmissions=%u\n",
75 sums
->tx_deferred_transmissions
);
76 p
+= sprintf(p
, "TxSingleRetryFrames=%u\n",
77 sums
->tx_single_retry_frames
);
78 p
+= sprintf(p
, "TxMultipleRetryFrames=%u\n",
79 sums
->tx_multiple_retry_frames
);
80 p
+= sprintf(p
, "TxRetryLimitExceeded=%u\n",
81 sums
->tx_retry_limit_exceeded
);
82 p
+= sprintf(p
, "TxDiscards=%u\n", sums
->tx_discards
);
83 p
+= sprintf(p
, "RxUnicastFrames=%u\n", sums
->rx_unicast_frames
);
84 p
+= sprintf(p
, "RxMulticastFrames=%u\n", sums
->rx_multicast_frames
);
85 p
+= sprintf(p
, "RxFragments=%u\n", sums
->rx_fragments
);
86 p
+= sprintf(p
, "RxUnicastOctets=%u\n", sums
->rx_unicast_octets
);
87 p
+= sprintf(p
, "RxMulticastOctets=%u\n", sums
->rx_multicast_octets
);
88 p
+= sprintf(p
, "RxFCSErrors=%u\n", sums
->rx_fcs_errors
);
89 p
+= sprintf(p
, "RxDiscardsNoBuffer=%u\n",
90 sums
->rx_discards_no_buffer
);
91 p
+= sprintf(p
, "TxDiscardsWrongSA=%u\n", sums
->tx_discards_wrong_sa
);
92 p
+= sprintf(p
, "RxDiscardsWEPUndecryptable=%u\n",
93 sums
->rx_discards_wep_undecryptable
);
94 p
+= sprintf(p
, "RxMessageInMsgFragments=%u\n",
95 sums
->rx_message_in_msg_fragments
);
96 p
+= sprintf(p
, "RxMessageInBadMsgFragments=%u\n",
97 sums
->rx_message_in_bad_msg_fragments
);
98 /* FIX: this may grow too long for one page(?) */
104 static int prism2_wds_proc_read(char *page
, char **start
, off_t off
,
105 int count
, int *eof
, void *data
)
108 local_info_t
*local
= (local_info_t
*) data
;
109 struct list_head
*ptr
;
110 struct hostap_interface
*iface
;
112 if (off
> PROC_LIMIT
) {
117 read_lock_bh(&local
->iface_lock
);
118 list_for_each(ptr
, &local
->hostap_interfaces
) {
119 iface
= list_entry(ptr
, struct hostap_interface
, list
);
120 if (iface
->type
!= HOSTAP_INTERFACE_WDS
)
122 p
+= sprintf(p
, "%s\t%pM\n",
124 iface
->u
.wds
.remote_addr
);
125 if ((p
- page
) > PROC_LIMIT
) {
126 printk(KERN_DEBUG
"%s: wds proc did not fit\n",
131 read_unlock_bh(&local
->iface_lock
);
133 if ((p
- page
) <= off
) {
140 return (p
- page
- off
);
144 static int prism2_bss_list_proc_read(char *page
, char **start
, off_t off
,
145 int count
, int *eof
, void *data
)
148 local_info_t
*local
= (local_info_t
*) data
;
149 struct list_head
*ptr
;
150 struct hostap_bss_info
*bss
;
153 if (off
> PROC_LIMIT
) {
158 p
+= sprintf(p
, "#BSSID\tlast_update\tcount\tcapab_info\tSSID(txt)\t"
159 "SSID(hex)\tWPA IE\n");
160 spin_lock_bh(&local
->lock
);
161 list_for_each(ptr
, &local
->bss_list
) {
162 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
163 p
+= sprintf(p
, "%pM\t%lu\t%u\t0x%x\t",
164 bss
->bssid
, bss
->last_update
,
165 bss
->count
, bss
->capab_info
);
166 for (i
= 0; i
< bss
->ssid_len
; i
++) {
167 p
+= sprintf(p
, "%c",
168 bss
->ssid
[i
] >= 32 && bss
->ssid
[i
] < 127 ?
171 p
+= sprintf(p
, "\t");
172 for (i
= 0; i
< bss
->ssid_len
; i
++) {
173 p
+= sprintf(p
, "%02x", bss
->ssid
[i
]);
175 p
+= sprintf(p
, "\t");
176 for (i
= 0; i
< bss
->wpa_ie_len
; i
++) {
177 p
+= sprintf(p
, "%02x", bss
->wpa_ie
[i
]);
179 p
+= sprintf(p
, "\n");
180 if ((p
- page
) > PROC_LIMIT
) {
181 printk(KERN_DEBUG
"%s: BSS proc did not fit\n",
186 spin_unlock_bh(&local
->lock
);
188 if ((p
- page
) <= off
) {
195 return (p
- page
- off
);
199 static int prism2_crypt_proc_read(char *page
, char **start
, off_t off
,
200 int count
, int *eof
, void *data
)
203 local_info_t
*local
= (local_info_t
*) data
;
206 if (off
> PROC_LIMIT
) {
211 p
+= sprintf(p
, "tx_keyidx=%d\n", local
->crypt_info
.tx_keyidx
);
212 for (i
= 0; i
< WEP_KEYS
; i
++) {
213 if (local
->crypt_info
.crypt
[i
] &&
214 local
->crypt_info
.crypt
[i
]->ops
&&
215 local
->crypt_info
.crypt
[i
]->ops
->print_stats
) {
216 p
= local
->crypt_info
.crypt
[i
]->ops
->print_stats(
217 p
, local
->crypt_info
.crypt
[i
]->priv
);
221 if ((p
- page
) <= off
) {
228 return (p
- page
- off
);
232 static int prism2_pda_proc_read(char *page
, char **start
, off_t off
,
233 int count
, int *eof
, void *data
)
235 local_info_t
*local
= (local_info_t
*) data
;
237 if (local
->pda
== NULL
|| off
>= PRISM2_PDA_SIZE
) {
242 if (off
+ count
> PRISM2_PDA_SIZE
)
243 count
= PRISM2_PDA_SIZE
- off
;
245 memcpy(page
, local
->pda
+ off
, count
);
250 static int prism2_aux_dump_proc_read(char *page
, char **start
, off_t off
,
251 int count
, int *eof
, void *data
)
253 local_info_t
*local
= (local_info_t
*) data
;
255 if (local
->func
->read_aux
== NULL
) {
260 if (local
->func
->read_aux(local
->dev
, off
, count
, page
)) {
270 #ifdef PRISM2_IO_DEBUG
271 static int prism2_io_debug_proc_read(char *page
, char **start
, off_t off
,
272 int count
, int *eof
, void *data
)
274 local_info_t
*local
= (local_info_t
*) data
;
275 int head
= local
->io_debug_head
;
276 int start_bytes
, left
, copy
, copied
;
278 if (off
+ count
> PRISM2_IO_DEBUG_SIZE
* 4) {
280 if (off
>= PRISM2_IO_DEBUG_SIZE
* 4)
282 count
= PRISM2_IO_DEBUG_SIZE
* 4 - off
;
286 start_bytes
= (PRISM2_IO_DEBUG_SIZE
- head
) * 4;
289 if (off
< start_bytes
) {
290 copy
= start_bytes
- off
;
293 memcpy(page
, ((u8
*) &local
->io_debug
[head
]) + off
, copy
);
296 memcpy(&page
[copy
], local
->io_debug
, left
);
298 memcpy(page
, ((u8
*) local
->io_debug
) + (off
- start_bytes
),
306 #endif /* PRISM2_IO_DEBUG */
309 #ifndef PRISM2_NO_STATION_MODES
310 static int prism2_scan_results_proc_read(char *page
, char **start
, off_t off
,
311 int count
, int *eof
, void *data
)
314 local_info_t
*local
= (local_info_t
*) data
;
315 int entry
, i
, len
, total
= 0;
316 struct hfa384x_hostscan_result
*scanres
;
319 p
+= sprintf(p
, "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates "
322 spin_lock_bh(&local
->lock
);
323 for (entry
= 0; entry
< local
->last_scan_results_count
; entry
++) {
324 scanres
= &local
->last_scan_results
[entry
];
326 if (total
+ (p
- page
) <= off
) {
330 if (total
+ (p
- page
) > off
+ count
)
332 if ((p
- page
) > (PAGE_SIZE
- 200))
335 p
+= sprintf(p
, "%d %d %d %d 0x%02x %d %pM %d ",
336 le16_to_cpu(scanres
->chid
),
337 (s16
) le16_to_cpu(scanres
->anl
),
338 (s16
) le16_to_cpu(scanres
->sl
),
339 le16_to_cpu(scanres
->beacon_interval
),
340 le16_to_cpu(scanres
->capability
),
341 le16_to_cpu(scanres
->rate
),
343 le16_to_cpu(scanres
->atim
));
345 pos
= scanres
->sup_rates
;
346 for (i
= 0; i
< sizeof(scanres
->sup_rates
); i
++) {
349 p
+= sprintf(p
, "<%02x>", pos
[i
]);
351 p
+= sprintf(p
, " ");
354 len
= le16_to_cpu(scanres
->ssid_len
);
357 for (i
= 0; i
< len
; i
++) {
358 unsigned char c
= pos
[i
];
359 if (c
>= 32 && c
< 127)
360 p
+= sprintf(p
, "%c", c
);
362 p
+= sprintf(p
, "<%02x>", c
);
364 p
+= sprintf(p
, "\n");
366 spin_unlock_bh(&local
->lock
);
369 if (total
>= off
+ count
)
378 if (len
> (p
- page
))
386 #endif /* PRISM2_NO_STATION_MODES */
389 void hostap_init_proc(local_info_t
*local
)
393 if (hostap_proc
== NULL
) {
394 printk(KERN_WARNING
"%s: hostap proc directory not created\n",
399 local
->proc
= proc_mkdir(local
->ddev
->name
, hostap_proc
);
400 if (local
->proc
== NULL
) {
401 printk(KERN_INFO
"/proc/net/hostap/%s creation failed\n",
406 #ifndef PRISM2_NO_PROCFS_DEBUG
407 create_proc_read_entry("debug", 0, local
->proc
,
408 prism2_debug_proc_read
, local
);
409 #endif /* PRISM2_NO_PROCFS_DEBUG */
410 create_proc_read_entry("stats", 0, local
->proc
,
411 prism2_stats_proc_read
, local
);
412 create_proc_read_entry("wds", 0, local
->proc
,
413 prism2_wds_proc_read
, local
);
414 create_proc_read_entry("pda", 0, local
->proc
,
415 prism2_pda_proc_read
, local
);
416 create_proc_read_entry("aux_dump", 0, local
->proc
,
417 prism2_aux_dump_proc_read
, local
);
418 create_proc_read_entry("bss_list", 0, local
->proc
,
419 prism2_bss_list_proc_read
, local
);
420 create_proc_read_entry("crypt", 0, local
->proc
,
421 prism2_crypt_proc_read
, local
);
422 #ifdef PRISM2_IO_DEBUG
423 create_proc_read_entry("io_debug", 0, local
->proc
,
424 prism2_io_debug_proc_read
, local
);
425 #endif /* PRISM2_IO_DEBUG */
426 #ifndef PRISM2_NO_STATION_MODES
427 create_proc_read_entry("scan_results", 0, local
->proc
,
428 prism2_scan_results_proc_read
, local
);
429 #endif /* PRISM2_NO_STATION_MODES */
433 void hostap_remove_proc(local_info_t
*local
)
435 if (local
->proc
!= NULL
) {
436 #ifndef PRISM2_NO_STATION_MODES
437 remove_proc_entry("scan_results", local
->proc
);
438 #endif /* PRISM2_NO_STATION_MODES */
439 #ifdef PRISM2_IO_DEBUG
440 remove_proc_entry("io_debug", local
->proc
);
441 #endif /* PRISM2_IO_DEBUG */
442 remove_proc_entry("pda", local
->proc
);
443 remove_proc_entry("aux_dump", local
->proc
);
444 remove_proc_entry("wds", local
->proc
);
445 remove_proc_entry("stats", local
->proc
);
446 remove_proc_entry("bss_list", local
->proc
);
447 remove_proc_entry("crypt", local
->proc
);
448 #ifndef PRISM2_NO_PROCFS_DEBUG
449 remove_proc_entry("debug", local
->proc
);
450 #endif /* PRISM2_NO_PROCFS_DEBUG */
451 if (hostap_proc
!= NULL
)
452 remove_proc_entry(local
->proc
->name
, hostap_proc
);
457 EXPORT_SYMBOL(hostap_init_proc
);
458 EXPORT_SYMBOL(hostap_remove_proc
);