Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-btrfs-devel.git] / drivers / staging / rtl8192e / rtl_debug.c
blob22bc2dd6e4387aa95650931fc9fc73d5987218aa
1 /******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
4 * Based on the r8180 driver, which is:
5 * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, 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.
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.
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
19 * The full GNU General Public License is included in this distribution in the
20 * file called LICENSE.
22 * Contact Information:
23 * wlanfae <wlanfae@realtek.com>
24 ******************************************************************************/
25 #include "rtl_debug.h"
26 #include "rtl_core.h"
27 #include "r8192E_phy.h"
28 #include "r8192E_phyreg.h"
29 #include "r8190P_rtl8256.h" /* RTL8225 Radio frontend */
30 #include "r8192E_cmdpkt.h"
32 u32 rt_global_debug_component = \
33 COMP_ERR ;
35 /*------------------Declare variable-----------------------*/
36 u32 DBGP_Type[DBGP_TYPE_MAX];
38 /*-----------------------------------------------------------------------------
39 * Function: DBGP_Flag_Init
41 * Overview: Refresh all debug print control flag content to zero.
43 * Input: NONE
45 * Output: NONE
47 * Return: NONE
49 * Revised History:
50 * When Who Remark
51 * 10/20/2006 MHC Create Version 0.
53 *---------------------------------------------------------------------------*/
54 void rtl8192_dbgp_flag_init(struct net_device *dev)
56 u8 i;
58 for (i = 0; i < DBGP_TYPE_MAX; i++)
59 DBGP_Type[i] = 0;
62 } /* DBGP_Flag_Init */
64 /* this is only for debugging */
65 void print_buffer(u32 *buffer, int len)
67 int i;
68 u8 *buf = (u8 *)buffer;
70 printk(KERN_INFO "ASCII BUFFER DUMP (len: %x):\n", len);
72 for (i = 0; i < len; i++)
73 printk(KERN_INFO "%c", buf[i]);
75 printk(KERN_INFO "\nBINARY BUFFER DUMP (len: %x):\n", len);
77 for (i = 0; i < len; i++)
78 printk(KERN_INFO "%x", buf[i]);
80 printk(KERN_INFO "\n");
83 /* this is only for debug */
84 void dump_eprom(struct net_device *dev)
86 int i;
88 for (i = 0; i < 0xff; i++)
89 RT_TRACE(COMP_INIT, "EEPROM addr %x : %x", i,
90 eprom_read(dev, i));
93 /* this is only for debug */
94 void rtl8192_dump_reg(struct net_device *dev)
96 int i;
97 int n;
98 int max = 0x5ff;
100 RT_TRACE(COMP_INIT, "Dumping NIC register map");
102 for (n = 0; n <= max; ) {
103 printk(KERN_INFO "\nD: %2x> ", n);
104 for (i = 0; i < 16 && n <= max; i++, n++)
105 printk(KERN_INFO "%2x ", read_nic_byte(dev, n));
107 printk(KERN_INFO "\n");
110 /****************************************************************************
111 -----------------------------PROCFS STUFF-------------------------
112 *****************************************************************************/
113 /*This part is related to PROC, which will record some statistics. */
114 static struct proc_dir_entry *rtl8192_proc;
116 static int proc_get_stats_ap(char *page, char **start,
117 off_t offset, int count,
118 int *eof, void *data)
120 struct net_device *dev = data;
121 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
122 struct rtllib_device *ieee = priv->rtllib;
123 struct rtllib_network *target;
124 int len = 0;
126 list_for_each_entry(target, &ieee->network_list, list) {
128 len += snprintf(page + len, count - len,
129 "%s ", target->ssid);
131 if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0)
132 len += snprintf(page + len, count - len,
133 "WPA\n");
134 else
135 len += snprintf(page + len, count - len,
136 "non_WPA\n");
140 *eof = 1;
141 return len;
144 static int proc_get_registers_0(char *page, char **start,
145 off_t offset, int count,
146 int *eof, void *data)
148 struct net_device *dev = data;
150 int len = 0;
151 int i, n, page0;
153 int max = 0xff;
154 page0 = 0x000;
156 len += snprintf(page + len, count - len,
157 "\n####################page %x##################\n ",
158 (page0>>8));
159 len += snprintf(page + len, count - len,
160 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
161 "0C 0D 0E 0F");
162 for (n = 0; n <= max;) {
163 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
164 for (i = 0; i < 16 && n <= max; n++, i++)
165 len += snprintf(page + len, count - len,
166 "%2.2x ", read_nic_byte(dev,
167 (page0 | n)));
169 len += snprintf(page + len, count - len, "\n");
170 *eof = 1;
171 return len;
174 static int proc_get_registers_1(char *page, char **start,
175 off_t offset, int count,
176 int *eof, void *data)
178 struct net_device *dev = data;
180 int len = 0;
181 int i, n, page0;
183 int max = 0xff;
184 page0 = 0x100;
186 /* This dump the current register page */
187 len += snprintf(page + len, count - len,
188 "\n####################page %x##################\n ",
189 (page0>>8));
190 len += snprintf(page + len, count - len,
191 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
192 "0C 0D 0E 0F");
193 for (n = 0; n <= max;) {
194 len += snprintf(page + len, count - len,
195 "\nD: %2x > ", n);
196 for (i = 0; i < 16 && n <= max; i++, n++)
197 len += snprintf(page + len, count - len,
198 "%2.2x ", read_nic_byte(dev,
199 (page0 | n)));
201 len += snprintf(page + len, count - len, "\n");
202 *eof = 1;
203 return len;
206 static int proc_get_registers_2(char *page, char **start,
207 off_t offset, int count,
208 int *eof, void *data)
210 struct net_device *dev = data;
212 int len = 0;
213 int i, n, page0;
215 int max = 0xff;
216 page0 = 0x200;
218 /* This dump the current register page */
219 len += snprintf(page + len, count - len,
220 "\n####################page %x##################\n ",
221 (page0 >> 8));
222 len += snprintf(page + len, count - len,
223 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C "
224 "0D 0E 0F");
225 for (n = 0; n <= max;) {
226 len += snprintf(page + len, count - len,
227 "\nD: %2x > ", n);
228 for (i = 0; i < 16 && n <= max; i++, n++)
229 len += snprintf(page + len, count - len,
230 "%2.2x ", read_nic_byte(dev,
231 (page0 | n)));
233 len += snprintf(page + len, count - len, "\n");
234 *eof = 1;
235 return len;
238 static int proc_get_registers_3(char *page, char **start,
239 off_t offset, int count,
240 int *eof, void *data)
242 struct net_device *dev = data;
244 int len = 0;
245 int i, n, page0;
247 int max = 0xff;
248 page0 = 0x300;
250 /* This dump the current register page */
251 len += snprintf(page + len, count - len,
252 "\n####################page %x##################\n ",
253 (page0>>8));
254 len += snprintf(page + len, count - len,
255 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
256 "0C 0D 0E 0F");
257 for (n = 0; n <= max;) {
258 len += snprintf(page + len, count - len,
259 "\nD: %2x > ", n);
260 for (i = 0; i < 16 && n <= max; i++, n++)
261 len += snprintf(page + len, count - len,
262 "%2.2x ", read_nic_byte(dev,
263 (page0 | n)));
265 len += snprintf(page + len, count - len, "\n");
266 *eof = 1;
267 return len;
270 static int proc_get_registers_4(char *page, char **start,
271 off_t offset, int count,
272 int *eof, void *data)
274 struct net_device *dev = data;
276 int len = 0;
277 int i, n, page0;
279 int max = 0xff;
280 page0 = 0x400;
282 /* This dump the current register page */
283 len += snprintf(page + len, count - len,
284 "\n####################page %x##################\n ",
285 (page0>>8));
286 len += snprintf(page + len, count - len,
287 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
288 "0C 0D 0E 0F");
289 for (n = 0; n <= max;) {
290 len += snprintf(page + len, count - len,
291 "\nD: %2x > ", n);
292 for (i = 0; i < 16 && n <= max; i++, n++)
293 len += snprintf(page + len, count - len,
294 "%2.2x ", read_nic_byte(dev,
295 (page0 | n)));
297 len += snprintf(page + len, count - len, "\n");
298 *eof = 1;
299 return len;
302 static int proc_get_registers_5(char *page, char **start,
303 off_t offset, int count,
304 int *eof, void *data)
306 struct net_device *dev = data;
308 int len = 0;
309 int i, n, page0;
311 int max = 0xff;
312 page0 = 0x500;
314 /* This dump the current register page */
315 len += snprintf(page + len, count - len,
316 "\n####################page %x##################\n ",
317 (page0 >> 8));
318 len += snprintf(page + len, count - len,
319 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
320 "0C 0D 0E 0F");
321 for (n = 0; n <= max;) {
322 len += snprintf(page + len, count - len,
323 "\nD: %2x > ", n);
324 for (i = 0; i < 16 && n <= max; i++, n++)
325 len += snprintf(page + len, count - len,
326 "%2.2x ", read_nic_byte(dev,
327 (page0 | n)));
329 len += snprintf(page + len, count - len, "\n");
330 *eof = 1;
331 return len;
334 static int proc_get_registers_6(char *page, char **start,
335 off_t offset, int count,
336 int *eof, void *data)
338 struct net_device *dev = data;
340 int len = 0;
341 int i, n, page0;
343 int max = 0xff;
344 page0 = 0x600;
346 /* This dump the current register page */
347 len += snprintf(page + len, count - len,
348 "\n####################page %x##################\n ",
349 (page0>>8));
350 len += snprintf(page + len, count - len,
351 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B "
352 "0C 0D 0E 0F");
353 for (n = 0; n <= max;) {
354 len += snprintf(page + len, count - len,
355 "\nD: %2x > ", n);
356 for (i = 0; i < 16 && n <= max; i++, n++)
357 len += snprintf(page + len, count - len,
358 "%2.2x ", read_nic_byte(dev,
359 (page0 | n)));
361 len += snprintf(page + len, count - len, "\n");
362 *eof = 1;
363 return len;
366 static int proc_get_registers_7(char *page, char **start,
367 off_t offset, int count,
368 int *eof, void *data)
370 struct net_device *dev = data;
372 int len = 0;
373 int i, n, page0;
375 int max = 0xff;
376 page0 = 0x700;
378 /* This dump the current register page */
379 len += snprintf(page + len, count - len,
380 "\n####################page %x##################\n ",
381 (page0 >> 8));
382 len += snprintf(page + len, count - len,
383 "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C "
384 "0D 0E 0F");
385 for (n = 0; n <= max;) {
386 len += snprintf(page + len, count - len,
387 "\nD: %2x > ", n);
388 for (i = 0; i < 16 && n <= max; i++, n++)
389 len += snprintf(page + len, count - len,
390 "%2.2x ", read_nic_byte(dev,
391 (page0 | n)));
393 len += snprintf(page + len, count - len, "\n");
394 *eof = 1;
395 return len;
398 static int proc_get_registers_8(char *page, char **start,
399 off_t offset, int count,
400 int *eof, void *data)
402 struct net_device *dev = data;
404 int len = 0;
405 int i, n, page0;
407 int max = 0xff;
408 page0 = 0x800;
410 /* This dump the current register page */
411 len += snprintf(page + len, count - len,
412 "\n####################page %x##################\n",
413 (page0 >> 8));
414 for (n = 0; n <= max;) {
415 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
416 for (i = 0; i < 4 && n <= max; n += 4, i++)
417 len += snprintf(page + len, count - len,
418 "%8.8x ", rtl8192_QueryBBReg(dev,
419 (page0 | n), bMaskDWord));
421 len += snprintf(page + len, count - len, "\n");
422 *eof = 1;
423 return len;
426 static int proc_get_registers_9(char *page, char **start,
427 off_t offset, int count,
428 int *eof, void *data)
430 struct net_device *dev = data;
432 int len = 0;
433 int i, n, page0;
435 int max = 0xff;
436 page0 = 0x900;
438 /* This dump the current register page */
439 len += snprintf(page + len, count - len,
440 "\n####################page %x##################\n",
441 (page0>>8));
442 for (n = 0; n <= max;) {
443 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
444 for (i = 0; i < 4 && n <= max; n += 4, i++)
445 len += snprintf(page + len, count - len,
446 "%8.8x ", rtl8192_QueryBBReg(dev,
447 (page0 | n), bMaskDWord));
449 len += snprintf(page + len, count - len, "\n");
450 *eof = 1;
451 return len;
453 static int proc_get_registers_a(char *page, char **start,
454 off_t offset, int count,
455 int *eof, void *data)
457 struct net_device *dev = data;
459 int len = 0;
460 int i, n, page0;
462 int max = 0xff;
463 page0 = 0xa00;
465 /* This dump the current register page */
466 len += snprintf(page + len, count - len,
467 "\n####################page %x##################\n",
468 (page0>>8));
469 for (n = 0; n <= max;) {
470 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
471 for (i = 0; i < 4 && n <= max; n += 4, i++)
472 len += snprintf(page + len, count - len,
473 "%8.8x ", rtl8192_QueryBBReg(dev,
474 (page0 | n), bMaskDWord));
476 len += snprintf(page + len, count - len, "\n");
477 *eof = 1;
478 return len;
480 static int proc_get_registers_b(char *page, char **start,
481 off_t offset, int count,
482 int *eof, void *data)
484 struct net_device *dev = data;
486 int len = 0;
487 int i, n, page0;
489 int max = 0xff;
490 page0 = 0xb00;
492 /* This dump the current register page */
493 len += snprintf(page + len, count - len,
494 "\n####################page %x##################\n",
495 (page0 >> 8));
496 for (n = 0; n <= max;) {
497 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
498 for (i = 0; i < 4 && n <= max; n += 4, i++)
499 len += snprintf(page + len, count - len,
500 "%8.8x ", rtl8192_QueryBBReg(dev,
501 (page0 | n), bMaskDWord));
503 len += snprintf(page + len, count - len, "\n");
504 *eof = 1;
505 return len;
507 static int proc_get_registers_c(char *page, char **start,
508 off_t offset, int count,
509 int *eof, void *data)
511 struct net_device *dev = data;
513 int len = 0;
514 int i, n, page0;
516 int max = 0xff;
517 page0 = 0xc00;
519 /* This dump the current register page */
520 len += snprintf(page + len, count - len,
521 "\n####################page %x##################\n",
522 (page0>>8));
523 for (n = 0; n <= max;) {
524 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
525 for (i = 0; i < 4 && n <= max; n += 4, i++)
526 len += snprintf(page + len, count - len,
527 "%8.8x ", rtl8192_QueryBBReg(dev,
528 (page0 | n), bMaskDWord));
530 len += snprintf(page + len, count - len, "\n");
531 *eof = 1;
532 return len;
534 static int proc_get_registers_d(char *page, char **start,
535 off_t offset, int count,
536 int *eof, void *data)
538 struct net_device *dev = data;
540 int len = 0;
541 int i, n, page0;
543 int max = 0xff;
544 page0 = 0xd00;
546 /* This dump the current register page */
547 len += snprintf(page + len, count - len,
548 "\n####################page %x##################\n",
549 (page0>>8));
550 for (n = 0; n <= max;) {
551 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
552 for (i = 0; i < 4 && n <= max; n += 4, i++)
553 len += snprintf(page + len, count - len,
554 "%8.8x ", rtl8192_QueryBBReg(dev,
555 (page0 | n), bMaskDWord));
557 len += snprintf(page + len, count - len, "\n");
558 *eof = 1;
559 return len;
561 static int proc_get_registers_e(char *page, char **start,
562 off_t offset, int count,
563 int *eof, void *data)
565 struct net_device *dev = data;
567 int len = 0;
568 int i, n, page0;
570 int max = 0xff;
571 page0 = 0xe00;
573 /* This dump the current register page */
574 len += snprintf(page + len, count - len,
575 "\n####################page %x##################\n",
576 (page0>>8));
577 for (n = 0; n <= max;) {
578 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
579 for (i = 0; i < 4 && n <= max; n += 4, i++)
580 len += snprintf(page + len, count - len,
581 "%8.8x ", rtl8192_QueryBBReg(dev,
582 (page0 | n), bMaskDWord));
584 len += snprintf(page + len, count - len, "\n");
585 *eof = 1;
586 return len;
589 static int proc_get_reg_rf_a(char *page, char **start,
590 off_t offset, int count,
591 int *eof, void *data)
593 struct net_device *dev = data;
595 int len = 0;
596 int i, n;
598 int max = 0xff;
600 /* This dump the current register page */
601 len += snprintf(page + len, count - len,
602 "\n#################### RF-A ##################\n ");
603 for (n = 0; n <= max;) {
604 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
605 for (i = 0; i < 4 && n <= max; n += 4, i++)
606 len += snprintf(page + len, count - len,
607 "%8.8x ", rtl8192_phy_QueryRFReg(dev,
608 (enum rf90_radio_path)RF90_PATH_A, n,
609 bMaskDWord));
611 len += snprintf(page + len, count - len, "\n");
612 *eof = 1;
613 return len;
616 static int proc_get_reg_rf_b(char *page, char **start,
617 off_t offset, int count,
618 int *eof, void *data)
620 struct net_device *dev = data;
622 int len = 0;
623 int i, n;
625 int max = 0xff;
627 /* This dump the current register page */
628 len += snprintf(page + len, count - len,
629 "\n#################### RF-B ##################\n ");
630 for (n = 0; n <= max;) {
631 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
632 for (i = 0; i < 4 && n <= max; n += 4, i++)
633 len += snprintf(page + len, count - len,
634 "%8.8x ", rtl8192_phy_QueryRFReg(dev,
635 (enum rf90_radio_path)RF90_PATH_B, n,
636 bMaskDWord));
638 len += snprintf(page + len, count - len, "\n");
639 *eof = 1;
640 return len;
643 static int proc_get_reg_rf_c(char *page, char **start,
644 off_t offset, int count,
645 int *eof, void *data)
647 struct net_device *dev = data;
649 int len = 0;
650 int i, n;
652 int max = 0xff;
654 /* This dump the current register page */
655 len += snprintf(page + len, count - len,
656 "\n#################### RF-C ##################\n");
657 for (n = 0; n <= max;) {
658 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
659 for (i = 0; i < 4 && n <= max; n += 4, i++)
660 len += snprintf(page + len, count - len,
661 "%8.8x ", rtl8192_phy_QueryRFReg(dev,
662 (enum rf90_radio_path)RF90_PATH_C, n,
663 bMaskDWord));
665 len += snprintf(page + len, count - len, "\n");
666 *eof = 1;
667 return len;
670 static int proc_get_reg_rf_d(char *page, char **start,
671 off_t offset, int count,
672 int *eof, void *data)
674 struct net_device *dev = data;
676 int len = 0;
677 int i, n;
679 int max = 0xff;
681 /* This dump the current register page */
682 len += snprintf(page + len, count - len,
683 "\n#################### RF-D ##################\n ");
684 for (n = 0; n <= max;) {
685 len += snprintf(page + len, count - len, "\nD: %2x > ", n);
686 for (i = 0; i < 4 && n <= max; n += 4, i++)
687 len += snprintf(page + len, count - len,
688 "%8.8x ", rtl8192_phy_QueryRFReg(dev,
689 (enum rf90_radio_path)RF90_PATH_D, n,
690 bMaskDWord));
692 len += snprintf(page + len, count - len, "\n");
693 *eof = 1;
694 return len;
697 static int proc_get_cam_register_1(char *page, char **start,
698 off_t offset, int count,
699 int *eof, void *data)
701 struct net_device *dev = data;
702 u32 target_command = 0;
703 u32 target_content = 0;
704 u8 entry_i = 0;
705 u32 ulStatus;
706 int len = 0;
707 int i = 100, j = 0;
709 /* This dump the current register page */
710 len += snprintf(page + len, count - len,
711 "\n#################### SECURITY CAM (0-10) ######"
712 "############\n ");
713 for (j = 0; j < 11; j++) {
714 len += snprintf(page + len, count - len, "\nD: %2x > ", j);
715 for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
716 target_command = entry_i+CAM_CONTENT_COUNT*j;
717 target_command = target_command | BIT31;
719 while ((i--) >= 0) {
720 ulStatus = read_nic_dword(dev, RWCAM);
721 if (ulStatus & BIT31)
722 continue;
723 else
724 break;
726 write_nic_dword(dev, RWCAM, target_command);
727 target_content = read_nic_dword(dev, RCAMO);
728 len += snprintf(page + len, count - len, "%8.8x ",
729 target_content);
733 len += snprintf(page + len, count - len, "\n");
734 *eof = 1;
735 return len;
738 static int proc_get_cam_register_2(char *page, char **start,
739 off_t offset, int count,
740 int *eof, void *data)
742 struct net_device *dev = data;
743 u32 target_command = 0;
744 u32 target_content = 0;
745 u8 entry_i = 0;
746 u32 ulStatus;
747 int len = 0;
748 int i = 100, j = 0;
750 /* This dump the current register page */
751 len += snprintf(page + len, count - len,
752 "\n#################### SECURITY CAM (11-21) "
753 "##################\n ");
754 for (j = 11; j < 22; j++) {
755 len += snprintf(page + len, count - len, "\nD: %2x > ", j);
756 for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
757 target_command = entry_i + CAM_CONTENT_COUNT * j;
758 target_command = target_command | BIT31;
760 while ((i--) >= 0) {
761 ulStatus = read_nic_dword(dev, RWCAM);
762 if (ulStatus & BIT31)
763 continue;
764 else
765 break;
767 write_nic_dword(dev, RWCAM, target_command);
768 target_content = read_nic_dword(dev, RCAMO);
769 len += snprintf(page + len, count - len, "%8.8x ",
770 target_content);
774 len += snprintf(page + len, count - len, "\n");
775 *eof = 1;
776 return len;
779 static int proc_get_cam_register_3(char *page, char **start,
780 off_t offset, int count,
781 int *eof, void *data)
783 struct net_device *dev = data;
784 u32 target_command = 0;
785 u32 target_content = 0;
786 u8 entry_i = 0;
787 u32 ulStatus;
788 int len = 0;
789 int i = 100, j = 0;
791 /* This dump the current register page */
792 len += snprintf(page + len, count - len,
793 "\n#################### SECURITY CAM (22-31) ######"
794 "############\n ");
795 for (j = 22; j < TOTAL_CAM_ENTRY; j++) {
796 len += snprintf(page + len, count - len, "\nD: %2x > ", j);
797 for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
798 target_command = entry_i + CAM_CONTENT_COUNT * j;
799 target_command = target_command | BIT31;
801 while ((i--) >= 0) {
802 ulStatus = read_nic_dword(dev, RWCAM);
803 if (ulStatus & BIT31)
804 continue;
805 else
806 break;
808 write_nic_dword(dev, RWCAM, target_command);
809 target_content = read_nic_dword(dev, RCAMO);
810 len += snprintf(page + len, count - len, "%8.8x ",
811 target_content);
815 len += snprintf(page + len, count - len, "\n");
816 *eof = 1;
817 return len;
819 static int proc_get_stats_tx(char *page, char **start,
820 off_t offset, int count,
821 int *eof, void *data)
823 struct net_device *dev = data;
824 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
826 int len = 0;
828 len += snprintf(page + len, count - len,
829 "TX VI priority ok int: %lu\n"
830 "TX VO priority ok int: %lu\n"
831 "TX BE priority ok int: %lu\n"
832 "TX BK priority ok int: %lu\n"
833 "TX MANAGE priority ok int: %lu\n"
834 "TX BEACON priority ok int: %lu\n"
835 "TX BEACON priority error int: %lu\n"
836 "TX CMDPKT priority ok int: %lu\n"
837 "TX queue stopped?: %d\n"
838 "TX fifo overflow: %lu\n"
839 "TX total data packets %lu\n"
840 "TX total data bytes :%lu\n",
841 priv->stats.txviokint,
842 priv->stats.txvookint,
843 priv->stats.txbeokint,
844 priv->stats.txbkokint,
845 priv->stats.txmanageokint,
846 priv->stats.txbeaconokint,
847 priv->stats.txbeaconerr,
848 priv->stats.txcmdpktokint,
849 netif_queue_stopped(dev),
850 priv->stats.txoverflow,
851 priv->rtllib->stats.tx_packets,
852 priv->rtllib->stats.tx_bytes
857 *eof = 1;
858 return len;
863 static int proc_get_stats_rx(char *page, char **start,
864 off_t offset, int count,
865 int *eof, void *data)
867 struct net_device *dev = data;
868 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
870 int len = 0;
872 len += snprintf(page + len, count - len,
873 "RX packets: %lu\n"
874 "RX data crc err: %lu\n"
875 "RX mgmt crc err: %lu\n"
876 "RX desc err: %lu\n"
877 "RX rx overflow error: %lu\n",
878 priv->stats.rxint,
879 priv->stats.rxdatacrcerr,
880 priv->stats.rxmgmtcrcerr,
881 priv->stats.rxrdu,
882 priv->stats.rxoverflow);
884 *eof = 1;
885 return len;
888 void rtl8192_proc_module_init(void)
890 RT_TRACE(COMP_INIT, "Initializing proc filesystem");
891 rtl8192_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net);
895 void rtl8192_proc_module_remove(void)
897 remove_proc_entry(DRV_NAME, init_net.proc_net);
901 void rtl8192_proc_remove_one(struct net_device *dev)
903 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
905 printk(KERN_INFO "dev name %s\n", dev->name);
907 if (priv->dir_dev) {
908 remove_proc_entry("stats-tx", priv->dir_dev);
909 remove_proc_entry("stats-rx", priv->dir_dev);
910 remove_proc_entry("stats-ap", priv->dir_dev);
911 remove_proc_entry("registers-0", priv->dir_dev);
912 remove_proc_entry("registers-1", priv->dir_dev);
913 remove_proc_entry("registers-2", priv->dir_dev);
914 remove_proc_entry("registers-3", priv->dir_dev);
915 remove_proc_entry("registers-4", priv->dir_dev);
916 remove_proc_entry("registers-5", priv->dir_dev);
917 remove_proc_entry("registers-6", priv->dir_dev);
918 remove_proc_entry("registers-7", priv->dir_dev);
919 remove_proc_entry("registers-8", priv->dir_dev);
920 remove_proc_entry("registers-9", priv->dir_dev);
921 remove_proc_entry("registers-a", priv->dir_dev);
922 remove_proc_entry("registers-b", priv->dir_dev);
923 remove_proc_entry("registers-c", priv->dir_dev);
924 remove_proc_entry("registers-d", priv->dir_dev);
925 remove_proc_entry("registers-e", priv->dir_dev);
926 remove_proc_entry("RF-A", priv->dir_dev);
927 remove_proc_entry("RF-B", priv->dir_dev);
928 remove_proc_entry("RF-C", priv->dir_dev);
929 remove_proc_entry("RF-D", priv->dir_dev);
930 remove_proc_entry("SEC-CAM-1", priv->dir_dev);
931 remove_proc_entry("SEC-CAM-2", priv->dir_dev);
932 remove_proc_entry("SEC-CAM-3", priv->dir_dev);
933 remove_proc_entry("wlan0", rtl8192_proc);
934 priv->dir_dev = NULL;
939 void rtl8192_proc_init_one(struct net_device *dev)
941 struct proc_dir_entry *e;
942 struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
944 priv->dir_dev = create_proc_entry(dev->name,
945 S_IFDIR | S_IRUGO | S_IXUGO,
946 rtl8192_proc);
947 if (!priv->dir_dev) {
948 RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192"
949 "/%s\n", dev->name);
950 return;
952 e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
953 priv->dir_dev, proc_get_stats_rx, dev);
955 if (!e)
956 RT_TRACE(COMP_ERR, "Unable to initialize "
957 "/proc/net/rtl8192/%s/stats-rx\n",
958 dev->name);
960 e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
961 priv->dir_dev, proc_get_stats_tx, dev);
963 if (!e)
964 RT_TRACE(COMP_ERR, "Unable to initialize "
965 "/proc/net/rtl8192/%s/stats-tx\n",
966 dev->name);
968 e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
969 priv->dir_dev, proc_get_stats_ap, dev);
971 if (!e)
972 RT_TRACE(COMP_ERR, "Unable to initialize "
973 "/proc/net/rtl8192/%s/stats-ap\n",
974 dev->name);
976 e = create_proc_read_entry("registers-0", S_IFREG | S_IRUGO,
977 priv->dir_dev, proc_get_registers_0, dev);
978 if (!e)
979 RT_TRACE(COMP_ERR, "Unable to initialize "
980 "/proc/net/rtl8192/%s/registers-0\n",
981 dev->name);
982 e = create_proc_read_entry("registers-1", S_IFREG | S_IRUGO,
983 priv->dir_dev, proc_get_registers_1, dev);
984 if (!e)
985 RT_TRACE(COMP_ERR, "Unable to initialize "
986 "/proc/net/rtl8192/%s/registers-1\n",
987 dev->name);
988 e = create_proc_read_entry("registers-2", S_IFREG | S_IRUGO,
989 priv->dir_dev, proc_get_registers_2, dev);
990 if (!e)
991 RT_TRACE(COMP_ERR, "Unable to initialize "
992 "/proc/net/rtl8192/%s/registers-2\n",
993 dev->name);
994 e = create_proc_read_entry("registers-3", S_IFREG | S_IRUGO,
995 priv->dir_dev, proc_get_registers_3, dev);
996 if (!e)
997 RT_TRACE(COMP_ERR, "Unable to initialize "
998 "/proc/net/rtl8192/%s/registers-3\n",
999 dev->name);
1000 e = create_proc_read_entry("registers-4", S_IFREG | S_IRUGO,
1001 priv->dir_dev, proc_get_registers_4, dev);
1002 if (!e)
1003 RT_TRACE(COMP_ERR, "Unable to initialize "
1004 "/proc/net/rtl8192/%s/registers-4\n",
1005 dev->name);
1006 e = create_proc_read_entry("registers-5", S_IFREG | S_IRUGO,
1007 priv->dir_dev, proc_get_registers_5, dev);
1008 if (!e)
1009 RT_TRACE(COMP_ERR, "Unable to initialize "
1010 "/proc/net/rtl8192/%s/registers-5\n",
1011 dev->name);
1012 e = create_proc_read_entry("registers-6", S_IFREG | S_IRUGO,
1013 priv->dir_dev, proc_get_registers_6, dev);
1014 if (!e)
1015 RT_TRACE(COMP_ERR, "Unable to initialize "
1016 "/proc/net/rtl8192/%s/registers-6\n",
1017 dev->name);
1018 e = create_proc_read_entry("registers-7", S_IFREG | S_IRUGO,
1019 priv->dir_dev, proc_get_registers_7, dev);
1020 if (!e)
1021 RT_TRACE(COMP_ERR, "Unable to initialize "
1022 "/proc/net/rtl8192/%s/registers-7\n",
1023 dev->name);
1024 e = create_proc_read_entry("registers-8", S_IFREG | S_IRUGO,
1025 priv->dir_dev, proc_get_registers_8, dev);
1026 if (!e)
1027 RT_TRACE(COMP_ERR, "Unable to initialize "
1028 "/proc/net/rtl8192/%s/registers-8\n",
1029 dev->name);
1030 e = create_proc_read_entry("registers-9", S_IFREG | S_IRUGO,
1031 priv->dir_dev, proc_get_registers_9, dev);
1032 if (!e)
1033 RT_TRACE(COMP_ERR, "Unable to initialize "
1034 "/proc/net/rtl8192/%s/registers-9\n",
1035 dev->name);
1036 e = create_proc_read_entry("registers-a", S_IFREG | S_IRUGO,
1037 priv->dir_dev, proc_get_registers_a, dev);
1038 if (!e)
1039 RT_TRACE(COMP_ERR, "Unable to initialize "
1040 "/proc/net/rtl8192/%s/registers-a\n",
1041 dev->name);
1042 e = create_proc_read_entry("registers-b", S_IFREG | S_IRUGO,
1043 priv->dir_dev, proc_get_registers_b, dev);
1044 if (!e)
1045 RT_TRACE(COMP_ERR, "Unable to initialize "
1046 "/proc/net/rtl8192/%s/registers-b\n",
1047 dev->name);
1048 e = create_proc_read_entry("registers-c", S_IFREG | S_IRUGO,
1049 priv->dir_dev, proc_get_registers_c, dev);
1050 if (!e)
1051 RT_TRACE(COMP_ERR, "Unable to initialize "
1052 "/proc/net/rtl8192/%s/registers-c\n",
1053 dev->name);
1054 e = create_proc_read_entry("registers-d", S_IFREG | S_IRUGO,
1055 priv->dir_dev, proc_get_registers_d, dev);
1056 if (!e)
1057 RT_TRACE(COMP_ERR, "Unable to initialize "
1058 "/proc/net/rtl8192/%s/registers-d\n",
1059 dev->name);
1060 e = create_proc_read_entry("registers-e", S_IFREG | S_IRUGO,
1061 priv->dir_dev, proc_get_registers_e, dev);
1062 if (!e)
1063 RT_TRACE(COMP_ERR, "Unable to initialize "
1064 "/proc/net/rtl8192/%s/registers-e\n",
1065 dev->name);
1066 e = create_proc_read_entry("RF-A", S_IFREG | S_IRUGO,
1067 priv->dir_dev, proc_get_reg_rf_a, dev);
1068 if (!e)
1069 RT_TRACE(COMP_ERR, "Unable to initialize "
1070 "/proc/net/rtl8192/%s/RF-A\n",
1071 dev->name);
1072 e = create_proc_read_entry("RF-B", S_IFREG | S_IRUGO,
1073 priv->dir_dev, proc_get_reg_rf_b, dev);
1074 if (!e)
1075 RT_TRACE(COMP_ERR, "Unable to initialize "
1076 "/proc/net/rtl8192/%s/RF-B\n",
1077 dev->name);
1078 e = create_proc_read_entry("RF-C", S_IFREG | S_IRUGO,
1079 priv->dir_dev, proc_get_reg_rf_c, dev);
1080 if (!e)
1081 RT_TRACE(COMP_ERR, "Unable to initialize "
1082 "/proc/net/rtl8192/%s/RF-C\n",
1083 dev->name);
1084 e = create_proc_read_entry("RF-D", S_IFREG | S_IRUGO,
1085 priv->dir_dev, proc_get_reg_rf_d, dev);
1086 if (!e)
1087 RT_TRACE(COMP_ERR, "Unable to initialize "
1088 "/proc/net/rtl8192/%s/RF-D\n",
1089 dev->name);
1090 e = create_proc_read_entry("SEC-CAM-1", S_IFREG | S_IRUGO,
1091 priv->dir_dev, proc_get_cam_register_1, dev);
1092 if (!e)
1093 RT_TRACE(COMP_ERR, "Unable to initialize "
1094 "/proc/net/rtl8192/%s/SEC-CAM-1\n",
1095 dev->name);
1096 e = create_proc_read_entry("SEC-CAM-2", S_IFREG | S_IRUGO,
1097 priv->dir_dev, proc_get_cam_register_2, dev);
1098 if (!e)
1099 RT_TRACE(COMP_ERR, "Unable to initialize "
1100 "/proc/net/rtl8192/%s/SEC-CAM-2\n",
1101 dev->name);
1102 e = create_proc_read_entry("SEC-CAM-3", S_IFREG | S_IRUGO,
1103 priv->dir_dev, proc_get_cam_register_3, dev);
1104 if (!e)
1105 RT_TRACE(COMP_ERR, "Unable to initialize "
1106 "/proc/net/rtl8192/%s/SEC-CAM-3\n",
1107 dev->name);