tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

mii_ticks = 0 problem



 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@localhost
                                 msaitoh%netbsd.org@localhost)


Home | Main Index | Thread Index | Old Index