Merge commit 'v3.15' into next
[deliverable/linux.git] / drivers / staging / rtl8821ae / debug.c
1 /******************************************************************************
2 *
3 * Copyright(c) 2009-2010 Realtek Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
21 * Contact Information:
22 * wlanfae <wlanfae@realtek.com>
23 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
24 * Hsinchu 300, Taiwan.
25 *
26 * Larry Finger <Larry.Finger@lwfinger.net>
27 *
28 *****************************************************************************/
29
30 #include "wifi.h"
31 #include "cam.h"
32
33 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
34 #define GET_INODE_DATA(__node) PDE_DATA(__node)
35 #else
36 #define GET_INODE_DATA(__node) PDE(__node)->data
37 #endif
38
39
40 void rtl_dbgp_flag_init(struct ieee80211_hw *hw)
41 {
42 struct rtl_priv *rtlpriv = rtl_priv(hw);
43 u8 i;
44
45 rtlpriv->dbg.global_debuglevel = DBG_DMESG;
46
47 rtlpriv->dbg.global_debugcomponents =
48 COMP_ERR |
49 COMP_FW |
50 COMP_INIT |
51 COMP_RECV |
52 COMP_SEND |
53 COMP_MLME |
54 COMP_SCAN |
55 COMP_INTR |
56 COMP_LED |
57 COMP_SEC |
58 COMP_BEACON |
59 COMP_RATE |
60 COMP_RXDESC |
61 COMP_DIG |
62 COMP_TXAGC |
63 COMP_POWER |
64 COMP_POWER_TRACKING |
65 COMP_BB_POWERSAVING |
66 COMP_SWAS |
67 COMP_RF |
68 COMP_TURBO |
69 COMP_RATR |
70 COMP_CMD |
71 COMP_EASY_CONCURRENT |
72 COMP_EFUSE |
73 COMP_QOS | COMP_MAC80211 | COMP_REGD |
74 COMP_CHAN |
75 COMP_BT_COEXIST |
76 COMP_IQK |
77 0;
78
79 for (i = 0; i < DBGP_TYPE_MAX; i++)
80 rtlpriv->dbg.dbgp_type[i] = 0;
81
82 /*Init Debug flag enable condition */
83 }
84
85 struct proc_dir_entry *proc_topdir;
86 static int rtl_proc_get_mac_0(struct seq_file *m, void *v)
87 {
88 struct ieee80211_hw *hw = m->private;
89 struct rtl_priv *rtlpriv = rtl_priv(hw);
90 int i, n, page;
91 int max = 0xff;
92 page = 0x000;
93
94 for (n = 0; n <= max; ) {
95 seq_printf(m, "\n%8.8x ", n + page);
96 for (i = 0; i < 4 && n <= max; i++, n += 4)
97 seq_printf(m, "%8.8x ",
98 rtl_read_dword(rtlpriv, (page | n)));
99 }
100 seq_puts(m, "\n");
101 return 0;
102 }
103
104 static int dl_proc_open_mac_0(struct inode *inode, struct file *file)
105 {
106 return single_open(file, rtl_proc_get_mac_0, GET_INODE_DATA(inode));
107 }
108
109 static const struct file_operations file_ops_mac_0 = {
110 .open = dl_proc_open_mac_0,
111 .read = seq_read,
112 .llseek = seq_lseek,
113 .release = seq_release,
114 };
115
116 static int rtl_proc_get_mac_1(struct seq_file *m, void *v)
117 {
118 struct ieee80211_hw *hw = m->private;
119 struct rtl_priv *rtlpriv = rtl_priv(hw);
120 int i, n, page;
121 int max = 0xff;
122 page = 0x100;
123
124 for (n = 0; n <= max; ) {
125 seq_printf(m, "\n%8.8x ", n + page);
126 for (i = 0; i < 4 && n <= max; i++, n += 4)
127 seq_printf(m, "%8.8x ",
128 rtl_read_dword(rtlpriv, (page | n)));
129 }
130 seq_puts(m, "\n");
131 return 0;
132 }
133
134 static int dl_proc_open_mac_1(struct inode *inode, struct file *file)
135 {
136 return single_open(file, rtl_proc_get_mac_1, GET_INODE_DATA(inode));
137 }
138
139 static const struct file_operations file_ops_mac_1 = {
140 .open = dl_proc_open_mac_1,
141 .read = seq_read,
142 .llseek = seq_lseek,
143 .release = seq_release,
144 };
145
146 static int rtl_proc_get_mac_2(struct seq_file *m, void *v)
147 {
148 struct ieee80211_hw *hw = m->private;
149 struct rtl_priv *rtlpriv = rtl_priv(hw);
150 int i, n, page;
151 int max = 0xff;
152 page = 0x200;
153
154 for (n = 0; n <= max; ) {
155 seq_printf(m, "\n%8.8x ", n + page);
156 for (i = 0; i < 4 && n <= max; i++, n += 4)
157 seq_printf(m, "%8.8x ",
158 rtl_read_dword(rtlpriv, (page | n)));
159 }
160 seq_puts(m, "\n");
161 return 0;
162 }
163
164 static int dl_proc_open_mac_2(struct inode *inode, struct file *file)
165 {
166 return single_open(file, rtl_proc_get_mac_2, GET_INODE_DATA(inode));
167 }
168
169 static const struct file_operations file_ops_mac_2 = {
170 .open = dl_proc_open_mac_2,
171 .read = seq_read,
172 .llseek = seq_lseek,
173 .release = seq_release,
174 };
175
176 static int rtl_proc_get_mac_3(struct seq_file *m, void *v)
177 {
178 struct ieee80211_hw *hw = m->private;
179 struct rtl_priv *rtlpriv = rtl_priv(hw);
180 int i, n, page;
181 int max = 0xff;
182 page = 0x300;
183
184 for (n = 0; n <= max; ) {
185 seq_printf(m, "\n%8.8x ", n + page);
186 for (i = 0; i < 4 && n <= max; i++, n += 4)
187 seq_printf(m, "%8.8x ",
188 rtl_read_dword(rtlpriv, (page | n)));
189 }
190 seq_puts(m, "\n");
191 return 0;
192 }
193
194 static int dl_proc_open_mac_3(struct inode *inode, struct file *file)
195 {
196 return single_open(file, rtl_proc_get_mac_3, GET_INODE_DATA(inode));
197 }
198
199 static const struct file_operations file_ops_mac_3 = {
200 .open = dl_proc_open_mac_3,
201 .read = seq_read,
202 .llseek = seq_lseek,
203 .release = seq_release,
204 };
205
206 static int rtl_proc_get_mac_4(struct seq_file *m, void *v)
207 {
208 struct ieee80211_hw *hw = m->private;
209 struct rtl_priv *rtlpriv = rtl_priv(hw);
210 int i, n, page;
211 int max = 0xff;
212 page = 0x400;
213
214 for (n = 0; n <= max; ) {
215 seq_printf(m, "\n%8.8x ", n + page);
216 for (i = 0; i < 4 && n <= max; i++, n += 4)
217 seq_printf(m, "%8.8x ",
218 rtl_read_dword(rtlpriv, (page | n)));
219 }
220 seq_puts(m, "\n");
221 return 0;
222 }
223
224 static int dl_proc_open_mac_4(struct inode *inode, struct file *file)
225 {
226 return single_open(file, rtl_proc_get_mac_4, GET_INODE_DATA(inode));
227 }
228
229 static const struct file_operations file_ops_mac_4 = {
230 .open = dl_proc_open_mac_4,
231 .read = seq_read,
232 .llseek = seq_lseek,
233 .release = seq_release,
234 };
235
236 static int rtl_proc_get_mac_5(struct seq_file *m, void *v)
237 {
238 struct ieee80211_hw *hw = m->private;
239 struct rtl_priv *rtlpriv = rtl_priv(hw);
240 int i, n, page;
241 int max = 0xff;
242 page = 0x500;
243
244 for (n = 0; n <= max; ) {
245 seq_printf(m, "\n%8.8x ", n + page);
246 for (i = 0; i < 4 && n <= max; i++, n += 4)
247 seq_printf(m, "%8.8x ",
248 rtl_read_dword(rtlpriv, (page | n)));
249 }
250 seq_puts(m, "\n");
251 return 0;
252 }
253
254 static int dl_proc_open_mac_5(struct inode *inode, struct file *file)
255 {
256 return single_open(file, rtl_proc_get_mac_5, GET_INODE_DATA(inode));
257 }
258
259 static const struct file_operations file_ops_mac_5 = {
260 .open = dl_proc_open_mac_5,
261 .read = seq_read,
262 .llseek = seq_lseek,
263 .release = seq_release,
264 };
265
266 static int rtl_proc_get_mac_6(struct seq_file *m, void *v)
267 {
268 struct ieee80211_hw *hw = m->private;
269 struct rtl_priv *rtlpriv = rtl_priv(hw);
270 int i, n, page;
271 int max = 0xff;
272 page = 0x600;
273
274 for (n = 0; n <= max; ) {
275 seq_printf(m, "\n%8.8x ", n + page);
276 for (i = 0; i < 4 && n <= max; i++, n += 4)
277 seq_printf(m, "%8.8x ",
278 rtl_read_dword(rtlpriv, (page | n)));
279 }
280 seq_puts(m, "\n");
281 return 0;
282 }
283
284 static int dl_proc_open_mac_6(struct inode *inode, struct file *file)
285 {
286 return single_open(file, rtl_proc_get_mac_6, GET_INODE_DATA(inode));
287 }
288
289 static const struct file_operations file_ops_mac_6 = {
290 .open = dl_proc_open_mac_6,
291 .read = seq_read,
292 .llseek = seq_lseek,
293 .release = seq_release,
294 };
295
296 static int rtl_proc_get_mac_7(struct seq_file *m, void *v)
297 {
298 struct ieee80211_hw *hw = m->private;
299 struct rtl_priv *rtlpriv = rtl_priv(hw);
300 int i, n, page;
301 int max = 0xff;
302 page = 0x700;
303
304 for (n = 0; n <= max; ) {
305 seq_printf(m, "\n%8.8x ", n + page);
306 for (i = 0; i < 4 && n <= max; i++, n += 4)
307 seq_printf(m, "%8.8x ",
308 rtl_read_dword(rtlpriv, (page | n)));
309 }
310 seq_puts(m, "\n");
311 return 0;
312 }
313
314 static int dl_proc_open_mac_7(struct inode *inode, struct file *file)
315 {
316 return single_open(file, rtl_proc_get_mac_7, GET_INODE_DATA(inode));
317 }
318
319 static const struct file_operations file_ops_mac_7 = {
320 .open = dl_proc_open_mac_7,
321 .read = seq_read,
322 .llseek = seq_lseek,
323 .release = seq_release,
324 };
325
326 static int rtl_proc_get_bb_8(struct seq_file *m, void *v)
327 {
328 struct ieee80211_hw *hw = m->private;
329 int i, n, page;
330 int max = 0xff;
331 page = 0x800;
332
333 for (n = 0; n <= max; ) {
334 seq_printf(m, "\n%8.8x ", n + page);
335 for (i = 0; i < 4 && n <= max; i++, n += 4)
336 seq_printf(m, "%8.8x ",
337 rtl_get_bbreg(hw, (page | n), 0xffffffff));
338 }
339 seq_puts(m, "\n");
340 return 0;
341 }
342
343 static int dl_proc_open_bb_8(struct inode *inode, struct file *file)
344 {
345 return single_open(file, rtl_proc_get_bb_8, GET_INODE_DATA(inode));
346 }
347
348 static const struct file_operations file_ops_bb_8 = {
349 .open = dl_proc_open_bb_8,
350 .read = seq_read,
351 .llseek = seq_lseek,
352 .release = seq_release,
353 };
354
355 static int rtl_proc_get_bb_9(struct seq_file *m, void *v)
356 {
357 struct ieee80211_hw *hw = m->private;
358 int i, n, page;
359 int max = 0xff;
360 page = 0x900;
361
362 for (n = 0; n <= max; ) {
363 seq_printf(m, "\n%8.8x ", n + page);
364 for (i = 0; i < 4 && n <= max; i++, n += 4)
365 seq_printf(m, "%8.8x ",
366 rtl_get_bbreg(hw, (page | n), 0xffffffff));
367 }
368 seq_puts(m, "\n");
369 return 0;
370 }
371
372 static int dl_proc_open_bb_9(struct inode *inode, struct file *file)
373 {
374 return single_open(file, rtl_proc_get_bb_9, GET_INODE_DATA(inode));
375 }
376
377 static const struct file_operations file_ops_bb_9 = {
378 .open = dl_proc_open_bb_9,
379 .read = seq_read,
380 .llseek = seq_lseek,
381 .release = seq_release,
382 };
383
384 static int rtl_proc_get_bb_a(struct seq_file *m, void *v)
385 {
386 struct ieee80211_hw *hw = m->private;
387 int i, n, page;
388 int max = 0xff;
389 page = 0xa00;
390
391 for (n = 0; n <= max; ) {
392 seq_printf(m, "\n%8.8x ", n + page);
393 for (i = 0; i < 4 && n <= max; i++, n += 4)
394 seq_printf(m, "%8.8x ",
395 rtl_get_bbreg(hw, (page | n), 0xffffffff));
396 }
397 seq_puts(m, "\n");
398 return 0;
399 }
400
401 static int dl_proc_open_bb_a(struct inode *inode, struct file *file)
402 {
403 return single_open(file, rtl_proc_get_bb_a, GET_INODE_DATA(inode));
404 }
405
406 static const struct file_operations file_ops_bb_a = {
407 .open = dl_proc_open_bb_a,
408 .read = seq_read,
409 .llseek = seq_lseek,
410 .release = seq_release,
411 };
412
413 static int rtl_proc_get_bb_b(struct seq_file *m, void *v)
414 {
415 struct ieee80211_hw *hw = m->private;
416 int i, n, page;
417 int max = 0xff;
418 page = 0xb00;
419
420 for (n = 0; n <= max; ) {
421 seq_printf(m, "\n%8.8x ", n + page);
422 for (i = 0; i < 4 && n <= max; i++, n += 4)
423 seq_printf(m, "%8.8x ",
424 rtl_get_bbreg(hw, (page | n), 0xffffffff));
425 }
426 seq_puts(m, "\n");
427 return 0;
428 }
429
430 static int dl_proc_open_bb_b(struct inode *inode, struct file *file)
431 {
432 return single_open(file, rtl_proc_get_bb_b, GET_INODE_DATA(inode));
433 }
434
435 static const struct file_operations file_ops_bb_b = {
436 .open = dl_proc_open_bb_b,
437 .read = seq_read,
438 .llseek = seq_lseek,
439 .release = seq_release,
440 };
441
442 static int rtl_proc_get_bb_c(struct seq_file *m, void *v)
443 {
444 struct ieee80211_hw *hw = m->private;
445 int i, n, page;
446 int max = 0xff;
447 page = 0xc00;
448
449 for (n = 0; n <= max; ) {
450 seq_printf(m, "\n%8.8x ", n + page);
451 for (i = 0; i < 4 && n <= max; i++, n += 4)
452 seq_printf(m, "%8.8x ",
453 rtl_get_bbreg(hw, (page | n), 0xffffffff));
454 }
455 seq_puts(m, "\n");
456 return 0;
457 }
458
459 static int dl_proc_open_bb_c(struct inode *inode, struct file *file)
460 {
461 return single_open(file, rtl_proc_get_bb_c, GET_INODE_DATA(inode));
462 }
463
464 static const struct file_operations file_ops_bb_c = {
465 .open = dl_proc_open_bb_c,
466 .read = seq_read,
467 .llseek = seq_lseek,
468 .release = seq_release,
469 };
470
471 static int rtl_proc_get_bb_d(struct seq_file *m, void *v)
472 {
473 struct ieee80211_hw *hw = m->private;
474 int i, n, page;
475 int max = 0xff;
476 page = 0xd00;
477
478 for (n = 0; n <= max; ) {
479 seq_printf(m, "\n%8.8x ", n + page);
480 for (i = 0; i < 4 && n <= max; i++, n += 4)
481 seq_printf(m, "%8.8x ",
482 rtl_get_bbreg(hw, (page | n), 0xffffffff));
483 }
484 seq_puts(m, "\n");
485 return 0;
486 }
487
488 static int dl_proc_open_bb_d(struct inode *inode, struct file *file)
489 {
490 return single_open(file, rtl_proc_get_bb_d, GET_INODE_DATA(inode));
491 }
492
493 static const struct file_operations file_ops_bb_d = {
494 .open = dl_proc_open_bb_d,
495 .read = seq_read,
496 .llseek = seq_lseek,
497 .release = seq_release,
498 };
499
500 static int rtl_proc_get_bb_e(struct seq_file *m, void *v)
501 {
502 struct ieee80211_hw *hw = m->private;
503 int i, n, page;
504 int max = 0xff;
505 page = 0xe00;
506
507 for (n = 0; n <= max; ) {
508 seq_printf(m, "\n%8.8x ", n + page);
509 for (i = 0; i < 4 && n <= max; i++, n += 4)
510 seq_printf(m, "%8.8x ",
511 rtl_get_bbreg(hw, (page | n), 0xffffffff));
512 }
513 seq_puts(m, "\n");
514 return 0;
515 }
516
517 static int dl_proc_open_bb_e(struct inode *inode, struct file *file)
518 {
519 return single_open(file, rtl_proc_get_bb_e, GET_INODE_DATA(inode));
520 }
521
522 static const struct file_operations file_ops_bb_e = {
523 .open = dl_proc_open_bb_e,
524 .read = seq_read,
525 .llseek = seq_lseek,
526 .release = seq_release,
527 };
528
529 static int rtl_proc_get_bb_f(struct seq_file *m, void *v)
530 {
531 struct ieee80211_hw *hw = m->private;
532 int i, n, page;
533 int max = 0xff;
534 page = 0xf00;
535
536 for (n = 0; n <= max; ) {
537 seq_printf(m, "\n%8.8x ", n + page);
538 for (i = 0; i < 4 && n <= max; i++, n += 4)
539 seq_printf(m, "%8.8x ",
540 rtl_get_bbreg(hw, (page | n), 0xffffffff));
541 }
542 seq_puts(m, "\n");
543 return 0;
544 }
545
546 static int dl_proc_open_bb_f(struct inode *inode, struct file *file)
547 {
548 return single_open(file, rtl_proc_get_bb_f, GET_INODE_DATA(inode));
549 }
550
551 static const struct file_operations file_ops_bb_f = {
552 .open = dl_proc_open_bb_f,
553 .read = seq_read,
554 .llseek = seq_lseek,
555 .release = seq_release,
556 };
557
558 static int rtl_proc_get_reg_rf_a(struct seq_file *m, void *v)
559 {
560 struct ieee80211_hw *hw = m->private;
561 int i, n;
562 int max = 0x40;
563
564 for (n = 0; n <= max; ) {
565 seq_printf(m, "\n%8.8x ", n);
566 for (i = 0; i < 4 && n <= max; n += 1, i++)
567 seq_printf(m, "%8.8x ",
568 rtl_get_rfreg(hw, RF90_PATH_A, n, 0xffffffff));
569 }
570 seq_puts(m, "\n");
571 return 0;
572 }
573
574 static int dl_proc_open_rf_a(struct inode *inode, struct file *file)
575 {
576 return single_open(file, rtl_proc_get_reg_rf_a, GET_INODE_DATA(inode));
577 }
578
579 static const struct file_operations file_ops_rf_a = {
580 .open = dl_proc_open_rf_a,
581 .read = seq_read,
582 .llseek = seq_lseek,
583 .release = seq_release,
584 };
585
586 static int rtl_proc_get_reg_rf_b(struct seq_file *m, void *v)
587 {
588 struct ieee80211_hw *hw = m->private;
589 int i, n;
590 int max = 0x40;
591
592 for (n = 0; n <= max; ) {
593 seq_printf(m, "\n%8.8x ", n);
594 for (i = 0; i < 4 && n <= max; n += 1, i++)
595 seq_printf(m, "%8.8x ",
596 rtl_get_rfreg(hw, RF90_PATH_B, n,
597 0xffffffff));
598 }
599 seq_puts(m, "\n");
600 return 0;
601 }
602
603 static int dl_proc_open_rf_b(struct inode *inode, struct file *file)
604 {
605 return single_open(file, rtl_proc_get_reg_rf_b, GET_INODE_DATA(inode));
606 }
607
608 static const struct file_operations file_ops_rf_b = {
609 .open = dl_proc_open_rf_b,
610 .read = seq_read,
611 .llseek = seq_lseek,
612 .release = seq_release,
613 };
614
615 static int rtl_proc_get_cam_register_1(struct seq_file *m, void *v)
616 {
617 struct ieee80211_hw *hw = m->private;
618 struct rtl_priv *rtlpriv = rtl_priv(hw);
619 u32 target_cmd = 0;
620 u32 target_val=0;
621 u8 entry_i=0;
622 u32 ulstatus;
623 int i = 100, j = 0;
624
625 /* This dump the current register page */
626 seq_puts(m,
627 "\n#################### SECURITY CAM (0-10) ##################\n ");
628
629 for (j = 0; j < 11; j++) {
630 seq_printf(m, "\nD: %2x > ", j);
631 for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
632 /* polling bit, and No Write enable, and address */
633 target_cmd = entry_i + CAM_CONTENT_COUNT * j;
634 target_cmd = target_cmd | BIT(31);
635
636 /* Check polling bit is clear */
637 while ((i--) >= 0) {
638 ulstatus = rtl_read_dword(rtlpriv,
639 rtlpriv->cfg->maps[RWCAM]);
640 if (ulstatus & BIT(31)) {
641 continue;
642 } else {
643 break;
644 }
645 }
646
647 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
648 target_cmd);
649 target_val = rtl_read_dword(rtlpriv,
650 rtlpriv->cfg->maps[RCAMO]);
651 seq_printf(m, "%8.8x ", target_val);
652 }
653 }
654 seq_puts(m, "\n");
655 return 0;
656 }
657
658 static int dl_proc_open_cam_1(struct inode *inode, struct file *file)
659 {
660 return single_open(file, rtl_proc_get_cam_register_1,
661 GET_INODE_DATA(inode));
662 }
663
664 static const struct file_operations file_ops_cam_1 = {
665 .open = dl_proc_open_cam_1,
666 .read = seq_read,
667 .llseek = seq_lseek,
668 .release = seq_release,
669 };
670
671 static int rtl_proc_get_cam_register_2(struct seq_file *m, void *v)
672 {
673 struct ieee80211_hw *hw = m->private;
674 struct rtl_priv *rtlpriv = rtl_priv(hw);
675 u32 target_cmd = 0;
676 u32 target_val = 0;
677 u8 entry_i = 0;
678 u32 ulstatus;
679 int i = 100, j = 0;
680
681 /* This dump the current register page */
682 seq_puts(m,
683 "\n################### SECURITY CAM (11-21) ##################\n ");
684
685 for (j = 11; j < 22; j++) {
686 seq_printf(m, "\nD: %2x > ", j);
687 for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
688 target_cmd = entry_i + CAM_CONTENT_COUNT * j;
689 target_cmd = target_cmd | BIT(31);
690
691 while ((i--) >= 0) {
692 ulstatus = rtl_read_dword(rtlpriv,
693 rtlpriv->cfg->maps[RWCAM]);
694 if (ulstatus & BIT(31)) {
695 continue;
696 } else {
697 break;
698 }
699 }
700
701 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
702 target_cmd);
703 target_val = rtl_read_dword(rtlpriv,
704 rtlpriv->cfg->maps[RCAMO]);
705 seq_printf(m, "%8.8x ", target_val);
706 }
707 }
708 seq_puts(m, "\n");
709 return 0;
710 }
711
712 static int dl_proc_open_cam_2(struct inode *inode, struct file *file)
713 {
714 return single_open(file, rtl_proc_get_cam_register_2,
715 GET_INODE_DATA(inode));
716 }
717
718 static const struct file_operations file_ops_cam_2 = {
719 .open = dl_proc_open_cam_2,
720 .read = seq_read,
721 .llseek = seq_lseek,
722 .release = seq_release,
723 };
724
725 static int rtl_proc_get_cam_register_3(struct seq_file *m, void *v)
726 {
727 struct ieee80211_hw *hw = m->private;
728 struct rtl_priv *rtlpriv = rtl_priv(hw);
729 u32 target_cmd = 0;
730 u32 target_val = 0;
731 u8 entry_i = 0;
732 u32 ulstatus;
733 int i = 100, j = 0;
734
735 /* This dump the current register page */
736 seq_puts(m,
737 "\n################### SECURITY CAM (22-31) ##################\n ");
738
739 for (j = 22; j < TOTAL_CAM_ENTRY; j++) {
740 seq_printf(m, "\nD: %2x > ", j);
741 for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
742 target_cmd = entry_i+CAM_CONTENT_COUNT*j;
743 target_cmd = target_cmd | BIT(31);
744
745 while ((i--) >= 0) {
746 ulstatus = rtl_read_dword(rtlpriv,
747 rtlpriv->cfg->maps[RWCAM]);
748 if (ulstatus & BIT(31)) {
749 continue;
750 } else {
751 break;
752 }
753 }
754
755 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
756 target_cmd);
757 target_val = rtl_read_dword(rtlpriv,
758 rtlpriv->cfg->maps[RCAMO]);
759 seq_printf(m, "%8.8x ", target_val);
760 }
761 }
762 seq_puts(m, "\n");
763 return 0;
764 }
765
766 static int dl_proc_open_cam_3(struct inode *inode, struct file *file)
767 {
768 return single_open(file, rtl_proc_get_cam_register_3,
769 GET_INODE_DATA(inode));
770 }
771
772 static const struct file_operations file_ops_cam_3 = {
773 .open = dl_proc_open_cam_3,
774 .read = seq_read,
775 .llseek = seq_lseek,
776 .release = seq_release,
777 };
778
779 void rtl_proc_add_one(struct ieee80211_hw *hw)
780 {
781 struct rtl_priv *rtlpriv = rtl_priv(hw);
782 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
783 struct proc_dir_entry *entry;
784
785 snprintf(rtlpriv->dbg.proc_name, 18, "%x-%x-%x-%x-%x-%x",
786 rtlefuse->dev_addr[0], rtlefuse->dev_addr[1],
787 rtlefuse->dev_addr[2], rtlefuse->dev_addr[3],
788 rtlefuse->dev_addr[4], rtlefuse->dev_addr[5]);
789
790 rtlpriv->dbg.proc_dir = proc_mkdir(rtlpriv->dbg.proc_name, proc_topdir);
791 if (!rtlpriv->dbg.proc_dir) {
792 RT_TRACE(COMP_INIT, DBG_EMERG, ("Unable to init "
793 "/proc/net/%s/%s\n", rtlpriv->cfg->name,
794 rtlpriv->dbg.proc_name));
795 return;
796 }
797
798 entry = proc_create_data("mac-0", S_IFREG | S_IRUGO,
799 rtlpriv->dbg.proc_dir, &file_ops_mac_0, hw);
800 if (!entry)
801 RT_TRACE(COMP_INIT, DBG_EMERG,
802 ("Unable to initialize /proc/net/%s/%s/mac-0\n",
803 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
804
805 entry = proc_create_data("mac-1", S_IFREG | S_IRUGO,
806 rtlpriv->dbg.proc_dir, &file_ops_mac_1, hw);
807 if (!entry)
808 RT_TRACE(COMP_INIT, COMP_ERR,
809 ("Unable to initialize /proc/net/%s/%s/mac-1\n",
810 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
811
812 entry = proc_create_data("mac-2", S_IFREG | S_IRUGO,
813 rtlpriv->dbg.proc_dir, &file_ops_mac_2, hw);
814 if (!entry)
815 RT_TRACE(COMP_INIT, COMP_ERR,
816 ("Unable to initialize /proc/net/%s/%s/mac-2\n",
817 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
818
819 entry = proc_create_data("mac-3", S_IFREG | S_IRUGO,
820 rtlpriv->dbg.proc_dir, &file_ops_mac_3, hw);
821 if (!entry)
822 RT_TRACE(COMP_INIT, COMP_ERR,
823 ("Unable to initialize /proc/net/%s/%s/mac-3\n",
824 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
825
826 entry = proc_create_data("mac-4", S_IFREG | S_IRUGO,
827 rtlpriv->dbg.proc_dir, &file_ops_mac_4, hw);
828 if (!entry)
829 RT_TRACE(COMP_INIT, COMP_ERR,
830 ("Unable to initialize /proc/net/%s/%s/mac-4\n",
831 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
832
833 entry = proc_create_data("mac-5", S_IFREG | S_IRUGO,
834 rtlpriv->dbg.proc_dir, &file_ops_mac_5, hw);
835 if (!entry)
836 RT_TRACE(COMP_INIT, COMP_ERR,
837 ("Unable to initialize /proc/net/%s/%s/mac-5\n",
838 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
839
840 entry = proc_create_data("mac-6", S_IFREG | S_IRUGO,
841 rtlpriv->dbg.proc_dir, &file_ops_mac_6, hw);
842 if (!entry)
843 RT_TRACE(COMP_INIT, COMP_ERR,
844 ("Unable to initialize /proc/net/%s/%s/mac-6\n",
845 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
846
847 entry = proc_create_data("mac-7", S_IFREG | S_IRUGO,
848 rtlpriv->dbg.proc_dir, &file_ops_mac_7, hw);
849 if (!entry)
850 RT_TRACE(COMP_INIT, COMP_ERR,
851 ("Unable to initialize /proc/net/%s/%s/mac-7\n",
852 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
853
854 entry = proc_create_data("bb-8", S_IFREG | S_IRUGO,
855 rtlpriv->dbg.proc_dir, &file_ops_bb_8, hw);
856 if (!entry)
857 RT_TRACE(COMP_INIT, COMP_ERR,
858 ("Unable to initialize /proc/net/%s/%s/bb-8\n",
859 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
860
861 entry = proc_create_data("bb-9", S_IFREG | S_IRUGO,
862 rtlpriv->dbg.proc_dir, &file_ops_bb_9, hw);
863 if (!entry)
864 RT_TRACE(COMP_INIT, COMP_ERR,
865 ("Unable to initialize /proc/net/%s/%s/bb-9\n",
866 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
867
868 entry = proc_create_data("bb-a", S_IFREG | S_IRUGO,
869 rtlpriv->dbg.proc_dir, &file_ops_bb_a, hw);
870 if (!entry)
871 RT_TRACE(COMP_INIT, COMP_ERR,
872 ("Unable to initialize /proc/net/%s/%s/bb-a\n",
873 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
874
875 entry = proc_create_data("bb-b", S_IFREG | S_IRUGO,
876 rtlpriv->dbg.proc_dir, &file_ops_bb_b, hw);
877 if (!entry)
878 RT_TRACE(COMP_INIT, COMP_ERR,
879 ("Unable to initialize /proc/net/%s/%s/bb-b\n",
880 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
881
882 entry = proc_create_data("bb-c", S_IFREG | S_IRUGO,
883 rtlpriv->dbg.proc_dir, &file_ops_bb_c, hw);
884 if (!entry)
885 RT_TRACE(COMP_INIT, COMP_ERR,
886 ("Unable to initialize /proc/net/%s/%s/bb-c\n",
887 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
888
889 entry = proc_create_data("bb-d", S_IFREG | S_IRUGO,
890 rtlpriv->dbg.proc_dir, &file_ops_bb_d, hw);
891 if (!entry)
892 RT_TRACE(COMP_INIT, COMP_ERR,
893 ("Unable to initialize /proc/net/%s/%s/bb-d\n",
894 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
895
896 entry = proc_create_data("bb-e", S_IFREG | S_IRUGO,
897 rtlpriv->dbg.proc_dir, &file_ops_bb_e, hw);
898 if (!entry)
899 RT_TRACE(COMP_INIT, COMP_ERR,
900 ("Unable to initialize /proc/net/%s/%s/bb-e\n",
901 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
902
903 entry = proc_create_data("bb-f", S_IFREG | S_IRUGO,
904 rtlpriv->dbg.proc_dir, &file_ops_bb_f, hw);
905 if (!entry)
906 RT_TRACE(COMP_INIT, COMP_ERR,
907 ("Unable to initialize /proc/net/%s/%s/bb-f\n",
908 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
909
910 entry = proc_create_data("rf-a", S_IFREG | S_IRUGO,
911 rtlpriv->dbg.proc_dir, &file_ops_rf_a, hw);
912 if (!entry)
913 RT_TRACE(COMP_INIT, COMP_ERR,
914 ("Unable to initialize /proc/net/%s/%s/rf-a\n",
915 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
916
917 entry = proc_create_data("rf-b", S_IFREG | S_IRUGO,
918 rtlpriv->dbg.proc_dir, &file_ops_rf_b, hw);
919 if (!entry)
920 RT_TRACE(COMP_INIT, COMP_ERR,
921 ("Unable to initialize /proc/net/%s/%s/rf-b\n",
922 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
923
924 entry = proc_create_data("cam-1", S_IFREG | S_IRUGO,
925 rtlpriv->dbg.proc_dir, &file_ops_cam_1, hw);
926 if (!entry)
927 RT_TRACE(COMP_INIT, COMP_ERR,
928 ("Unable to initialize /proc/net/%s/%s/cam-1\n",
929 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
930
931 entry = proc_create_data("cam-2", S_IFREG | S_IRUGO,
932 rtlpriv->dbg.proc_dir, &file_ops_cam_2, hw);
933 if (!entry)
934 RT_TRACE(COMP_INIT, COMP_ERR,
935 ("Unable to initialize /proc/net/%s/%s/cam-2\n",
936 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
937
938 entry = proc_create_data("cam-3", S_IFREG | S_IRUGO,
939 rtlpriv->dbg.proc_dir, &file_ops_cam_3, hw);
940 if (!entry)
941 RT_TRACE(COMP_INIT, COMP_ERR,
942 ("Unable to initialize /proc/net/%s/%s/cam-3\n",
943 rtlpriv->cfg->name, rtlpriv->dbg.proc_name));
944 }
945
946 void rtl_proc_remove_one(struct ieee80211_hw *hw)
947 {
948 struct rtl_priv *rtlpriv = rtl_priv(hw);
949
950 if (rtlpriv->dbg.proc_dir) {
951 remove_proc_entry("mac-0", rtlpriv->dbg.proc_dir);
952 remove_proc_entry("mac-1", rtlpriv->dbg.proc_dir);
953 remove_proc_entry("mac-2", rtlpriv->dbg.proc_dir);
954 remove_proc_entry("mac-3", rtlpriv->dbg.proc_dir);
955 remove_proc_entry("mac-4", rtlpriv->dbg.proc_dir);
956 remove_proc_entry("mac-5", rtlpriv->dbg.proc_dir);
957 remove_proc_entry("mac-6", rtlpriv->dbg.proc_dir);
958 remove_proc_entry("mac-7", rtlpriv->dbg.proc_dir);
959 remove_proc_entry("bb-8", rtlpriv->dbg.proc_dir);
960 remove_proc_entry("bb-9", rtlpriv->dbg.proc_dir);
961 remove_proc_entry("bb-a", rtlpriv->dbg.proc_dir);
962 remove_proc_entry("bb-b", rtlpriv->dbg.proc_dir);
963 remove_proc_entry("bb-c", rtlpriv->dbg.proc_dir);
964 remove_proc_entry("bb-d", rtlpriv->dbg.proc_dir);
965 remove_proc_entry("bb-e", rtlpriv->dbg.proc_dir);
966 remove_proc_entry("bb-f", rtlpriv->dbg.proc_dir);
967 remove_proc_entry("rf-a", rtlpriv->dbg.proc_dir);
968 remove_proc_entry("rf-b", rtlpriv->dbg.proc_dir);
969 remove_proc_entry("cam-1", rtlpriv->dbg.proc_dir);
970 remove_proc_entry("cam-2", rtlpriv->dbg.proc_dir);
971 remove_proc_entry("cam-3", rtlpriv->dbg.proc_dir);
972
973 remove_proc_entry(rtlpriv->dbg.proc_name, proc_topdir);
974
975 rtlpriv->dbg.proc_dir = NULL;
976 }
977 }
978
979 void rtl_proc_add_topdir(void)
980 {
981 proc_topdir = proc_mkdir("rtlwifi", init_net.proc_net);
982 }
983
984 void rtl_proc_remove_topdir(void)
985 {
986 if (proc_topdir)
987 remove_proc_entry("rtlwifi", init_net.proc_net);
988 }
This page took 0.084971 seconds and 6 git commands to generate.