Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/mii The bit location of link ability is different be...
details: https://anonhg.NetBSD.org/src/rev/04048d899599
branches: trunk
changeset: 787401:04048d899599
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Sun Jun 16 06:29:08 2013 +0000
description:
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.
diffstat:
sys/dev/mii/atphy.c | 6 +++---
sys/dev/mii/brgphy.c | 6 +++---
sys/dev/mii/mii.h | 31 +++++++++++++++++++++----------
sys/dev/mii/mii_physubr.c | 37 +++++++++++++++++++++----------------
sys/dev/mii/rgephy.c | 6 +++---
5 files changed, 51 insertions(+), 35 deletions(-)
diffs (232 lines):
diff -r da37b8a103c7 -r 04048d899599 sys/dev/mii/atphy.c
--- a/sys/dev/mii/atphy.c Sun Jun 16 03:55:35 2013 +0000
+++ b/sys/dev/mii/atphy.c Sun Jun 16 06:29:08 2013 +0000
@@ -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 @@
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 |
diff -r da37b8a103c7 -r 04048d899599 sys/dev/mii/brgphy.c
--- a/sys/dev/mii/brgphy.c Sun Jun 16 03:55:35 2013 +0000
+++ b/sys/dev/mii/brgphy.c Sun Jun 16 06:29:08 2013 +0000
@@ -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 @@
} 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);
diff -r da37b8a103c7 -r 04048d899599 sys/dev/mii/mii.h
--- a/sys/dev/mii/mii.h Sun Jun 16 03:55:35 2013 +0000
+++ b/sys/dev/mii/mii.h Sun Jun 16 06:29:08 2013 +0000
@@ -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 */
diff -r da37b8a103c7 -r 04048d899599 sys/dev/mii/mii_physubr.c
--- a/sys/dev/mii/mii_physubr.c Sun Jun 16 03:55:35 2013 +0000
+++ b/sys/dev/mii/mii_physubr.c Sun Jun 16 06:29:08 2013 +0000
@@ -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 @@
/* 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 @@
/* 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 @@
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:
diff -r da37b8a103c7 -r 04048d899599 sys/dev/mii/rgephy.c
--- a/sys/dev/mii/rgephy.c Sun Jun 16 03:55:35 2013 +0000
+++ b/sys/dev/mii/rgephy.c Sun Jun 16 06:29:08 2013 +0000
@@ -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 @@
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);
Home |
Main Index |
Thread Index |
Old Index