NetBSD Problem Report #20700

Received: (qmail 16958 invoked by uid 605); 14 Mar 2003 12:10:21 -0000
Message-Id: <20030314121019.EC3651C72@druid.net>
Date: Fri, 14 Mar 2003 07:10:19 -0500 (EST)
From: darcy@druid.net
Sender: gnats-bugs-owner@netbsd.org
Reply-To: darcy@druid.net
To: gnats-bugs@gnats.netbsd.org
Subject: Manual ethernet media setting disables Nway autonegotiation
X-Send-Pr-Version: 3.95

>Number:         20700
>Category:       kern
>Synopsis:       Manual ethernet media setting disables Nway autonegotiation
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 14 12:11:00 +0000 2003
>Closed-Date:    Wed Jan 25 19:56:58 +0000 2012
>Last-Modified:  Tue Jun 12 14:30:02 +0000 2012
>Originator:     D'Arcy J.M. Cain
>Release:        NetBSD 1.6P
>Organization:
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.
>Environment:


System: NetBSD druid.net 1.6P NetBSD 1.6P (DRUID) #1: Tue Mar 4 07:35:48 EST 2003 door@druid.net:/usr/src/sys/arch/i386/compile/DRUID i386
Architecture: i386
Machine: i386
>Description:
I have an Intel i82544EI 1000BASET Ethernet.  I could not get the board to
use 1000Base-T media.  It would not see carrier.  Jason Thorpe pointed out
that Gig-E basically requires Nway autonegotiation in order to function at
all and the way our manual media settings work disables autonegotiation.
>How-To-Repeat:
With the above card try to set media to 1000BaseT.  Note lack of carrier.
>Fix:
Work around is to set media to auto which uses the Nway autonegotiation.

>Release-Note:
>Audit-Trail:
From: buhrow@lothlorien.nfbcal.org (Brian Buhrow)
To: gnats@netbsd.org
Cc: buhrow@lothlorien.nfbcal.org, darcy@druidvex.net
Subject: Re: kern/20700
Date: Tue, 29 Nov 2011 18:01:01 -0800

 	Hello.  I realize this bug is incredibly old, but I've recently
 written a patch which addresses this very issue.  The patch essentially
 turns on Nway negotiation on a NIC when its mode is set either to auto or
 to 1000baset with any mediaopt options.  This has the nice side effect of
 also allowing a NIC to regain link if a connection is lost after theinitial
 ifconfig is run at boot time or reconfig time.
 	If you could try the following patch and see if it makes things work
 better for you, I'll commit and request a pullup for 5.x.  I've tested this
 patch against 4.x and 5.x, and am working on testing against current, but I
 think it will work against 3.x, 2.x, and pretty much anything since we got
 the mii code.

 	Please let me know what you find.

 -thanks
 -Brian


 --- mii_physubr.c.40	2007-11-15 20:14:47.000000000 -0800
 +++ mii_physubr.c	2011-11-28 13:34:52.000000000 -0800
 @@ -170,9 +170,13 @@
  		bmcr |= BMCR_LOOP;

  	PHY_WRITE(sc, MII_ANAR, anar);
 -	PHY_WRITE(sc, MII_BMCR, bmcr);
  	if (sc->mii_flags & MIIF_HAVE_GTCR)
  		PHY_WRITE(sc, MII_100T2CR, gtcr);
 +	if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) {
 +		mii_phy_auto(sc, 0);
 +	} else {
 +		PHY_WRITE(sc, MII_BMCR, bmcr);
 +	}
  }

  int
 @@ -294,7 +298,8 @@
  	 * status so we can generate an announcement if the status
  	 * changes.
  	 */
 -	if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
 +	if ((IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) &&
 +	(IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T))
  		return (0);

  	/* Read the status register twice; BMSR_LINK is latch-low. */

State-Changed-From-To: open->feedback
State-Changed-By: buhrow@NetBSD.org
State-Changed-When: Wed, 30 Nov 2011 02:16:52 +0000
State-Changed-Why:
Wrote a patch which turns on Nway negotiation if the media type is set to 1000baset.


From: Manuel Bouyer <bouyer@antioche.eu.org>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org,
        darcy@druid.net
