Group: fa.openbsd.tech




Subject: Enable flow control for re(4)
From: Mark Kettenis
Date: 12/28/2006 4:15:06 PM
This diff makes rgephy(4) advertise flow control capabilities when autonegotiating. As far as I can determine this works just fine, but this could use a bit more testing. If the other end of the link support flow control, ifconfig will show you something like: re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 lladdr 00:0c:76:6c:65:a8 groups: egress media: Ethernet autoselect (1000baseT full-duplex,rxpause,txpause) status: active or re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 lladdr 00:0c:76:6c:65:a8 groups: egress media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause) status: active Note that some managed switches have flow control disabled by default, so you might need to turn it on to test whether flow control actually works. But my el-cheapo 100baseTX switch advertises flow control, so this is worth a try even if you don't have a fancy switch. Mark Index: mii/rgephy.c =================================================================== RCS file: /cvs/src/sys/dev/mii/rgephy.c,v retrieving revision 1.20 diff -u -p -r1.20 rgephy.c --- mii/rgephy.c 27 Dec 2006 19:11:09 -0000 1.20 +++ mii/rgephy.c 28 Dec 2006 12:45:37 -0000 @@ -334,7 +334,7 @@ rgephy_status(struct mii_softc *sc) mii->mii_media_active |= IFM_10_T; if (bmsr & RL_GMEDIASTAT_FDX) - mii->mii_media_active |= IFM_FDX; + mii->mii_media_active |= mii_phy_flowstatus(sc) | IFM_FDX; else mii->mii_media_active |= IFM_HDX; @@ -348,11 +348,16 @@ rgephy_status(struct mii_softc *sc) int rgephy_mii_phy_auto(struct mii_softc *sc) { + int anar; + rgephy_loop(sc); PHY_RESET(sc); - PHY_WRITE(sc, RGEPHY_MII_ANAR, - BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA); + anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA; + if (sc->mii_flags & MIIF_DOPAUSE) + anar |= RGEPHY_ANAR_PC | RGEPHY_ANAR_ASP; + + PHY_WRITE(sc, RGEPHY_MII_ANAR, anar); DELAY(1000); PHY_WRITE(sc, RGEPHY_MII_1000CTL, RGEPHY_1000CTL_AHD | RGEPHY_1000CTL_AFD); Index: ic/re.c =================================================================== RCS file: /cvs/src/sys/dev/ic/re.c,v retrieving revision 1.60 diff -u -p -r1.60 re.c --- ic/re.c 21 Dec 2006 05:15:06 -0000 1.60 +++ ic/re.c 28 Dec 2006 12:45:38 -0000 @@ -1001,7 +1001,7 @@ re_attach(struct rl_softc *sc, const cha ifmedia_init(&sc->sc_mii.mii_media, IFM_IMASK, re_ifmedia_upd, re_ifmedia_sts); mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, - MII_OFFSET_ANY, 0); + MII_OFFSET_ANY, MIIF_DOPAUSE); if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) { printf("%s: no PHY found!\n", sc->sc_dev.dv_xname); ifmedia_add(&sc->sc_mii.mii_media,