summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikeb <mikeb@openbsd.org>2013-05-28 09:46:06 +0000
committermikeb <mikeb@openbsd.org>2013-05-28 09:46:06 +0000
commit0919571ef5f773e7b1fb70c644d58d52aa813e1f (patch)
treef7f20bef407e4797b0ef7103d1d81e002cde463a
parentMVME181 updates. (diff)
downloadwireguard-openbsd-0919571ef5f773e7b1fb70c644d58d52aa813e1f.tar.xz
wireguard-openbsd-0919571ef5f773e7b1fb70c644d58d52aa813e1f.zip
Fix a common issue across different PHY drivers to reset the
autonegotiation timer when PHY gets the link so that if we restart the timer the mii_ticks value would be sane. Lifted originally from FreeBSD, tested by a few on re(4) and bge(4), ok kettenis
-rw-r--r--sys/dev/mii/brgphy.c6
-rw-r--r--sys/dev/mii/dcphy.c6
-rw-r--r--sys/dev/mii/mlphy.c3
-rw-r--r--sys/dev/mii/rgephy.c12
-rw-r--r--sys/dev/mii/urlphy.c8
-rw-r--r--sys/dev/mii/xmphy.c6
-rw-r--r--sys/dev/sbus/be.c3
7 files changed, 29 insertions, 15 deletions
diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c
index 7f0bae2ae40..fe39a3e0ea6 100644
--- a/sys/dev/mii/brgphy.c
+++ b/sys/dev/mii/brgphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: brgphy.c,v 1.101 2013/03/17 00:23:44 brad Exp $ */
+/* $OpenBSD: brgphy.c,v 1.102 2013/05/28 09:46:06 mikeb Exp $ */
/*
* Copyright (c) 2000
@@ -412,8 +412,10 @@ setit:
* the BMSR twice in case it's latched.
*/
reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR);
- if (reg & BMSR_LINK)
+ if (reg & BMSR_LINK) {
+ sc->mii_ticks = 0; /* Reset autoneg timer. */
break;
+ }
/*
* Only retry autonegotiation every mii_anegticks seconds.
diff --git a/sys/dev/mii/dcphy.c b/sys/dev/mii/dcphy.c
index d1ad0b4dc44..bde973f28fe 100644
--- a/sys/dev/mii/dcphy.c
+++ b/sys/dev/mii/dcphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dcphy.c,v 1.23 2008/09/11 17:20:18 brad Exp $ */
+/* $OpenBSD: dcphy.c,v 1.24 2013/05/28 09:46:06 mikeb Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -272,8 +272,10 @@ dcphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
break;
reg = CSR_READ_4(dc_sc, DC_10BTSTAT);
- if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100))
+ if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100)) {
+ sc->mii_ticks = 0;
break;
+ }
/*
* Only retry autonegotiation every mii_anegticks seconds.
diff --git a/sys/dev/mii/mlphy.c b/sys/dev/mii/mlphy.c
index 56858b5dafb..b5b458bc899 100644
--- a/sys/dev/mii/mlphy.c
+++ b/sys/dev/mii/mlphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mlphy.c,v 1.2 2011/11/19 13:00:14 claudio Exp $ */
+/* $OpenBSD: mlphy.c,v 1.3 2013/05/28 09:46:06 mikeb Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999
@@ -306,6 +306,7 @@ mlphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
msc->ml_linked = 1;
mlphy_status(sc);
}
+ sc->mii_ticks = 0;
break;
}
/*
diff --git a/sys/dev/mii/rgephy.c b/sys/dev/mii/rgephy.c
index 2c1ddbb950b..2c137700afd 100644
--- a/sys/dev/mii/rgephy.c
+++ b/sys/dev/mii/rgephy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rgephy.c,v 1.29 2008/09/17 07:19:19 brad Exp $ */
+/* $OpenBSD: rgephy.c,v 1.30 2013/05/28 09:46:06 mikeb Exp $ */
/*
* Copyright (c) 2003
* Bill Paul <wpaul@windriver.com>. All rights reserved.
@@ -251,12 +251,16 @@ setit:
*/
if (sc->mii_rev < 2) {
reg = PHY_READ(sc, RL_GMEDIASTAT);
- if (reg & RL_GMEDIASTAT_LINK)
+ if (reg & RL_GMEDIASTAT_LINK) {
+ sc->mii_ticks = 0;
break;
+ }
} else {
reg = PHY_READ(sc, RGEPHY_SR);
- if (reg & RGEPHY_SR_LINK)
+ if (reg & RGEPHY_SR_LINK) {
+ sc->mii_ticks = 0;
break;
+ }
}
/*
@@ -267,7 +271,7 @@ setit:
sc->mii_ticks = 0;
rgephy_mii_phy_auto(sc);
- return (0);
+ break;
}
/* Update the media status. */
diff --git a/sys/dev/mii/urlphy.c b/sys/dev/mii/urlphy.c
index 09df2bd7ccc..96a544607b0 100644
--- a/sys/dev/mii/urlphy.c
+++ b/sys/dev/mii/urlphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: urlphy.c,v 1.13 2008/09/08 07:50:15 brad Exp $ */
+/* $OpenBSD: urlphy.c,v 1.14 2013/05/28 09:46:06 mikeb Exp $ */
/* $NetBSD: urlphy.c,v 1.1 2002/03/28 21:07:53 ichiro Exp $ */
/*
* Copyright (c) 2001, 2002
@@ -186,8 +186,10 @@ urlphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
/* Read the status register twice; MSR_LINK is latch-low. */
reg = PHY_READ(sc, URLPHY_MSR) | PHY_READ(sc, URLPHY_MSR);
- if (reg & URLPHY_MSR_LINK)
- return (0);
+ if (reg & URLPHY_MSR_LINK) {
+ sc->mii_ticks = 0;
+ break;
+ }
/*
* Only retry autonegotiation every mii_anegticks seconds.
diff --git a/sys/dev/mii/xmphy.c b/sys/dev/mii/xmphy.c
index 1d3e2eaba2f..69812fbfb57 100644
--- a/sys/dev/mii/xmphy.c
+++ b/sys/dev/mii/xmphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xmphy.c,v 1.18 2008/09/17 07:19:19 brad Exp $ */
+/* $OpenBSD: xmphy.c,v 1.19 2013/05/28 09:46:06 mikeb Exp $ */
/*
* Copyright (c) 2000
@@ -212,8 +212,10 @@ xmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
* the BMSR twice in case it's latched.
*/
reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR);
- if (reg & BMSR_LINK)
+ if (reg & BMSR_LINK) {
+ sc->mii_ticks = 0;
break;
+ }
/*
* Only retry autonegotiation every mii_anegticks seconds.
diff --git a/sys/dev/sbus/be.c b/sys/dev/sbus/be.c
index 1527ff0008b..d508c4c2512 100644
--- a/sys/dev/sbus/be.c
+++ b/sys/dev/sbus/be.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: be.c,v 1.23 2008/11/28 02:44:18 brad Exp $ */
+/* $OpenBSD: be.c,v 1.24 2013/05/28 09:46:06 mikeb Exp $ */
/* $NetBSD: be.c,v 1.26 2001/03/20 15:39:20 pk Exp $ */
/*-
@@ -1531,6 +1531,7 @@ be_intphy_service(struct be_softc *sc, struct mii_data *mii, int cmd)
sc->sc_dev.dv_xname,
(bmcr & BMCR_S100) ? "100" : "10");
}
+ sc->sc_mii_ticks = 0;
return (0);
}