root/drivers/net/wireless/intersil/hostap/hostap_proc.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. prism2_debug_proc_show
  2. prism2_stats_proc_show
  3. prism2_wds_proc_show
  4. prism2_wds_proc_start
  5. prism2_wds_proc_next
  6. prism2_wds_proc_stop
  7. prism2_bss_list_proc_show
  8. prism2_bss_list_proc_start
  9. prism2_bss_list_proc_next
  10. prism2_bss_list_proc_stop
  11. prism2_crypt_proc_show
  12. prism2_pda_proc_read
  13. prism2_aux_dump_proc_no_read
  14. prism2_io_debug_proc_read
  15. prism2_scan_results_proc_show
  16. prism2_scan_results_proc_start
  17. prism2_scan_results_proc_next
  18. prism2_scan_results_proc_stop
  19. hostap_init_proc
  20. hostap_remove_proc

   1 // SPDX-License-Identifier: GPL-2.0
   2 /* /proc routines for Host AP driver */
   3 
   4 #include <linux/types.h>
   5 #include <linux/proc_fs.h>
   6 #include <linux/export.h>
   7 #include <net/lib80211.h>
   8 
   9 #include "hostap_wlan.h"
  10 #include "hostap.h"
  11 
  12 #define PROC_LIMIT (PAGE_SIZE - 80)
  13 
  14 #if !defined(PRISM2_NO_PROCFS_DEBUG) && defined(CONFIG_PROC_FS)
  15 static int prism2_debug_proc_show(struct seq_file *m, void *v)
  16 {
  17         local_info_t *local = m->private;
  18         int i;
  19 
  20         seq_printf(m, "next_txfid=%d next_alloc=%d\n",
  21                    local->next_txfid, local->next_alloc);
  22         for (i = 0; i < PRISM2_TXFID_COUNT; i++)
  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);
  31         for (i = 0; i < WEP_KEYS; i++) {
  32                 if (local->crypt_info.crypt[i] &&
  33                     local->crypt_info.crypt[i]->ops) {
  34                         seq_printf(m, "crypt[%d]=%s\n", i,
  35                                    local->crypt_info.crypt[i]->ops->name);
  36                 }
  37         }
  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 }
  45 #endif
  46 
  47 #ifdef CONFIG_PROC_FS
  48 static int prism2_stats_proc_show(struct seq_file *m, void *v)
  49 {
  50         local_info_t *local = m->private;
  51         struct comm_tallies_sums *sums = &local->comm_tallies;
  52 
  53         seq_printf(m, "TxUnicastFrames=%u\n", sums->tx_unicast_frames);
  54         seq_printf(m, "TxMulticastframes=%u\n", sums->tx_multicast_frames);
  55         seq_printf(m, "TxFragments=%u\n", sums->tx_fragments);
  56         seq_printf(m, "TxUnicastOctets=%u\n", sums->tx_unicast_octets);
  57         seq_printf(m, "TxMulticastOctets=%u\n", sums->tx_multicast_octets);
  58         seq_printf(m, "TxDeferredTransmissions=%u\n",
  59                    sums->tx_deferred_transmissions);
  60         seq_printf(m, "TxSingleRetryFrames=%u\n", sums->tx_single_retry_frames);
  61         seq_printf(m, "TxMultipleRetryFrames=%u\n",
  62                    sums->tx_multiple_retry_frames);
  63         seq_printf(m, "TxRetryLimitExceeded=%u\n",
  64                    sums->tx_retry_limit_exceeded);
  65         seq_printf(m, "TxDiscards=%u\n", sums->tx_discards);
  66         seq_printf(m, "RxUnicastFrames=%u\n", sums->rx_unicast_frames);
  67         seq_printf(m, "RxMulticastFrames=%u\n", sums->rx_multicast_frames);
  68         seq_printf(m, "RxFragments=%u\n", sums->rx_fragments);
  69         seq_printf(m, "RxUnicastOctets=%u\n", sums->rx_unicast_octets);
  70         seq_printf(m, "RxMulticastOctets=%u\n", sums->rx_multicast_octets);
  71         seq_printf(m, "RxFCSErrors=%u\n", sums->rx_fcs_errors);
  72         seq_printf(m, "RxDiscardsNoBuffer=%u\n", sums->rx_discards_no_buffer);
  73         seq_printf(m, "TxDiscardsWrongSA=%u\n", sums->tx_discards_wrong_sa);
  74         seq_printf(m, "RxDiscardsWEPUndecryptable=%u\n",
  75                    sums->rx_discards_wep_undecryptable);
  76         seq_printf(m, "RxMessageInMsgFragments=%u\n",
  77                    sums->rx_message_in_msg_fragments);
  78         seq_printf(m, "RxMessageInBadMsgFragments=%u\n",
  79                    sums->rx_message_in_bad_msg_fragments);
  80         /* FIX: this may grow too long for one page(?) */
  81 
  82         return 0;
  83 }
  84 #endif
  85 
  86 static int prism2_wds_proc_show(struct seq_file *m, void *v)
  87 {
  88         struct list_head *ptr = v;
  89         struct hostap_interface *iface;
  90 
  91         iface = list_entry(ptr, struct hostap_interface, list);
  92         if (iface->type == HOSTAP_INTERFACE_WDS)
  93                 seq_printf(m, "%s\t%pM\n",
  94                            iface->dev->name, iface->u.wds.remote_addr);
  95         return 0;
  96 }
  97 
  98 static void *prism2_wds_proc_start(struct seq_file *m, loff_t *_pos)
  99 {
 100         local_info_t *local = PDE_DATA(file_inode(m->file));
 101         read_lock_bh(&local->iface_lock);
 102         return seq_list_start(&local->hostap_interfaces, *_pos);
 103 }
 104 
 105 static void *prism2_wds_proc_next(struct seq_file *m, void *v, loff_t *_pos)
 106 {
 107         local_info_t *local = PDE_DATA(file_inode(m->file));
 108         return seq_list_next(v, &local->hostap_interfaces, _pos);
 109 }
 110 
 111 static void prism2_wds_proc_stop(struct seq_file *m, void *v)
 112 {
 113         local_info_t *local = PDE_DATA(file_inode(m->file));
 114         read_unlock_bh(&local->iface_lock);
 115 }
 116 
 117 static const struct seq_operations prism2_wds_proc_seqops = {
 118         .start  = prism2_wds_proc_start,
 119         .next   = prism2_wds_proc_next,
 120         .stop   = prism2_wds_proc_stop,
 121         .show   = prism2_wds_proc_show,
 122 };
 123 
 124 static int prism2_bss_list_proc_show(struct seq_file *m, void *v)
 125 {
 126         local_info_t *local = PDE_DATA(file_inode(m->file));
 127         struct list_head *ptr = v;
 128         struct hostap_bss_info *bss;
 129 
 130         if (ptr == &local->bss_list) {
 131                 seq_printf(m, "#BSSID\tlast_update\tcount\tcapab_info\tSSID(txt)\t"
 132                            "SSID(hex)\tWPA IE\n");
 133                 return 0;
 134         }
 135 
 136         bss = list_entry(ptr, struct hostap_bss_info, list);
 137         seq_printf(m, "%pM\t%lu\t%u\t0x%x\t",
 138                    bss->bssid, bss->last_update,
 139                    bss->count, bss->capab_info);
 140 
 141         seq_printf(m, "%*pE", (int)bss->ssid_len, bss->ssid);
 142 
 143         seq_putc(m, '\t');
 144         seq_printf(m, "%*phN", (int)bss->ssid_len, bss->ssid);
 145         seq_putc(m, '\t');
 146         seq_printf(m, "%*phN", (int)bss->wpa_ie_len, bss->wpa_ie);
 147         seq_putc(m, '\n');
 148         return 0;
 149 }
 150 
 151 static void *prism2_bss_list_proc_start(struct seq_file *m, loff_t *_pos)
 152 {
 153         local_info_t *local = PDE_DATA(file_inode(m->file));
 154         spin_lock_bh(&local->lock);
 155         return seq_list_start_head(&local->bss_list, *_pos);
 156 }
 157 
 158 static void *prism2_bss_list_proc_next(struct seq_file *m, void *v, loff_t *_pos)
 159 {
 160         local_info_t *local = PDE_DATA(file_inode(m->file));
 161         return seq_list_next(v, &local->bss_list, _pos);
 162 }
 163 
 164 static void prism2_bss_list_proc_stop(struct seq_file *m, void *v)
 165 {
 166         local_info_t *local = PDE_DATA(file_inode(m->file));
 167         spin_unlock_bh(&local->lock);
 168 }
 169 
 170 static const struct seq_operations prism2_bss_list_proc_seqops = {
 171         .start  = prism2_bss_list_proc_start,
 172         .next   = prism2_bss_list_proc_next,
 173         .stop   = prism2_bss_list_proc_stop,
 174         .show   = prism2_bss_list_proc_show,
 175 };
 176 
 177 #ifdef CONFIG_PROC_FS
 178 static int prism2_crypt_proc_show(struct seq_file *m, void *v)
 179 {
 180         local_info_t *local = m->private;
 181         int i;
 182 
 183         seq_printf(m, "tx_keyidx=%d\n", local->crypt_info.tx_keyidx);
 184         for (i = 0; i < WEP_KEYS; i++) {
 185                 if (local->crypt_info.crypt[i] &&
 186                     local->crypt_info.crypt[i]->ops &&
 187                     local->crypt_info.crypt[i]->ops->print_stats) {
 188                         local->crypt_info.crypt[i]->ops->print_stats(
 189                                 m, local->crypt_info.crypt[i]->priv);
 190                 }
 191         }
 192         return 0;
 193 }
 194 #endif
 195 
 196 static ssize_t prism2_pda_proc_read(struct file *file, char __user *buf,
 197                                     size_t count, loff_t *_pos)
 198 {
 199         local_info_t *local = PDE_DATA(file_inode(file));
 200         size_t off;
 201 
 202         if (local->pda == NULL || *_pos >= PRISM2_PDA_SIZE)
 203                 return 0;
 204 
 205         off = *_pos;
 206         if (count > PRISM2_PDA_SIZE - off)
 207                 count = PRISM2_PDA_SIZE - off;
 208         if (copy_to_user(buf, local->pda + off, count) != 0)
 209                 return -EFAULT;
 210         *_pos += count;
 211         return count;
 212 }
 213 
 214 static const struct file_operations prism2_pda_proc_fops = {
 215         .read           = prism2_pda_proc_read,
 216         .llseek         = generic_file_llseek,
 217 };
 218 
 219 
 220 static ssize_t prism2_aux_dump_proc_no_read(struct file *file, char __user *buf,
 221                                             size_t bufsize, loff_t *_pos)
 222 {
 223         return 0;
 224 }
 225 
 226 static const struct file_operations prism2_aux_dump_proc_fops = {
 227         .read           = prism2_aux_dump_proc_no_read,
 228 };
 229 
 230 
 231 #ifdef PRISM2_IO_DEBUG
 232 static int prism2_io_debug_proc_read(char *page, char **start, off_t off,
 233                                      int count, int *eof, void *data)
 234 {
 235         local_info_t *local = (local_info_t *) data;
 236         int head = local->io_debug_head;
 237         int start_bytes, left, copy;
 238 
 239         if (off + count > PRISM2_IO_DEBUG_SIZE * 4) {
 240                 *eof = 1;
 241                 if (off >= PRISM2_IO_DEBUG_SIZE * 4)
 242                         return 0;
 243                 count = PRISM2_IO_DEBUG_SIZE * 4 - off;
 244         }
 245 
 246         start_bytes = (PRISM2_IO_DEBUG_SIZE - head) * 4;
 247         left = count;
 248 
 249         if (off < start_bytes) {
 250                 copy = start_bytes - off;
 251                 if (copy > count)
 252                         copy = count;
 253                 memcpy(page, ((u8 *) &local->io_debug[head]) + off, copy);
 254                 left -= copy;
 255                 if (left > 0)
 256                         memcpy(&page[copy], local->io_debug, left);
 257         } else {
 258                 memcpy(page, ((u8 *) local->io_debug) + (off - start_bytes),
 259                        left);
 260         }
 261 
 262         *start = page;
 263 
 264         return count;
 265 }
 266 #endif /* PRISM2_IO_DEBUG */
 267 
 268 
 269 #ifndef PRISM2_NO_STATION_MODES
 270 static int prism2_scan_results_proc_show(struct seq_file *m, void *v)
 271 {
 272         local_info_t *local = PDE_DATA(file_inode(m->file));
 273         unsigned long entry;
 274         int i, len;
 275         struct hfa384x_hostscan_result *scanres;
 276         u8 *p;
 277 
 278         if (v == SEQ_START_TOKEN) {
 279                 seq_printf(m,
 280                            "CHID ANL SL BcnInt Capab Rate BSSID ATIM SupRates SSID\n");
 281                 return 0;
 282         }
 283 
 284         entry = (unsigned long)v - 2;
 285         scanres = &local->last_scan_results[entry];
 286 
 287         seq_printf(m, "%d %d %d %d 0x%02x %d %pM %d ",
 288                    le16_to_cpu(scanres->chid),
 289                    (s16) le16_to_cpu(scanres->anl),
 290                    (s16) le16_to_cpu(scanres->sl),
 291                    le16_to_cpu(scanres->beacon_interval),
 292                    le16_to_cpu(scanres->capability),
 293                    le16_to_cpu(scanres->rate),
 294                    scanres->bssid,
 295                    le16_to_cpu(scanres->atim));
 296 
 297         p = scanres->sup_rates;
 298         for (i = 0; i < sizeof(scanres->sup_rates); i++) {
 299                 if (p[i] == 0)
 300                         break;
 301                 seq_printf(m, "<%02x>", p[i]);
 302         }
 303         seq_putc(m, ' ');
 304 
 305         p = scanres->ssid;
 306         len = le16_to_cpu(scanres->ssid_len);
 307         if (len > 32)
 308                 len = 32;
 309         for (i = 0; i < len; i++) {
 310                 unsigned char c = p[i];
 311                 if (c >= 32 && c < 127)
 312                         seq_putc(m, c);
 313                 else
 314                         seq_printf(m, "<%02x>", c);
 315         }
 316         seq_putc(m, '\n');
 317         return 0;
 318 }
 319 
 320 static void *prism2_scan_results_proc_start(struct seq_file *m, loff_t *_pos)
 321 {
 322         local_info_t *local = PDE_DATA(file_inode(m->file));
 323         spin_lock_bh(&local->lock);
 324 
 325         /* We have a header (pos 0) + N results to show (pos 1...N) */
 326         if (*_pos > local->last_scan_results_count)
 327                 return NULL;
 328         return (void *)(unsigned long)(*_pos + 1); /* 0 would be EOF */
 329 }
 330 
 331 static void *prism2_scan_results_proc_next(struct seq_file *m, void *v, loff_t *_pos)
 332 {
 333         local_info_t *local = PDE_DATA(file_inode(m->file));
 334 
 335         ++*_pos;
 336         if (*_pos > local->last_scan_results_count)
 337                 return NULL;
 338         return (void *)(unsigned long)(*_pos + 1); /* 0 would be EOF */
 339 }
 340 
 341 static void prism2_scan_results_proc_stop(struct seq_file *m, void *v)
 342 {
 343         local_info_t *local = PDE_DATA(file_inode(m->file));
 344         spin_unlock_bh(&local->lock);
 345 }
 346 
 347 static const struct seq_operations prism2_scan_results_proc_seqops = {
 348         .start  = prism2_scan_results_proc_start,
 349         .next   = prism2_scan_results_proc_next,
 350         .stop   = prism2_scan_results_proc_stop,
 351         .show   = prism2_scan_results_proc_show,
 352 };
 353 #endif /* PRISM2_NO_STATION_MODES */
 354 
 355 
 356 void hostap_init_proc(local_info_t *local)
 357 {
 358         local->proc = NULL;
 359 
 360         if (hostap_proc == NULL) {
 361                 printk(KERN_WARNING "%s: hostap proc directory not created\n",
 362                        local->dev->name);
 363                 return;
 364         }
 365 
 366         local->proc = proc_mkdir(local->ddev->name, hostap_proc);
 367         if (local->proc == NULL) {
 368                 printk(KERN_INFO "/proc/net/hostap/%s creation failed\n",
 369                        local->ddev->name);
 370                 return;
 371         }
 372 
 373 #ifndef PRISM2_NO_PROCFS_DEBUG
 374         proc_create_single_data("debug", 0, local->proc,
 375                         prism2_debug_proc_show, local);
 376 #endif /* PRISM2_NO_PROCFS_DEBUG */
 377         proc_create_single_data("stats", 0, local->proc, prism2_stats_proc_show,
 378                         local);
 379         proc_create_seq_data("wds", 0, local->proc,
 380                         &prism2_wds_proc_seqops, local);
 381         proc_create_data("pda", 0, local->proc,
 382                          &prism2_pda_proc_fops, local);
 383         proc_create_data("aux_dump", 0, local->proc,
 384                          local->func->read_aux_fops ?: &prism2_aux_dump_proc_fops,
 385                          local);
 386         proc_create_seq_data("bss_list", 0, local->proc,
 387                         &prism2_bss_list_proc_seqops, local);
 388         proc_create_single_data("crypt", 0, local->proc, prism2_crypt_proc_show,
 389                 local);
 390 #ifdef PRISM2_IO_DEBUG
 391         proc_create_single_data("io_debug", 0, local->proc,
 392                         prism2_debug_proc_show, local);
 393 #endif /* PRISM2_IO_DEBUG */
 394 #ifndef PRISM2_NO_STATION_MODES
 395         proc_create_seq_data("scan_results", 0, local->proc,
 396                         &prism2_scan_results_proc_seqops, local);
 397 #endif /* PRISM2_NO_STATION_MODES */
 398 }
 399 
 400 
 401 void hostap_remove_proc(local_info_t *local)
 402 {
 403         proc_remove(local->proc);
 404 }
 405 
 406 
 407 EXPORT_SYMBOL(hostap_init_proc);
 408 EXPORT_SYMBOL(hostap_remove_proc);

/* [<][>][^][v][top][bottom][index][help] */