Module Name: src
Committed By: msaitoh
Date: Sun Jun 16 06:29:09 UTC 2013
Modified Files:
src/sys/dev/mii: atphy.c brgphy.c mii.h mii_physubr.c rgephy.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/mii/atphy.c
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/mii/brgphy.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/mii/mii.h
cvs rdiff -u -r1.78 -r1.79 src/sys/dev/mii/mii_physubr.c
cvs rdiff -u -r1.32 -r1.33 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.14 src/sys/dev/mii/atphy.c:1.15
--- src/sys/dev/mii/atphy.c:1.14 Sun Jun 9 08:42:16 2013
+++ src/sys/dev/mii/atphy.c Sun Jun 16 06:29:08 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: atphy.c,v 1.14 2013/06/09 08:42:16 msaitoh Exp $ */
+/* $NetBSD: atphy.c,v 1.15 2013/06/16 06:29:08 msaitoh 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.14 2013/06/09 08:42:16 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atphy.c,v 1.15 2013/06/16 06:29:08 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -233,7 +233,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.65 src/sys/dev/mii/brgphy.c:1.66
--- src/sys/dev/mii/brgphy.c:1.65 Fri Jun 14 06:21:51 2013
+++ src/sys/dev/mii/brgphy.c Sun Jun 16 06:29:08 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: brgphy.c,v 1.65 2013/06/14 06:21:51 msaitoh Exp $ */
+/* $NetBSD: brgphy.c,v 1.66 2013/06/16 06:29:08 msaitoh 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.65 2013/06/14 06:21:51 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.66 2013/06/16 06:29:08 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -600,7 +600,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.16 src/sys/dev/mii/mii.h:1.17
--- src/sys/dev/mii/mii.h:1.16 Mon Apr 15 08:09:48 2013
+++ src/sys/dev/mii/mii.h Sun Jun 16 06:29:08 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: mii.h,v 1.16 2013/04/15 08:09:48 msaitoh Exp $ */
+/* $NetBSD: mii.h,v 1.17 2013/06/16 06:29:08 msaitoh 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.78 src/sys/dev/mii/mii_physubr.c:1.79
--- src/sys/dev/mii/mii_physubr.c:1.78 Sun Jun 9 09:56:17 2013
+++ src/sys/dev/mii/mii_physubr.c Sun Jun 16 06:29:08 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: mii_physubr.c,v 1.78 2013/06/09 09:56:17 msaitoh Exp $ */
+/* $NetBSD: mii_physubr.c,v 1.79 2013/06/16 06:29:08 msaitoh 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.78 2013/06/09 09:56:17 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.79 2013/06/16 06:29:08 msaitoh 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;
}
}
@@ -232,8 +232,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;
}
/*
@@ -647,30 +647,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.32 src/sys/dev/mii/rgephy.c:1.33
--- src/sys/dev/mii/rgephy.c:1.32 Sun Jun 9 09:31:32 2013
+++ src/sys/dev/mii/rgephy.c Sun Jun 16 06:29:08 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: rgephy.c,v 1.32 2013/06/09 09:31:32 msaitoh Exp $ */
+/* $NetBSD: rgephy.c,v 1.33 2013/06/16 06:29:08 msaitoh Exp $ */
/*
* Copyright (c) 2003
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.32 2013/06/09 09:31:32 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rgephy.c,v 1.33 2013/06/16 06:29:08 msaitoh Exp $");
/*
@@ -440,7 +440,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);