diff -ruN /mnt/src/share/man/man4/re.4 share/man/man4/re.4 --- /mnt/src/share/man/man4/re.4 2011-01-12 16:14:28.000000000 +0300 +++ share/man/man4/re.4 2011-01-12 19:00:11.000000000 +0300 @@ -178,6 +178,26 @@ .It Va hw.re.msi_disable This tunable disables MSI support on the Ethernet hardware. The default value is 0. +.It Va dev.rgephy.%d.autoneg_can_be_disabled +By default, rgephy, PHY used with supported Realtek controllers, always +uses autonegotiation, even if +.Cm media +or +.Cm mdeiaopt +are specified by user. It is done to avoid bug in some PHY +implementations. Sometimes you need to disable autonegotiation anywhere. +This tunable, if set to non-zero value, enables to use manual media settings +without autonegoteation at all. If +.Cm media +is set as +.Cm autoselect +autonegotiation will not depend on this tunable. This tunable is accessible +as sysctl too, but affects only future using of +.Cm media +and +.Cm mediaopt +options of +.Xr ifconfig 8 .El .Sh DIAGNOSTICS .Bl -diag diff -ruN /mnt/src/sys/dev/mii/rgephy.c sys/dev/mii/rgephy.c --- /mnt/src/sys/dev/mii/rgephy.c 2011-01-12 16:14:26.000000000 +0300 +++ sys/dev/mii/rgephy.c 2011-01-12 18:52:06.000000000 +0300 @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -66,6 +67,7 @@ struct mii_softc mii_sc; int mii_model; int mii_revision; + int mii_autoneg_can_be_disabled; }; static device_method_t rgephy_methods[] = { @@ -113,6 +115,7 @@ struct mii_softc *sc; struct mii_attach_args *ma; struct mii_data *mii; + char tn[64]; rsc = device_get_softc(dev); sc = &rsc->mii_sc; @@ -129,6 +132,16 @@ rsc->mii_model = MII_MODEL(ma->mii_id2); rsc->mii_revision = MII_REV(ma->mii_id2); + + rsc->mii_autoneg_can_be_disabled = 0; + snprintf(tn, sizeof(tn), "dev.%s.%d.autoneg_can_be_disabled", + device_get_name(dev), device_get_unit(dev)); + TUNABLE_INT_FETCH(tn, &rsc->mii_autoneg_can_be_disabled); + SYSCTL_ADD_INT(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "autoneg_can_be_disabled", CTLFLAG_RW, + &rsc->mii_autoneg_can_be_disabled, 0, + "Autonegation can be disabled on adapter"); #define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) @@ -213,11 +226,12 @@ } if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) { + if (!rsc->mii_autoneg_can_be_disabled) + speed |= RGEPHY_BMCR_AUTOEN | + RGEPHY_BMCR_STARTNEG; PHY_WRITE(sc, RGEPHY_MII_1000CTL, 0); PHY_WRITE(sc, RGEPHY_MII_ANAR, anar); - PHY_WRITE(sc, RGEPHY_MII_BMCR, speed | - RGEPHY_BMCR_AUTOEN | - RGEPHY_BMCR_STARTNEG); + PHY_WRITE(sc, RGEPHY_MII_BMCR, speed); break; }