[tulip-bug] [PATCH] check_duplex bug causes HD operation, carrier errors

Bhavesh P. Davda bhavesh@avaya.com
Thu Jun 27 17:46:01 2002


Finally was able to track this bug down to a fairly simple set of 
operations:

-------------------------------------------------------------------------

[root@cof110earth net]# ifdown eth1
[root@cof110earth net]# rmmod tulip
[root@cof110earth net]# ifup eth1
[root@cof110earth net]# ping -n 192.11.13.14 -f
PING 192.11.13.14 (192.11.13.14) from 192.11.13.13 : 56(84) bytes of data.
.
--- 192.11.13.14 ping statistics ---
43475 packets transmitted, 43474 packets received, 0% packet loss
round-trip min/avg/max = 0.0/0.0/286.9 ms
[root@cof110earth net]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:80:C8:CF:AC:9D  
          inet addr:192.11.13.13  Bcast:192.11.13.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:43476 errors:0 dropped:0 overruns:0 frame:0
          TX packets:43476 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          Interrupt:5 Base address:0x4000 

[root@cof110earth net]# ifconfig eth1 down && ifconfig eth1 up
[root@cof110earth net]# ping -n 192.11.13.14 -f
PING 192.11.13.14 (192.11.13.14) from 192.11.13.13 : 56(84) bytes of data.
.
--- 192.11.13.14 ping statistics ---
35942 packets transmitted, 35941 packets received, 0% packet loss
round-trip min/avg/max = 0.0/0.0/20.0 ms
[root@cof110earth net]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:80:C8:CF:AC:9D  
          inet addr:192.11.13.13  Bcast:192.11.13.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:79419 errors:0 dropped:0 overruns:0 frame:0
          TX packets:43476 errors:35943 dropped:0 overruns:0 carrier:35943
          collisions:0 txqueuelen:100 
          Interrupt:5 Base address:0x4000 

-------------------------------------------------------------------------

Here is a patch that fixes this problem:

diff -Naur orig/tulip.c new/tulip.c
--- orig/tulip.c	Thu Jun 27 15:37:41 2002
+++ new/tulip.c	Thu Jun 27 15:39:05 2002
@@ -1916,21 +1916,18 @@
 	duplex = ((negotiated & 0x0300) == 0x0100
 			  || (negotiated & 0x00C0) == 0x0040);
 	/* 100baseTx-FD  or  10T-FD, but not 100-HD */
-	if (tp->full_duplex != duplex) {
-		tp->full_duplex = duplex;
-		if (negotiated & 0x0380)	/* 100mbps. */
-			tp->csr6 &= ~0x00400000;
-		if (tp->full_duplex) tp->csr6 |= FullDuplex;
-		else				 tp->csr6 &= ~FullDuplex;
-		outl(tp->csr6 | RxOn, ioaddr + CSR6);
-		outl(tp->csr6 | TxOn | RxOn, ioaddr + CSR6);
-		if (tp->msg_level & NETIF_MSG_LINK)
-			printk(KERN_INFO "%s: Setting %s-duplex based on MII "
-				   "#%d link partner capability of %4.4x.\n",
-				   dev->name, tp->full_duplex ? "full" : "half",
-				   tp->phys[0], mii_reg5);
-		return 1;
-	}
+	tp->full_duplex = duplex;
+	if (negotiated & 0x0380)	/* 100mbps. */
+		tp->csr6 &= ~0x00400000;
+	if (tp->full_duplex) tp->csr6 |= FullDuplex;
+	else				 tp->csr6 &= ~FullDuplex;
+	outl(tp->csr6 | RxOn, ioaddr + CSR6);
+	outl(tp->csr6 | TxOn | RxOn, ioaddr + CSR6);
+	if (tp->msg_level & NETIF_MSG_LINK)
+		printk(KERN_INFO "%s: Setting %s-duplex based on MII "
+			   "#%d link partner capability of %4.4x.\n",
+			   dev->name, tp->full_duplex ? "full" : "half",
+			   tp->phys[0], mii_reg5);
 	return 0;
 }
 
-- 
Bhavesh P. Davda
Avaya Inc
bhavesh@avaya.com