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