1 /******************************************************************************/
3 /* Copyright (c) 2004-2006 Silicom, Ltd */
4 /* All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation, located in the file LICENSE. */
11 /******************************************************************************/
13 #include <linux/version.h>
14 #if defined(CONFIG_SMP) && ! defined(__SMP__)
18 #include <linux/proc_fs.h>
19 #include <linux/netdevice.h>
20 #include <asm/uaccess.h>
21 //#include <linux/smp_lock.h>
24 #define BP_PROC_DIR "bypass"
25 //#define BYPASS_SUPPORT "bypass"
29 #define GPIO6_SET_ENTRY_SD "gpio6_set"
30 #define GPIO6_CLEAR_ENTRY_SD "gpio6_clear"
32 #define GPIO7_SET_ENTRY_SD "gpio7_set"
33 #define GPIO7_CLEAR_ENTRY_SD "gpio7_clear"
35 #define PULSE_SET_ENTRY_SD "pulse_set"
36 #define ZERO_SET_ENTRY_SD "zero_set"
37 #define PULSE_GET1_ENTRY_SD "pulse_get1"
38 #define PULSE_GET2_ENTRY_SD "pulse_get2"
40 #define CMND_ON_ENTRY_SD "cmnd_on"
41 #define CMND_OFF_ENTRY_SD "cmnd_off"
42 #define RESET_CONT_ENTRY_SD "reset_cont"
45 #define BYPASS_INFO_ENTRY_SD "bypass_info"
46 #define BYPASS_SLAVE_ENTRY_SD "bypass_slave"
47 #define BYPASS_CAPS_ENTRY_SD "bypass_caps"
48 #define WD_SET_CAPS_ENTRY_SD "wd_set_caps"
49 #define BYPASS_ENTRY_SD "bypass"
50 #define BYPASS_CHANGE_ENTRY_SD "bypass_change"
51 #define BYPASS_WD_ENTRY_SD "bypass_wd"
52 #define WD_EXPIRE_TIME_ENTRY_SD "wd_expire_time"
53 #define RESET_BYPASS_WD_ENTRY_SD "reset_bypass_wd"
54 #define DIS_BYPASS_ENTRY_SD "dis_bypass"
55 #define BYPASS_PWUP_ENTRY_SD "bypass_pwup"
56 #define BYPASS_PWOFF_ENTRY_SD "bypass_pwoff"
57 #define STD_NIC_ENTRY_SD "std_nic"
58 #define STD_NIC_ENTRY_SD "std_nic"
59 #define TAP_ENTRY_SD "tap"
60 #define TAP_CHANGE_ENTRY_SD "tap_change"
61 #define DIS_TAP_ENTRY_SD "dis_tap"
62 #define TAP_PWUP_ENTRY_SD "tap_pwup"
63 #define TWO_PORT_LINK_ENTRY_SD "two_port_link"
64 #define WD_EXP_MODE_ENTRY_SD "wd_exp_mode"
65 #define WD_AUTORESET_ENTRY_SD "wd_autoreset"
66 #define TPL_ENTRY_SD "tpl"
67 #define WAIT_AT_PWUP_ENTRY_SD "wait_at_pwup"
68 #define HW_RESET_ENTRY_SD "hw_reset"
69 #define DISC_ENTRY_SD "disc"
70 #define DISC_CHANGE_ENTRY_SD "disc_change"
71 #define DIS_DISC_ENTRY_SD "dis_disc"
72 #define DISC_PWUP_ENTRY_SD "disc_pwup"
73 #endif //bypass_support
74 static struct proc_dir_entry
*bp_procfs_dir
;
76 static struct proc_dir_entry
*proc_getdir(char *name
,
77 struct proc_dir_entry
*proc_dir
)
79 struct proc_dir_entry
*pde
= proc_dir
;
80 for (pde
= pde
->subdir
; pde
; pde
= pde
->next
) {
81 if (pde
->namelen
&& (strcmp(name
, pde
->name
) == 0)) {
82 /* directory exists */
86 if (pde
== (struct proc_dir_entry
*)0) {
87 /* create the directory */
88 pde
= create_proc_entry(name
, S_IFDIR
, proc_dir
);
89 if (pde
== (struct proc_dir_entry
*)0) {
99 bypass_proc_create_entry_sd(struct pfs_unit
*pfs_unit_curr
,
101 write_proc_t
* write_proc
,
102 read_proc_t
* read_proc
,
103 struct proc_dir_entry
*parent_pfs
, void *data
)
105 strcpy(pfs_unit_curr
->proc_name
, proc_name
);
106 pfs_unit_curr
->proc_entry
= create_proc_entry(pfs_unit_curr
->proc_name
,
109 S_IROTH
, parent_pfs
);
110 if (pfs_unit_curr
->proc_entry
== 0) {
115 pfs_unit_curr
->proc_entry
->read_proc
= read_proc
;
116 pfs_unit_curr
->proc_entry
->write_proc
= write_proc
;
117 pfs_unit_curr
->proc_entry
->data
= data
;
124 get_bypass_info_pfs(char *page
, char **start
, off_t off
, int count
,
125 int *eof
, void *data
)
127 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
130 len
+= sprintf(page
, "Name\t\t\t%s\n", pbp_device_block
->bp_name
);
132 sprintf(page
+ len
, "Firmware version\t0x%x\n",
133 pbp_device_block
->bp_fw_ver
);
140 get_bypass_slave_pfs(char *page
, char **start
, off_t off
, int count
,
141 int *eof
, void *data
)
143 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
145 struct pci_dev
*pci_slave_dev
= pbp_device_block
->bp_slave
;
146 struct net_device
*net_slave_dev
;
149 if (is_bypass_fn(pbp_device_block
)) {
150 net_slave_dev
= pci_get_drvdata(pci_slave_dev
);
152 len
= sprintf(page
, "%s\n", net_slave_dev
->name
);
154 len
= sprintf(page
, "fail\n");
156 len
= sprintf(page
, "fail\n");
163 get_bypass_caps_pfs(char *page
, char **start
, off_t off
, int count
,
164 int *eof
, void *data
)
166 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
168 int len
= 0, ret
= 0;
170 ret
= get_bypass_caps_fn(pbp_device_block
);
171 if (ret
== BP_NOT_CAP
)
172 len
= sprintf(page
, "-1\n");
174 len
= sprintf(page
, "0x%x\n", ret
);
181 get_wd_set_caps_pfs(char *page
, char **start
, off_t off
, int count
,
182 int *eof
, void *data
)
184 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
186 int len
= 0, ret
= 0;
188 ret
= get_wd_set_caps_fn(pbp_device_block
);
189 if (ret
== BP_NOT_CAP
)
190 len
= sprintf(page
, "-1\n");
192 len
= sprintf(page
, "0x%x\n", ret
);
198 set_bypass_pfs(struct file
*file
, const char *buffer
,
199 unsigned long count
, void *data
)
203 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
205 int bypass_param
= 0, length
= 0;
207 if (count
> (sizeof(kbuf
) - 1))
210 if (copy_from_user(&kbuf
, buffer
, count
)) {
215 length
= strlen(kbuf
);
216 if (kbuf
[length
- 1] == '\n')
217 kbuf
[--length
] = '\0';
219 if (strcmp(kbuf
, "on") == 0)
221 else if (strcmp(kbuf
, "off") == 0)
224 set_bypass_fn(pbp_device_block
, bypass_param
);
230 set_tap_pfs(struct file
*file
, const char *buffer
,
231 unsigned long count
, void *data
)
235 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
237 int tap_param
= 0, length
= 0;
239 if (count
> (sizeof(kbuf
) - 1))
242 if (copy_from_user(&kbuf
, buffer
, count
)) {
247 length
= strlen(kbuf
);
248 if (kbuf
[length
- 1] == '\n')
249 kbuf
[--length
] = '\0';
251 if (strcmp(kbuf
, "on") == 0)
253 else if (strcmp(kbuf
, "off") == 0)
256 set_tap_fn(pbp_device_block
, tap_param
);
262 set_disc_pfs(struct file
*file
, const char *buffer
,
263 unsigned long count
, void *data
)
267 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
269 int tap_param
= 0, length
= 0;
271 if (count
> (sizeof(kbuf
) - 1))
274 if (copy_from_user(&kbuf
, buffer
, count
)) {
279 length
= strlen(kbuf
);
280 if (kbuf
[length
- 1] == '\n')
281 kbuf
[--length
] = '\0';
283 if (strcmp(kbuf
, "on") == 0)
285 else if (strcmp(kbuf
, "off") == 0)
288 set_disc_fn(pbp_device_block
, tap_param
);
294 get_bypass_pfs(char *page
, char **start
, off_t off
, int count
,
295 int *eof
, void *data
)
297 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
299 int len
= 0, ret
= 0;
301 ret
= get_bypass_fn(pbp_device_block
);
302 if (ret
== BP_NOT_CAP
)
303 len
= sprintf(page
, "fail\n");
305 len
= sprintf(page
, "on\n");
307 len
= sprintf(page
, "off\n");
314 get_tap_pfs(char *page
, char **start
, off_t off
, int count
,
315 int *eof
, void *data
)
317 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
319 int len
= 0, ret
= 0;
321 ret
= get_tap_fn(pbp_device_block
);
322 if (ret
== BP_NOT_CAP
)
323 len
= sprintf(page
, "fail\n");
325 len
= sprintf(page
, "on\n");
327 len
= sprintf(page
, "off\n");
334 get_disc_pfs(char *page
, char **start
, off_t off
, int count
,
335 int *eof
, void *data
)
337 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
339 int len
= 0, ret
= 0;
341 ret
= get_disc_fn(pbp_device_block
);
342 if (ret
== BP_NOT_CAP
)
343 len
= sprintf(page
, "fail\n");
345 len
= sprintf(page
, "on\n");
347 len
= sprintf(page
, "off\n");
354 get_bypass_change_pfs(char *page
, char **start
, off_t off
, int count
,
355 int *eof
, void *data
)
357 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
359 int len
= 0, ret
= 0;
361 ret
= get_bypass_change_fn(pbp_device_block
);
363 len
= sprintf(page
, "on\n");
365 len
= sprintf(page
, "off\n");
367 len
= sprintf(page
, "fail\n");
374 get_tap_change_pfs(char *page
, char **start
, off_t off
, int count
,
375 int *eof
, void *data
)
377 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
379 int len
= 0, ret
= 0;
381 ret
= get_tap_change_fn(pbp_device_block
);
383 len
= sprintf(page
, "on\n");
385 len
= sprintf(page
, "off\n");
387 len
= sprintf(page
, "fail\n");
394 get_disc_change_pfs(char *page
, char **start
, off_t off
, int count
,
395 int *eof
, void *data
)
397 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
399 int len
= 0, ret
= 0;
401 ret
= get_disc_change_fn(pbp_device_block
);
403 len
= sprintf(page
, "on\n");
405 len
= sprintf(page
, "off\n");
407 len
= sprintf(page
, "fail\n");
414 set_bypass_wd_pfs(struct file
*file
, const char *buffer
,
415 unsigned long count
, void *data
)
419 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
421 unsigned int timeout
= 0;
422 char *timeout_ptr
= kbuf
;
424 if (copy_from_user(&kbuf
, buffer
, count
)) {
429 timeout
= atoi(&timeout_ptr
);
431 set_bypass_wd_fn(pbp_device_block
, timeout
);
437 get_bypass_wd_pfs(char *page
, char **start
, off_t off
, int count
,
438 int *eof
, void *data
)
440 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
442 int len
= 0, ret
= 0, timeout
= 0;
444 ret
= get_bypass_wd_fn(pbp_device_block
, &timeout
);
445 if (ret
== BP_NOT_CAP
)
446 len
= sprintf(page
, "fail\n");
447 else if (timeout
== -1)
448 len
= sprintf(page
, "unknown\n");
449 else if (timeout
== 0)
450 len
= sprintf(page
, "disable\n");
452 len
= sprintf(page
, "%d\n", timeout
);
459 get_wd_expire_time_pfs(char *page
, char **start
, off_t off
, int count
,
460 int *eof
, void *data
)
462 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
464 int len
= 0, ret
= 0, timeout
= 0;
466 ret
= get_wd_expire_time_fn(pbp_device_block
, &timeout
);
467 if (ret
== BP_NOT_CAP
)
468 len
= sprintf(page
, "fail\n");
469 else if (timeout
== -1)
470 len
= sprintf(page
, "expire\n");
471 else if (timeout
== 0)
472 len
= sprintf(page
, "disable\n");
475 len
= sprintf(page
, "%d\n", timeout
);
481 get_tpl_pfs(char *page
, char **start
, off_t off
, int count
,
482 int *eof
, void *data
)
484 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
486 int len
= 0, ret
= 0;
488 ret
= get_tpl_fn(pbp_device_block
);
489 if (ret
== BP_NOT_CAP
)
490 len
= sprintf(page
, "fail\n");
492 len
= sprintf(page
, "on\n");
494 len
= sprintf(page
, "off\n");
502 get_wait_at_pwup_pfs(char *page
, char **start
, off_t off
, int count
,
503 int *eof
, void *data
)
505 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
507 int len
= 0, ret
= 0;
509 ret
= get_bp_wait_at_pwup_fn(pbp_device_block
);
510 if (ret
== BP_NOT_CAP
)
511 len
= sprintf(page
, "fail\n");
513 len
= sprintf(page
, "on\n");
515 len
= sprintf(page
, "off\n");
522 get_hw_reset_pfs(char *page
, char **start
, off_t off
, int count
,
523 int *eof
, void *data
)
525 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
527 int len
= 0, ret
= 0;
529 ret
= get_bp_hw_reset_fn(pbp_device_block
);
530 if (ret
== BP_NOT_CAP
)
531 len
= sprintf(page
, "fail\n");
533 len
= sprintf(page
, "on\n");
535 len
= sprintf(page
, "off\n");
541 #endif /*PMC_WAIT_FLAG */
544 reset_bypass_wd_pfs(char *page
, char **start
, off_t off
, int count
,
545 int *eof
, void *data
)
547 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
549 int len
= 0, ret
= 0;
551 ret
= reset_bypass_wd_timer_fn(pbp_device_block
);
552 if (ret
== BP_NOT_CAP
)
553 len
= sprintf(page
, "fail\n");
555 len
= sprintf(page
, "disable\n");
557 len
= sprintf(page
, "success\n");
564 set_dis_bypass_pfs(struct file
*file
, const char *buffer
,
565 unsigned long count
, void *data
)
569 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
571 int bypass_param
= 0, length
= 0;
573 if (copy_from_user(&kbuf
, buffer
, count
)) {
578 length
= strlen(kbuf
);
579 if (kbuf
[length
- 1] == '\n')
580 kbuf
[--length
] = '\0';
582 if (strcmp(kbuf
, "on") == 0)
584 else if (strcmp(kbuf
, "off") == 0)
587 set_dis_bypass_fn(pbp_device_block
, bypass_param
);
593 set_dis_tap_pfs(struct file
*file
, const char *buffer
,
594 unsigned long count
, void *data
)
598 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
600 int tap_param
= 0, length
= 0;
602 if (copy_from_user(&kbuf
, buffer
, count
)) {
607 length
= strlen(kbuf
);
608 if (kbuf
[length
- 1] == '\n')
609 kbuf
[--length
] = '\0';
611 if (strcmp(kbuf
, "on") == 0)
613 else if (strcmp(kbuf
, "off") == 0)
616 set_dis_tap_fn(pbp_device_block
, tap_param
);
622 set_dis_disc_pfs(struct file
*file
, const char *buffer
,
623 unsigned long count
, void *data
)
627 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
629 int tap_param
= 0, length
= 0;
631 if (copy_from_user(&kbuf
, buffer
, count
)) {
636 length
= strlen(kbuf
);
637 if (kbuf
[length
- 1] == '\n')
638 kbuf
[--length
] = '\0';
640 if (strcmp(kbuf
, "on") == 0)
642 else if (strcmp(kbuf
, "off") == 0)
645 set_dis_disc_fn(pbp_device_block
, tap_param
);
651 get_dis_bypass_pfs(char *page
, char **start
, off_t off
, int count
,
652 int *eof
, void *data
)
654 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
656 int len
= 0, ret
= 0;
658 ret
= get_dis_bypass_fn(pbp_device_block
);
659 if (ret
== BP_NOT_CAP
)
660 len
= sprintf(page
, "fail\n");
662 len
= sprintf(page
, "off\n");
664 len
= sprintf(page
, "on\n");
671 get_dis_tap_pfs(char *page
, char **start
, off_t off
, int count
,
672 int *eof
, void *data
)
674 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
676 int len
= 0, ret
= 0;
678 ret
= get_dis_tap_fn(pbp_device_block
);
679 if (ret
== BP_NOT_CAP
)
680 len
= sprintf(page
, "fail\n");
682 len
= sprintf(page
, "off\n");
684 len
= sprintf(page
, "on\n");
691 get_dis_disc_pfs(char *page
, char **start
, off_t off
, int count
,
692 int *eof
, void *data
)
694 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
696 int len
= 0, ret
= 0;
698 ret
= get_dis_disc_fn(pbp_device_block
);
699 if (ret
== BP_NOT_CAP
)
700 len
= sprintf(page
, "fail\n");
702 len
= sprintf(page
, "off\n");
704 len
= sprintf(page
, "on\n");
711 set_bypass_pwup_pfs(struct file
*file
, const char *buffer
,
712 unsigned long count
, void *data
)
716 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
718 int bypass_param
= 0, length
= 0;
720 if (copy_from_user(&kbuf
, buffer
, count
)) {
725 length
= strlen(kbuf
);
726 if (kbuf
[length
- 1] == '\n')
727 kbuf
[--length
] = '\0';
729 if (strcmp(kbuf
, "on") == 0)
731 else if (strcmp(kbuf
, "off") == 0)
734 set_bypass_pwup_fn(pbp_device_block
, bypass_param
);
740 set_bypass_pwoff_pfs(struct file
*file
, const char *buffer
,
741 unsigned long count
, void *data
)
745 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
747 int bypass_param
= 0, length
= 0;
749 if (copy_from_user(&kbuf
, buffer
, count
)) {
754 length
= strlen(kbuf
);
755 if (kbuf
[length
- 1] == '\n')
756 kbuf
[--length
] = '\0';
758 if (strcmp(kbuf
, "on") == 0)
760 else if (strcmp(kbuf
, "off") == 0)
763 set_bypass_pwoff_fn(pbp_device_block
, bypass_param
);
769 set_tap_pwup_pfs(struct file
*file
, const char *buffer
,
770 unsigned long count
, void *data
)
774 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
776 int tap_param
= 0, length
= 0;
778 if (copy_from_user(&kbuf
, buffer
, count
)) {
783 length
= strlen(kbuf
);
784 if (kbuf
[length
- 1] == '\n')
785 kbuf
[--length
] = '\0';
787 if (strcmp(kbuf
, "on") == 0)
789 else if (strcmp(kbuf
, "off") == 0)
792 set_tap_pwup_fn(pbp_device_block
, tap_param
);
798 set_disc_pwup_pfs(struct file
*file
, const char *buffer
,
799 unsigned long count
, void *data
)
803 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
805 int tap_param
= 0, length
= 0;
807 if (copy_from_user(&kbuf
, buffer
, count
)) {
812 length
= strlen(kbuf
);
813 if (kbuf
[length
- 1] == '\n')
814 kbuf
[--length
] = '\0';
816 if (strcmp(kbuf
, "on") == 0)
818 else if (strcmp(kbuf
, "off") == 0)
821 set_disc_pwup_fn(pbp_device_block
, tap_param
);
827 get_bypass_pwup_pfs(char *page
, char **start
, off_t off
, int count
,
828 int *eof
, void *data
)
830 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
832 int len
= 0, ret
= 0;
834 ret
= get_bypass_pwup_fn(pbp_device_block
);
835 if (ret
== BP_NOT_CAP
)
836 len
= sprintf(page
, "fail\n");
838 len
= sprintf(page
, "off\n");
840 len
= sprintf(page
, "on\n");
847 get_bypass_pwoff_pfs(char *page
, char **start
, off_t off
, int count
,
848 int *eof
, void *data
)
850 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
852 int len
= 0, ret
= 0;
854 ret
= get_bypass_pwoff_fn(pbp_device_block
);
855 if (ret
== BP_NOT_CAP
)
856 len
= sprintf(page
, "fail\n");
858 len
= sprintf(page
, "off\n");
860 len
= sprintf(page
, "on\n");
867 get_tap_pwup_pfs(char *page
, char **start
, off_t off
, int count
,
868 int *eof
, void *data
)
870 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
872 int len
= 0, ret
= 0;
874 ret
= get_tap_pwup_fn(pbp_device_block
);
875 if (ret
== BP_NOT_CAP
)
876 len
= sprintf(page
, "fail\n");
878 len
= sprintf(page
, "off\n");
880 len
= sprintf(page
, "on\n");
887 get_disc_pwup_pfs(char *page
, char **start
, off_t off
, int count
,
888 int *eof
, void *data
)
890 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
892 int len
= 0, ret
= 0;
894 ret
= get_disc_pwup_fn(pbp_device_block
);
895 if (ret
== BP_NOT_CAP
)
896 len
= sprintf(page
, "fail\n");
898 len
= sprintf(page
, "off\n");
900 len
= sprintf(page
, "on\n");
907 set_std_nic_pfs(struct file
*file
, const char *buffer
,
908 unsigned long count
, void *data
)
912 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
914 int bypass_param
= 0, length
= 0;
916 if (copy_from_user(&kbuf
, buffer
, count
)) {
921 length
= strlen(kbuf
);
922 if (kbuf
[length
- 1] == '\n')
923 kbuf
[--length
] = '\0';
925 if (strcmp(kbuf
, "on") == 0)
927 else if (strcmp(kbuf
, "off") == 0)
930 set_std_nic_fn(pbp_device_block
, bypass_param
);
936 get_std_nic_pfs(char *page
, char **start
, off_t off
, int count
,
937 int *eof
, void *data
)
939 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
941 int len
= 0, ret
= 0;
943 ret
= get_std_nic_fn(pbp_device_block
);
944 if (ret
== BP_NOT_CAP
)
945 len
= sprintf(page
, "fail\n");
947 len
= sprintf(page
, "off\n");
949 len
= sprintf(page
, "on\n");
956 get_wd_exp_mode_pfs(char *page
, char **start
, off_t off
, int count
,
957 int *eof
, void *data
)
959 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
961 int len
= 0, ret
= 0;
963 ret
= get_wd_exp_mode_fn(pbp_device_block
);
965 len
= sprintf(page
, "tap\n");
967 len
= sprintf(page
, "bypass\n");
969 len
= sprintf(page
, "disc\n");
972 len
= sprintf(page
, "fail\n");
979 set_wd_exp_mode_pfs(struct file
*file
, const char *buffer
,
980 unsigned long count
, void *data
)
984 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
986 int bypass_param
= 0, length
= 0;
988 if (count
> (sizeof(kbuf
) - 1))
991 if (copy_from_user(&kbuf
, buffer
, count
)) {
996 length
= strlen(kbuf
);
997 if (kbuf
[length
- 1] == '\n')
998 kbuf
[--length
] = '\0';
1000 if (strcmp(kbuf
, "tap") == 0)
1002 else if (strcmp(kbuf
, "bypass") == 0)
1004 else if (strcmp(kbuf
, "disc") == 0)
1007 set_wd_exp_mode_fn(pbp_device_block
, bypass_param
);
1013 get_wd_autoreset_pfs(char *page
, char **start
, off_t off
, int count
,
1014 int *eof
, void *data
)
1016 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
1018 int len
= 0, ret
= 0;
1020 ret
= get_wd_autoreset_fn(pbp_device_block
);
1022 len
= sprintf(page
, "%d\n", ret
);
1024 len
= sprintf(page
, "fail\n");
1031 set_wd_autoreset_pfs(struct file
*file
, const char *buffer
,
1032 unsigned long count
, void *data
)
1035 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
1037 char *timeout_ptr
= kbuf
;
1039 if (copy_from_user(&kbuf
, buffer
, count
)) {
1044 timeout
= atoi(&timeout_ptr
);
1046 set_wd_autoreset_fn(pbp_device_block
, timeout
);
1052 set_tpl_pfs(struct file
*file
, const char *buffer
,
1053 unsigned long count
, void *data
)
1057 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
1059 int tpl_param
= 0, length
= 0;
1061 if (count
> (sizeof(kbuf
) - 1))
1064 if (copy_from_user(&kbuf
, buffer
, count
)) {
1069 length
= strlen(kbuf
);
1070 if (kbuf
[length
- 1] == '\n')
1071 kbuf
[--length
] = '\0';
1073 if (strcmp(kbuf
, "on") == 0)
1075 else if (strcmp(kbuf
, "off") == 0)
1078 set_tpl_fn(pbp_device_block
, tpl_param
);
1085 set_wait_at_pwup_pfs(struct file
*file
, const char *buffer
,
1086 unsigned long count
, void *data
)
1090 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
1092 int tpl_param
= 0, length
= 0;
1094 if (count
> (sizeof(kbuf
) - 1))
1097 if (copy_from_user(&kbuf
, buffer
, count
)) {
1102 length
= strlen(kbuf
);
1103 if (kbuf
[length
- 1] == '\n')
1104 kbuf
[--length
] = '\0';
1106 if (strcmp(kbuf
, "on") == 0)
1108 else if (strcmp(kbuf
, "off") == 0)
1111 set_bp_wait_at_pwup_fn(pbp_device_block
, tpl_param
);
1117 set_hw_reset_pfs(struct file
*file
, const char *buffer
,
1118 unsigned long count
, void *data
)
1122 bpctl_dev_t
*pbp_device_block
= (bpctl_dev_t
*) data
;
1124 int tpl_param
= 0, length
= 0;
1126 if (count
> (sizeof(kbuf
) - 1))
1129 if (copy_from_user(&kbuf
, buffer
, count
)) {
1134 length
= strlen(kbuf
);
1135 if (kbuf
[length
- 1] == '\n')
1136 kbuf
[--length
] = '\0';
1138 if (strcmp(kbuf
, "on") == 0)
1140 else if (strcmp(kbuf
, "off") == 0)
1143 set_bp_hw_reset_fn(pbp_device_block
, tpl_param
);
1148 #endif /*PMC_FIX_FLAG */
1150 int bypass_proc_create_dev_sd(bpctl_dev_t
* pbp_device_block
)
1152 struct bypass_pfs_sd
*current_pfs
= &(pbp_device_block
->bypass_pfs_set
);
1153 static struct proc_dir_entry
*procfs_dir
= NULL
;
1156 sprintf(current_pfs
->dir_name
, "bypass_%s", dev
->name
);
1161 /* create device proc dir */
1162 procfs_dir
= proc_getdir(current_pfs
->dir_name
, bp_procfs_dir
);
1163 if (procfs_dir
== 0) {
1164 printk(KERN_DEBUG
"Could not create procfs directory %s\n",
1165 current_pfs
->dir_name
);
1168 current_pfs
->bypass_entry
= procfs_dir
;
1170 if (bypass_proc_create_entry(&(current_pfs
->bypass_info
), BYPASS_INFO_ENTRY_SD
, NULL
, /* write */
1171 get_bypass_info_pfs
, /* read */
1172 procfs_dir
, pbp_device_block
))
1175 if (pbp_device_block
->bp_caps
& SW_CTL_CAP
) {
1177 /* Create set param proc's */
1178 if (bypass_proc_create_entry_sd(&(current_pfs
->bypass_slave
), BYPASS_SLAVE_ENTRY_SD
, NULL
, /* write */
1179 get_bypass_slave_pfs
, /* read */
1180 procfs_dir
, pbp_device_block
))
1183 if (bypass_proc_create_entry_sd(&(current_pfs
->bypass_caps
), BYPASS_CAPS_ENTRY_SD
, NULL
, /* write */
1184 get_bypass_caps_pfs
, /* read */
1185 procfs_dir
, pbp_device_block
))
1188 if (bypass_proc_create_entry_sd(&(current_pfs
->wd_set_caps
), WD_SET_CAPS_ENTRY_SD
, NULL
, /* write */
1189 get_wd_set_caps_pfs
, /* read */
1190 procfs_dir
, pbp_device_block
))
1192 if (bypass_proc_create_entry_sd(&(current_pfs
->bypass_wd
), BYPASS_WD_ENTRY_SD
, set_bypass_wd_pfs
, /* write */
1193 get_bypass_wd_pfs
, /* read */
1194 procfs_dir
, pbp_device_block
))
1197 if (bypass_proc_create_entry_sd(&(current_pfs
->wd_expire_time
), WD_EXPIRE_TIME_ENTRY_SD
, NULL
, /* write */
1198 get_wd_expire_time_pfs
, /* read */
1199 procfs_dir
, pbp_device_block
))
1202 if (bypass_proc_create_entry_sd(&(current_pfs
->reset_bypass_wd
), RESET_BYPASS_WD_ENTRY_SD
, NULL
, /* write */
1203 reset_bypass_wd_pfs
, /* read */
1204 procfs_dir
, pbp_device_block
))
1207 if (bypass_proc_create_entry_sd(&(current_pfs
->std_nic
), STD_NIC_ENTRY_SD
, set_std_nic_pfs
, /* write */
1208 get_std_nic_pfs
, /* read */
1209 procfs_dir
, pbp_device_block
))
1212 if (pbp_device_block
->bp_caps
& BP_CAP
) {
1213 if (bypass_proc_create_entry_sd(&(current_pfs
->bypass
), BYPASS_ENTRY_SD
, set_bypass_pfs
, /* write */
1214 get_bypass_pfs
, /* read */
1219 if (bypass_proc_create_entry_sd(&(current_pfs
->dis_bypass
), DIS_BYPASS_ENTRY_SD
, set_dis_bypass_pfs
, /* write */
1220 get_dis_bypass_pfs
, /* read */
1225 if (bypass_proc_create_entry_sd(&(current_pfs
->bypass_pwup
), BYPASS_PWUP_ENTRY_SD
, set_bypass_pwup_pfs
, /* write */
1226 get_bypass_pwup_pfs
, /* read */
1230 if (bypass_proc_create_entry_sd(&(current_pfs
->bypass_pwoff
), BYPASS_PWOFF_ENTRY_SD
, set_bypass_pwoff_pfs
, /* write */
1231 get_bypass_pwoff_pfs
, /* read */
1236 if (bypass_proc_create_entry_sd(&(current_pfs
->bypass_change
), BYPASS_CHANGE_ENTRY_SD
, NULL
, /* write */
1237 get_bypass_change_pfs
, /* read */
1243 if (pbp_device_block
->bp_caps
& TAP_CAP
) {
1245 if (bypass_proc_create_entry_sd(&(current_pfs
->tap
), TAP_ENTRY_SD
, set_tap_pfs
, /* write */
1246 get_tap_pfs
, /* read */
1251 if (bypass_proc_create_entry_sd(&(current_pfs
->dis_tap
), DIS_TAP_ENTRY_SD
, set_dis_tap_pfs
, /* write */
1252 get_dis_tap_pfs
, /* read */
1257 if (bypass_proc_create_entry_sd(&(current_pfs
->tap_pwup
), TAP_PWUP_ENTRY_SD
, set_tap_pwup_pfs
, /* write */
1258 get_tap_pwup_pfs
, /* read */
1263 if (bypass_proc_create_entry_sd(&(current_pfs
->tap_change
), TAP_CHANGE_ENTRY_SD
, NULL
, /* write */
1264 get_tap_change_pfs
, /* read */
1269 if (pbp_device_block
->bp_caps
& DISC_CAP
) {
1271 if (bypass_proc_create_entry_sd(&(current_pfs
->tap
), DISC_ENTRY_SD
, set_disc_pfs
, /* write */
1272 get_disc_pfs
, /* read */
1278 if (bypass_proc_create_entry_sd(&(current_pfs
->dis_tap
), DIS_DISC_ENTRY_SD
, set_dis_disc_pfs
, /* write */
1279 get_dis_disc_pfs
, /* read */
1285 if (bypass_proc_create_entry_sd(&(current_pfs
->tap_pwup
), DISC_PWUP_ENTRY_SD
, set_disc_pwup_pfs
, /* write */
1286 get_disc_pwup_pfs
, /* read */
1291 if (bypass_proc_create_entry_sd(&(current_pfs
->tap_change
), DISC_CHANGE_ENTRY_SD
, NULL
, /* write */
1292 get_disc_change_pfs
, /* read */
1298 if (bypass_proc_create_entry_sd(&(current_pfs
->wd_exp_mode
), WD_EXP_MODE_ENTRY_SD
, set_wd_exp_mode_pfs
, /* write */
1299 get_wd_exp_mode_pfs
, /* read */
1300 procfs_dir
, pbp_device_block
))
1303 if (bypass_proc_create_entry_sd(&(current_pfs
->wd_autoreset
), WD_AUTORESET_ENTRY_SD
, set_wd_autoreset_pfs
, /* write */
1304 get_wd_autoreset_pfs
, /* read */
1305 procfs_dir
, pbp_device_block
))
1307 if (bypass_proc_create_entry_sd(&(current_pfs
->tpl
), TPL_ENTRY_SD
, set_tpl_pfs
, /* write */
1308 get_tpl_pfs
, /* read */
1309 procfs_dir
, pbp_device_block
))
1312 if (bypass_proc_create_entry_sd(&(current_pfs
->tpl
), WAIT_AT_PWUP_ENTRY_SD
, set_wait_at_pwup_pfs
, /* write */
1313 get_wait_at_pwup_pfs
, /* read */
1314 procfs_dir
, pbp_device_block
))
1316 if (bypass_proc_create_entry_sd(&(current_pfs
->tpl
), HW_RESET_ENTRY_SD
, set_hw_reset_pfs
, /* write */
1317 get_hw_reset_pfs
, /* read */
1318 procfs_dir
, pbp_device_block
))
1325 printk(KERN_DEBUG
"Create proc entry failed\n");
1330 int bypass_proc_remove_dev_sd(bpctl_dev_t
* pbp_device_block
)
1333 struct bypass_pfs_sd
*current_pfs
= &pbp_device_block
->bypass_pfs_set
;
1334 struct proc_dir_entry
*pde
= current_pfs
->bypass_entry
, *pde_curr
=
1338 for (pde
= pde
->subdir
; pde
;) {
1339 strcpy(name
, pde
->name
);
1342 remove_proc_entry(name
, current_pfs
->bypass_entry
);
1345 remove_proc_entry(current_pfs
->dir_name
, bp_procfs_dir
);
1350 #endif /* BYPASS_SUPPORT */
This page took 0.058044 seconds and 6 git commands to generate.