Patch: link state detection for 8139too against 2.5.41
Subsystems (2)
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
drivers/net/8139too.c renamed from drivers/net/8139too.c.orig +9 -2
@@ -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);
Quoted 6 lines · Stefan Rompf
Date: Sat, 12 Oct 2002 01:55:04 +0200
From: Stefan Rompf <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Patch: link state detection for 8139too against 2.5.41
Quoted 8 lines
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.
Uhmmm, you don't need to poll with the rtl8139. There is a link change interrupt. Here is the recently added from rtl8139.c
if (status & RxUnderrun){
/* This might actually be a link change event. */
if ((tp->drv_flags & HAS_LNK_CHNG) && link_changed) {
/* Really link-change on new chips. */
int lpar = inw(ioaddr + NWayLPAR);
int duplex = (lpar&0x0100) || (lpar & 0x01C0) == 0x0040
|| tp->duplex_lock;
/* Do not use MII_BMSR as that clears sticky bit. */
if (inw(ioaddr + GPPinData) & 0x0004) {
netif_link_down(dev);
} else
netif_link_up(dev);
if (tp->msg_level & NETIF_MSG_LINK)
printk(KERN_DEBUG "%s: Link changed, link partner "
"%4.4x new duplex %d.\n",
dev->name, lpar, duplex);
tp->full_duplex = duplex;
/* Only count as errors with no link change. */
status &= ~RxUnderrun;
} else {Signature · 4 lines
Donald Becker [email protected] Scyld Computing Corporation http://www.scyld.com 410 Severn Ave. Suite 210 Scyld Beowulf cluster system Annapolis MD 21403 410-990-9993
Hi,
Quoted 5 lines
Quoted 2 lines
I've written this stuff on a friends' computer using 2.4.18, so it is only slightly tested.
Uhmmm, you don't need to poll with the rtl8139. There is a link change interrupt. Here is the recently added from
rtl8139.c
ok, I'll try this next time I have access to the card.
Stefan
Take a look at how 8139cp driver does link state... it should be an also exact copy of 8139cp's code.
(8139cp will eventually get GMII/TBI support, but for now this statement is correct)
Re: Patch: link state detection for 8139too against 2.4.20rc2 / 2.5
In reply to Stefan RompfHi,
Quoted 4 lines
Quoted 2 lines
Uhmmm, you don't need to poll with the rtl8139. There is a link change interrupt. Here is the recently added from
rtl8139.cok, I'll try this next time I have access to the card.
...that was some days ago. I've seen that Jeff is enhancing the MII interface library, so I used the functions provided there. Patch is against 2.4.20rc2 and 2.5 with some offset. Please apply if it looks good.
Cheers, Stefan
drivers/net/8139too.c renamed from drivers/net/8139too.c.old +2 -24
@@ -1335,18 +1335,7 @@struct rtl8139_private *tp = dev->priv;if (tp->phys[0 ] >=0 ) { -u16 mii_lpa =mdio_read (dev, tp->phys[0 ],MII_LPA ); -if (mii_lpa ==0xffff ) - ;/* Not there */ -else if ((mii_lpa &LPA_100FULL ) ==LPA_100FULL - || (mii_lpa &0x00C0 ) ==LPA_10FULL ) - tp->mii.full_duplex =1 ; - -printk (KERN_INFO "%s: Setting %s%s-duplex based on" -" auto-negotiated partner ability %4.4x.\n" , - dev->name, mii_lpa ==0 ?"" : - (mii_lpa &0x0180 ) ?"100mbps " :"10mbps " , - tp->mii.full_duplex ?"full" :"half" , mii_lpa); +mii_check_media (&tp->mii,1 ,1 ); } }
@@ -1994,18 +1983,7 @@if ((status & RxUnderrun) && link_changed && (tp->drv_flags &HAS_LNK_CHNG )) { -/* Really link-change on new chips. */ -int lpar =RTL_R16 (NWayLPAR); -int duplex = (lpar &LPA_100FULL ) || (lpar &0x01C0 ) ==0x0040 - || tp->mii.force_media; -if (tp->mii.full_duplex != duplex) { - tp->mii.full_duplex = duplex; -#if 0 -RTL_W8 (Cfg9346, Cfg9346_Unlock); -RTL_W8 (Config1, tp->mii.full_duplex ?0x60 :0x20 ); -RTL_W8 (Cfg9346, Cfg9346_Lock); -#endif - } +rtl_check_media (dev); status &= ~RxUnderrun; }
Re: Patch: link state detection for 8139too against 2.4.20rc2 / 2.5
Hi,
Quoted 4 lines · Jeff Garzik
Quoted 4 lines
...that was some days ago. I've seen that Jeff is enhancing the MII interface library, so I used the functions provided there. Patch is against 2.4.20rc2 and 2.5 with some offset. Please apply if it looks good.
[...]
Quoted 2 lines
close -- you don't want to unconditionally "initialize" the media (
mii_check_mediasecond arg).
I've just seen the reason: No need to read the MII_ADVERTISE register once the structure has been initialized. Expect another patch the next days.
Quoted 2 lines
the phy code is gonna be pretty darned similar. Eventually the phy code needs to move to a common
8139lib.c, because both old-8139 line and
May be. However, I cannot help there. I just have one card of the 8139 family, and all I could produce is some compiles for me stuff - something that I would not consider helpful.
Stefan
Re: Patch: link state detection for 8139too against 2.4.20rc2 / 2.5
Quoted 9 lines · Stefan Rompf
Hi,
Quoted 4 lines · Jeff Garzik
Quoted 4 lines
...that was some days ago. I've seen that Jeff is enhancing the MII interface library, so I used the functions provided there. Patch is against 2.4.20rc2 and 2.5 with some offset. Please apply if it looks good.
Quoted 8 lines
[...]
Quoted 2 lines
close -- you don't want to unconditionally "initialize" the media (
mii_check_mediasecond arg).I've just seen the reason: No need to read the
MII_ADVERTISEregister once the structure has been initialized. Expect another patch the next days.
Thanks.
Quoted 6 lines
Quoted 2 lines
the phy code is gonna be pretty darned similar. Eventually the phy code needs to move to a common
8139lib.c, because both old-8139 line andMay be. However, I cannot help there. I just have one card of the 8139 family, and all I could produce is some compiles for me stuff - something that I would not consider helpful.
<shrug> I would consider it helpful. If you are willing to do the coding and worksforme testing, I can review and do further testing. Part of the power of open source :)
Jeff
Re: Patch: link state detection for 8139too against 2.4.20rc2 / 2.5
In reply to Donald BeckerQuoted 28 lines · Stefan Rompf
Hi,
Quoted 4 lines
Quoted 2 lines
Uhmmm, you don't need to poll with the rtl8139. There is a link change interrupt. Here is the recently added from
rtl8139.cok, I'll try this next time I have access to the card.
...that was some days ago. I've seen that Jeff is enhancing the MII interface library, so I used the functions provided there. Patch is against 2.4.20rc2 and 2.5 with some offset. Please apply if it looks good.
Cheers, Stefan
------------------------------------------------------------------------
drivers/net/8139too.c renamed from drivers/net/8139too.c.old +0
-3@@ -1335,18 +1335,7 @@struct rtl8139_private *tp = dev->priv;if (tp->phys[0 ] >=0 ) { -u16 mii_lpa =mdio_read (dev, tp->phys[0 ],MII_LPA ); -if (mii_lpa ==0xffff ) - ;/* Not there */
drivers/net/8139too.c line 1338
Quoted 10 lines
drivers/net/8139too.c renamed from drivers/net/8139too.c.old +1
-9-else if ((mii_lpa &LPA_100FULL ) ==LPA_100FULL - || (mii_lpa &0x00C0 ) ==LPA_10FULL ) - tp->mii.full_duplex =1 ; - -printk (KERN_INFO "%s: Setting %s%s-duplex based on" -" auto-negotiated partner ability %4.4x.\n" , - dev->name, mii_lpa ==0 ?"" : - (mii_lpa &0x0180 ) ?"100mbps " :"10mbps " , - tp->mii.full_duplex ?"full" :"half" , mii_lpa); +mii_check_media (&tp->mii,1 ,1 );
close -- you don't want to unconditionally "initialize" the media (mii_check_media second arg).
You can also kibbitz from 8139cp.c in 2.4.20-rc4 / 2.5.<recent> because the phy code is gonna be pretty darned similar. Eventually the phy code needs to move to a common 8139lib.c, because both old-8139 line and 8139C+ support external MII phys as well as the normal on-chip phy found in most 8139s.
Jeff