diff options
author | marius <marius@FreeBSD.org> | 2004-05-29 18:23:26 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2004-05-29 18:23:26 +0000 |
commit | ab35591f627123ae34119d73d589b19e3a851ae8 (patch) | |
tree | 7b67d977603246eed635bb613877d6bad800c7f7 /sys/dev/mii | |
parent | ad9892f32e3bc2aaaf0ff187fb9bb9fcdc80353c (diff) | |
download | FreeBSD-src-ab35591f627123ae34119d73d589b19e3a851ae8.zip FreeBSD-src-ab35591f627123ae34119d73d589b19e3a851ae8.tar.gz |
DP83840A on hme(4) don't advertise their media capabilities themselves
properly. This causes the autonegotiation to e.g. never establish a
100baseTX full-duplex link. The solution to this problem is to manually
write the capabilities from the BMSR to the ANAR every time a media
change occurs, even when already in autonegotiation mode.
The NetBSD way of doing this is to set their MIIF_FORCEANEG flag in the
NIC driver. This causes mii_phy_setmedia() to call mii_phy_auto() (which
will set the ANAR according to the BMSR) even when the PHY alread is in
autonegotiation mode. However, while doing the same on FreeBSD (which
involves porting the MIIF_FORCEANEG flag and converting nsphy.c to use
mii_phy_setmedia()) fixes autonegotiation, using mii_phy_setmedia()
causes this driver to no longer work properly in the other modes.
Another drawback of that approach is that this will also force writing
the ANAR on other PHYs whose drivers use mii_phy_setmedia() and which
are used with a NIC whose driver sets MIIF_FORCEANEG (e.g. hme(4) is
known to be used together with 3 different PHYs while only the DP83840A
require this workaround).
So instead of moving to MIIF_FORCEANEG, just call mii_phy_auto() in
nsphy_service() unconditionally when hanging off of a hme(4) and serving
a media change
This is part 1/2 of fixing autonegotiation on hme(4) using DP83840A PHYs.
Diffstat (limited to 'sys/dev/mii')
-rw-r--r-- | sys/dev/mii/nsphy.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/dev/mii/nsphy.c b/sys/dev/mii/nsphy.c index 7968498..70676dd 100644 --- a/sys/dev/mii/nsphy.c +++ b/sys/dev/mii/nsphy.c @@ -196,6 +196,7 @@ nsphy_service(sc, mii, cmd) { struct ifmedia_entry *ife = mii->mii_media.ifm_cur; int reg; + device_t parent; switch (cmd) { case MII_POLLSTAT: @@ -223,6 +224,8 @@ nsphy_service(sc, mii, cmd) if ((mii->mii_ifp->if_flags & IFF_UP) == 0) break; + parent = device_get_parent(sc->mii_dev); + reg = PHY_READ(sc, MII_NSPHY_PCR); /* @@ -256,16 +259,20 @@ nsphy_service(sc, mii, cmd) */ reg |= 0x0100 | 0x0400; - if (strcmp(device_get_name(device_get_parent(sc->mii_dev)), - "fxp") == 0) + if (strcmp(device_get_name(parent), "fxp") == 0) PHY_WRITE(sc, MII_NSPHY_PCR, reg); switch (IFM_SUBTYPE(ife->ifm_media)) { case IFM_AUTO: /* - * If we're already in auto mode, just return. + * If we're already in auto mode and don't hang off + * of a hme(4), just return. DP83840A on hme(4) don't + * advertise their media capabilities themselves + * properly so force writing the ANAR according to + * the BMSR by mii_phy_auto() every time. */ - if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) + if ((PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) == 0 && + strcmp(device_get_name(parent), "hme") != 0) return (0); (void) mii_phy_auto(sc); break; |