12 #include <linux/version.h>
14 #include <linux/kernel.h>
15 #include <linux/module.h>
17 #include <linux/pci.h>
19 #include <linux/netdevice.h>
20 #include <linux/rtnetlink.h>
25 #include <linux/sched.h>
26 #include <linux/ethtool.h>
35 #define BP_MOD_VER "9.0.4"
36 #define BP_MOD_DESCR "Silicom Bypass-SD Control driver"
37 #define BP_SYNC_FLAG 1
39 static int Device_Open = 0;
40 static int major_num = 0;
48 #define lock_bpctl() \
49 if (down_interruptible(&bpctl_sema)) { \
50 return -ERESTARTSYS; \
53 #define unlock_bpctl() \
143 static int device_num = 0;
145 static int get_dev_idx(
int ifindex);
149 static int wdt_timer(
bpctl_dev_t *pbpctl_dev,
int *time_left);
151 static void if_scan_init(
void);
160 static unsigned long str_to_hex(
char *
p);
166 int dev_num = 0,
ret = 0, ret_d = 0, time_left = 0;
177 int i = 0, ifindex, idx_dev = 0;
185 memset(&drvinfo, 0,
sizeof(drvinfo));
189 if (!drvinfo.bus_info)
191 if (!
strcmp(drvinfo.bus_info,
"N/A"))
193 memcpy(&cbuf, drvinfo.bus_info, 32);
196 while (*buf++ !=
':') ;
197 for (i = 0; i < 10; i++, buf++) {
204 bus = str_to_hex(res);
207 for (i = 0; i < 10; i++, buf++) {
214 slot = str_to_hex(res);
215 func = str_to_hex(buf);
220 bpctl_dev_arr[idx_dev].
ifindex = ifindex;
221 bpctl_dev_arr[idx_dev].
ndev =
dev;
237 ((bpctl_dev_arr[idx_dev].
pdev !=
NULL)
238 && (idx_dev < device_num)); idx_dev++) {
239 if (bpctl_dev_arr[idx_dev].
ndev == dev) {
254 ((bpctl_dev_arr[idx_dev].
pdev !=
NULL)
255 && (idx_dev < device_num)); idx_dev++) {
256 if (bpctl_dev_arr[idx_dev].
ndev == dev) {
274 if (netif_carrier_ok(dev))
277 if (((dev_num = get_dev_idx(dev->
ifindex)) == -1) ||
278 (!(pbpctl_dev = &bpctl_dev_arr[dev_num])))
282 pbpctl_dev_m = pbpctl_dev;
284 pbpctl_dev_m = get_master_port_fn(pbpctl_dev);
287 ret = bypass_status(pbpctl_dev_m);
289 printk(
"bpmod: %s is in the Bypass mode now",
291 ret_d = disc_status(pbpctl_dev_m);
294 (
"bpmod: %s is in the Disconnect mode now",
297 wdt_timer(pbpctl_dev_m, &time_left);
299 printk(
"; WDT has expired");
316 .notifier_call = bp_device_event,
322 printk(
"device_open(%p)\n", file);
334 printk(
"device_release(%p,%p)\n", inode, file);
344 unsigned int ctrl_ext,
345 unsigned char value,
unsigned char len)
347 unsigned char ctrl_val = 0;
348 unsigned int i = len;
349 unsigned int ctrl = 0;
358 if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev)))
364 ctrl_val = (value >>
i) & 0x1;
388 }
else if (pbpctl_dev->
bp_i80) {
399 }
else if (pbpctl_dev->
bp_540) {
409 }
else if (pbpctl_dev->
bp_10gb) {
418 }
else if (!pbpctl_dev->
bp_10g)
457 }
else if (pbpctl_dev->
bp_i80) {
469 }
else if (pbpctl_dev->
bp_540) {
476 }
else if (pbpctl_dev->
bp_10gb) {
486 }
else if (!pbpctl_dev->
bp_10g)
527 }
else if (pbpctl_dev->
bp_i80) {
539 }
else if (pbpctl_dev->
bp_540) {
546 }
else if (pbpctl_dev->
bp_10gb) {
555 }
else if (!pbpctl_dev->
bp_10g)
594 }
else if (pbpctl_dev->
bp_i80) {
607 }
else if (pbpctl_dev->
bp_540) {
613 }
else if (pbpctl_dev->
bp_10gb) {
623 }
else if (!pbpctl_dev->
bp_10g)
645 static int read_pulse(
bpctl_dev_t *pbpctl_dev,
unsigned int ctrl_ext,
648 unsigned char ctrl_val = 0;
649 unsigned int i = len;
650 unsigned int ctrl = 0;
658 if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev)))
681 }
else if (pbpctl_dev->
bp_i80) {
689 }
else if (pbpctl_dev->
bp_540) {
694 }
else if (pbpctl_dev->
bp_10gb) {
703 }
else if (!pbpctl_dev->
bp_10g)
735 }
else if (pbpctl_dev->
bp_i80) {
743 }
else if (pbpctl_dev->
bp_540) {
749 }
else if (pbpctl_dev->
bp_10gb) {
757 }
else if (!pbpctl_dev->
bp_10g)
777 }
else if (pbpctl_dev->
bp_540) {
779 }
else if (pbpctl_dev->
bp_10gb)
782 else if (!pbpctl_dev->
bp_10g)
795 }
else if (pbpctl_dev->
bp_i80) {
798 }
else if (pbpctl_dev->
bp_540) {
801 }
else if (pbpctl_dev->
bp_10gb) {
805 }
else if (!pbpctl_dev->
bp_10g) {
827 if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev)))
862 }
else if (pbpctl_dev->
bp_i80) {
873 }
else if (pbpctl_dev->
bp_540) {
881 }
else if (pbpctl_dev->
bp_10gb) {
889 }
else if (!pbpctl_dev->
bp_10g) {
917 write_pulse(pbpctl_dev, ctrl_ext, value,
WR_DATA_LEN);
937 }
else if (pbpctl_dev->
bp_i80) {
945 }
else if (pbpctl_dev->
bp_540) {
951 }
else if (pbpctl_dev->
bp_10gb) {
957 }
else if (!pbpctl_dev->
bp_10g)
988 static void write_data(
bpctl_dev_t *pbpctl_dev,
unsigned char value)
995 uint32_t ctrl_ext = 0, ctrl = 0, ctrl_value = 0;
1005 if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev)))
1033 }
else if (pbpctl_dev->
bp_i80) {
1044 }
else if (pbpctl_dev->
bp_540) {
1052 }
else if (pbpctl_dev->
bp_10gb) {
1078 printk(
"2reg=%x\n", ctrl_ext);
1090 }
else if (!pbpctl_dev->
bp_10g) {
1143 }
else if (pbpctl_dev->
bp_i80) {
1152 }
else if (pbpctl_dev->
bp_540) {
1157 }
else if (pbpctl_dev->
bp_10gb) {
1164 }
else if (!pbpctl_dev->
bp_10g)
1184 ctrl_value = read_pulse(pbpctl_dev, ctrl_ext,
RD_DATA_LEN);
1208 }
else if (pbpctl_dev->
bp_i80) {
1217 }
else if (pbpctl_dev->
bp_540) {
1224 }
else if (pbpctl_dev->
bp_10gb) {
1231 }
else if (!pbpctl_dev->
bp_10g) {
1267 unsigned long flags;
1276 if (!(pbpctl_dev_c = get_status_port_fn(pbpctl_dev)))
1303 }
else if (pbpctl_dev->
bp_i80) {
1313 }
else if (pbpctl_dev->
bp_540) {
1319 }
else if (pbpctl_dev->
bp_10gb) {
1326 }
else if (!pbpctl_dev->
bp_10g) {
1366 }
else if (pbpctl_dev->
bp_i80) {
1375 }
else if (pbpctl_dev->
bp_540) {
1382 }
else if (pbpctl_dev->
bp_10gb) {
1390 }
else if (!pbpctl_dev->
bp_10g)
1428 }
else if (pbpctl_dev->
bp_i80) {
1437 }
else if (pbpctl_dev->
bp_540) {
1443 }
else if (pbpctl_dev->
bp_10gb) {
1450 }
else if (!pbpctl_dev->
bp_10g)
1476 static void data_pulse(
bpctl_dev_t *pbpctl_dev,
unsigned char value)
1481 unsigned long flags;
1542 static int send_wdt_pulse(
bpctl_dev_t *pbpctl_dev)
1547 unsigned long flags;
1610 write_pulse_1(pbpctl_dev, ctrl_ext, counter, counter);
1612 pbpctl_dev->bypass_wdt_status = 0;
1614 write_pulse_1(pbpctl_dev, ctrl_ext, counter, counter);
1619 data_pulse(pbpctl_dev, counter);
1624 data_pulse(pbpctl_dev, counter);
1632 uint32_t ctrl_ext = 0, ctrl_value = 0;
1657 uint32_t ctrl_ext = 0, ctrl_value = 0;
1662 printk(
"pulse_get_fn\n");
1664 ctrl_value = read_pulse_2(pbpctl_dev, ctrl_ext);
1665 printk(
"read:%d\n", ctrl_value);
1672 uint32_t ctrl_ext = 0, ctrl_value = 0;
1678 printk(
"pulse_get_fn\n");
1681 ctrl_value = read_pulse_1(pbpctl_dev, ctrl_ext);
1682 printk(
"read:%d\n", ctrl_value);
1736 if (pbpctl_dev ==
NULL)
1739 if ((pbpctl_dev->
func == 0) || (pbpctl_dev->
func == 2)) {
1741 ((bpctl_dev_arr[idx_dev].
pdev !=
NULL)
1742 && (idx_dev < device_num)); idx_dev++) {
1743 if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->
bus)
1744 && (bpctl_dev_arr[idx_dev].
slot == pbpctl_dev->
slot)
1745 && ((bpctl_dev_arr[idx_dev].
func == 1)
1746 && (pbpctl_dev->
func == 0))) {
1748 return &(bpctl_dev_arr[idx_dev]);
1750 if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->
bus) &&
1751 (bpctl_dev_arr[idx_dev].
slot == pbpctl_dev->
slot) &&
1752 ((bpctl_dev_arr[idx_dev].
func == 3)
1753 && (pbpctl_dev->
func == 2))) {
1755 return &(bpctl_dev_arr[idx_dev]);
1766 if (pbpctl_dev ==
NULL)
1769 if ((pbpctl_dev->
func == 1) || (pbpctl_dev->
func == 3)) {
1771 ((bpctl_dev_arr[idx_dev].
pdev !=
NULL)
1772 && (idx_dev < device_num)); idx_dev++) {
1773 if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->
bus)
1774 && (bpctl_dev_arr[idx_dev].
slot == pbpctl_dev->
slot)
1775 && ((bpctl_dev_arr[idx_dev].
func == 0)
1776 && (pbpctl_dev->
func == 1))) {
1778 return &(bpctl_dev_arr[idx_dev]);
1780 if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->
bus) &&
1781 (bpctl_dev_arr[idx_dev].
slot == pbpctl_dev->
slot) &&
1782 ((bpctl_dev_arr[idx_dev].
func == 2)
1783 && (pbpctl_dev->
func == 3))) {
1785 return &(bpctl_dev_arr[idx_dev]);
1796 static void write_data_port_int(
bpctl_dev_t *pbpctl_dev,
1797 unsigned char ctrl_value)
1821 static int write_data_int(
bpctl_dev_t *pbpctl_dev,
unsigned char value)
1825 if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev)))
1828 write_data_port_int(pbpctl_dev, value & 0x3);
1829 write_data_port_int(pbpctl_dev_b, ((value & 0
xc) >> 2));
1867 write_data(pbpctl_dev,
CMND_ON);
1869 data_pulse(pbpctl_dev,
CMND_ON);
1943 write_data(pbpctl_dev,
TAP_OFF);
1956 write_data(pbpctl_dev,
TAP_ON);
1980 write_data(pbpctl_dev, 0x85);
1994 pbpctl_dev_m = pbpctl_dev;
1996 pbpctl_dev_m = get_master_port_fn(pbpctl_dev);
1997 if (pbpctl_dev_m ==
NULL)
2003 write_data(pbpctl_dev_m,
TX_DISA);
2006 write_data(pbpctl_dev_m,
TX_DISB);
2022 pbpctl_dev_m = pbpctl_dev;
2024 pbpctl_dev_m = get_master_port_fn(pbpctl_dev);
2025 if (pbpctl_dev_m ==
NULL)
2030 write_data(pbpctl_dev_m,
TX_ENA);
2032 write_data(pbpctl_dev_m,
TX_ENB);
2043 int ret = 0, ctrl = 0;
2046 if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev)))
2051 write_data(pbpctl_dev,
TPL2_ON);
2070 int ret = 0, ctrl = 0;
2073 if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev)))
2101 write_data(pbpctl_dev,
WDT_OFF);
2103 data_pulse(pbpctl_dev,
WDT_OFF);
2114 wdt_val_array[] = { 1000, 1500, 2000, 3000, 4000, 8000, 16000, 32000, 0 };
2120 unsigned int pulse = 0, temp_value = 0, temp_cnt = 0;
2124 for (; wdt_val_array[temp_cnt]; temp_cnt++)
2125 if (timeout <= wdt_val_array[temp_cnt])
2128 if (!wdt_val_array[temp_cnt])
2131 timeout = wdt_val_array[temp_cnt];
2137 write_data_int(pbpctl_dev, temp_cnt);
2148 temp_value = timeout / 100;
2149 while ((temp_value >>= 1))
2151 if (timeout > ((1 << temp_cnt) * 100))
2154 pulse = (
WDT_ON | temp_cnt);
2156 data_pulse(pbpctl_dev, pulse);
2158 write_data(pbpctl_dev, pulse);
2160 (1 << temp_cnt) * 100;
2187 while (i < timeout) {
2198 (
"bpctl_mod: Driver can't access device - SMBI bit is set.\n");
2204 for (i = 0; i < timeout; i++) {
2218 printk(
"bpctl_mod: Driver can't access the NVM\n");
2227 static void bp75_release_phy(
bpctl_dev_t *pbpctl_dev)
2232 if ((pbpctl_dev->
func == 1) || (pbpctl_dev->
func == 3))
2254 if ((pbpctl_dev->
func == 1) || (pbpctl_dev->
func == 3))
2258 fwmask = mask << 16;
2260 while (i < timeout) {
2267 if (!(swfw_sync & (fwmask | swmask)))
2277 (
"bpctl_mod: Driver can't access resource, SW_FW_SYNC timeout.\n");
2282 swfw_sync |= swmask;
2309 printk(
"bpctl_mod: MDI Read did not complete\n");
2314 printk(
"bpctl_mod: MDI Error\n");
2330 mdic = (((
u32) data) |
2343 printk(
"bpctl_mod: MDI Write did not complete\n");
2348 printk(
"bpctl_mod: MDI Error\n");
2361 ret_val = bp75_acquire_phy(pbpctl_dev);
2378 bp75_release_phy(pbpctl_dev);
2387 ret_val = bp75_acquire_phy(pbpctl_dev);
2404 bp75_release_phy(pbpctl_dev);
2413 int ret = 0, ctrl = 0;
2416 pbpctl_dev_m = pbpctl_dev;
2418 pbpctl_dev_m = get_master_port_fn(pbpctl_dev);
2419 if (pbpctl_dev_m ==
NULL)
2424 if (pbpctl_dev->
bp_540) {
2436 if (pbpctl_dev->
bp_540) {
2456 bp75_read_phy_reg(pbpctl_dev,
2465 ~BPCTLI_MII_CR_POWER_DOWN);
2472 bp75_read_phy_reg(pbpctl_dev,
2478 bp75_write_phy_reg(pbpctl_dev,
2488 }
else if (pbpctl_dev->
bp_10gb)
2491 else if (!pbpctl_dev->
bp_10g)
2508 }
else if (pbpctl_dev->
bp_10gb) {
2509 if ((pbpctl_dev->
func == 1)
2510 || (pbpctl_dev->
func == 3))
2524 }
else if (pbpctl_dev->
bp_i80) {
2529 }
else if (pbpctl_dev->
bp_540) {
2537 else if (!pbpctl_dev->
bp_10g)
2559 }
else if (pbpctl_dev->
bp_10gb) {
2560 if ((bpctl_dev_arr->
func == 1)
2561 || (bpctl_dev_arr->
func == 3))
2575 }
else if (pbpctl_dev->
bp_i80) {
2580 }
else if (pbpctl_dev->
bp_540) {
2587 else if (!pbpctl_dev->
bp_10g) {
2613 static int set_bp_force_link(
bpctl_dev_t *pbpctl_dev,
int tx_state)
2615 int ret = 0, ctrl = 0;
2807 pbpctl_dev_m = pbpctl_dev;
2809 pbpctl_dev_m = get_master_port_fn(pbpctl_dev);
2810 if (pbpctl_dev_m ==
NULL)
2832 pbpctl_dev_m = pbpctl_dev;
2834 pbpctl_dev_m = get_master_port_fn(pbpctl_dev);
2835 if (pbpctl_dev_m ==
NULL)
2891 write_data(pbpctl_dev,
TAP_OFF);
2973 unsigned long curr_time =
jiffies, delta_time = 0, wdt_on_time =
2984 wdt_on_time) ? (curr_time - wdt_on_time) : (~wdt_on_time +
2988 if (time_left < 0) {
3001 static int wdt_timer(
bpctl_dev_t *pbpctl_dev,
int *time_left)
3017 static int wdt_timer_reload(
bpctl_dev_t *pbpctl_dev)
3027 ret = wdt_pulse(pbpctl_dev);
3029 ret = wdt_pulse_int(pbpctl_dev);
3031 ret = send_wdt_pulse(pbpctl_dev);
3039 static void wd_reset_timer(
unsigned long param)
3054 skb_tmp = dev_alloc_skb(BPTEST_DATA_LEN + 2);
3055 if ((skb_tmp) && (pbpctl_dev->
ndev) && (pbpctl_dev->
bp_tx_data)) {
3058 skb_tmp->
dev = pbpctl_dev->
ndev;
3063 goto bp_timer_reload;
3069 wdt_timer_reload(pbpctl_dev);
3145 uint32_t status_reg = 0, status_reg1 = 0;
3172 ~WDTE_DISC_BPN_MASK,
3177 status_reg & ~WDTE_TAP_BPN_MASK,
3184 status_reg | WDTE_TAP_BPN_MASK,
3217 pbpctl_dev_m = pbpctl_dev;
3219 pbpctl_dev_m = get_master_port_fn(pbpctl_dev);
3220 if (pbpctl_dev_m ==
NULL)
3227 if (pbpctl_dev->
bp_540) {
3259 }
else if (pbpctl_dev->
bp_10gb) {
3266 if ((pbpctl_dev->
func == 1) || (pbpctl_dev->
func == 3))
3278 if (!pbpctl_dev->
bp_10g) {
3282 return ((ctrl & BPCTLI_CTRL_SWDPIN1) !=
3284 if (pbpctl_dev->
bp_540) {
3299 static int bp_force_link_status(
bpctl_dev_t *pbpctl_dev)
3319 && (pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) {
3336 && (pbpctl_dev_b = get_status_port_fn(pbpctl_dev))) {
3351 BYPASS_FLAG_MASK) ? 1 : 0);
3410 if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev)))
3433 }
else if (pbpctl_dev->
bp_540) {
3439 || (pbpctl_dev->
bp_i80)) {
3442 }
else if (pbpctl_dev->
bp_10gb) {
3456 else if (!pbpctl_dev->
bp_10g)
3475 BPCTLI_CTRL_SWDPIN1) != 0 ? 1 : 0);
3494 == DFLT_PWRON_MASK) ? 0 : 1);
3503 static int default_pwroff_status(
bpctl_dev_t *pbpctl_dev)
3524 DIS_BYPASS_CAP_MASK) ? 1 : 0);
3563 *timeout = (1 << wdt_val) * 100;
3567 int curr_wdt_status = pbpctl_dev->
wdt_status;
3698 if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev)))
3735 DFLT_PWRON_TAP_MASK) ? 1 : 0);
3746 DIS_TAP_CAP_MASK) ? 1 : 0);
3794 if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev)))
3800 if (pbpctl_dev->
bp_i80) {
3805 if (pbpctl_dev->
bp_540) {
3815 DISC_OFF_MASK) == DISC_OFF_MASK) ? 1 : 0);
3819 BPCTLI_CTRL_SWDPIN1) != 0 ? 1 : 0);
3836 BPCTLI_CTRL_SWDPIN1) != 0 ? 1 : 0);
3837 }
else if (pbpctl_dev->
bp_10gb) {
3850 if (!pbpctl_dev->
bp_10g) {
3878 return ((ctrl == 0) ? 1 : 0);
3890 DFLT_PWRON_DISC_MASK) ? 1 : 0);
3901 DIS_DISC_CAP_MASK) ? 1 : 0);
3912 pbpctl_dev_m = pbpctl_dev;
3914 pbpctl_dev_m = get_master_port_fn(pbpctl_dev);
3915 if (pbpctl_dev_m ==
NULL)
3936 pbpctl_dev_m = pbpctl_dev;
3938 pbpctl_dev_m = get_master_port_fn(pbpctl_dev);
3939 if (pbpctl_dev_m ==
NULL)
3971 WDTE_TAP_BPN_MASK) ? 1 : 0);
3992 if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev)))
4008 WAIT_AT_PWUP_MASK) ? 1 : 0);
4021 EN_HW_RESET_MASK) ? 1 : 0);
4084 printk(
"VER_REG reg1=%x\n", ret);
4086 printk(
"PRODUCT_CAP reg=%x\n", ret);
4088 printk(
"STATUS_TAP reg1=%x\n", ret);
4090 printk(
"SIG_REG reg1=%x\n", ret);
4092 printk(
"STATUS_REG_ADDR=%x\n", ret);
4094 printk(
"WDT_REG_ADDR=%x\n", ret);
4096 printk(
"TMRL_REG_ADDR=%x\n", ret);
4098 printk(
"TMRH_REG_ADDR=%x\n", ret);
4103 }
else if (pbpctl_dev->
bp_10gb) {
4111 else if (pbpctl_dev->
bp_540)
4113 else if (!pbpctl_dev->
bp_10g) {
4200 NORMAL_UNSUPPORT_MASK)
4212 BYPASS_SUPPORT_MASK) {
4248 DISC_PORT_SUPPORT_MASK) {
4272 if ((pbpctl_dev->
subdevice & 0xa00) == 0xa00)
4280 pbpctl_dev_m = get_master_port_fn(pbpctl_dev);
4281 if (pbpctl_dev_m !=
NULL) {
4286 DISC_PORT_SUPPORT_MASK)
4298 if ((ret =
cmnd_on(pbpctl_dev)) < 0)
4321 pbpctl_dev_sl = get_status_port_fn(pbpctl_dev);
4322 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31))
4323 if (pbpctl_dev_sl && (pbpctl_dev_sl->
ndev)
4324 && (pbpctl_dev_sl->
ndev->hard_start_xmit)
4327 pbpctl_dev_sl->
ndev->hard_start_xmit =
4332 if (pbpctl_dev_sl && (pbpctl_dev_sl->
ndev)) {
4333 if ((pbpctl_dev_sl->
ndev->netdev_ops)
4334 && (pbpctl_dev_sl->
old_ops)) {
4336 pbpctl_dev_sl->
ndev->netdev_ops =
4356 pbpctl_dev->
bp_timer.function = &wd_reset_timer;
4371 ((bpctl_dev_arr[idx_dev].
ndev !=
NULL) && (idx_dev < device_num));
4373 if (bpctl_dev_arr[idx_dev].
ndev == dev) {
4374 pbpctl_dev = &bpctl_dev_arr[idx_dev];
4382 pbpctl_dev_m = get_master_port_fn(pbpctl_dev);
4385 if (bypass_status(pbpctl_dev_m)) {
4390 wdt_timer_reload(pbpctl_dev_m);
4429 int set_bp_self_test(
bpctl_dev_t *pbpctl_dev,
unsigned int param)
4435 pbpctl_dev_sl = get_status_port_fn(pbpctl_dev);
4436 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31))
4437 if ((pbpctl_dev_sl->
ndev) &&
4438 (pbpctl_dev_sl->
ndev->hard_start_xmit)) {
4443 pbpctl_dev_sl->
ndev->hard_start_xmit;
4444 pbpctl_dev_sl->
ndev->hard_start_xmit =
4447 pbpctl_dev_sl->
ndev->hard_start_xmit =
4453 if ((pbpctl_dev_sl->
ndev) && (pbpctl_dev_sl->
ndev->netdev_ops)) {
4458 pbpctl_dev_sl->
ndev->netdev_ops;
4461 pbpctl_dev_sl->
new_ops.ndo_start_xmit =
4463 pbpctl_dev_sl->
ndev->netdev_ops =
4466 }
else if (pbpctl_dev_sl->
old_ops) {
4467 pbpctl_dev_sl->
ndev->netdev_ops =
4504 return (((pbpctl_dev->
func == 0) || (pbpctl_dev->
func == 2)) ? 1 : 0);
4513 if ((ret =
cmnd_on(pbpctl_dev)) < 0)
4526 return bypass_status(pbpctl_dev);
4545 if ((ret =
cmnd_on(pbpctl_dev)) < 0)
4571 if ((ret =
cmnd_on(pbpctl_dev)) < 0)
4586 return default_pwroff_status(pbpctl_dev);
4597 if ((ret =
cmnd_on(pbpctl_dev)) < 0)
4624 if ((ret =
cmnd_on(pbpctl_dev)) < 0)
4629 wdt_on(pbpctl_dev, timeout);
4649 return wdt_timer(pbpctl_dev, time_left);
4657 return wdt_timer_reload(pbpctl_dev);
4671 while ((step_value >>= 1))
4693 if ((ret =
cmnd_on(pbpctl_dev)) < 0)
4742 && ((
cmnd_on(pbpctl_dev)) >= 0)) {
4761 return ((ret == 0) ? 1 : 0);
4820 ret = disc_status(pbpctl_dev);
4832 && ((
cmnd_on(pbpctl_dev)) >= 0)) {
4850 return (ret == 0 ? 1 : (ret < 0 ?
BP_NOT_CAP : 0));
4870 && ((
cmnd_on(pbpctl_dev)) >= 0)) {
4936 return ((ret == 0) ? 1 : 0);
4961 if ((ret =
cmnd_on(pbpctl_dev)) < 0)
4977 }
else if ((pbpctl_dev_b = get_master_port_fn(pbpctl_dev))) {
4982 return set_tx(pbpctl_dev, tx_state);
4989 if ((dev_num < 0) || (dev_num > device_num)
4990 || (bpctl_dev_arr[dev_num].
pdev ==
NULL))
4992 bpctl_dev_curr = &bpctl_dev_arr[dev_num];
4994 return set_bp_force_link(bpctl_dev_curr, tx_state);
5014 int set_bp_self_test_fn(
bpctl_dev_t *pbpctl_dev,
int param)
5019 return set_bp_self_test(pbpctl_dev, param);
5027 return get_bp_self_test(pbpctl_dev);
5047 if ((pbpctl_dev->
func == 0) || (pbpctl_dev->
func == 2)) {
5049 ((bpctl_dev_arr[idx_dev].
pdev !=
NULL)
5050 && (idx_dev < device_num)); idx_dev++) {
5051 if ((bpctl_dev_arr[idx_dev].bus == pbpctl_dev->
bus)
5052 && (bpctl_dev_arr[idx_dev].
slot ==
5053 pbpctl_dev->
slot)) {
5054 if ((pbpctl_dev->
func == 0)
5055 && (bpctl_dev_arr[idx_dev].
func == 1)) {
5057 &bpctl_dev_arr[idx_dev];
5060 if ((pbpctl_dev->
func == 2) &&
5061 (bpctl_dev_arr[idx_dev].
func == 3)) {
5063 &bpctl_dev_arr[idx_dev];
5078 if ((pbpctl_dev->
func == 0) || (pbpctl_dev->
func == 2))
5094 }
else if ((pbpctl_dev_b = get_master_port_fn(pbpctl_dev))) {
5106 if ((dev_num < 0) || (dev_num > device_num)
5107 || (bpctl_dev_arr[dev_num].
pdev ==
NULL))
5109 bpctl_dev_curr = &bpctl_dev_arr[dev_num];
5111 return bp_force_link_status(bpctl_dev_curr);
5114 static int get_bypass_link_status(
bpctl_dev_t *pbpctl_dev)
5121 BPCTLI_CTRL_SWDPIN1));
5128 static void bp_tpl_timer_fn(
unsigned long param)
5134 if (!(pbpctl_dev_b = get_status_port_fn(pbpctl_dev)))
5142 link1 = get_bypass_link_status(pbpctl_dev);
5144 link2 = get_bypass_link_status(pbpctl_dev_b);
5145 if ((link1) && (
tx_status(pbpctl_dev))) {
5146 if ((!link2) && (
tx_status(pbpctl_dev_b))) {
5151 }
else if ((!link1) && (
tx_status(pbpctl_dev))) {
5152 if ((link2) && (
tx_status(pbpctl_dev_b))) {
5155 }
else if ((link1) && (!
tx_status(pbpctl_dev))) {
5156 if ((link2) && (
tx_status(pbpctl_dev_b))) {
5159 }
else if ((!link1) && (!
tx_status(pbpctl_dev))) {
5160 if ((link2) && (
tx_status(pbpctl_dev_b))) {
5173 pbpctl_dev_b = get_status_port_fn(pbpctl_dev);
5178 pbpctl_dev_b = get_status_port_fn(pbpctl_dev);
5234 pbpctl_dev_b = get_status_port_fn(pbpctl_dev);
5238 if ((pbpctl_dev_b = get_status_port_fn(pbpctl_dev)))
5354 ((bpctl_dev_arr[idx_dev].
pdev !=
NULL) && (idx_dev < device_num));
5356 if ((bus == bpctl_dev_arr[idx_dev].bus)
5357 && (slot == bpctl_dev_arr[idx_dev].
slot)
5358 && (func == bpctl_dev_arr[idx_dev].func))
5365 static void str_low(
char *
str)
5369 for (i = 0; i <
strlen(str); i++)
5370 if ((str[i] >= 65) && (str[
i] <= 90))
5374 static unsigned long str_to_hex(
char *
p)
5376 unsigned long hex = 0;
5378 unsigned char dig = 0;
5388 dig = dig <
'a' ? (dig -
'0') : (dig -
'a' + 0xa);
5389 hex |= (dig << shift);
5395 static int get_dev_idx(
int ifindex)
5400 ((bpctl_dev_arr[idx_dev].
pdev !=
NULL) && (idx_dev < device_num));
5402 if (ifindex == bpctl_dev_arr[idx_dev].ifindex)
5414 ((bpctl_dev_arr[idx_dev].
pdev !=
NULL) && (idx_dev < device_num));
5416 if (ifindex == bpctl_dev_arr[idx_dev].ifindex)
5417 return &bpctl_dev_arr[idx_dev];
5423 static void if_scan_init(
void)
5432 #if (LINUX_VERSION_CODE >= 0x020618)
5434 #elif (LINUX_VERSION_CODE >= 0x20616)
5437 for (dev = dev_base;
dev; dev = dev->next)
5453 memset(&drvinfo, 0,
sizeof(drvinfo));
5457 if (!drvinfo.bus_info)
5459 if (!
strcmp(drvinfo.bus_info,
"N/A"))
5461 memcpy(&cbuf, drvinfo.bus_info, 32);
5464 while (*buf++ !=
':') ;
5465 for (i = 0; i < 10; i++, buf++) {
5472 bus = str_to_hex(res);
5475 for (i = 0; i < 10; i++, buf++) {
5482 slot = str_to_hex(res);
5483 func = str_to_hex(buf);
5486 if (idx_dev != -1) {
5488 bpctl_dev_arr[idx_dev].
ifindex = ifindex;
5489 bpctl_dev_arr[idx_dev].
ndev =
dev;
5500 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
5503 unsigned int ioctl_num,
5504 unsigned long ioctl_param)
5506 static long device_ioctl(
struct file *file,
5507 unsigned int ioctl_num,
5508 unsigned long ioctl_param)
5516 unsigned long flags;
5520 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30))
5561 if (!spin_trylock(&bpvm_lock)) {
5581 if (dev_idx < 0 || dev_idx > device_num) {
5587 spin_unlock_irqrestore(&bpvm_lock, flags);
5596 if ((bpctl_dev_arr[dev_idx].bp_10gb)
5597 && (!(bpctl_dev_arr[dev_idx].ifindex))) {
5598 printk(
"Please load network driver for %s adapter!\n",
5599 bpctl_dev_arr[dev_idx].
name);
5604 spin_unlock_irqrestore(&bpvm_lock, flags);
5608 if ((bpctl_dev_arr[dev_idx].bp_10gb) && (bpctl_dev_arr[dev_idx].
ndev)) {
5609 if (!(bpctl_dev_arr[dev_idx].ndev->flags &
IFF_UP)) {
5610 if (!(bpctl_dev_arr[dev_idx].ndev->flags & IFF_UP)) {
5612 (
"Please bring up network interfaces for %s adapter!\n",
5613 bpctl_dev_arr[dev_idx].
name);
5618 spin_unlock_irqrestore(&bpvm_lock, flags);
5625 if ((dev_idx < 0) || (dev_idx > device_num)
5626 || (bpctl_dev_arr[dev_idx].pdev ==
NULL)) {
5631 pbpctl_dev = &bpctl_dev_arr[dev_idx];
5633 switch (ioctl_num) {
5751 spin_unlock_irqrestore(&bpvm_lock, flags);
5891 spin_unlock_irqrestore(&bpvm_lock, flags);
5898 spin_unlock_irqrestore(&bpvm_lock, flags);
5903 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30))
5914 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
5915 .ioctl = device_ioctl,
5917 .unlocked_ioctl = device_ioctl,
5920 .open = device_open,
5921 .release = device_release,
5925 #define PCI_DEVICE(vend,dev) \
5926 .vendor = (vend), .device = (dev), \
5927 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
5930 #define SILICOM_E1000BP_ETHERNET_DEVICE(device_id) {\
5931 PCI_DEVICE(SILICOM_VID, device_id)}
6108 {
"Silicom Bypass PXG2BPFI-SD series adapter"},
6109 {
"Silicom Bypass PXG2BPFIL-SD series adapter"},
6110 {
"Silicom Bypass PXG2BPFILX-SD series adapter"},
6111 {
"Silicom Bypass PXG2BPFILLX-SD series adapter"},
6112 {
"Silicom Bypass PXG2BPI-SD series adapter"},
6113 {
"Silicom Bypass PXG2BPIG-SD series adapter"},
6114 {
"Silicom Bypass PXG2TBFI-SD series adapter"},
6115 {
"Silicom Bypass PXG4BPI-SD series adapter"},
6116 {
"Silicom Bypass PXG4BPFI-SD series adapter"},
6117 {
"Silicom Bypass PEG4BPI-SD series adapter"},
6118 {
"Silicom Bypass PEG2BPI-SD series adapter"},
6119 {
"Silicom Bypass PEG4BPIN-SD series adapter"},
6120 {
"Silicom Bypass PEG2BPFI-SD series adapter"},
6121 {
"Silicom Bypass PEG2BPFI-LX-SD series adapter"},
6122 {
"Silicom Bypass PMCX2BPFI-SD series adapter"},
6123 {
"Silicom Bypass PMCX2BPFI-N series adapter"},
6124 {
"Intel Bypass PEG2BPII series adapter"},
6125 {
"Intel Bypass PEG2BPFII series adapter"},
6126 {
"Silicom Bypass PXG4BPFILX-SD series adapter"},
6127 {
"Silicom Bypass PMCX2BPI-N series adapter"},
6128 {
"Silicom Bypass PMCX4BPI-N series adapter"},
6129 {
"Silicom Bypass PXG2BISC1-SD series adapter"},
6130 {
"Silicom Bypass PEG2TBFI-SD series adapter"},
6131 {
"Silicom Bypass PXG2TBI-SD series adapter"},
6132 {
"Silicom Bypass PXG4BPFID-SD series adapter"},
6133 {
"Silicom Bypass PEG4BPFI-SD series adapter"},
6134 {
"Silicom Bypass PEG4BPIPT-SD series adapter"},
6135 {
"Silicom Bypass PXG6BPI-SD series adapter"},
6136 {
"Silicom Bypass PEG4BPIL-SD series adapter"},
6137 {
"Silicom Bypass PMCX2BPI-N2 series adapter"},
6138 {
"Silicom Bypass PMCX4BPI-N2 series adapter"},
6139 {
"Silicom Bypass PMCX2BPI-SD series adapter"},
6140 {
"Silicom Bypass PEG2BPFID-SD series adapter"},
6141 {
"Silicom Bypass PEG2BPFIDLX-SD series adapter"},
6142 {
"Silicom Bypass PMCX4BPI-SD series adapter"},
6143 {
"Silicom Bypass MEG2BPFILN-SD series adapter"},
6144 {
"Silicom Bypass MEG2BPFINX-SD series adapter"},
6145 {
"Silicom Bypass PEG4BPFILX-SD series adapter"},
6146 {
"Silicom Bypass PE10G2BPISR-SD series adapter"},
6147 {
"Silicom Bypass PE10G2BPILR-SD series adapter"},
6148 {
"Silicom Bypass MHIO8AD-SD series adapter"},
6149 {
"Silicom Bypass PE10G2BPICX4-SD series adapter"},
6150 {
"Silicom Bypass PEG2BPI5-SD series adapter"},
6151 {
"Silicom Bypass PEG6BPI5-SD series adapter"},
6152 {
"Silicom Bypass PEG4BPFI5-SD series adapter"},
6153 {
"Silicom Bypass PEG4BPFI5LX-SD series adapter"},
6154 {
"Silicom Bypass MEG2BPFILXLN-SD series adapter"},
6155 {
"Silicom Bypass PEG2BPIX1-SD series adapter"},
6156 {
"Silicom Bypass MEG2BPFILXNX-SD series adapter"},
6157 {
"Silicom Bypass XE10G2BPIT-SD series adapter"},
6158 {
"Silicom Bypass XE10G2BPICX4-SD series adapter"},
6159 {
"Silicom Bypass XE10G2BPISR-SD series adapter"},
6160 {
"Silicom Bypass XE10G2BPILR-SD series adapter"},
6161 {
"Intel Bypass PEG2BPFII0 series adapter"},
6162 {
"Silicom Bypass XE10G2BPIXR series adapter"},
6163 {
"Silicom Bypass PE10G2DBISR series adapter"},
6164 {
"Silicom Bypass PEG2BI5SC6 series adapter"},
6165 {
"Silicom Bypass PEG6BPI5FC series adapter"},
6167 {
"Silicom Bypass PE10G2BPTCX4 series adapter"},
6168 {
"Silicom Bypass PE10G2BPTSR series adapter"},
6169 {
"Silicom Bypass PE10G2BPTLR series adapter"},
6170 {
"Silicom Bypass PE10G2BPTT series adapter"},
6171 {
"Silicom Bypass PEG4BPI6 series adapter"},
6172 {
"Silicom Bypass PEG4BPFI6 series adapter"},
6173 {
"Silicom Bypass PEG4BPFI6LX series adapter"},
6174 {
"Silicom Bypass PEG4BPFI6ZX series adapter"},
6175 {
"Silicom Bypass PEG2BPI6 series adapter"},
6176 {
"Silicom Bypass PEG2BPFI6 series adapter"},
6177 {
"Silicom Bypass PEG2BPFI6LX series adapter"},
6178 {
"Silicom Bypass PEG2BPFI6ZX series adapter"},
6179 {
"Silicom Bypass PEG2BPFI6FLXM series adapter"},
6180 {
"Silicom Bypass PEG4BPI6FC series adapter"},
6181 {
"Silicom Bypass PEG4BPFI6FC series adapter"},
6182 {
"Silicom Bypass PEG4BPFI6FCLX series adapter"},
6183 {
"Silicom Bypass PEG4BPFI6FCZX series adapter"},
6184 {
"Silicom Bypass PEG6BPI6 series adapter"},
6185 {
"Silicom Bypass PEG2BPI6SC6 series adapter"},
6186 {
"Silicom Bypass MEG2BPI6 series adapter"},
6187 {
"Silicom Bypass XEG2BPI6 series adapter"},
6188 {
"Silicom Bypass MEG4BPI6 series adapter"},
6189 {
"Silicom Bypass PEG2BPFI5-SD series adapter"},
6190 {
"Silicom Bypass PEG2BPFI5LX-SD series adapter"},
6191 {
"Silicom Bypass PXEG4BPFI-SD series adapter"},
6192 {
"Silicom Bypass MxEG2BPI6 series adapter"},
6193 {
"Silicom Bypass MxEG2BPFI6 series adapter"},
6194 {
"Silicom Bypass MxEG2BPFI6LX series adapter"},
6195 {
"Silicom Bypass MxEG2BPFI6ZX series adapter"},
6196 {
"Silicom Bypass MxEG4BPI6 series adapter"},
6197 {
"Silicom Bypass MxEG4BPFI6 series adapter"},
6198 {
"Silicom Bypass MxEG4BPFI6LX series adapter"},
6199 {
"Silicom Bypass MxEG4BPFI6ZX series adapter"},
6200 {
"Silicom Bypass MxEG6BPI6 series adapter"},
6201 {
"Silicom Bypass MxE2G4BPi80 series adapter"},
6202 {
"Silicom Bypass MxE2G4BPFi80 series adapter"},
6203 {
"Silicom Bypass MxE2G4BPFi80LX series adapter"},
6204 {
"Silicom Bypass MxE2G4BPFi80ZX series adapter"},
6206 {
"Silicom Bypass PE210G2SPI9 series adapter"},
6208 {
"Silicom Bypass MxE210G2BPI9CX4 series adapter"},
6209 {
"Silicom Bypass MxE210G2BPI9SR series adapter"},
6210 {
"Silicom Bypass MxE210G2BPI9LR series adapter"},
6211 {
"Silicom Bypass MxE210G2BPI9T series adapter"},
6213 {
"Silicom Bypass PE210G2BPI9CX4 series adapter"},
6214 {
"Silicom Bypass PE210G2BPI9SR series adapter"},
6215 {
"Silicom Bypass PE210G2BPI9LR series adapter"},
6216 {
"Silicom Bypass PE210G2BPI9T series adapter"},
6218 {
"Silicom Bypass M2EG2BPFI6 series adapter"},
6219 {
"Silicom Bypass M2EG2BPFI6LX series adapter"},
6220 {
"Silicom Bypass M2EG2BPFI6ZX series adapter"},
6221 {
"Silicom Bypass M2EG4BPI6 series adapter"},
6222 {
"Silicom Bypass M2EG4BPFI6 series adapter"},
6223 {
"Silicom Bypass M2EG4BPFI6LX series adapter"},
6224 {
"Silicom Bypass M2EG4BPFI6ZX series adapter"},
6225 {
"Silicom Bypass M2EG6BPI6 series adapter"},
6227 {
"Silicom Bypass PEG2DBI6 series adapter"},
6228 {
"Silicom Bypass PEG2DBFI6 series adapter"},
6229 {
"Silicom Bypass PEG2DBFI6LX series adapter"},
6230 {
"Silicom Bypass PEG2DBFI6ZX series adapter"},
6232 {
"Silicom Bypass PE2G4BPi80 series adapter"},
6233 {
"Silicom Bypass PE2G4BPFi80 series adapter"},
6234 {
"Silicom Bypass PE2G4BPFi80LX series adapter"},
6235 {
"Silicom Bypass PE2G4BPFi80ZX series adapter"},
6237 {
"Silicom Bypass PE2G4BPi80L series adapter"},
6238 {
"Silicom Bypass MxE2G8BPi80A series adapter"},
6240 {
"Silicom Bypass PE2G2BPi35 series adapter"},
6241 {
"Silicom Bypass PAC1200BPi35 series adapter"},
6242 {
"Silicom Bypass PE2G2BPFi35 series adapter"},
6243 {
"Silicom Bypass PE2G2BPFi35LX series adapter"},
6244 {
"Silicom Bypass PE2G2BPFi35ZX series adapter"},
6246 {
"Silicom Bypass PE2G4BPi35 series adapter"},
6247 {
"Silicom Bypass PE2G4BPi35L series adapter"},
6248 {
"Silicom Bypass PE2G4BPFi35 series adapter"},
6249 {
"Silicom Bypass PE2G4BPFi35LX series adapter"},
6250 {
"Silicom Bypass PE2G4BPFi35ZX series adapter"},
6252 {
"Silicom Bypass PE2G6BPi35 series adapter"},
6253 {
"Silicom Bypass PE2G6BPi35CX series adapter"},
6255 {
"Silicom Bypass PE2G2BPi80 series adapter"},
6256 {
"Silicom Bypass PE2G2BPFi80 series adapter"},
6257 {
"Silicom Bypass PE2G2BPFi80LX series adapter"},
6258 {
"Silicom Bypass PE2G2BPFi80ZX series adapter"},
6260 {
"Silicom Bypass M2E10G2BPI9CX4 series adapter"},
6261 {
"Silicom Bypass M2E10G2BPI9SR series adapter"},
6262 {
"Silicom Bypass M2E10G2BPI9LR series adapter"},
6263 {
"Silicom Bypass M2E10G2BPI9T series adapter"},
6264 {
"Silicom Bypass MxE2G8BPi80 series adapter"},
6265 {
"Silicom Bypass PE210G2DBi9SR series adapter"},
6266 {
"Silicom Bypass PE210G2DBi9SRRB series adapter"},
6267 {
"Silicom Bypass PE210G2DBi9LR series adapter"},
6268 {
"Silicom Bypass PE210G2DBi9LRRB series adapter"},
6269 {
"Silicom Bypass PE310G4DBi9-SR series adapter"},
6270 {
"Silicom Bypass PE310G4BPi9T series adapter"},
6271 {
"Silicom Bypass PE310G4BPi9SR series adapter"},
6272 {
"Silicom Bypass PE310G4BPi9LR series adapter"},
6273 {
"Silicom Bypass PE210G2BPi40T series adapter"},
6749 static int __init bypass_init_module(
void)
6751 int ret_val,
idx, idx_dev = 0;
6753 unsigned long mmio_start, mmio_len;
6756 ret_val = register_chrdev(major_num,
DEVICE_NAME, &Fops);
6761 major_num = ret_val;
6762 for (idx = 0; tx_ctl_pci_tbl[
idx].
vendor; idx++) {
6764 tx_ctl_pci_tbl[idx].
device,
6773 printk(
"No such device\n");
6780 if (!bpctl_dev_arr) {
6781 printk(
"Allocation error\n");
6788 for (idx = 0; tx_ctl_pci_tbl[
idx].
vendor; idx++) {
6790 tx_ctl_pci_tbl[idx].
device,
6794 bpctl_dev_arr[idx_dev].
pdev = pdev1;
6799 bpctl_dev_arr[idx_dev].
desc =
6801 bpctl_dev_arr[idx_dev].
name =
6803 bpctl_dev_arr[idx_dev].
device =
6805 bpctl_dev_arr[idx_dev].
vendor =
6814 bpctl_dev_arr[idx_dev].
bus = pdev1->
bus->number;
6815 bpctl_dev_arr[idx_dev].
mem_map =
6821 bpctl_dev_arr[idx_dev].
bp_10g9 = 1;
6823 bpctl_dev_arr[idx_dev].
bp_10g = 1;
6826 bpctl_dev_arr[idx_dev].
bp_540 = 1;
6831 bpctl_dev_arr[idx_dev].
bp_i80 = 1;
6833 bpctl_dev_arr[idx_dev].
bp_i80 = 1;
6834 if ((bpctl_dev_arr[idx_dev].subdevice & 0xa00) == 0xa00)
6835 bpctl_dev_arr[idx_dev].
bp_i80 = 1;
6837 if (bpctl_dev_arr[idx_dev].ifindex == 0) {
6838 unregister_chrdev(major_num,
6841 (
"Please load network driver for %s adapter!\n",
6842 bpctl_dev_arr[idx_dev].
name);
6846 if (bpctl_dev_arr[idx_dev].ndev) {
6848 (bpctl_dev_arr[idx_dev].ndev->
6851 (bpctl_dev_arr[idx_dev].
6852 ndev->flags & IFF_UP)) {
6857 (
"Please bring up network interfaces for %s adapter!\n",
6865 bpctl_dev_arr[idx_dev].
bp_10gb = 1;
6868 if (!bpctl_dev_arr[idx_dev].bp_10g9) {
6872 bpctl_dev_arr[idx_dev].
name);
6874 (bpctl_dev_arr[idx_dev].subdevice))
6877 (bpctl_dev_arr[idx_dev].
6879 bpctl_dev_arr[idx_dev].
6882 bpctl_dev_arr[idx_dev].
6886 if ((bpctl_dev_arr[idx_dev].bp_10gb ==
6888 && (bpctl_dev_arr[idx_dev].
6889 bp_fw_ver == 0xff)) {
6904 bpctl_dev_arr[idx_dev].
6910 bpctl_dev_arr[idx_dev].
6923 printk(
"firmware version: 0x%x\n",
6924 bpctl_dev_arr[idx_dev].
6930 atomic_set(&bpctl_dev_arr[idx_dev].wdt_busy, 0);
6938 (bpctl_dev_arr[idx_dev].subdevice))
6942 if ((bpctl_dev_arr[idx_dev].bp_tx_data =
6945 memset(bpctl_dev_arr[idx_dev].bp_tx_data, 0x0,
6948 memset(bpctl_dev_arr[idx_dev].bp_tx_data, 0xff,
6950 memset(bpctl_dev_arr[idx_dev].bp_tx_data + 6,
6952 memset(bpctl_dev_arr[idx_dev].bp_tx_data + 7,
6955 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
6957 (ETH_P_BPTEST >> 8) & 0xff;
6959 ETH_P_BPTEST & 0xff;
6961 *(
__be16 *) (bpctl_dev_arr[idx_dev].bp_tx_data +
6962 12) =
htons(ETH_P_BPTEST);
6966 printk(
"bp_ctl: Memory allocation error!\n");
6974 sema_init(&bpctl_sema, 1);
6980 ((bpctl_dev_arr[idx_dev].
pdev !=
NULL)
6981 && (idx_dev < device_num)); idx_dev++) {
6982 if (bpctl_dev_arr[idx_dev].bp_10g9) {
6984 get_status_port_fn(&bpctl_dev_arr[idx_dev]);
6987 bpctl_dev_arr[idx_dev].
name);
6991 printk(
"firmware version: 0x%x\n",
6992 bpctl_dev_arr[idx_dev].
6999 atomic_set(&bpctl_dev_arr[idx_dev].wdt_busy, 0);
7012 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
7014 inter_module_register(
"get_bypass_slave_sd",
THIS_MODULE,
7016 inter_module_register(
"get_bypass_caps_sd",
THIS_MODULE,
7018 inter_module_register(
"get_wd_set_caps_sd",
THIS_MODULE,
7022 inter_module_register(
"get_bypass_change_sd",
THIS_MODULE,
7024 inter_module_register(
"set_dis_bypass_sd",
THIS_MODULE,
7026 inter_module_register(
"get_dis_bypass_sd",
THIS_MODULE,
7028 inter_module_register(
"set_bypass_pwoff_sd",
THIS_MODULE,
7030 inter_module_register(
"get_bypass_pwoff_sd",
THIS_MODULE,
7032 inter_module_register(
"set_bypass_pwup_sd",
THIS_MODULE,
7034 inter_module_register(
"get_bypass_pwup_sd",
THIS_MODULE,
7036 inter_module_register(
"get_bypass_wd_sd",
THIS_MODULE,
7038 inter_module_register(
"set_bypass_wd_sd",
THIS_MODULE,
7040 inter_module_register(
"get_wd_expire_time_sd",
THIS_MODULE,
7042 inter_module_register(
"reset_bypass_wd_timer_sd",
THIS_MODULE,
7051 inter_module_register(
"set_bp_hw_reset_sd",
THIS_MODULE,
7053 inter_module_register(
"get_bp_hw_reset_sd",
THIS_MODULE,
7058 inter_module_register(
"get_tap_change_sd",
THIS_MODULE,
7066 inter_module_register(
"get_bp_disc_change_sd",
THIS_MODULE,
7068 inter_module_register(
"set_bp_dis_disc_sd",
THIS_MODULE,
7070 inter_module_register(
"get_bp_dis_disc_sd",
THIS_MODULE,
7072 inter_module_register(
"set_bp_disc_pwup_sd",
THIS_MODULE,
7074 inter_module_register(
"get_bp_disc_pwup_sd",
THIS_MODULE,
7076 inter_module_register(
"set_wd_exp_mode_sd",
THIS_MODULE,
7078 inter_module_register(
"get_wd_exp_mode_sd",
THIS_MODULE,
7080 inter_module_register(
"set_wd_autoreset_sd",
THIS_MODULE,
7082 inter_module_register(
"get_wd_autoreset_sd",
THIS_MODULE,
7084 inter_module_register(
"get_bypass_info_sd",
THIS_MODULE,
7090 #ifdef BP_PROC_SUPPORT
7096 for (i = 0; i < device_num; i++) {
7097 if (bpctl_dev_arr[i].ifindex) {
7115 static void __exit bypass_cleanup_module(
void)
7118 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23))
7123 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
7124 inter_module_unregister(
"is_bypass_sd");
7125 inter_module_unregister(
"get_bypass_slave_sd");
7126 inter_module_unregister(
"get_bypass_caps_sd");
7127 inter_module_unregister(
"get_wd_set_caps_sd");
7128 inter_module_unregister(
"set_bypass_sd");
7129 inter_module_unregister(
"get_bypass_sd");
7130 inter_module_unregister(
"get_bypass_change_sd");
7131 inter_module_unregister(
"set_dis_bypass_sd");
7132 inter_module_unregister(
"get_dis_bypass_sd");
7133 inter_module_unregister(
"set_bypass_pwoff_sd");
7134 inter_module_unregister(
"get_bypass_pwoff_sd");
7135 inter_module_unregister(
"set_bypass_pwup_sd");
7136 inter_module_unregister(
"get_bypass_pwup_sd");
7137 inter_module_unregister(
"set_bypass_wd_sd");
7138 inter_module_unregister(
"get_bypass_wd_sd");
7139 inter_module_unregister(
"get_wd_expire_time_sd");
7140 inter_module_unregister(
"reset_bypass_wd_timer_sd");
7141 inter_module_unregister(
"set_std_nic_sd");
7142 inter_module_unregister(
"get_std_nic_sd");
7143 inter_module_unregister(
"set_tx_sd");
7144 inter_module_unregister(
"get_tx_sd");
7145 inter_module_unregister(
"set_tpl_sd");
7146 inter_module_unregister(
"get_tpl_sd");
7147 inter_module_unregister(
"set_tap_sd");
7148 inter_module_unregister(
"get_tap_sd");
7149 inter_module_unregister(
"get_tap_change_sd");
7150 inter_module_unregister(
"set_dis_tap_sd");
7151 inter_module_unregister(
"get_dis_tap_sd");
7152 inter_module_unregister(
"set_tap_pwup_sd");
7153 inter_module_unregister(
"get_tap_pwup_sd");
7154 inter_module_unregister(
"set_bp_disc_sd");
7155 inter_module_unregister(
"get_bp_disc_sd");
7156 inter_module_unregister(
"get_bp_disc_change_sd");
7157 inter_module_unregister(
"set_bp_dis_disc_sd");
7158 inter_module_unregister(
"get_bp_dis_disc_sd");
7159 inter_module_unregister(
"set_bp_disc_pwup_sd");
7160 inter_module_unregister(
"get_bp_disc_pwup_sd");
7161 inter_module_unregister(
"set_wd_exp_mode_sd");
7162 inter_module_unregister(
"get_wd_exp_mode_sd");
7163 inter_module_unregister(
"set_wd_autoreset_sd");
7164 inter_module_unregister(
"get_wd_autoreset_sd");
7165 inter_module_unregister(
"get_bypass_info_sd");
7166 inter_module_unregister(
"bp_if_scan_sd");
7170 for (i = 0; i < device_num; i++) {
7172 #ifdef BP_PROC_SUPPORT
7186 for (i = 0; i < device_num; i++) {
7188 if (bpctl_dev_arr[i].bp_tx_data)
7189 kfree(bpctl_dev_arr[i].bp_tx_data);
7196 kfree(bpctl_dev_arr);
7201 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23))
7207 printk(
"Error in module_unregister_chrdev: %d\n", ret);
7219 return is_bypass(get_dev_idx_p(ifindex));
7277 if ((
is_bypass(get_dev_idx_p(if_index))) <= 0)
7320 return set_tap_fn(get_dev_idx_p(ifindex), tap_mode);
7362 return set_disc_fn(get_dev_idx_p(ifindex), disc_mode);
7421 return set_tx_fn(get_dev_idx_p(ifindex), tx_state);
7427 return set_tpl_fn(get_dev_idx_p(ifindex), tpl_state);
7459 return pbpctl_dev_out->
ifindex;
7466 return get_tx_fn(get_dev_idx_p(ifindex));
7539 #define BP_PROC_DIR "bypass"
7541 #define GPIO6_SET_ENTRY_SD "gpio6_set"
7542 #define GPIO6_CLEAR_ENTRY_SD "gpio6_clear"
7544 #define GPIO7_SET_ENTRY_SD "gpio7_set"
7545 #define GPIO7_CLEAR_ENTRY_SD "gpio7_clear"
7547 #define PULSE_SET_ENTRY_SD "pulse_set"
7548 #define ZERO_SET_ENTRY_SD "zero_set"
7549 #define PULSE_GET1_ENTRY_SD "pulse_get1"
7550 #define PULSE_GET2_ENTRY_SD "pulse_get2"
7552 #define CMND_ON_ENTRY_SD "cmnd_on"
7553 #define CMND_OFF_ENTRY_SD "cmnd_off"
7554 #define RESET_CONT_ENTRY_SD "reset_cont"
7557 #define BYPASS_INFO_ENTRY_SD "bypass_info"
7558 #define BYPASS_SLAVE_ENTRY_SD "bypass_slave"
7559 #define BYPASS_CAPS_ENTRY_SD "bypass_caps"
7560 #define WD_SET_CAPS_ENTRY_SD "wd_set_caps"
7561 #define BYPASS_ENTRY_SD "bypass"
7562 #define BYPASS_CHANGE_ENTRY_SD "bypass_change"
7563 #define BYPASS_WD_ENTRY_SD "bypass_wd"
7564 #define WD_EXPIRE_TIME_ENTRY_SD "wd_expire_time"
7565 #define RESET_BYPASS_WD_ENTRY_SD "reset_bypass_wd"
7566 #define DIS_BYPASS_ENTRY_SD "dis_bypass"
7567 #define BYPASS_PWUP_ENTRY_SD "bypass_pwup"
7568 #define BYPASS_PWOFF_ENTRY_SD "bypass_pwoff"
7569 #define STD_NIC_ENTRY_SD "std_nic"
7570 #define STD_NIC_ENTRY_SD "std_nic"
7571 #define TAP_ENTRY_SD "tap"
7572 #define TAP_CHANGE_ENTRY_SD "tap_change"
7573 #define DIS_TAP_ENTRY_SD "dis_tap"
7574 #define TAP_PWUP_ENTRY_SD "tap_pwup"
7575 #define TWO_PORT_LINK_ENTRY_SD "two_port_link"
7576 #define WD_EXP_MODE_ENTRY_SD "wd_exp_mode"
7577 #define WD_AUTORESET_ENTRY_SD "wd_autoreset"
7578 #define TPL_ENTRY_SD "tpl"
7579 #define WAIT_AT_PWUP_ENTRY_SD "wait_at_pwup"
7580 #define HW_RESET_ENTRY_SD "hw_reset"
7581 #define DISC_ENTRY_SD "disc"
7582 #define DISC_CHANGE_ENTRY_SD "disc_change"
7583 #define DIS_DISC_ENTRY_SD "dis_disc"
7584 #define DISC_PWUP_ENTRY_SD "disc_pwup"
7592 for (pde = pde->
subdir; pde; pde = pde->
next) {
7600 #if (LINUX_VERSION_CODE > 0x20300)
7619 "Could not create procfs nicinfo directory %s\n",
7651 int *eof,
void *data)
7656 len +=
sprintf(page,
"Name\t\t\t%s\n", pbp_device_block->
name);
7658 sprintf(page + len,
"Firmware version\t0x%x\n",
7667 int *eof,
void *data)
7676 if ((pbp_device_block->
func == 0) || (pbp_device_block->
func == 2)) {
7678 ((bpctl_dev_arr[idx_dev].
pdev !=
NULL)
7679 && (idx_dev < device_num)); idx_dev++) {
7680 if ((bpctl_dev_arr[idx_dev].bus ==
7681 pbp_device_block->
bus)
7682 && (bpctl_dev_arr[idx_dev].
slot ==
7683 pbp_device_block->
slot)) {
7684 if ((pbp_device_block->
func == 0)
7685 && (bpctl_dev_arr[idx_dev].
func == 1)) {
7686 pbp_device_block_slave =
7687 &bpctl_dev_arr[idx_dev];
7690 if ((pbp_device_block->
func == 2) &&
7691 (bpctl_dev_arr[idx_dev].
func == 3)) {
7692 pbp_device_block_slave =
7693 &bpctl_dev_arr[idx_dev];
7699 pbp_device_block_slave = pbp_device_block;
7700 if (!pbp_device_block_slave) {
7701 len =
sprintf(page,
"fail\n");
7705 net_slave_dev = pbp_device_block_slave->
ndev;
7706 if (net_slave_dev) {
7710 len =
sprintf(page,
"fail\n");
7720 int *eof,
void *data)
7724 int len = 0, ret = 0;
7730 len =
sprintf(page,
"0x%x\n", ret);
7738 int *eof,
void *data)
7742 int len = 0, ret = 0;
7748 len =
sprintf(page,
"0x%x\n", ret);
7755 unsigned long count,
void *data)
7761 int bypass_param = 0, length = 0;
7763 if (count > (
sizeof(kbuf) - 1))
7772 if (kbuf[length - 1] ==
'\n')
7775 if (
strcmp(kbuf,
"on") == 0)
7777 else if (
strcmp(kbuf,
"off") == 0)
7787 unsigned long count,
void *data)
7793 int tap_param = 0, length = 0;
7795 if (count > (
sizeof(kbuf) - 1))
7804 if (kbuf[length - 1] ==
'\n')
7807 if (
strcmp(kbuf,
"on") == 0)
7809 else if (
strcmp(kbuf,
"off") == 0)
7819 unsigned long count,
void *data)
7825 int tap_param = 0, length = 0;
7827 if (count > (
sizeof(kbuf) - 1))
7836 if (kbuf[length - 1] ==
'\n')
7839 if (
strcmp(kbuf,
"on") == 0)
7841 else if (
strcmp(kbuf,
"off") == 0)
7851 int *eof,
void *data)
7855 int len = 0, ret = 0;
7859 len =
sprintf(page,
"fail\n");
7871 int *eof,
void *data)
7875 int len = 0, ret = 0;
7879 len =
sprintf(page,
"fail\n");
7891 int *eof,
void *data)
7895 int len = 0, ret = 0;
7899 len =
sprintf(page,
"fail\n");
7911 int *eof,
void *data)
7915 int len = 0, ret = 0;
7923 len =
sprintf(page,
"fail\n");
7931 int *eof,
void *data)
7935 int len = 0, ret = 0;
7943 len =
sprintf(page,
"fail\n");
7951 int *eof,
void *data)
7955 int len = 0, ret = 0;
7963 len =
sprintf(page,
"fail\n");
7969 #define isdigit(c) (c >= '0' && c <= '9')
7974 i = i * 10 + *((*s)++) -
'0';
7980 unsigned long count,
void *data)
7996 int *eof,
void *data)
8000 int len = 0, ret = 0,
timeout = 0;
8004 len =
sprintf(page,
"fail\n");
8006 len =
sprintf(page,
"unknown\n");
8008 len =
sprintf(page,
"disable\n");
8018 int *eof,
void *data)
8022 int len = 0, ret = 0,
timeout = 0;
8026 len =
sprintf(page,
"fail\n");
8028 len =
sprintf(page,
"expire\n");
8030 len =
sprintf(page,
"disable\n");
8040 int *eof,
void *data)
8044 int len = 0, ret = 0;
8048 len =
sprintf(page,
"fail\n");
8061 int *eof,
void *data)
8065 int len = 0, ret = 0;
8069 len =
sprintf(page,
"fail\n");
8080 get_hw_reset_pfs(
char *page,
char **start,
off_t off,
int count,
8081 int *eof,
void *data)
8085 int len = 0, ret = 0;
8089 len =
sprintf(page,
"fail\n");
8103 int *eof,
void *data)
8107 int len = 0, ret = 0;
8111 len =
sprintf(page,
"fail\n");
8113 len =
sprintf(page,
"disable\n");
8115 len =
sprintf(page,
"success\n");
8123 unsigned long count,
void *data)
8129 int bypass_param = 0, length = 0;
8131 if (count >=
sizeof(kbuf))
8140 if (kbuf[length - 1] ==
'\n')
8143 if (
strcmp(kbuf,
"on") == 0)
8145 else if (
strcmp(kbuf,
"off") == 0)
8155 unsigned long count,
void *data)
8161 int tap_param = 0, length = 0;
8163 if (count >=
sizeof(kbuf))
8172 if (kbuf[length - 1] ==
'\n')
8175 if (
strcmp(kbuf,
"on") == 0)
8177 else if (
strcmp(kbuf,
"off") == 0)
8187 unsigned long count,
void *data)
8193 int tap_param = 0, length = 0;
8195 if (count >=
sizeof(kbuf))
8204 if (kbuf[length - 1] ==
'\n')
8207 if (
strcmp(kbuf,
"on") == 0)
8209 else if (
strcmp(kbuf,
"off") == 0)
8219 int *eof,
void *data)
8223 int len = 0, ret = 0;
8227 len =
sprintf(page,
"fail\n");
8239 int *eof,
void *data)
8243 int len = 0, ret = 0;
8247 len =
sprintf(page,
"fail\n");
8259 int *eof,
void *data)
8263 int len = 0, ret = 0;
8267 len =
sprintf(page,
"fail\n");
8279 unsigned long count,
void *data)
8285 int bypass_param = 0, length = 0;
8287 if (count >=
sizeof(kbuf))
8296 if (kbuf[length - 1] ==
'\n')
8299 if (
strcmp(kbuf,
"on") == 0)
8301 else if (
strcmp(kbuf,
"off") == 0)
8311 unsigned long count,
void *data)
8317 int bypass_param = 0, length = 0;
8319 if (count >=
sizeof(kbuf))
8328 if (kbuf[length - 1] ==
'\n')
8331 if (
strcmp(kbuf,
"on") == 0)
8333 else if (
strcmp(kbuf,
"off") == 0)
8343 unsigned long count,
void *data)
8349 int tap_param = 0, length = 0;
8351 if (count >=
sizeof(kbuf))
8360 if (kbuf[length - 1] ==
'\n')
8363 if (
strcmp(kbuf,
"on") == 0)
8365 else if (
strcmp(kbuf,
"off") == 0)
8375 unsigned long count,
void *data)
8381 int tap_param = 0, length = 0;
8383 if (count >=
sizeof(kbuf))
8392 if (kbuf[length - 1] ==
'\n')
8395 if (
strcmp(kbuf,
"on") == 0)
8397 else if (
strcmp(kbuf,
"off") == 0)
8407 int *eof,
void *data)
8411 int len = 0, ret = 0;
8415 len =
sprintf(page,
"fail\n");
8427 int *eof,
void *data)
8431 int len = 0, ret = 0;
8435 len =
sprintf(page,
"fail\n");
8447 int *eof,
void *data)
8451 int len = 0, ret = 0;
8455 len =
sprintf(page,
"fail\n");
8467 int *eof,
void *data)
8471 int len = 0, ret = 0;
8475 len =
sprintf(page,
"fail\n");
8487 unsigned long count,
void *data)
8493 int bypass_param = 0, length = 0;
8495 if (count >=
sizeof(kbuf))
8504 if (kbuf[length - 1] ==
'\n')
8507 if (
strcmp(kbuf,
"on") == 0)
8509 else if (
strcmp(kbuf,
"off") == 0)
8519 int *eof,
void *data)
8523 int len = 0, ret = 0;
8527 len =
sprintf(page,
"fail\n");
8539 int *eof,
void *data)
8543 int len = 0, ret = 0;
8549 len =
sprintf(page,
"bypass\n");
8551 len =
sprintf(page,
"disc\n");
8554 len =
sprintf(page,
"fail\n");
8562 unsigned long count,
void *data)
8568 int bypass_param = 0, length = 0;
8570 if (count > (
sizeof(kbuf) - 1))
8579 if (kbuf[length - 1] ==
'\n')
8582 if (
strcmp(kbuf,
"tap") == 0)
8584 else if (
strcmp(kbuf,
"bypass") == 0)
8586 else if (
strcmp(kbuf,
"disc") == 0)
8596 int *eof,
void *data)
8600 int len = 0, ret = 0;
8604 len =
sprintf(page,
"%d\n", ret);
8606 len =
sprintf(page,
"fail\n");
8614 unsigned long count,
void *data)
8630 unsigned long count,
void *data)
8636 int tpl_param = 0, length = 0;
8638 if (count > (
sizeof(kbuf) - 1))
8647 if (kbuf[length - 1] ==
'\n')
8650 if (
strcmp(kbuf,
"on") == 0)
8652 else if (
strcmp(kbuf,
"off") == 0)
8662 set_wait_at_pwup_pfs(
struct file *file,
const char *
buffer,
8663 unsigned long count,
void *data)
8669 int tpl_param = 0, length = 0;
8671 if (count > (
sizeof(kbuf) - 1))
8680 if (kbuf[length - 1] ==
'\n')
8683 if (
strcmp(kbuf,
"on") == 0)
8685 else if (
strcmp(kbuf,
"off") == 0)
8694 set_hw_reset_pfs(
struct file *file,
const char *buffer,
8695 unsigned long count,
void *data)
8701 int tpl_param = 0, length = 0;
8703 if (count > (
sizeof(kbuf) - 1))
8712 if (kbuf[length - 1] ==
'\n')
8715 if (
strcmp(kbuf,
"on") == 0)
8717 else if (
strcmp(kbuf,
"off") == 0)
8733 if (!pbp_device_block->
ndev)
8736 pbp_device_block->
ndev->name);
8742 procfs_dir = proc_getdir(current_pfs->
dir_name, bp_procfs_dir);
8743 if (procfs_dir == 0) {
8752 procfs_dir, pbp_device_block))
8760 procfs_dir, pbp_device_block))
8765 procfs_dir, pbp_device_block))
8770 procfs_dir, pbp_device_block))
8774 procfs_dir, pbp_device_block))
8779 procfs_dir, pbp_device_block))
8784 procfs_dir, pbp_device_block))
8789 procfs_dir, pbp_device_block))
8880 procfs_dir, pbp_device_block))
8885 procfs_dir, pbp_device_block))
8889 procfs_dir, pbp_device_block))
8893 get_wait_at_pwup_pfs,
8894 procfs_dir, pbp_device_block))
8898 procfs_dir, pbp_device_block))
8920 for (pde = pde->
subdir; pde;) {