Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rtl_debug.c
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
3  *
4  * Based on the r8180 driver, which is:
5  * Copyright 2004-2005 Andrea Merello <[email protected]>, et al.
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of version 2 of the GNU General Public License as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18  *
19  * The full GNU General Public License is included in this distribution in the
20  * file called LICENSE.
21  *
22  * Contact Information:
23  * wlanfae <[email protected]>
24 ******************************************************************************/
25 #include "rtl_core.h"
26 #include "r8192E_phy.h"
27 #include "r8192E_phyreg.h"
28 #include "r8190P_rtl8256.h" /* RTL8225 Radio frontend */
29 #include "r8192E_cmdpkt.h"
30 
31 /****************************************************************************
32  -----------------------------PROCFS STUFF-------------------------
33 *****************************************************************************/
34 /*This part is related to PROC, which will record some statistics. */
35 static struct proc_dir_entry *rtl8192_proc;
36 
37 static int proc_get_stats_ap(char *page, char **start,
38  off_t offset, int count,
39  int *eof, void *data)
40 {
41  struct net_device *dev = data;
42  struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
43  struct rtllib_device *ieee = priv->rtllib;
44  struct rtllib_network *target;
45  int len = 0;
46 
47  list_for_each_entry(target, &ieee->network_list, list) {
48 
49  len += snprintf(page + len, count - len,
50  "%s ", target->ssid);
51 
52  if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0)
53  len += snprintf(page + len, count - len,
54  "WPA\n");
55  else
56  len += snprintf(page + len, count - len,
57  "non_WPA\n");
58 
59  }
60 
61  *eof = 1;
62  return len;
63 }
64 
65 static int proc_get_registers_0(char *page, char **start,
66  off_t offset, int count,
67  int *eof, void *data)
68 {
69  struct net_device *dev = data;
70 
71  int len = 0;
72  int i, n, page0;
73 
74  int max = 0xff;
75  page0 = 0x000;
76 
77  len += snprintf(page + len, count - len,
78  "\n####################page %x##################\n ",
79  (page0>>8));
80  len += snprintf(page + len, count - len,
81  "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
82  "0C 0D 0E 0F");
83  for (n = 0; n <= max;) {
84  len += snprintf(page + len, count - len, "\nD: %2x > ", n);
85  for (i = 0; i < 16 && n <= max; n++, i++)
86  len += snprintf(page + len, count - len,
87  "%2.2x ", read_nic_byte(dev,
88  (page0 | n)));
89  }
90  len += snprintf(page + len, count - len, "\n");
91  *eof = 1;
92  return len;
93 
94 }
95 static int proc_get_registers_1(char *page, char **start,
96  off_t offset, int count,
97  int *eof, void *data)
98 {
99  struct net_device *dev = data;
100 
101  int len = 0;
102  int i, n, page0;
103 
104  int max = 0xff;
105  page0 = 0x100;
106 
107  /* This dump the current register page */
108  len += snprintf(page + len, count - len,
109  "\n####################page %x##################\n ",
110  (page0>>8));
111  len += snprintf(page + len, count - len,
112  "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
113  "0C 0D 0E 0F");
114  for (n = 0; n <= max;) {
115  len += snprintf(page + len, count - len,
116  "\nD: %2x > ", n);
117  for (i = 0; i < 16 && n <= max; i++, n++)
118  len += snprintf(page + len, count - len,
119  "%2.2x ", read_nic_byte(dev,
120  (page0 | n)));
121  }
122  len += snprintf(page + len, count - len, "\n");
123  *eof = 1;
124  return len;
125 
126 }
127 static int proc_get_registers_2(char *page, char **start,
128  off_t offset, int count,
129  int *eof, void *data)
130 {
131  struct net_device *dev = data;
132 
133  int len = 0;
134  int i, n, page0;
135 
136  int max = 0xff;
137  page0 = 0x200;
138 
139  /* This dump the current register page */
140  len += snprintf(page + len, count - len,
141  "\n####################page %x##################\n ",
142  (page0 >> 8));
143  len += snprintf(page + len, count - len,
144  "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C "
145  "0D 0E 0F");
146  for (n = 0; n <= max;) {
147  len += snprintf(page + len, count - len,
148  "\nD: %2x > ", n);
149  for (i = 0; i < 16 && n <= max; i++, n++)
150  len += snprintf(page + len, count - len,
151  "%2.2x ", read_nic_byte(dev,
152  (page0 | n)));
153  }
154  len += snprintf(page + len, count - len, "\n");
155  *eof = 1;
156  return len;
157 
158 }
159 static int proc_get_registers_3(char *page, char **start,
160  off_t offset, int count,
161  int *eof, void *data)
162 {
163  struct net_device *dev = data;
164 
165  int len = 0;
166  int i, n, page0;
167 
168  int max = 0xff;
169  page0 = 0x300;
170 
171  /* This dump the current register page */
172  len += snprintf(page + len, count - len,
173  "\n####################page %x##################\n ",
174  (page0>>8));
175  len += snprintf(page + len, count - len,
176  "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
177  "0C 0D 0E 0F");
178  for (n = 0; n <= max;) {
179  len += snprintf(page + len, count - len,
180  "\nD: %2x > ", n);
181  for (i = 0; i < 16 && n <= max; i++, n++)
182  len += snprintf(page + len, count - len,
183  "%2.2x ", read_nic_byte(dev,
184  (page0 | n)));
185  }
186  len += snprintf(page + len, count - len, "\n");
187  *eof = 1;
188  return len;
189 
190 }
191 static int proc_get_registers_4(char *page, char **start,
192  off_t offset, int count,
193  int *eof, void *data)
194 {
195  struct net_device *dev = data;
196 
197  int len = 0;
198  int i, n, page0;
199 
200  int max = 0xff;
201  page0 = 0x400;
202 
203  /* This dump the current register page */
204  len += snprintf(page + len, count - len,
205  "\n####################page %x##################\n ",
206  (page0>>8));
207  len += snprintf(page + len, count - len,
208  "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
209  "0C 0D 0E 0F");
210  for (n = 0; n <= max;) {
211  len += snprintf(page + len, count - len,
212  "\nD: %2x > ", n);
213  for (i = 0; i < 16 && n <= max; i++, n++)
214  len += snprintf(page + len, count - len,
215  "%2.2x ", read_nic_byte(dev,
216  (page0 | n)));
217  }
218  len += snprintf(page + len, count - len, "\n");
219  *eof = 1;
220  return len;
221 
222 }
223 static int proc_get_registers_5(char *page, char **start,
224  off_t offset, int count,
225  int *eof, void *data)
226 {
227  struct net_device *dev = data;
228 
229  int len = 0;
230  int i, n, page0;
231 
232  int max = 0xff;
233  page0 = 0x500;
234 
235  /* This dump the current register page */
236  len += snprintf(page + len, count - len,
237  "\n####################page %x##################\n ",
238  (page0 >> 8));
239  len += snprintf(page + len, count - len,
240  "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
241  "0C 0D 0E 0F");
242  for (n = 0; n <= max;) {
243  len += snprintf(page + len, count - len,
244  "\nD: %2x > ", n);
245  for (i = 0; i < 16 && n <= max; i++, n++)
246  len += snprintf(page + len, count - len,
247  "%2.2x ", read_nic_byte(dev,
248  (page0 | n)));
249  }
250  len += snprintf(page + len, count - len, "\n");
251  *eof = 1;
252  return len;
253 
254 }
255 static int proc_get_registers_6(char *page, char **start,
256  off_t offset, int count,
257  int *eof, void *data)
258 {
259  struct net_device *dev = data;
260 
261  int len = 0;
262  int i, n, page0;
263 
264  int max = 0xff;
265  page0 = 0x600;
266 
267  /* This dump the current register page */
268  len += snprintf(page + len, count - len,
269  "\n####################page %x##################\n ",
270  (page0>>8));
271  len += snprintf(page + len, count - len,
272  "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
273  "0C 0D 0E 0F");
274  for (n = 0; n <= max;) {
275  len += snprintf(page + len, count - len,
276  "\nD: %2x > ", n);
277  for (i = 0; i < 16 && n <= max; i++, n++)
278  len += snprintf(page + len, count - len,
279  "%2.2x ", read_nic_byte(dev,
280  (page0 | n)));
281  }
282  len += snprintf(page + len, count - len, "\n");
283  *eof = 1;
284  return len;
285 
286 }
287 static int proc_get_registers_7(char *page, char **start,
288  off_t offset, int count,
289  int *eof, void *data)
290 {
291  struct net_device *dev = data;
292 
293  int len = 0;
294  int i, n, page0;
295 
296  int max = 0xff;
297  page0 = 0x700;
298 
299  /* This dump the current register page */
300  len += snprintf(page + len, count - len,
301  "\n####################page %x##################\n ",
302  (page0 >> 8));
303  len += snprintf(page + len, count - len,
304  "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C "
305  "0D 0E 0F");
306  for (n = 0; n <= max;) {
307  len += snprintf(page + len, count - len,
308  "\nD: %2x > ", n);
309  for (i = 0; i < 16 && n <= max; i++, n++)
310  len += snprintf(page + len, count - len,
311  "%2.2x ", read_nic_byte(dev,
312  (page0 | n)));
313  }
314  len += snprintf(page + len, count - len, "\n");
315  *eof = 1;
316  return len;
317 
318 }
319 static int proc_get_registers_8(char *page, char **start,
320  off_t offset, int count,
321  int *eof, void *data)
322 {
323  struct net_device *dev = data;
324 
325  int len = 0;
326  int i, n, page0;
327 
328  int max = 0xff;
329  page0 = 0x800;
330 
331  /* This dump the current register page */
332  len += snprintf(page + len, count - len,
333  "\n####################page %x##################\n",
334  (page0 >> 8));
335  for (n = 0; n <= max;) {
336  len += snprintf(page + len, count - len, "\nD: %2x > ", n);
337  for (i = 0; i < 4 && n <= max; n += 4, i++)
338  len += snprintf(page + len, count - len,
339  "%8.8x ", rtl8192_QueryBBReg(dev,
340  (page0 | n), bMaskDWord));
341  }
342  len += snprintf(page + len, count - len, "\n");
343  *eof = 1;
344  return len;
345 
346 }
347 static int proc_get_registers_9(char *page, char **start,
348  off_t offset, int count,
349  int *eof, void *data)
350 {
351  struct net_device *dev = data;
352 
353  int len = 0;
354  int i, n, page0;
355 
356  int max = 0xff;
357  page0 = 0x900;
358 
359  /* This dump the current register page */
360  len += snprintf(page + len, count - len,
361  "\n####################page %x##################\n",
362  (page0>>8));
363  for (n = 0; n <= max;) {
364  len += snprintf(page + len, count - len, "\nD: %2x > ", n);
365  for (i = 0; i < 4 && n <= max; n += 4, i++)
366  len += snprintf(page + len, count - len,
367  "%8.8x ", rtl8192_QueryBBReg(dev,
368  (page0 | n), bMaskDWord));
369  }
370  len += snprintf(page + len, count - len, "\n");
371  *eof = 1;
372  return len;
373 }
374 static int proc_get_registers_a(char *page, char **start,
375  off_t offset, int count,
376  int *eof, void *data)
377 {
378  struct net_device *dev = data;
379 
380  int len = 0;
381  int i, n, page0;
382 
383  int max = 0xff;
384  page0 = 0xa00;
385 
386  /* This dump the current register page */
387  len += snprintf(page + len, count - len,
388  "\n####################page %x##################\n",
389  (page0>>8));
390  for (n = 0; n <= max;) {
391  len += snprintf(page + len, count - len, "\nD: %2x > ", n);
392  for (i = 0; i < 4 && n <= max; n += 4, i++)
393  len += snprintf(page + len, count - len,
394  "%8.8x ", rtl8192_QueryBBReg(dev,
395  (page0 | n), bMaskDWord));
396  }
397  len += snprintf(page + len, count - len, "\n");
398  *eof = 1;
399  return len;
400 }
401 static int proc_get_registers_b(char *page, char **start,
402  off_t offset, int count,
403  int *eof, void *data)
404 {
405  struct net_device *dev = data;
406 
407  int len = 0;
408  int i, n, page0;
409 
410  int max = 0xff;
411  page0 = 0xb00;
412 
413  /* This dump the current register page */
414  len += snprintf(page + len, count - len,
415  "\n####################page %x##################\n",
416  (page0 >> 8));
417  for (n = 0; n <= max;) {
418  len += snprintf(page + len, count - len, "\nD: %2x > ", n);
419  for (i = 0; i < 4 && n <= max; n += 4, i++)
420  len += snprintf(page + len, count - len,
421  "%8.8x ", rtl8192_QueryBBReg(dev,
422  (page0 | n), bMaskDWord));
423  }
424  len += snprintf(page + len, count - len, "\n");
425  *eof = 1;
426  return len;
427 }
428 static int proc_get_registers_c(char *page, char **start,
429  off_t offset, int count,
430  int *eof, void *data)
431 {
432  struct net_device *dev = data;
433 
434  int len = 0;
435  int i, n, page0;
436 
437  int max = 0xff;
438  page0 = 0xc00;
439 
440  /* This dump the current register page */
441  len += snprintf(page + len, count - len,
442  "\n####################page %x##################\n",
443  (page0>>8));
444  for (n = 0; n <= max;) {
445  len += snprintf(page + len, count - len, "\nD: %2x > ", n);
446  for (i = 0; i < 4 && n <= max; n += 4, i++)
447  len += snprintf(page + len, count - len,
448  "%8.8x ", rtl8192_QueryBBReg(dev,
449  (page0 | n), bMaskDWord));
450  }
451  len += snprintf(page + len, count - len, "\n");
452  *eof = 1;
453  return len;
454 }
455 static int proc_get_registers_d(char *page, char **start,
456  off_t offset, int count,
457  int *eof, void *data)
458 {
459  struct net_device *dev = data;
460 
461  int len = 0;
462  int i, n, page0;
463 
464  int max = 0xff;
465  page0 = 0xd00;
466 
467  /* This dump the current register page */
468  len += snprintf(page + len, count - len,
469  "\n####################page %x##################\n",
470  (page0>>8));
471  for (n = 0; n <= max;) {
472  len += snprintf(page + len, count - len, "\nD: %2x > ", n);
473  for (i = 0; i < 4 && n <= max; n += 4, i++)
474  len += snprintf(page + len, count - len,
475  "%8.8x ", rtl8192_QueryBBReg(dev,
476  (page0 | n), bMaskDWord));
477  }
478  len += snprintf(page + len, count - len, "\n");
479  *eof = 1;
480  return len;
481 }
482 static int proc_get_registers_e(char *page, char **start,
483  off_t offset, int count,
484  int *eof, void *data)
485 {
486  struct net_device *dev = data;
487 
488  int len = 0;
489  int i, n, page0;
490 
491  int max = 0xff;
492  page0 = 0xe00;
493 
494  /* This dump the current register page */
495  len += snprintf(page + len, count - len,
496  "\n####################page %x##################\n",
497  (page0>>8));
498  for (n = 0; n <= max;) {
499  len += snprintf(page + len, count - len, "\nD: %2x > ", n);
500  for (i = 0; i < 4 && n <= max; n += 4, i++)
501  len += snprintf(page + len, count - len,
502  "%8.8x ", rtl8192_QueryBBReg(dev,
503  (page0 | n), bMaskDWord));
504  }
505  len += snprintf(page + len, count - len, "\n");
506  *eof = 1;
507  return len;
508 }
509 
510 static int proc_get_reg_rf_a(char *page, char **start,
511  off_t offset, int count,
512  int *eof, void *data)
513 {
514  struct net_device *dev = data;
515 
516  int len = 0;
517  int i, n;
518 
519  int max = 0xff;
520 
521  /* This dump the current register page */
522  len += snprintf(page + len, count - len,
523  "\n#################### RF-A ##################\n ");
524  for (n = 0; n <= max;) {
525  len += snprintf(page + len, count - len, "\nD: %2x > ", n);
526  for (i = 0; i < 4 && n <= max; n += 4, i++)
527  len += snprintf(page + len, count - len,
528  "%8.8x ", rtl8192_phy_QueryRFReg(dev,
529  (enum rf90_radio_path)RF90_PATH_A, n,
530  bMaskDWord));
531  }
532  len += snprintf(page + len, count - len, "\n");
533  *eof = 1;
534  return len;
535 }
536 
537 static int proc_get_reg_rf_b(char *page, char **start,
538  off_t offset, int count,
539  int *eof, void *data)
540 {
541  struct net_device *dev = data;
542 
543  int len = 0;
544  int i, n;
545 
546  int max = 0xff;
547 
548  /* This dump the current register page */
549  len += snprintf(page + len, count - len,
550  "\n#################### RF-B ##################\n ");
551  for (n = 0; n <= max;) {
552  len += snprintf(page + len, count - len, "\nD: %2x > ", n);
553  for (i = 0; i < 4 && n <= max; n += 4, i++)
554  len += snprintf(page + len, count - len,
555  "%8.8x ", rtl8192_phy_QueryRFReg(dev,
556  (enum rf90_radio_path)RF90_PATH_B, n,
557  bMaskDWord));
558  }
559  len += snprintf(page + len, count - len, "\n");
560  *eof = 1;
561  return len;
562 }
563 
564 static int proc_get_reg_rf_c(char *page, char **start,
565  off_t offset, int count,
566  int *eof, void *data)
567 {
568  struct net_device *dev = data;
569 
570  int len = 0;
571  int i, n;
572 
573  int max = 0xff;
574 
575  /* This dump the current register page */
576  len += snprintf(page + len, count - len,
577  "\n#################### RF-C ##################\n");
578  for (n = 0; n <= max;) {
579  len += snprintf(page + len, count - len, "\nD: %2x > ", n);
580  for (i = 0; i < 4 && n <= max; n += 4, i++)
581  len += snprintf(page + len, count - len,
582  "%8.8x ", rtl8192_phy_QueryRFReg(dev,
583  (enum rf90_radio_path)RF90_PATH_C, n,
584  bMaskDWord));
585  }
586  len += snprintf(page + len, count - len, "\n");
587  *eof = 1;
588  return len;
589 }
590 
591 static int proc_get_reg_rf_d(char *page, char **start,
592  off_t offset, int count,
593  int *eof, void *data)
594 {
595  struct net_device *dev = data;
596 
597  int len = 0;
598  int i, n;
599 
600  int max = 0xff;
601 
602  /* This dump the current register page */
603  len += snprintf(page + len, count - len,
604  "\n#################### RF-D ##################\n ");
605  for (n = 0; n <= max;) {
606  len += snprintf(page + len, count - len, "\nD: %2x > ", n);
607  for (i = 0; i < 4 && n <= max; n += 4, i++)
608  len += snprintf(page + len, count - len,
609  "%8.8x ", rtl8192_phy_QueryRFReg(dev,
610  (enum rf90_radio_path)RF90_PATH_D, n,
611  bMaskDWord));
612  }
613  len += snprintf(page + len, count - len, "\n");
614  *eof = 1;
615  return len;
616 }
617 
618 static int proc_get_cam_register_1(char *page, char **start,
619  off_t offset, int count,
620  int *eof, void *data)
621 {
622  struct net_device *dev = data;
623  u32 target_command = 0;
624  u32 target_content = 0;
625  u8 entry_i = 0;
626  u32 ulStatus;
627  int len = 0;
628  int i = 100, j = 0;
629 
630  /* This dump the current register page */
631  len += snprintf(page + len, count - len,
632  "\n#################### SECURITY CAM (0-10) ######"
633  "############\n ");
634  for (j = 0; j < 11; j++) {
635  len += snprintf(page + len, count - len, "\nD: %2x > ", j);
636  for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
637  target_command = entry_i+CAM_CONTENT_COUNT*j;
638  target_command = target_command | BIT31;
639 
640  while ((i--) >= 0) {
641  ulStatus = read_nic_dword(dev, RWCAM);
642  if (ulStatus & BIT31)
643  continue;
644  else
645  break;
646  }
647  write_nic_dword(dev, RWCAM, target_command);
648  target_content = read_nic_dword(dev, RCAMO);
649  len += snprintf(page + len, count - len, "%8.8x ",
650  target_content);
651  }
652  }
653 
654  len += snprintf(page + len, count - len, "\n");
655  *eof = 1;
656  return len;
657 }
658 
659 static int proc_get_cam_register_2(char *page, char **start,
660  off_t offset, int count,
661  int *eof, void *data)
662 {
663  struct net_device *dev = data;
664  u32 target_command = 0;
665  u32 target_content = 0;
666  u8 entry_i = 0;
667  u32 ulStatus;
668  int len = 0;
669  int i = 100, j = 0;
670 
671  /* This dump the current register page */
672  len += snprintf(page + len, count - len,
673  "\n#################### SECURITY CAM (11-21) "
674  "##################\n ");
675  for (j = 11; j < 22; j++) {
676  len += snprintf(page + len, count - len, "\nD: %2x > ", j);
677  for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
678  target_command = entry_i + CAM_CONTENT_COUNT * j;
679  target_command = target_command | BIT31;
680 
681  while ((i--) >= 0) {
682  ulStatus = read_nic_dword(dev, RWCAM);
683  if (ulStatus & BIT31)
684  continue;
685  else
686  break;
687  }
688  write_nic_dword(dev, RWCAM, target_command);
689  target_content = read_nic_dword(dev, RCAMO);
690  len += snprintf(page + len, count - len, "%8.8x ",
691  target_content);
692  }
693  }
694 
695  len += snprintf(page + len, count - len, "\n");
696  *eof = 1;
697  return len;
698 }
699 
700 static int proc_get_cam_register_3(char *page, char **start,
701  off_t offset, int count,
702  int *eof, void *data)
703 {
704  struct net_device *dev = data;
705  u32 target_command = 0;
706  u32 target_content = 0;
707  u8 entry_i = 0;
708  u32 ulStatus;
709  int len = 0;
710  int i = 100, j = 0;
711 
712  /* This dump the current register page */
713  len += snprintf(page + len, count - len,
714  "\n#################### SECURITY CAM (22-31) ######"
715  "############\n ");
716  for (j = 22; j < TOTAL_CAM_ENTRY; j++) {
717  len += snprintf(page + len, count - len, "\nD: %2x > ", j);
718  for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
719  target_command = entry_i + CAM_CONTENT_COUNT * j;
720  target_command = target_command | BIT31;
721 
722  while ((i--) >= 0) {
723  ulStatus = read_nic_dword(dev, RWCAM);
724  if (ulStatus & BIT31)
725  continue;
726  else
727  break;
728  }
729  write_nic_dword(dev, RWCAM, target_command);
730  target_content = read_nic_dword(dev, RCAMO);
731  len += snprintf(page + len, count - len, "%8.8x ",
732  target_content);
733  }
734  }
735 
736  len += snprintf(page + len, count - len, "\n");
737  *eof = 1;
738  return len;
739 }
740 static int proc_get_stats_tx(char *page, char **start,
741  off_t offset, int count,
742  int *eof, void *data)
743 {
744  struct net_device *dev = data;
745  struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
746 
747  int len = 0;
748 
749  len += snprintf(page + len, count - len,
750  "TX VI priority ok int: %lu\n"
751  "TX VO priority ok int: %lu\n"
752  "TX BE priority ok int: %lu\n"
753  "TX BK priority ok int: %lu\n"
754  "TX MANAGE priority ok int: %lu\n"
755  "TX BEACON priority ok int: %lu\n"
756  "TX BEACON priority error int: %lu\n"
757  "TX CMDPKT priority ok int: %lu\n"
758  "TX queue stopped?: %d\n"
759  "TX fifo overflow: %lu\n"
760  "TX total data packets %lu\n"
761  "TX total data bytes :%lu\n",
762  priv->stats.txviokint,
763  priv->stats.txvookint,
764  priv->stats.txbeokint,
765  priv->stats.txbkokint,
766  priv->stats.txmanageokint,
767  priv->stats.txbeaconokint,
768  priv->stats.txbeaconerr,
769  priv->stats.txcmdpktokint,
770  netif_queue_stopped(dev),
771  priv->stats.txoverflow,
772  priv->rtllib->stats.tx_packets,
773  priv->rtllib->stats.tx_bytes
774 
775 
776  );
777 
778  *eof = 1;
779  return len;
780 }
781 
782 
783 
784 static int proc_get_stats_rx(char *page, char **start,
785  off_t offset, int count,
786  int *eof, void *data)
787 {
788  struct net_device *dev = data;
789  struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
790 
791  int len = 0;
792 
793  len += snprintf(page + len, count - len,
794  "RX packets: %lu\n"
795  "RX data crc err: %lu\n"
796  "RX mgmt crc err: %lu\n"
797  "RX desc err: %lu\n"
798  "RX rx overflow error: %lu\n",
799  priv->stats.rxint,
800  priv->stats.rxdatacrcerr,
801  priv->stats.rxmgmtcrcerr,
802  priv->stats.rxrdu,
803  priv->stats.rxoverflow);
804 
805  *eof = 1;
806  return len;
807 }
808 
810 {
811  RT_TRACE(COMP_INIT, "Initializing proc filesystem");
812  rtl8192_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net);
813 }
814 
815 
817 {
819 }
820 
821 
823 {
824  struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
825 
826  printk(KERN_INFO "dev name %s\n", dev->name);
827 
828  if (priv->dir_dev) {
829  remove_proc_entry("stats-tx", priv->dir_dev);
830  remove_proc_entry("stats-rx", priv->dir_dev);
831  remove_proc_entry("stats-ap", priv->dir_dev);
832  remove_proc_entry("registers-0", priv->dir_dev);
833  remove_proc_entry("registers-1", priv->dir_dev);
834  remove_proc_entry("registers-2", priv->dir_dev);
835  remove_proc_entry("registers-3", priv->dir_dev);
836  remove_proc_entry("registers-4", priv->dir_dev);
837  remove_proc_entry("registers-5", priv->dir_dev);
838  remove_proc_entry("registers-6", priv->dir_dev);
839  remove_proc_entry("registers-7", priv->dir_dev);
840  remove_proc_entry("registers-8", priv->dir_dev);
841  remove_proc_entry("registers-9", priv->dir_dev);
842  remove_proc_entry("registers-a", priv->dir_dev);
843  remove_proc_entry("registers-b", priv->dir_dev);
844  remove_proc_entry("registers-c", priv->dir_dev);
845  remove_proc_entry("registers-d", priv->dir_dev);
846  remove_proc_entry("registers-e", priv->dir_dev);
847  remove_proc_entry("RF-A", priv->dir_dev);
848  remove_proc_entry("RF-B", priv->dir_dev);
849  remove_proc_entry("RF-C", priv->dir_dev);
850  remove_proc_entry("RF-D", priv->dir_dev);
851  remove_proc_entry("SEC-CAM-1", priv->dir_dev);
852  remove_proc_entry("SEC-CAM-2", priv->dir_dev);
853  remove_proc_entry("SEC-CAM-3", priv->dir_dev);
854  remove_proc_entry("wlan0", rtl8192_proc);
855  priv->dir_dev = NULL;
856  }
857 }
858 
859 
861 {
862  struct proc_dir_entry *e;
863  struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
864 
865  priv->dir_dev = create_proc_entry(dev->name,
866  S_IFDIR | S_IRUGO | S_IXUGO,
867  rtl8192_proc);
868  if (!priv->dir_dev) {
869  RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192"
870  "/%s\n", dev->name);
871  return;
872  }
873  e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
874  priv->dir_dev, proc_get_stats_rx, dev);
875 
876  if (!e)
877  RT_TRACE(COMP_ERR, "Unable to initialize "
878  "/proc/net/rtl8192/%s/stats-rx\n",
879  dev->name);
880 
881  e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
882  priv->dir_dev, proc_get_stats_tx, dev);
883 
884  if (!e)
885  RT_TRACE(COMP_ERR, "Unable to initialize "
886  "/proc/net/rtl8192/%s/stats-tx\n",
887  dev->name);
888 
889  e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
890  priv->dir_dev, proc_get_stats_ap, dev);
891 
892  if (!e)
893  RT_TRACE(COMP_ERR, "Unable to initialize "
894  "/proc/net/rtl8192/%s/stats-ap\n",
895  dev->name);
896 
897  e = create_proc_read_entry("registers-0", S_IFREG | S_IRUGO,
898  priv->dir_dev, proc_get_registers_0, dev);
899  if (!e)
900  RT_TRACE(COMP_ERR, "Unable to initialize "
901  "/proc/net/rtl8192/%s/registers-0\n",
902  dev->name);
903  e = create_proc_read_entry("registers-1", S_IFREG | S_IRUGO,
904  priv->dir_dev, proc_get_registers_1, dev);
905  if (!e)
906  RT_TRACE(COMP_ERR, "Unable to initialize "
907  "/proc/net/rtl8192/%s/registers-1\n",
908  dev->name);
909  e = create_proc_read_entry("registers-2", S_IFREG | S_IRUGO,
910  priv->dir_dev, proc_get_registers_2, dev);
911  if (!e)
912  RT_TRACE(COMP_ERR, "Unable to initialize "
913  "/proc/net/rtl8192/%s/registers-2\n",
914  dev->name);
915  e = create_proc_read_entry("registers-3", S_IFREG | S_IRUGO,
916  priv->dir_dev, proc_get_registers_3, dev);
917  if (!e)
918  RT_TRACE(COMP_ERR, "Unable to initialize "
919  "/proc/net/rtl8192/%s/registers-3\n",
920  dev->name);
921  e = create_proc_read_entry("registers-4", S_IFREG | S_IRUGO,
922  priv->dir_dev, proc_get_registers_4, dev);
923  if (!e)
924  RT_TRACE(COMP_ERR, "Unable to initialize "
925  "/proc/net/rtl8192/%s/registers-4\n",
926  dev->name);
927  e = create_proc_read_entry("registers-5", S_IFREG | S_IRUGO,
928  priv->dir_dev, proc_get_registers_5, dev);
929  if (!e)
930  RT_TRACE(COMP_ERR, "Unable to initialize "
931  "/proc/net/rtl8192/%s/registers-5\n",
932  dev->name);
933  e = create_proc_read_entry("registers-6", S_IFREG | S_IRUGO,
934  priv->dir_dev, proc_get_registers_6, dev);
935  if (!e)
936  RT_TRACE(COMP_ERR, "Unable to initialize "
937  "/proc/net/rtl8192/%s/registers-6\n",
938  dev->name);
939  e = create_proc_read_entry("registers-7", S_IFREG | S_IRUGO,
940  priv->dir_dev, proc_get_registers_7, dev);
941  if (!e)
942  RT_TRACE(COMP_ERR, "Unable to initialize "
943  "/proc/net/rtl8192/%s/registers-7\n",
944  dev->name);
945  e = create_proc_read_entry("registers-8", S_IFREG | S_IRUGO,
946  priv->dir_dev, proc_get_registers_8, dev);
947  if (!e)
948  RT_TRACE(COMP_ERR, "Unable to initialize "
949  "/proc/net/rtl8192/%s/registers-8\n",
950  dev->name);
951  e = create_proc_read_entry("registers-9", S_IFREG | S_IRUGO,
952  priv->dir_dev, proc_get_registers_9, dev);
953  if (!e)
954  RT_TRACE(COMP_ERR, "Unable to initialize "
955  "/proc/net/rtl8192/%s/registers-9\n",
956  dev->name);
957  e = create_proc_read_entry("registers-a", S_IFREG | S_IRUGO,
958  priv->dir_dev, proc_get_registers_a, dev);
959  if (!e)
960  RT_TRACE(COMP_ERR, "Unable to initialize "
961  "/proc/net/rtl8192/%s/registers-a\n",
962  dev->name);
963  e = create_proc_read_entry("registers-b", S_IFREG | S_IRUGO,
964  priv->dir_dev, proc_get_registers_b, dev);
965  if (!e)
966  RT_TRACE(COMP_ERR, "Unable to initialize "
967  "/proc/net/rtl8192/%s/registers-b\n",
968  dev->name);
969  e = create_proc_read_entry("registers-c", S_IFREG | S_IRUGO,
970  priv->dir_dev, proc_get_registers_c, dev);
971  if (!e)
972  RT_TRACE(COMP_ERR, "Unable to initialize "
973  "/proc/net/rtl8192/%s/registers-c\n",
974  dev->name);
975  e = create_proc_read_entry("registers-d", S_IFREG | S_IRUGO,
976  priv->dir_dev, proc_get_registers_d, dev);
977  if (!e)
978  RT_TRACE(COMP_ERR, "Unable to initialize "
979  "/proc/net/rtl8192/%s/registers-d\n",
980  dev->name);
981  e = create_proc_read_entry("registers-e", S_IFREG | S_IRUGO,
982  priv->dir_dev, proc_get_registers_e, dev);
983  if (!e)
984  RT_TRACE(COMP_ERR, "Unable to initialize "
985  "/proc/net/rtl8192/%s/registers-e\n",
986  dev->name);
987  e = create_proc_read_entry("RF-A", S_IFREG | S_IRUGO,
988  priv->dir_dev, proc_get_reg_rf_a, dev);
989  if (!e)
990  RT_TRACE(COMP_ERR, "Unable to initialize "
991  "/proc/net/rtl8192/%s/RF-A\n",
992  dev->name);
993  e = create_proc_read_entry("RF-B", S_IFREG | S_IRUGO,
994  priv->dir_dev, proc_get_reg_rf_b, dev);
995  if (!e)
996  RT_TRACE(COMP_ERR, "Unable to initialize "
997  "/proc/net/rtl8192/%s/RF-B\n",
998  dev->name);
999  e = create_proc_read_entry("RF-C", S_IFREG | S_IRUGO,
1000  priv->dir_dev, proc_get_reg_rf_c, dev);
1001  if (!e)
1002  RT_TRACE(COMP_ERR, "Unable to initialize "
1003  "/proc/net/rtl8192/%s/RF-C\n",
1004  dev->name);
1005  e = create_proc_read_entry("RF-D", S_IFREG | S_IRUGO,
1006  priv->dir_dev, proc_get_reg_rf_d, dev);
1007  if (!e)
1008  RT_TRACE(COMP_ERR, "Unable to initialize "
1009  "/proc/net/rtl8192/%s/RF-D\n",
1010  dev->name);
1011  e = create_proc_read_entry("SEC-CAM-1", S_IFREG | S_IRUGO,
1012  priv->dir_dev, proc_get_cam_register_1, dev);
1013  if (!e)
1014  RT_TRACE(COMP_ERR, "Unable to initialize "
1015  "/proc/net/rtl8192/%s/SEC-CAM-1\n",
1016  dev->name);
1017  e = create_proc_read_entry("SEC-CAM-2", S_IFREG | S_IRUGO,
1018  priv->dir_dev, proc_get_cam_register_2, dev);
1019  if (!e)
1020  RT_TRACE(COMP_ERR, "Unable to initialize "
1021  "/proc/net/rtl8192/%s/SEC-CAM-2\n",
1022  dev->name);
1023  e = create_proc_read_entry("SEC-CAM-3", S_IFREG | S_IRUGO,
1024  priv->dir_dev, proc_get_cam_register_3, dev);
1025  if (!e)
1026  RT_TRACE(COMP_ERR, "Unable to initialize "
1027  "/proc/net/rtl8192/%s/SEC-CAM-3\n",
1028  dev->name);
1029 }