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.
This commit is contained in:
marius 2004-05-29 18:23:26 +00:00
parent 836a98de10
commit 7065dc23f2

View File

@ -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;