Subject: Re: kern/20700
Date: Wed, 30 Nov 2011 12:46:28 +0100

 On Wed, Nov 30, 2011 at 02:15:05AM +0000, Brian Buhrow wrote:
 >  	Hello.  I realize this bug is incredibly old, but I've recently
 >  written a patch which addresses this very issue.  The patch essentially
 >  turns on Nway negotiation on a NIC when its mode is set either to auto or
 >  to 1000baset with any mediaopt options.  This has the nice side effect of
 >  also allowing a NIC to regain link if a connection is lost after theinitial
 >  ifconfig is run at boot time or reconfig time.
 >  	If you could try the following patch and see if it makes things work
 >  better for you, I'll commit and request a pullup for 5.x.  I've tested this
 >  patch against 4.x and 5.x, and am working on testing against current, but I
 >  think it will work against 3.x, 2.x, and pretty much anything since we got
 >  the mii code.
 >  
 >  	Please let me know what you find.

 With this patch it can give some strange things:
 # ifconfig wm0
 wm0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu 150
         capabilities=2bf80<TSO4,IP4CSUM_Rx,IP4CSUM_Tx,TCP4CSUM_Rx,TCP4CSUM_Tx,U>
         enabled=0
         address: 00:13:72:54:ee:13
         media: Ethernet 1000baseT (1000baseT full-duplex)

 I asked for 1000baseT, it negociated (and is using) 1000baseT full-duplex.
 But the link is up and working.

 But there's something worse: I configured the cisco to negociate
 only 100baseTX, and I get:
         media: Ethernet 1000baseT (100baseTX full-duplex)
         status: active

 I think there's some filtering missing on our side to only
 advertise/accept the configured media (basically 'media 1000baseT' is now
 an alias for 'media auto').

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --

