Subject: Patch: link state detection for 8139too against 2.5.41

From: Stefan Rompf <[email-masked]>
Date: Sat, 12 Oct 2002 01:55:04 +0200

Hi Jeff,

attached you find a patch that enables link state detection for the
8139too driver. It applies cleanly against 2.5.41 and with some line
offset against 2.4.19.

I've written this stuff on a friends' computer using 2.4.18, so it is
only slightly tested.

Cheers, Stefan

--- linux/drivers/net/8139too.c.orig	Tue Oct  1 09:05:46 2002
+++ linux/drivers/net/8139too.c	Thu Oct 10 00:37:37 2002
@@ -1534,9 +1534,16 @@
 				 struct rtl8139_private *tp,
 				 void *ioaddr)
 {
-	int mii_lpa;
+	int mii_lpa, mii_bmsr;
 
 	mii_lpa = mdio_read (dev, tp->phys[0], MII_LPA);
+	mii_bmsr = mdio_read(dev, tp->phys[0], MII_BMSR);
+
+	if (mii_bmsr & BMSR_LSTATUS && !netif_carrier_ok(dev)) {
+		netif_carrier_on(dev);
+	} else if (netif_carrier_ok(dev)) {
+		netif_carrier_off(dev);
+	}
 
 	if (!tp->mii.force_media && mii_lpa != 0xffff) {
 		int duplex = (mii_lpa & LPA_100FULL)
@@ -1563,7 +1570,7 @@
 		}
 	}
 
-	next_tick = HZ * 60;
+	next_tick = HZ * 3;
 
 	rtl8139_tune_twister (dev, tp);