Article View: fa.netbsd.tech.kern
Article #129mii_ticks = 0 problem
From: Masanobu SAITOH
Date: Mon, 03 Jun 2013 02:41
Date: Mon, 03 Jun 2013 02:41
145 lines
5841 bytes
5841 bytes
Hi.
The following patch fix a problem that a lot of phys misunderstand
the auto negotiation timer. Usually the autonegotiaton timer is set
to 10(MII_ANEGTICKS_GIGE), but a lot of dirver don't work as expected.
e.g.:
(mii_ticks == 0)
ifconfig bge0 media auto up
(after 2 seconds, the link was up)
ifconfig bge0 down
ifconfig bge0 up
(timer start from 2!!!)
This problem is not serious but we should fix to work as we expected.
Currently, some drivers do "sc->mii_ticks = 0;" BEFORE calling
*mii_phy_auto(). Some drivers don't do it. To not to forget it and to
reduce the duplication, I think it's better to move "sc->mii_ticks = 0;"
into *mii_phy_auto().
Any objection?
Index: atphy.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/atphy.c,v
retrieving revision 1.12
diff -u -p -r1.12 atphy.c
--- atphy.c 23 Jul 2012 00:09:49 -0000 1.12
+++ atphy.c 3 Jun 2013 02:34:03 -0000
@@ -289,7 +289,6 @@ done:
if (sc->mii_ticks <= sc->mii_anegticks)
break;
- sc->mii_ticks = 0;
atphy_mii_phy_auto(sc);
break;
}
@@ -405,6 +404,7 @@ atphy_mii_phy_auto(struct mii_softc *sc)
{
uint16_t anar;
+ sc->mii_ticks = 0;
anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA;
if (sc->mii_flags & MIIF_DOPAUSE)
anar |= ANAR_X_PAUSE_TOWARDS;
Index: brgphy.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/brgphy.c,v
retrieving revision 1.63
diff -u -p -r1.63 brgphy.c
--- brgphy.c 1 Apr 2013 13:41:37 -0000 1.63
+++ brgphy.c 3 Jun 2013 02:34:04 -0000
@@ -581,6 +581,7 @@ brgphy_mii_phy_auto(struct mii_softc *sc
{
int anar, ktcr = 0;
+ sc->mii_ticks = 0;
brgphy_loop(sc);
PHY_RESET(sc);
Index: ciphy.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/ciphy.c,v
retrieving revision 1.19
diff -u -p -r1.19 ciphy.c
--- ciphy.c 12 May 2009 14:31:27 -0000 1.19
+++ ciphy.c 3 Jun 2013 02:34:04 -0000
@@ -275,7 +275,6 @@ setit:
if (++sc->mii_ticks <= MII_ANEGTICKS)
break;
- sc->mii_ticks = 0;
mii_phy_auto(sc, 0);
return (0);
}
Index: mii_physubr.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/mii_physubr.c,v
retrieving revision 1.75
diff -u -p -r1.75 mii_physubr.c
--- mii_physubr.c 3 Oct 2012 07:08:58 -0000 1.75
+++ mii_physubr.c 3 Jun 2013 02:34:04 -0000
@@ -202,6 +202,7 @@ mii_phy_auto(struct mii_softc *sc, int w
struct mii_data *mii = sc->mii_pdata;
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
+ sc->mii_ticks = 0;
if ((sc->mii_flags & MIIF_DOINGAUTO) == 0) {
/*
* Check for 1000BASE-X. Autonegotiation is a bit
@@ -346,7 +347,6 @@ mii_phy_tick(struct mii_softc *sc)
if (++sc->mii_ticks <= sc->mii_anegticks)
return (EJUSTRETURN);
- sc->mii_ticks = 0;
PHY_RESET(sc);
if (mii_phy_auto(sc, 0) == EJUSTRETURN)
Index: rgephy.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/rgephy.c,v
retrieving revision 1.29
diff -u -p -r1.29 rgephy.c
--- rgephy.c 18 Jul 2010 03:00:39 -0000 1.29
+++ rgephy.c 3 Jun 2013 02:34:04 -0000
@@ -319,7 +319,6 @@ rgephy_service(struct mii_softc *sc, str
if (sc->mii_ticks <= sc->mii_anegticks)
return 0;
- sc->mii_ticks = 0;
rgephy_mii_phy_auto(sc);
break;
}
@@ -428,6 +427,7 @@ rgephy_mii_phy_auto(struct mii_softc *mi
{
int anar;
+ mii->mii_ticks = 0;
rgephy_loop(mii);
rgephy_reset(mii);
Index: urlphy.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/urlphy.c,v
retrieving revision 1.25
diff -u -p -r1.25 urlphy.c
--- urlphy.c 31 Jan 2009 05:44:05 -0000 1.25
+++ urlphy.c 3 Jun 2013 02:34:04 -0000
@@ -196,7 +196,6 @@ urlphy_service(struct mii_softc *sc, str
if (++sc->mii_ticks <= sc->mii_anegticks)
return (0);
- sc->mii_ticks = 0;
PHY_RESET(sc);
if (mii_phy_auto(sc, 0) == EJUSTRETURN)
--
-----------------------------------------------
SAITOH Masanobu (msaitoh@execsw.org
msaitoh@netbsd.org)
Technical Details
Message-ID:
<fa.cs2437EQlJq9Uf5qhIzWedDLjag@ifi.uio.no>Path:
arc1-ca.pugleaf.net!bp1ni32672pbd.1!nntp.google.com!npeer03.iad.highwinds-media.com!feed-me.highwinds-media.com!cyclone03.ams2.highwinds-media.com!news.highwinds-media.com!voer-me.highwinds-media.com!goblin3!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: b7e13b6095,75d74a6fa0d8344c,start
X-Google-Attributes: gidb7e13b6095,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII-7-bit
X-Received: by 10.66.192.8 with SMTP id hc8mr3737280pac.11.1370227314838;
Sun, 02 Jun 2013 19:41:54 -0700 (PDT)
Path: arc1-ca.pugleaf.net!bp1ni32672pbd.1!nntp.google.com!npeer03.iad.highwinds-media.com!feed-me.highwinds-media.com!cyclone03.ams2.highwinds-media.com!news.highwinds-media.com!voer-me.highwinds-media.com!goblin3!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail
From: Masanobu SAITOH <msaitoh@execsw.org>
Newsgroups: fa.netbsd.tech.kern
Subject: mii_ticks = 0 problem
Date: Mon, 03 Jun 2013 02:41:54 UTC
Organization: Internet mailing list
Lines: 145
Sender: tech-kern-owner@NetBSD.org
Message-ID: <fa.cs2437EQlJq9Uf5qhIzWedDLjag@ifi.uio.no>
NNTP-Posting-Host: mail-jess.uio.no
Mime-Version: 1.0
X-Trace: readme.uio.no 1370227314 13381 129.240.7.9 (3 Jun 2013 02:41:54 GMT)
X-Complaints-To: abuse@uio.no
NNTP-Posting-Date: Mon, 3 Jun 2013 02:41:54 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6
Cc: msaitoh@execsw.org
To: tech-kern@netbsd.org
Delivered-To: tech-kern@netbsd.org
X-Virus-Scanned: amavisd-new at NetBSD.org
List-Id: tech-kern.NetBSD.org
Original-Date: Mon, 03 Jun 2013 11:41:31 +0900
Original-Message-Id: <51AC025B.6080708@execsw.org>
X-Received-Bytes: 5462
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit