2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2001-04-09 21:29:44 +00:00
|
|
|
* Principal Author: Parag Patel
|
|
|
|
* Copyright (c) 2001
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice unmodified, this list of conditions, and the following
|
|
|
|
* disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Additonal Copyright (c) 2001 by Traakan Software under same licence.
|
|
|
|
* Secondary Author: Matthew Jacob
|
|
|
|
*/
|
|
|
|
|
2004-05-29 17:45:45 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2001-04-09 21:29:44 +00:00
|
|
|
/*
|
|
|
|
* driver for the Marvell 88E1000 series external 1000/100/10-BT PHY.
|
|
|
|
*/
|
|
|
|
|
2003-09-20 10:53:08 +00:00
|
|
|
/*
|
|
|
|
* Support added for the Marvell 88E1011 (Alaska) 1000/100/10baseTX and
|
|
|
|
* 1000baseSX PHY.
|
|
|
|
* Nathan Binkert <nate@openbsd.org>
|
|
|
|
* Jung-uk Kim <jkim@niksun.com>
|
|
|
|
*/
|
|
|
|
|
2001-04-09 21:29:44 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
2004-05-30 17:57:46 +00:00
|
|
|
#include <sys/module.h>
|
2001-04-09 21:29:44 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
|
|
|
|
#include <dev/mii/mii.h>
|
|
|
|
#include <dev/mii/miivar.h>
|
2003-01-19 02:59:34 +00:00
|
|
|
#include "miidevs.h"
|
2001-04-09 21:29:44 +00:00
|
|
|
|
|
|
|
#include <dev/mii/e1000phyreg.h>
|
|
|
|
|
|
|
|
#include "miibus_if.h"
|
|
|
|
|
2006-12-11 10:22:24 +00:00
|
|
|
static int e1000phy_probe(device_t);
|
|
|
|
static int e1000phy_attach(device_t);
|
2001-04-09 21:29:44 +00:00
|
|
|
|
2006-12-11 11:09:48 +00:00
|
|
|
struct e1000phy_softc {
|
|
|
|
struct mii_softc mii_sc;
|
|
|
|
int mii_model;
|
|
|
|
};
|
|
|
|
|
2001-04-09 21:29:44 +00:00
|
|
|
static device_method_t e1000phy_methods[] = {
|
|
|
|
/* device interface */
|
|
|
|
DEVMETHOD(device_probe, e1000phy_probe),
|
|
|
|
DEVMETHOD(device_attach, e1000phy_attach),
|
2002-04-29 13:07:38 +00:00
|
|
|
DEVMETHOD(device_detach, mii_phy_detach),
|
2001-04-09 21:29:44 +00:00
|
|
|
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static devclass_t e1000phy_devclass;
|
|
|
|
static driver_t e1000phy_driver = {
|
2006-12-11 11:09:48 +00:00
|
|
|
"e1000phy",
|
|
|
|
e1000phy_methods,
|
|
|
|
sizeof(struct e1000phy_softc)
|
2001-04-09 21:29:44 +00:00
|
|
|
};
|
2006-12-11 11:09:48 +00:00
|
|
|
|
2001-04-09 21:29:44 +00:00
|
|
|
DRIVER_MODULE(e1000phy, miibus, e1000phy_driver, e1000phy_devclass, 0, 0);
|
|
|
|
|
2001-09-29 19:18:52 +00:00
|
|
|
static int e1000phy_service(struct mii_softc *, struct mii_data *, int);
|
|
|
|
static void e1000phy_status(struct mii_softc *);
|
|
|
|
static void e1000phy_reset(struct mii_softc *);
|
o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.
Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks
2010-11-14 13:26:10 +00:00
|
|
|
static int e1000phy_mii_phy_auto(struct e1000phy_softc *, int);
|
2006-12-11 11:09:48 +00:00
|
|
|
|
|
|
|
static const struct mii_phydesc e1000phys[] = {
|
|
|
|
MII_PHY_DESC(MARVELL, E1000),
|
|
|
|
MII_PHY_DESC(MARVELL, E1011),
|
|
|
|
MII_PHY_DESC(MARVELL, E1000_3),
|
|
|
|
MII_PHY_DESC(MARVELL, E1000S),
|
|
|
|
MII_PHY_DESC(MARVELL, E1000_5),
|
2010-08-07 23:16:21 +00:00
|
|
|
MII_PHY_DESC(MARVELL, E1101),
|
2006-12-11 11:09:48 +00:00
|
|
|
MII_PHY_DESC(MARVELL, E3082),
|
|
|
|
MII_PHY_DESC(MARVELL, E1112),
|
|
|
|
MII_PHY_DESC(MARVELL, E1149),
|
|
|
|
MII_PHY_DESC(MARVELL, E1111),
|
|
|
|
MII_PHY_DESC(MARVELL, E1116),
|
2008-09-04 11:09:40 +00:00
|
|
|
MII_PHY_DESC(MARVELL, E1116R),
|
2006-12-11 11:09:48 +00:00
|
|
|
MII_PHY_DESC(MARVELL, E1118),
|
2009-05-25 02:36:29 +00:00
|
|
|
MII_PHY_DESC(MARVELL, E3016),
|
2010-04-30 19:01:55 +00:00
|
|
|
MII_PHY_DESC(MARVELL, PHYG65G),
|
2006-12-11 11:09:48 +00:00
|
|
|
MII_PHY_DESC(xxMARVELL, E1000),
|
|
|
|
MII_PHY_DESC(xxMARVELL, E1011),
|
|
|
|
MII_PHY_DESC(xxMARVELL, E1000_3),
|
|
|
|
MII_PHY_DESC(xxMARVELL, E1000_5),
|
|
|
|
MII_PHY_DESC(xxMARVELL, E1111),
|
|
|
|
MII_PHY_END
|
|
|
|
};
|
2001-04-09 21:29:44 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
e1000phy_probe(device_t dev)
|
|
|
|
{
|
|
|
|
|
2006-12-11 11:09:48 +00:00
|
|
|
return (mii_phy_dev_probe(dev, e1000phys, BUS_PROBE_DEFAULT));
|
2001-04-09 21:29:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
e1000phy_attach(device_t dev)
|
|
|
|
{
|
2006-12-11 11:09:48 +00:00
|
|
|
struct e1000phy_softc *esc;
|
2001-04-09 21:29:44 +00:00
|
|
|
struct mii_softc *sc;
|
|
|
|
struct mii_attach_args *ma;
|
|
|
|
struct mii_data *mii;
|
2009-09-28 21:03:28 +00:00
|
|
|
struct ifnet *ifp;
|
2001-04-09 21:29:44 +00:00
|
|
|
|
2006-12-11 11:09:48 +00:00
|
|
|
esc = device_get_softc(dev);
|
|
|
|
sc = &esc->mii_sc;
|
2001-04-09 21:29:44 +00:00
|
|
|
ma = device_get_ivars(dev);
|
|
|
|
sc->mii_dev = device_get_parent(dev);
|
2010-09-27 20:31:03 +00:00
|
|
|
mii = ma->mii_data;
|
2001-04-09 21:29:44 +00:00
|
|
|
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
|
|
|
|
2010-10-15 14:52:11 +00:00
|
|
|
sc->mii_flags = miibus_get_flags(dev);
|
2010-10-02 18:53:12 +00:00
|
|
|
sc->mii_inst = mii->mii_instance++;
|
2001-04-09 21:29:44 +00:00
|
|
|
sc->mii_phy = ma->mii_phyno;
|
|
|
|
sc->mii_service = e1000phy_service;
|
|
|
|
sc->mii_pdata = mii;
|
2006-12-11 11:09:48 +00:00
|
|
|
|
o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.
Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks
2010-11-14 13:26:10 +00:00
|
|
|
sc->mii_flags |= MIIF_NOMANPAUSE;
|
|
|
|
|
2006-12-11 11:09:48 +00:00
|
|
|
esc->mii_model = MII_MODEL(ma->mii_id2);
|
2009-09-28 21:03:28 +00:00
|
|
|
ifp = sc->mii_pdata->mii_ifp;
|
2010-10-15 14:52:11 +00:00
|
|
|
if (strcmp(ifp->if_dname, "msk") == 0 &&
|
|
|
|
(sc->mii_flags & MIIF_MACPRIV0) != 0)
|
|
|
|
sc->mii_flags |= MIIF_PHYPRIV0;
|
2009-09-28 21:03:28 +00:00
|
|
|
|
2006-12-11 11:09:48 +00:00
|
|
|
switch (esc->mii_model) {
|
|
|
|
case MII_MODEL_MARVELL_E1011:
|
|
|
|
case MII_MODEL_MARVELL_E1112:
|
|
|
|
if (PHY_READ(sc, E1000_ESSR) & E1000_ESSR_FIBER_LINK)
|
|
|
|
sc->mii_flags |= MIIF_HAVEFIBER;
|
|
|
|
break;
|
2008-10-17 05:26:51 +00:00
|
|
|
case MII_MODEL_MARVELL_E1149:
|
|
|
|
/*
|
|
|
|
* Some 88E1149 PHY's page select is initialized to
|
|
|
|
* point to other bank instead of copper/fiber bank
|
|
|
|
* which in turn resulted in wrong registers were
|
|
|
|
* accessed during PHY operation. It is believed that
|
|
|
|
* page 0 should be used for copper PHY so reinitialize
|
|
|
|
* E1000_EADR to select default copper PHY. If parent
|
|
|
|
* device know the type of PHY(either copper or fiber),
|
|
|
|
* that information should be used to select default
|
|
|
|
* type of PHY.
|
|
|
|
*/
|
|
|
|
PHY_WRITE(sc, E1000_EADR, 0);
|
|
|
|
break;
|
2006-12-11 11:09:48 +00:00
|
|
|
}
|
|
|
|
|
2001-04-09 21:29:44 +00:00
|
|
|
e1000phy_reset(sc);
|
|
|
|
|
2009-05-25 01:41:05 +00:00
|
|
|
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
|
|
|
if (sc->mii_capabilities & BMSR_EXTSTAT)
|
|
|
|
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
|
2001-09-29 18:59:17 +00:00
|
|
|
device_printf(dev, " ");
|
2009-05-25 01:41:05 +00:00
|
|
|
mii_phy_add_media(sc);
|
|
|
|
printf("\n");
|
2001-04-09 21:29:44 +00:00
|
|
|
|
|
|
|
MIIBUS_MEDIAINIT(sc->mii_dev);
|
2006-12-11 10:22:24 +00:00
|
|
|
return (0);
|
2001-04-09 21:29:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
e1000phy_reset(struct mii_softc *sc)
|
|
|
|
{
|
2006-12-11 11:09:48 +00:00
|
|
|
struct e1000phy_softc *esc;
|
2008-09-30 08:18:38 +00:00
|
|
|
uint16_t reg, page;
|
2001-04-09 21:29:44 +00:00
|
|
|
|
2006-12-11 11:09:48 +00:00
|
|
|
esc = (struct e1000phy_softc *)sc;
|
2001-04-09 21:29:44 +00:00
|
|
|
reg = PHY_READ(sc, E1000_SCR);
|
2006-12-11 11:09:48 +00:00
|
|
|
if ((sc->mii_flags & MIIF_HAVEFIBER) != 0) {
|
|
|
|
reg &= ~E1000_SCR_AUTO_X_MODE;
|
|
|
|
PHY_WRITE(sc, E1000_SCR, reg);
|
|
|
|
if (esc->mii_model == MII_MODEL_MARVELL_E1112) {
|
|
|
|
/* Select 1000BASE-X only mode. */
|
2008-09-30 08:18:38 +00:00
|
|
|
page = PHY_READ(sc, E1000_EADR);
|
2006-12-11 11:09:48 +00:00
|
|
|
PHY_WRITE(sc, E1000_EADR, 2);
|
|
|
|
reg = PHY_READ(sc, E1000_SCR);
|
|
|
|
reg &= ~E1000_SCR_MODE_MASK;
|
|
|
|
reg |= E1000_SCR_MODE_1000BX;
|
|
|
|
PHY_WRITE(sc, E1000_SCR, reg);
|
2010-10-30 20:51:25 +00:00
|
|
|
if ((sc->mii_flags & MIIF_PHYPRIV0) != 0) {
|
2009-09-28 21:03:28 +00:00
|
|
|
/* Set SIGDET polarity low for SFP module. */
|
|
|
|
PHY_WRITE(sc, E1000_EADR, 1);
|
|
|
|
reg = PHY_READ(sc, E1000_SCR);
|
|
|
|
reg |= E1000_SCR_FIB_SIGDET_POLARITY;
|
|
|
|
PHY_WRITE(sc, E1000_SCR, reg);
|
|
|
|
}
|
2008-09-30 08:18:38 +00:00
|
|
|
PHY_WRITE(sc, E1000_EADR, page);
|
2006-12-11 11:09:48 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (esc->mii_model) {
|
|
|
|
case MII_MODEL_MARVELL_E1111:
|
|
|
|
case MII_MODEL_MARVELL_E1112:
|
|
|
|
case MII_MODEL_MARVELL_E1116:
|
|
|
|
case MII_MODEL_MARVELL_E1118:
|
|
|
|
case MII_MODEL_MARVELL_E1149:
|
2010-04-30 19:01:55 +00:00
|
|
|
case MII_MODEL_MARVELL_PHYG65G:
|
2006-12-11 11:09:48 +00:00
|
|
|
/* Disable energy detect mode. */
|
|
|
|
reg &= ~E1000_SCR_EN_DETECT_MASK;
|
|
|
|
reg |= E1000_SCR_AUTO_X_MODE;
|
2007-10-29 05:50:22 +00:00
|
|
|
if (esc->mii_model == MII_MODEL_MARVELL_E1116)
|
|
|
|
reg &= ~E1000_SCR_POWER_DOWN;
|
2009-05-25 02:36:29 +00:00
|
|
|
reg |= E1000_SCR_ASSERT_CRS_ON_TX;
|
2006-12-11 11:09:48 +00:00
|
|
|
break;
|
|
|
|
case MII_MODEL_MARVELL_E3082:
|
|
|
|
reg |= (E1000_SCR_AUTO_X_MODE >> 1);
|
2009-05-25 02:36:29 +00:00
|
|
|
reg |= E1000_SCR_ASSERT_CRS_ON_TX;
|
|
|
|
break;
|
|
|
|
case MII_MODEL_MARVELL_E3016:
|
|
|
|
reg |= E1000_SCR_AUTO_MDIX;
|
|
|
|
reg &= ~(E1000_SCR_EN_DETECT |
|
|
|
|
E1000_SCR_SCRAMBLER_DISABLE);
|
|
|
|
reg |= E1000_SCR_LPNP;
|
|
|
|
/* XXX Enable class A driver for Yukon FE+ A0. */
|
|
|
|
PHY_WRITE(sc, 0x1C, PHY_READ(sc, 0x1C) | 0x0001);
|
2001-04-09 21:29:44 +00:00
|
|
|
break;
|
2006-12-11 11:09:48 +00:00
|
|
|
default:
|
|
|
|
reg &= ~E1000_SCR_AUTO_X_MODE;
|
2009-05-25 02:36:29 +00:00
|
|
|
reg |= E1000_SCR_ASSERT_CRS_ON_TX;
|
2006-12-11 11:09:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-05-25 02:36:29 +00:00
|
|
|
if (esc->mii_model != MII_MODEL_MARVELL_E3016) {
|
|
|
|
/* Auto correction for reversed cable polarity. */
|
|
|
|
reg &= ~E1000_SCR_POLARITY_REVERSAL;
|
|
|
|
}
|
2006-12-11 11:09:48 +00:00
|
|
|
PHY_WRITE(sc, E1000_SCR, reg);
|
2007-10-29 05:50:22 +00:00
|
|
|
|
2009-06-02 00:30:30 +00:00
|
|
|
if (esc->mii_model == MII_MODEL_MARVELL_E1116 ||
|
|
|
|
esc->mii_model == MII_MODEL_MARVELL_E1149) {
|
2007-10-29 05:50:22 +00:00
|
|
|
PHY_WRITE(sc, E1000_EADR, 2);
|
|
|
|
reg = PHY_READ(sc, E1000_SCR);
|
|
|
|
reg |= E1000_SCR_RGMII_POWER_UP;
|
|
|
|
PHY_WRITE(sc, E1000_SCR, reg);
|
2009-08-18 20:20:15 +00:00
|
|
|
PHY_WRITE(sc, E1000_EADR, 0);
|
2007-10-29 05:50:22 +00:00
|
|
|
}
|
2001-04-09 21:29:44 +00:00
|
|
|
}
|
|
|
|
|
2009-09-28 19:48:17 +00:00
|
|
|
switch (esc->mii_model) {
|
2006-12-11 11:09:48 +00:00
|
|
|
case MII_MODEL_MARVELL_E3082:
|
|
|
|
case MII_MODEL_MARVELL_E1112:
|
|
|
|
case MII_MODEL_MARVELL_E1118:
|
2009-06-02 00:30:30 +00:00
|
|
|
break;
|
|
|
|
case MII_MODEL_MARVELL_E1116:
|
|
|
|
page = PHY_READ(sc, E1000_EADR);
|
|
|
|
/* Select page 3, LED control register. */
|
|
|
|
PHY_WRITE(sc, E1000_EADR, 3);
|
|
|
|
PHY_WRITE(sc, E1000_SCR,
|
|
|
|
E1000_SCR_LED_LOS(1) | /* Link/Act */
|
|
|
|
E1000_SCR_LED_INIT(8) | /* 10Mbps */
|
|
|
|
E1000_SCR_LED_STAT1(7) | /* 100Mbps */
|
|
|
|
E1000_SCR_LED_STAT0(7)); /* 1000Mbps */
|
|
|
|
/* Set blink rate. */
|
|
|
|
PHY_WRITE(sc, E1000_IER, E1000_PULSE_DUR(E1000_PULSE_170MS) |
|
|
|
|
E1000_BLINK_RATE(E1000_BLINK_84MS));
|
|
|
|
PHY_WRITE(sc, E1000_EADR, page);
|
2006-12-11 11:09:48 +00:00
|
|
|
break;
|
2009-05-25 02:36:29 +00:00
|
|
|
case MII_MODEL_MARVELL_E3016:
|
|
|
|
/* LED2 -> ACT, LED1 -> LINK, LED0 -> SPEED. */
|
|
|
|
PHY_WRITE(sc, 0x16, 0x0B << 8 | 0x05 << 4 | 0x04);
|
|
|
|
/* Integrated register calibration workaround. */
|
|
|
|
PHY_WRITE(sc, 0x1D, 17);
|
|
|
|
PHY_WRITE(sc, 0x1E, 0x3F60);
|
|
|
|
break;
|
2006-12-11 11:09:48 +00:00
|
|
|
default:
|
|
|
|
/* Force TX_CLK to 25MHz clock. */
|
|
|
|
reg = PHY_READ(sc, E1000_ESCR);
|
|
|
|
reg |= E1000_ESCR_TX_CLK_25;
|
|
|
|
PHY_WRITE(sc, E1000_ESCR, reg);
|
|
|
|
break;
|
|
|
|
}
|
2001-04-09 21:29:44 +00:00
|
|
|
|
2006-12-11 11:09:48 +00:00
|
|
|
/* Reset the PHY so all changes take effect. */
|
|
|
|
reg = PHY_READ(sc, E1000_CR);
|
|
|
|
reg |= E1000_CR_RESET;
|
|
|
|
PHY_WRITE(sc, E1000_CR, reg);
|
2001-04-09 21:29:44 +00:00
|
|
|
}
|
|
|
|
|
2001-09-29 19:18:52 +00:00
|
|
|
static int
|
2001-04-09 21:29:44 +00:00
|
|
|
e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
|
|
|
{
|
|
|
|
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
2006-12-11 11:09:48 +00:00
|
|
|
struct e1000phy_softc *esc = (struct e1000phy_softc *)sc;
|
|
|
|
uint16_t speed, gig;
|
2001-04-09 21:29:44 +00:00
|
|
|
int reg;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case MII_POLLSTAT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MII_MEDIACHG:
|
|
|
|
/*
|
|
|
|
* If the interface is not up, don't do anything.
|
|
|
|
*/
|
2006-12-11 10:22:24 +00:00
|
|
|
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
2001-04-09 21:29:44 +00:00
|
|
|
break;
|
|
|
|
|
2006-12-11 11:09:48 +00:00
|
|
|
if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) {
|
o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.
Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks
2010-11-14 13:26:10 +00:00
|
|
|
e1000phy_mii_phy_auto(esc, ife->ifm_media);
|
2001-04-09 21:29:44 +00:00
|
|
|
break;
|
2006-12-11 11:09:48 +00:00
|
|
|
}
|
2001-04-09 21:29:44 +00:00
|
|
|
|
2006-12-11 11:09:48 +00:00
|
|
|
speed = 0;
|
|
|
|
switch (IFM_SUBTYPE(ife->ifm_media)) {
|
2002-04-28 20:34:20 +00:00
|
|
|
case IFM_1000_T:
|
2009-05-25 01:41:05 +00:00
|
|
|
if ((sc->mii_extcapabilities &
|
|
|
|
(EXTSR_1000TFDX | EXTSR_1000THDX)) == 0)
|
2006-12-11 11:09:48 +00:00
|
|
|
return (EINVAL);
|
|
|
|
speed = E1000_CR_SPEED_1000;
|
2001-04-09 21:29:44 +00:00
|
|
|
break;
|
2003-09-20 10:53:08 +00:00
|
|
|
case IFM_1000_SX:
|
2009-05-25 01:41:05 +00:00
|
|
|
if ((sc->mii_extcapabilities &
|
|
|
|
(EXTSR_1000XFDX | EXTSR_1000XHDX)) == 0)
|
2006-12-11 11:09:48 +00:00
|
|
|
return (EINVAL);
|
|
|
|
speed = E1000_CR_SPEED_1000;
|
2003-09-20 10:53:08 +00:00
|
|
|
break;
|
2001-04-09 21:29:44 +00:00
|
|
|
case IFM_100_TX:
|
2006-12-11 11:09:48 +00:00
|
|
|
speed = E1000_CR_SPEED_100;
|
2001-04-09 21:29:44 +00:00
|
|
|
break;
|
|
|
|
case IFM_10_T:
|
2006-12-11 11:09:48 +00:00
|
|
|
speed = E1000_CR_SPEED_10;
|
2001-04-09 21:29:44 +00:00
|
|
|
break;
|
2006-12-11 11:09:48 +00:00
|
|
|
case IFM_NONE:
|
|
|
|
reg = PHY_READ(sc, E1000_CR);
|
|
|
|
PHY_WRITE(sc, E1000_CR,
|
|
|
|
reg | E1000_CR_ISOLATE | E1000_CR_POWER_DOWN);
|
|
|
|
goto done;
|
2001-04-09 21:29:44 +00:00
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
2006-12-11 11:09:48 +00:00
|
|
|
if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) {
|
|
|
|
speed |= E1000_CR_FULL_DUPLEX;
|
|
|
|
gig = E1000_1GCR_1000T_FD;
|
|
|
|
} else
|
|
|
|
gig = E1000_1GCR_1000T;
|
|
|
|
|
|
|
|
reg = PHY_READ(sc, E1000_CR);
|
|
|
|
reg &= ~E1000_CR_AUTO_NEG_ENABLE;
|
|
|
|
PHY_WRITE(sc, E1000_CR, reg | E1000_CR_RESET);
|
2001-04-09 21:29:44 +00:00
|
|
|
|
o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.
Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks
2010-11-14 13:26:10 +00:00
|
|
|
if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) {
|
|
|
|
gig |= E1000_1GCR_MS_ENABLE;
|
|
|
|
if ((ife->ifm_media & IFM_ETH_MASTER) != 0)
|
|
|
|
gig |= E1000_1GCR_MS_VALUE;
|
|
|
|
PHY_WRITE(sc, E1000_1GCR, gig);
|
|
|
|
} else if ((sc->mii_extcapabilities &
|
|
|
|
(EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
|
|
|
|
PHY_WRITE(sc, E1000_1GCR, 0);
|
2006-12-11 11:09:48 +00:00
|
|
|
PHY_WRITE(sc, E1000_AR, E1000_AR_SELECTOR_FIELD);
|
|
|
|
PHY_WRITE(sc, E1000_CR, speed | E1000_CR_RESET);
|
|
|
|
done:
|
|
|
|
break;
|
2001-04-09 21:29:44 +00:00
|
|
|
case MII_TICK:
|
|
|
|
/*
|
2001-09-29 19:18:52 +00:00
|
|
|
* Is the interface even up?
|
2001-04-09 21:29:44 +00:00
|
|
|
*/
|
2001-09-29 19:18:52 +00:00
|
|
|
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
2001-04-09 21:29:44 +00:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
/*
|
2001-09-29 19:18:52 +00:00
|
|
|
* Only used for autonegotiation.
|
2001-04-09 21:29:44 +00:00
|
|
|
*/
|
2007-11-16 10:39:18 +00:00
|
|
|
if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) {
|
|
|
|
sc->mii_ticks = 0;
|
2001-09-29 19:18:52 +00:00
|
|
|
break;
|
2007-11-16 10:39:18 +00:00
|
|
|
}
|
2001-04-09 21:29:44 +00:00
|
|
|
|
|
|
|
/*
|
2001-09-29 19:18:52 +00:00
|
|
|
* check for link.
|
|
|
|
* Read the status register twice; BMSR_LINK is latch-low.
|
2001-04-09 21:29:44 +00:00
|
|
|
*/
|
2001-09-29 19:18:52 +00:00
|
|
|
reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR);
|
2006-12-11 11:09:48 +00:00
|
|
|
if (reg & BMSR_LINK) {
|
|
|
|
sc->mii_ticks = 0;
|
2001-09-29 19:18:52 +00:00
|
|
|
break;
|
2006-12-11 11:09:48 +00:00
|
|
|
}
|
2001-04-09 21:29:44 +00:00
|
|
|
|
2006-12-11 11:09:48 +00:00
|
|
|
/* Announce link loss right after it happens. */
|
2007-11-16 10:39:18 +00:00
|
|
|
if (sc->mii_ticks++ == 0)
|
|
|
|
break;
|
2006-12-11 11:09:48 +00:00
|
|
|
if (sc->mii_ticks <= sc->mii_anegticks)
|
2009-05-25 01:45:28 +00:00
|
|
|
break;
|
2001-04-09 21:29:44 +00:00
|
|
|
|
2001-09-29 19:18:52 +00:00
|
|
|
sc->mii_ticks = 0;
|
2001-04-09 21:29:44 +00:00
|
|
|
e1000phy_reset(sc);
|
o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.
Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks
2010-11-14 13:26:10 +00:00
|
|
|
e1000phy_mii_phy_auto(esc, ife->ifm_media);
|
2006-12-11 11:09:48 +00:00
|
|
|
break;
|
2001-04-09 21:29:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the media status. */
|
|
|
|
e1000phy_status(sc);
|
|
|
|
|
|
|
|
/* Callback if something changed. */
|
2001-09-29 19:18:52 +00:00
|
|
|
mii_phy_update(sc, cmd);
|
2001-04-09 21:29:44 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2001-09-29 19:18:52 +00:00
|
|
|
static void
|
2001-04-09 21:29:44 +00:00
|
|
|
e1000phy_status(struct mii_softc *sc)
|
|
|
|
{
|
|
|
|
struct mii_data *mii = sc->mii_pdata;
|
o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.
Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks
2010-11-14 13:26:10 +00:00
|
|
|
int bmcr, bmsr, ssr;
|
2001-04-09 21:29:44 +00:00
|
|
|
|
|
|
|
mii->mii_media_status = IFM_AVALID;
|
|
|
|
mii->mii_media_active = IFM_ETHER;
|
|
|
|
|
|
|
|
bmsr = PHY_READ(sc, E1000_SR) | PHY_READ(sc, E1000_SR);
|
|
|
|
bmcr = PHY_READ(sc, E1000_CR);
|
|
|
|
ssr = PHY_READ(sc, E1000_SSR);
|
|
|
|
|
|
|
|
if (bmsr & E1000_SR_LINK_STATUS)
|
|
|
|
mii->mii_media_status |= IFM_ACTIVE;
|
|
|
|
|
|
|
|
if (bmcr & E1000_CR_LOOPBACK)
|
|
|
|
mii->mii_media_active |= IFM_LOOP;
|
|
|
|
|
2009-05-25 01:56:19 +00:00
|
|
|
if ((bmcr & E1000_CR_AUTO_NEG_ENABLE) != 0 &&
|
|
|
|
(ssr & E1000_SSR_SPD_DPLX_RESOLVED) == 0) {
|
2001-04-09 21:29:44 +00:00
|
|
|
/* Erg, still trying, I guess... */
|
|
|
|
mii->mii_media_active |= IFM_NONE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-09-20 10:53:08 +00:00
|
|
|
if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
|
2009-05-25 01:56:19 +00:00
|
|
|
switch (ssr & E1000_SSR_SPEED) {
|
|
|
|
case E1000_SSR_1000MBS:
|
2003-09-20 10:53:08 +00:00
|
|
|
mii->mii_media_active |= IFM_1000_T;
|
2009-05-25 01:56:19 +00:00
|
|
|
break;
|
|
|
|
case E1000_SSR_100MBS:
|
2003-09-20 10:53:08 +00:00
|
|
|
mii->mii_media_active |= IFM_100_TX;
|
2009-05-25 01:56:19 +00:00
|
|
|
break;
|
|
|
|
case E1000_SSR_10MBS:
|
2003-09-20 10:53:08 +00:00
|
|
|
mii->mii_media_active |= IFM_10_T;
|
2009-05-25 01:56:19 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mii->mii_media_active |= IFM_NONE;
|
|
|
|
return;
|
|
|
|
}
|
2003-09-20 10:53:08 +00:00
|
|
|
} else {
|
2009-09-28 19:53:53 +00:00
|
|
|
/*
|
|
|
|
* Some fiber PHY(88E1112) does not seem to set resolved
|
|
|
|
* speed so always assume we've got IFM_1000_SX.
|
|
|
|
*/
|
|
|
|
mii->mii_media_active |= IFM_1000_SX;
|
2003-09-20 10:53:08 +00:00
|
|
|
}
|
2001-04-09 21:29:44 +00:00
|
|
|
|
o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.
Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks
2010-11-14 13:26:10 +00:00
|
|
|
if (ssr & E1000_SSR_DUPLEX) {
|
2001-04-09 21:29:44 +00:00
|
|
|
mii->mii_media_active |= IFM_FDX;
|
o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.
Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks
2010-11-14 13:26:10 +00:00
|
|
|
if ((sc->mii_flags & MIIF_HAVEFIBER) == 0)
|
|
|
|
mii->mii_media_active |= mii_phy_flowstatus(sc);
|
|
|
|
} else
|
2001-04-09 21:29:44 +00:00
|
|
|
mii->mii_media_active |= IFM_HDX;
|
|
|
|
|
o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.
Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks
2010-11-14 13:26:10 +00:00
|
|
|
if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T) {
|
|
|
|
if (((PHY_READ(sc, E1000_1GSR) | PHY_READ(sc, E1000_1GSR)) &
|
|
|
|
E1000_1GSR_MS_CONFIG_RES) != 0)
|
|
|
|
mii->mii_media_active |= IFM_ETH_MASTER;
|
2006-12-11 11:09:48 +00:00
|
|
|
}
|
2001-04-09 21:29:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.
Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks
2010-11-14 13:26:10 +00:00
|
|
|
e1000phy_mii_phy_auto(struct e1000phy_softc *esc, int media)
|
2001-04-09 21:29:44 +00:00
|
|
|
{
|
2006-12-11 11:09:48 +00:00
|
|
|
struct mii_softc *sc;
|
2009-05-25 02:05:00 +00:00
|
|
|
uint16_t reg;
|
2001-04-09 21:29:44 +00:00
|
|
|
|
2006-12-11 11:09:48 +00:00
|
|
|
sc = &esc->mii_sc;
|
2009-05-25 02:05:00 +00:00
|
|
|
if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
|
|
|
|
reg = PHY_READ(sc, E1000_AR);
|
|
|
|
reg |= E1000_AR_10T | E1000_AR_10T_FD |
|
o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.
Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks
2010-11-14 13:26:10 +00:00
|
|
|
E1000_AR_100TX | E1000_AR_100TX_FD;
|
|
|
|
if ((media & IFM_FLOW) != 0 ||
|
|
|
|
(sc->mii_flags & MIIF_FORCEPAUSE) != 0)
|
|
|
|
reg |= E1000_AR_PAUSE | E1000_AR_ASM_DIR;
|
2009-05-25 02:05:00 +00:00
|
|
|
PHY_WRITE(sc, E1000_AR, reg | E1000_AR_SELECTOR_FIELD);
|
|
|
|
} else
|
o Flesh out the generic IEEE 802.3 annex 31B full duplex flow control
support in mii(4):
- Merge generic flow control advertisement (which can be enabled by
passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from
NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD,
IFM_FLOW isn't implemented as a global option via the "don't care
mask" but instead as a media specific option this. This has the
following advantages:
o allows flow control advertisement with autonegotiation to be
turned on and off via ifconfig(8) with the default typically
being off (though MIIF_FORCEPAUSE has been added causing flow
control to be always advertised, allowing to easily MFC this
changes for drivers that previously used home-grown support for
flow control that behaved that way without breaking POLA)
o allows to deal with PHY drivers where flow control advertisement
with manual selection doesn't work or at least isn't implemented,
like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4),
by setting MIIF_NOMANPAUSE
o the available combinations of media options are readily available
from the `ifconfig -m` output
- Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE
and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so
these are understood by ifconfig(8).
o Make the master/slave support in mii(4) actually usable:
- Change IFM_ETH_MASTER from being implemented as a global option via
the "don't care mask" to a media specific one as it actually is only
applicable to IFM_1000_T to date.
- Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to
actually configure manually selected slave mode (like we also do in
the PHY specific implementations).
- Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it
is understood by ifconfig(8).
o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4),
e1000phy(4) and ip1000phy(4) to use the generic flow control support
instead of home-grown solutions via IFM_FLAGs. This includes changing
these PHY drivers and smcphy(4) to no longer unconditionally advertise
support for flow control but only if the selected media has IFM_FLOW
set (or MIIF_FORCEPAUSE is set) and implemented for these media variants,
i.e. typically only for copper.
o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and
set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0
and some IFM_FLAGn.
o Switch brgphy(4) to add at least the the supported copper media based on
the contents of the BMSR via mii_phy_add_media() instead of hardcoding
them. The latter approach seems to have developed historically, besides
causing unnecessary code duplication it was also undesirable because
brgphy_mii_phy_auto() already based the capability advertisement on the
contents of the BMSR though.
o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not
just BCM5701. Apparently this was a misinterpretation of a workaround
in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and
BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but
this doesn't mean we can't set these as well on other PHYs for manual
media selection.
o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so
IFM_1000_T master mode support now is generally available with all PHY
drivers.
o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's
not applicable there.
Reviewed by: yongari (plus additional testing)
Obtained from: NetBSD (partially), OpenBSD (partially)
MFC after: 2 weeks
2010-11-14 13:26:10 +00:00
|
|
|
PHY_WRITE(sc, E1000_AR, E1000_FA_1000X_FD | E1000_FA_1000X);
|
2009-05-25 01:41:05 +00:00
|
|
|
if ((sc->mii_extcapabilities & (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
|
2006-12-11 11:09:48 +00:00
|
|
|
PHY_WRITE(sc, E1000_1GCR,
|
|
|
|
E1000_1GCR_1000T_FD | E1000_1GCR_1000T);
|
|
|
|
PHY_WRITE(sc, E1000_CR,
|
|
|
|
E1000_CR_AUTO_NEG_ENABLE | E1000_CR_RESTART_AUTO_NEG);
|
2001-04-09 21:29:44 +00:00
|
|
|
|
|
|
|
return (EJUSTRETURN);
|
|
|
|
}
|