Module Name: src
Committed By: martin
Date: Tue Nov 4 09:23:20 UTC 2014
Modified Files:
src/sys/dev/mii [netbsd-6]: atphy.c brgphy.c mii.h mii_physubr.c
rgephy.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1146):
sys/dev/mii/mii_physubr.c: revision 1.79
sys/dev/mii/rgephy.c: revision 1.33
sys/dev/mii/brgphy.c: revision 1.66
sys/dev/mii/atphy.c: revision 1.15
sys/dev/mii/mii.h: revision 1.17
The bit location of link ability is different between 1000Base-X and others
(See annex 28B.2 and 28D). The old mii.h defined ANAR_X_PAUSE_* macros. Those
macros were named for 1000Base-X, but the bit definitions were not for
1000Base-X but for others (e.g. 1000BaseT). So there was bug in auto
negotiation for 1000Base-X, but there was no bug for other media. Define new
macro named ANAR_PAUSE_* and ANLPAR_PAUSE_* for other than 1000Base-X and fix
the bit definitions of ANAR_X_PAUSE_* and ANLPPAR_X_*. Change some PHY drivers
to use true macro. Same as other *BSDs.
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.8.1 src/sys/dev/mii/atphy.c
cvs rdiff -u -r1.59.8.4 -r1.59.8.5 src/sys/dev/mii/brgphy.c
cvs rdiff -u -r1.14 -r1.14.18.1 src/sys/dev/mii/mii.h
cvs rdiff -u -r1.73 -r1.73.2.1 src/sys/dev/mii/mii_physubr.c
cvs rdiff -u -r1.29 -r1.29.14.1 src/sys/dev/mii/rgephy.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/mii/atphy.c
diff -u src/sys/dev/mii/atphy.c:1.11 src/sys/dev/mii/atphy.c:1.11.8.1
--- src/sys/dev/mii/atphy.c:1.11 Sun Oct 2 21:42:19 2011
+++ src/sys/dev/mii/atphy.c Tue Nov 4 09:23:20 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: atphy.c,v 1.11 2011/10/02 21:42:19 jmcneill Exp $ */
+/* $NetBSD: atphy.c,v 1.11.8.1 2014/11/04 09:23:20 martin Exp $ */
/* $OpenBSD: atphy.c,v 1.1 2008/09/25 20:47:16 brad Exp $ */
/*-
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atphy.c,v 1.11 2011/10/02 21:42:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atphy.c,v 1.11.8.1 2014/11/04 09:23:20 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -231,7 +231,7 @@ atphy_service(struct mii_softc *sc, stru
bmcr |= BMCR_FDX;
/* Enable pause. */
if (sc->mii_flags & MIIF_DOPAUSE)
- anar |= ANAR_X_PAUSE_TOWARDS;
+ anar |= ANAR_PAUSE_TOWARDS;
}
if ((sc->mii_extcapabilities & (EXTSR_1000TFDX |
Index: src/sys/dev/mii/brgphy.c
diff -u src/sys/dev/mii/brgphy.c:1.59.8.4 src/sys/dev/mii/brgphy.c:1.59.8.5
--- src/sys/dev/mii/brgphy.c:1.59.8.4 Mon Nov 18 02:38:15 2013
+++ src/sys/dev/mii/brgphy.c Tue Nov 4 09:23:20 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: brgphy.c,v 1.59.8.4 2013/11/18 02:38:15 msaitoh Exp $ */
+/* $NetBSD: brgphy.c,v 1.59.8.5 2014/11/04 09:23:20 martin Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.59.8.4 2013/11/18 02:38:15 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.59.8.5 2014/11/04 09:23:20 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -638,7 +638,7 @@ brgphy_mii_phy_auto(struct mii_softc *sc
} else {
anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA;
if (sc->mii_flags & MIIF_DOPAUSE)
- anar |= ANAR_FC | ANAR_X_PAUSE_ASYM;
+ anar |= ANAR_FC | ANAR_PAUSE_ASYM;
}
PHY_WRITE(sc, MII_ANAR, anar);
DELAY(1000);
Index: src/sys/dev/mii/mii.h
diff -u src/sys/dev/mii/mii.h:1.14 src/sys/dev/mii/mii.h:1.14.18.1
--- src/sys/dev/mii/mii.h:1.14 Mon Oct 19 18:41:14 2009
+++ src/sys/dev/mii/mii.h Tue Nov 4 09:23:20 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: mii.h,v 1.14 2009/10/19 18:41:14 bouyer Exp $ */
+/* $NetBSD: mii.h,v 1.14.18.1 2014/11/04 09:23:20 martin Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer. All rights reserved.
@@ -107,6 +107,7 @@
#define ANAR_NP 0x8000 /* Next page (ro) */
#define ANAR_ACK 0x4000 /* link partner abilities acknowledged (ro) */
#define ANAR_RF 0x2000 /* remote fault (ro) */
+ /* Annex 28B.2 */
#define ANAR_FC 0x0400 /* local device supports PAUSE */
#define ANAR_T4 0x0200 /* local device supports 100bT4 */
#define ANAR_TX_FD 0x0100 /* local device supports 100bTx FD */
@@ -114,13 +115,18 @@
#define ANAR_10_FD 0x0040 /* local device supports 10bT FD */
#define ANAR_10 0x0020 /* local device supports 10bT */
#define ANAR_CSMA 0x0001 /* protocol selector CSMA/CD */
+#define ANAR_PAUSE_NONE (0 << 10)
+#define ANAR_PAUSE_SYM (1 << 10)
+#define ANAR_PAUSE_ASYM (2 << 10)
+#define ANAR_PAUSE_TOWARDS (3 << 10)
+ /* Annex 28D */
#define ANAR_X_FD 0x0020 /* local device supports 1000BASE-X FD */
#define ANAR_X_HD 0x0040 /* local device supports 1000BASE-X HD */
-#define ANAR_X_PAUSE_NONE (0 << 10)
-#define ANAR_X_PAUSE_SYM (1 << 10)
-#define ANAR_X_PAUSE_ASYM (2 << 10)
-#define ANAR_X_PAUSE_TOWARDS (3 << 10)
+#define ANAR_X_PAUSE_NONE (0 << 7)
+#define ANAR_X_PAUSE_SYM (1 << 7)
+#define ANAR_X_PAUSE_ASYM (2 << 7)
+#define ANAR_X_PAUSE_TOWARDS (3 << 7)
#define MII_ANLPAR 0x05 /* Autonegotiation lnk partner abilities (rw) */
/* section 28.2.4.1 and 37.2.6.1 */
@@ -134,14 +140,19 @@
#define ANLPAR_10_FD 0x0040 /* link partner supports 10bT FD */
#define ANLPAR_10 0x0020 /* link partner supports 10bT */
#define ANLPAR_CSMA 0x0001 /* protocol selector CSMA/CD */
+#define ANLPAR_PAUSE_MASK (3 << 10)
+#define ANLPAR_PAUSE_NONE (0 << 10)
+#define ANLPAR_PAUSE_SYM (1 << 10)
+#define ANLPAR_PAUSE_ASYM (2 << 10)
+#define ANLPAR_PAUSE_TOWARDS (3 << 10)
#define ANLPAR_X_FD 0x0020 /* local device supports 1000BASE-X FD */
#define ANLPAR_X_HD 0x0040 /* local device supports 1000BASE-X HD */
-#define ANLPAR_X_PAUSE_MASK (3 << 10)
-#define ANLPAR_X_PAUSE_NONE (0 << 10)
-#define ANLPAR_X_PAUSE_SYM (1 << 10)
-#define ANLPAR_X_PAUSE_ASYM (2 << 10)
-#define ANLPAR_X_PAUSE_TOWARDS (3 << 10)
+#define ANLPAR_X_PAUSE_MASK (3 << 7)
+#define ANLPAR_X_PAUSE_NONE (0 << 7)
+#define ANLPAR_X_PAUSE_SYM (1 << 7)
+#define ANLPAR_X_PAUSE_ASYM (2 << 7)
+#define ANLPAR_X_PAUSE_TOWARDS (3 << 7)
#define MII_ANER 0x06 /* Autonegotiation expansion (ro) */
/* section 28.2.4.1 and 37.2.6.1 */
Index: src/sys/dev/mii/mii_physubr.c
diff -u src/sys/dev/mii/mii_physubr.c:1.73 src/sys/dev/mii/mii_physubr.c:1.73.2.1
--- src/sys/dev/mii/mii_physubr.c:1.73 Sat Dec 10 02:46:07 2011
+++ src/sys/dev/mii/mii_physubr.c Tue Nov 4 09:23:20 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: mii_physubr.c,v 1.73 2011/12/10 02:46:07 buhrow Exp $ */
+/* $NetBSD: mii_physubr.c,v 1.73.2.1 2014/11/04 09:23:20 martin Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.73 2011/12/10 02:46:07 buhrow Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.73.2.1 2014/11/04 09:23:20 martin Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -177,8 +177,8 @@ mii_phy_setmedia(struct mii_softc *sc)
/* XXX Only 1000BASE-T has PAUSE_ASYM? */
if ((sc->mii_flags & MIIF_HAVE_GTCR) &&
(sc->mii_extcapabilities &
- (EXTSR_1000THDX|EXTSR_1000TFDX)))
- anar |= ANAR_X_PAUSE_ASYM;
+ (EXTSR_1000THDX | EXTSR_1000TFDX)))
+ anar |= ANAR_PAUSE_ASYM;
}
}
@@ -231,8 +231,8 @@ mii_phy_auto(struct mii_softc *sc, int w
/* XXX Only 1000BASE-T has PAUSE_ASYM? */
if ((sc->mii_flags & MIIF_HAVE_GTCR) &&
(sc->mii_extcapabilities &
- (EXTSR_1000THDX|EXTSR_1000TFDX)))
- anar |= ANAR_X_PAUSE_ASYM;
+ (EXTSR_1000THDX | EXTSR_1000TFDX)))
+ anar |= ANAR_PAUSE_ASYM;
}
/*
@@ -630,30 +630,35 @@ mii_phy_flowstatus(struct mii_softc *sc)
anar = PHY_READ(sc, MII_ANAR);
anlpar = PHY_READ(sc, MII_ANLPAR);
- if ((anar & ANAR_X_PAUSE_SYM) & (anlpar & ANLPAR_X_PAUSE_SYM))
+ /* For 1000baseX, the bits are in a different location. */
+ if (sc->mii_flags & MIIF_IS_1000X) {
+ anar <<= 3;
+ anlpar <<= 3;
+ }
+
+ if ((anar & ANAR_PAUSE_SYM) & (anlpar & ANLPAR_PAUSE_SYM))
return (IFM_FLOW|IFM_ETH_TXPAUSE|IFM_ETH_RXPAUSE);
- if ((anar & ANAR_X_PAUSE_SYM) == 0) {
- if ((anar & ANAR_X_PAUSE_ASYM) &&
- ((anlpar &
- ANLPAR_X_PAUSE_TOWARDS) == ANLPAR_X_PAUSE_TOWARDS))
+ if ((anar & ANAR_PAUSE_SYM) == 0) {
+ if ((anar & ANAR_PAUSE_ASYM) &&
+ ((anlpar & ANLPAR_PAUSE_TOWARDS) == ANLPAR_PAUSE_TOWARDS))
return (IFM_FLOW|IFM_ETH_TXPAUSE);
else
return (0);
}
- if ((anar & ANAR_X_PAUSE_ASYM) == 0) {
- if (anlpar & ANLPAR_X_PAUSE_SYM)
+ if ((anar & ANAR_PAUSE_ASYM) == 0) {
+ if (anlpar & ANLPAR_PAUSE_SYM)
return (IFM_FLOW|IFM_ETH_TXPAUSE|IFM_ETH_RXPAUSE);
else
return (0);
}
- switch ((anlpar & ANLPAR_X_PAUSE_TOWARDS)) {
- case ANLPAR_X_PAUSE_NONE:
+ switch ((anlpar & ANLPAR_PAUSE_TOWARDS)) {
+ case ANLPAR_PAUSE_NONE:
return (0);
- case ANLPAR_X_PAUSE_ASYM:
+ case ANLPAR_PAUSE_ASYM:
return (IFM_FLOW|IFM_ETH_RXPAUSE);
default:
Index: src/sys/dev/mii/rgephy.c
diff -u src/sys/dev/mii/rgephy.c:1.29 src/sys/dev/mii/rgephy.c:1.29.14.1
--- src/sys/dev/mii/rgephy.c:1.29 Sun Jul 18 03:00:39 2010
+++ src/sys/dev/mii/rgephy.c Tue Nov 4 09:23:20 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: rgephy.c,v 1.29 2010/07/18 03:00:39 jakllsch Exp $ */
+/* $NetBSD: rgephy.c,v 1.29.14.1 2014/11/04 09:23:20 martin Exp $ */
/*
* Copyright (c) 2003
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.29 2010/07/18 03:00:39 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.29.14.1 2014/11/04 09:23:20 martin Exp $");
/*
@@ -433,7 +433,7 @@ rgephy_mii_phy_auto(struct mii_softc *mi
anar = BMSR_MEDIA_TO_ANAR(mii->mii_capabilities) | ANAR_CSMA;
if (mii->mii_flags & MIIF_DOPAUSE)
- anar |= ANAR_FC | ANAR_X_PAUSE_ASYM;
+ anar |= ANAR_FC | ANAR_PAUSE_ASYM;
PHY_WRITE(mii, MII_ANAR, anar);
DELAY(1000);