From: buhrow@lothlorien.nfbcal.org (Brian Buhrow)
To: gnats@netbsd.org
Cc: darcy@druidvex.net, buhrow@lothlorien.nfbcal.org
Subject: Re: kern/20700
Date: Wed, 7 Dec 2011 22:43:58 -0800

 	Hello.  After working on this problem for a while, I propose
 committing the diff below as a fix for this bug.  The problem of
 negotiating link at a speed other than the 1000-base-T remains, but see
 below for my reasoning on this topic.

 	the current state of affairs is that Nway autonegotiation works for
 twisted pair copper connections.  Nailed up speed requests work with 10 and
 100mbit connections, but will never work with 1000-base-T connections,
 unless the chip has initialized, and hence negotiated, a connection before
 ifconfig is called in the boot sequence.

 	What this patch does is turn on Nway autonegotiation when the user
 requests 1000baset with ifconfig and turn off advertisements for speeds
 other than 1000baset in the Nway autonegotiation process.  This makes 
 1000baset nailed links work, which, in my view, is the behavior of least
 astonishment.

 	Because of the race between Nway negotiation and parallel detection,
 which Thor alluded to earlier in this thread, I've found it very difficult
 to prevent the chip from establishing link with its partners at speeds
 other than the requested speed without totally disabling the ability for
 the link to come up again on its own once the proper speeds and duplexes
 were configured on both ends of the link.  I experimented with disallowing
 the interface from passing traffic if the link speed didn't match the
 requested speed, but that seemed even less intuitive, since ifconfig would
 show the interface as being active, but wouldn't actually work.  Finally,
 I figured out that I could probably implement the requested behavior to fix
 this bug completely, but to do so would require that I touch every phy
 driver in the system, creating a huge patch and a larger testing problem.

 	In summary, in my view, this patch improves the state of the world,
 permitting more configuration cases to work than do today, as well as
 causing the system to behave in less astonishing ways than it does today.
 Right now, if you get a link at 1000baset when the system boots, and you
 don't have autonegotiation configured, if you pull the plug or otherwise
 bounce the port, you have to reboot or turn autonegotiation on to
 re-establish link.  this patch insures that you'll get a restoration of
 service, regardless of how you set ifconfig, without user intervention.

 	If folks don't strongly object, I'll commit this patch in the next
 week or so and request a pullup for the 5.x branch.  If someone has an idea
 for fully implementing the requested behavior without having to touch all
 the phy drivers, I'm very interested and will be happy to implement and
 test.

 -thanks
 -Brian

 P.S.  This patch applies cleanly to 4.x, 5.x and -current source trees.


 --- mii_physubr.c.40	2007-11-15 20:14:47.000000000 -0800
 +++ mii_physubr.c	2011-12-07 10:01:39.000000000 -0800
 @@ -170,15 +170,21 @@
  		bmcr |= BMCR_LOOP;

  	PHY_WRITE(sc, MII_ANAR, anar);
 -	PHY_WRITE(sc, MII_BMCR, bmcr);
  	if (sc->mii_flags & MIIF_HAVE_GTCR)
  		PHY_WRITE(sc, MII_100T2CR, gtcr);
 +	if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) {
 +		mii_phy_auto(sc, 0);
 +	} else {
 +		PHY_WRITE(sc, MII_BMCR, bmcr);
 +	}
  }

  int
  mii_phy_auto(struct mii_softc *sc, int waitfor)
  {
  	int i;
 +	struct mii_data *mii = sc->mii_pdata;
 +	struct ifmedia_entry *ife = mii->mii_media.ifm_cur;

  	if ((sc->mii_flags & MIIF_DOINGAUTO) == 0) {
  		/*
 @@ -212,6 +218,16 @@
  				     (EXTSR_1000THDX|EXTSR_1000TFDX)))
  					anar |= ANAR_X_PAUSE_ASYM;
  			}
 +
 +			/*
 +			 *for 1000-base-T, autonegotiation mus be enabled, but 
 +			 *if we're not set to auto, only advertise
 +			 *1000-base-T with the link partner.
 +			 */
 +			if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) {
 +				anar &= ~(ANAR_T4|ANAR_TX_FD|ANAR_TX|ANAR_10_FD|ANAR_10);
 +			}
 +				
  			PHY_WRITE(sc, MII_ANAR, anar);
  			if (sc->mii_flags & MIIF_HAVE_GTCR) {
  				uint16_t gtcr = 0;
 @@ -294,7 +310,8 @@
  	 * status so we can generate an announcement if the status
  	 * changes.
  	 */
 -	if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
 +	if ((IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) &&
 +	(IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T))
  		return (0);

  	/* Read the status register twice; BMSR_LINK is latch-low. */

From: "Brian Buhrow" <buhrow@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/20700 CVS commit: src/sys/dev/mii
Date: Sat, 10 Dec 2011 02:46:07 +0000

 Module Name:	src
 Committed By:	buhrow
 Date:		Sat Dec 10 02:46:07 UTC 2011

 Modified Files:
 	src/sys/dev/mii: mii_physubr.c

 Log Message:
 Fixes PR kern/20700 reported by Darcy Cain

 Make 1000baset connections work even when the user specifies media 1000baset
 connections with ifconfig(8) rather then only when media auto is specified.

 For a further discussion of this fix, see:
 http://mail-index.NetBSD.org/current-users/2011/12/07/msg018561.html


 To generate a diff of this commit:
 cvs rdiff -u -r1.72 -r1.73 src/sys/dev/mii/mii_physubr.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: feedback->pending-pullups
State-Changed-By: buhrow@NetBSD.org
State-Changed-When: Sat, 10 Dec 2011 03:02:04 +0000
State-Changed-Why:
Requested pullup to NetBSD-5.x


From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/20700 CVS commit: [netbsd-5] src/sys/dev/mii
Date: Wed, 25 Jan 2012 18:14:37 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Wed Jan 25 18:14:37 UTC 2012

 Modified Files:
 	src/sys/dev/mii [netbsd-5]: mii_physubr.c

 Log Message:
 Pull up following revision(s) (requested by buhrow in ticket #1701):
 	sys/dev/mii/mii_physubr.c: revision 1.73
 Fixes PR kern/20700 reported by Darcy Cain
 Make 1000baset connections work even when the user specifies media 1000baset
 connections with ifconfig(8) rather then only when media auto is specified.
 For a further discussion of this fix, see:
 http://mail-index.NetBSD.org/current-users/2011/12/07/msg018561.html


 To generate a diff of this commit:
 cvs rdiff -u -r1.60.10.1 -r1.60.10.2 src/sys/dev/mii/mii_physubr.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: buhrow@NetBSD.org
State-Changed-When: Wed, 25 Jan 2012 19:56:58 +0000
State-Changed-Why:
The fix has been pulled up to 5.x sources.


From: "Stephen Borrill" <sborrill@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/20700 CVS commit: [netbsd-4] src/sys/dev/mii
Date: Tue, 12 Jun 2012 14:27:40 +0000

 Module Name:	src
 Committed By:	sborrill
 Date:		Tue Jun 12 14:27:39 UTC 2012

 Modified Files:
 	src/sys/dev/mii [netbsd-4]: mii_physubr.c

 Log Message:
 Pull up the following revisions(s) (requested by buhrow in ticket #1448):
 	sys/dev/mii/mii_physubr.c:	revision 1.73 via patch

 Make 1000baseT connections work even when the user specifies media 1000baseT
 connections with ifconfig(8) rather than only when media auto is specified.
 Fixes PR kern/20700.


 To generate a diff of this commit:
 cvs rdiff -u -r1.53 -r1.53.2.1 src/sys/dev/mii/mii_physubr.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.