NetBSD Problem Report #44630

From river@TCX.ORG.UK  Thu Feb 24 06:17:47 2011
Return-Path: <river@TCX.ORG.UK>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 7AB8863B842
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 24 Feb 2011 06:17:47 +0000 (UTC)
Message-Id: <20110224061743.B2791481FC@MAIL.TCX.ORG.UK>
Date: Thu, 24 Feb 2011 06:17:43 +0000 (GMT)
From: r.tarnell@IEEE.ORG
Reply-To: r.tarnell@IEEE.ORG
To: gnats-bugs@gnats.NetBSD.org
Subject: rgephy(4) likes auto-negotiation too much
X-Send-Pr-Version: 3.95

>Number:         44630
>Category:       kern
>Synopsis:       rgephy(4) likes auto-negotiation too much
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 24 06:20:00 +0000 2011
>Last-Modified:  Thu Feb 24 08:05:01 +0000 2011
>Originator:     River Tarnell
>Release:        NetBSD 5.1.0_PATCH
>Organization:
TCX.ORG.UK
>Environment:
System: NetBSD tamara.TCX.ORG.UK 5.1.0_PATCH NetBSD 5.1.0_PATCH (TAMARA) #2: Thu Feb 24 06:06:17 GMT 2011 root@tamara.TCX.ORG.UK:/usr/src/sys/arch/amd64/compile/TAMARA amd64
Architecture: x86_64
Machine: amd64
>Description:
rgephy(4) enables auto-negotiation even when the user explicitly
specifies a media type.  This is unfortunate, because if the switch is
forced to 100-FD, the card will fail to negotiate and fall back to
100-HD.  The duplex mismatch makes it so slow as to be unusable.

# ifconfig re0 media 100basetx mediaopt full-duplex
# ifconfig re0
	...
	media: Ethernet 100baseTX full-duplex (100baseTX half-duplex)
>How-To-Repeat:
See description.
>Fix:
This patch will use the user's specified media type unconditionally if
the link1 flag is set on the interface.  This is the same fix FreeBSD
uses in r215298.  From what I understand, some hardware revisions
become confused by this, which is why it's not enabled by default.

Index: rgephy.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/rgephy.c,v
retrieving revision 1.21.10.1
diff -u -r1.21.10.1 rgephy.c
--- rgephy.c	19 Jun 2009 21:51:43 -0000	1.21.10.1
+++ rgephy.c	24 Feb 2011 06:06:08 -0000
@@ -244,10 +244,16 @@
 			}

 			if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) {
+				/*
+				 * To prevent problems with some (older?) 
+				 * hardware revisions, always enable autoneg
+				 * unless link1 is specified.
+				 */
+				if ((mii->mii_ifp->if_flags & IFF_LINK1) == 0)
+					speed |= RGEPHY_BMCR_AUTOEN | RGEPHY_BMCR_STARTNEG;
 				PHY_WRITE(sc, RGEPHY_MII_1000CTL, 0);
 				PHY_WRITE(sc, RGEPHY_MII_ANAR, anar);
-				PHY_WRITE(sc, RGEPHY_MII_BMCR, speed |
-				    RGEPHY_BMCR_AUTOEN | RGEPHY_BMCR_STARTNEG);
+				PHY_WRITE(sc, RGEPHY_MII_BMCR, speed);
 				break;
 			}


>Audit-Trail:
From: David Laight <david@l8s.co.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/44630: rgephy(4) likes auto-negotiation too much
Date: Thu, 24 Feb 2011 07:53:53 +0000

 On Thu, Feb 24, 2011 at 06:20:00AM +0000, r.tarnell@IEEE.ORG wrote:
 > >Number:         44630
 > >Category:       kern
 > >Synopsis:       rgephy(4) likes auto-negotiation too much
 ...
 > rgephy(4) enables auto-negotiation even when the user explicitly
 > specifies a media type.  This is unfortunate, because if the switch is
 > forced to 100-FD, the card will fail to negotiate and fall back to
 > 100-HD.  The duplex mismatch makes it so slow as to be unusable.
 > 
 > # ifconfig re0 media 100basetx mediaopt full-duplex
 > # ifconfig re0
 > 	...
 > 	media: Ethernet 100baseTX full-duplex (100baseTX half-duplex)
 > >How-To-Repeat:
 > See description.
 > >Fix:
 > This patch will use the user's specified media type unconditionally if
 > the link1 flag is set on the interface.  This is the same fix FreeBSD
 > uses in r215298.  From what I understand, some hardware revisions
 > become confused by this, which is why it's not enabled by default.

 Does setting the PHYs autonegotiate advertise register (ANAR)
 to the required mode help?
 IMHO that should be done instead of forcing the actual mode.
 The only time this doesn't work is when the PHY auto-detects between
 10M HDX and 100M HDX (which will work regardless of the ANAR settings).

 	David

 -- 
 David Laight: david@l8s.co.uk

From: River Tarnell <r.tarnell@IEEE.ORG>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org
Subject: Re: kern/44630: rgephy(4) likes auto-negotiation too much
Date: Thu, 24 Feb 2011 08:00:34 +0000

 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1

 David Laight:
 >  > rgephy(4) enables auto-negotiation even when the user explicitly
 >  > specifies a media type.  This is unfortunate, because if the switch is
 >  > forced to 100-FD, the card will fail to negotiate and fall back to
 >  > 100-HD.  The duplex mismatch makes it so slow as to be unusable.

 >  Does setting the PHYs autonegotiate advertise register (ANAR)
 >  to the required mode help?

 Isn't this already done when 'ifconfig re0 media 100basetx' is 
 specified?

                 case IFM_100_TX:
                         speed = RGEPHY_S100;
                         anar |= RGEPHY_ANAR_TX_FD | RGEPHY_ANAR_TX;

 ANAR_TX is later removed by 'mediaopt full-duplex':

                         if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) {
                                 speed |= RGEPHY_BMCR_FDX;
                                 gig = RGEPHY_1000CTL_AFD;
                                 anar &= ~(RGEPHY_ANAR_TX | RGEPHY_ANAR_10);

 ... which leaves anar = RGEPHY_ANAR_TX_FD (100Base-TX).

 >  IMHO that should be done instead of forcing the actual mode.

 In this particular case I believe this is the right solution, because 
 the switch is forced to 100-FD, i.e. auto-negotiation is disabled.

 	- river.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (NetBSD)

 iEYEARECAAYFAk1mECIACgkQIXd7fCuc5vLPVgCeMR48UIFok58K1aJA4Z9LacaH
 iMYAn2SV0pJNTiDbVRePUL/cjkC2c0LO
 =hY49
 -----END PGP SIGNATURE-----

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.