- In the spirit of previous simplifications factor out the checks for a
different PHY instance being selected and isolation out into the wrappers around the service methods rather than duplicating them over and over again (besides, a PHY driver shouldn't need to care about which instance it actually is). - Centralize the check for the need to isolate a non-zero PHY instance not supporting isolation in mii_mediachg() and just ignore it rather than panicing, which should sufficient given that a) things are likely to just work anyway if one doesn't plug in more than one port at a time and b) refusing to attach in this case just leaves us in a unknown but most likely also not exactly correct configuration (besides several drivers setting MIIF_NOISOLATE didn't care about these anyway, probably due to setting this flag for no real reason). - Minor fixes like removing unnecessary setting of sc->mii_anegticks, using sc->mii_anegticks instead of hardcoded values etc.
This commit is contained in:
parent
a03e344a7f
commit
de1add1e45
@ -149,7 +149,7 @@ dcphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = dcphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
@ -159,8 +159,6 @@ dcphy_attach(device_t dev)
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
/*dcphy_reset(sc);*/
|
||||
dc_sc = mii->mii_ifp->if_softc;
|
||||
CSR_WRITE_4(dc_sc, DC_10BTSTAT, 0);
|
||||
@ -204,21 +202,9 @@ dcphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -275,12 +261,6 @@ dcphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
|
@ -132,7 +132,7 @@ pnphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = pnphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
@ -142,8 +142,6 @@ pnphy_attach(device_t dev)
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
sc->mii_capabilities =
|
||||
BMSR_100TXFDX | BMSR_100TXHDX | BMSR_10TFDX | BMSR_10THDX;
|
||||
sc->mii_capabilities &= ma->mii_capmask;
|
||||
@ -162,21 +160,9 @@ pnphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -211,12 +197,6 @@ pnphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
|
@ -132,17 +132,14 @@ acphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = acphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
acphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
@ -167,22 +164,8 @@ acphy_attach(device_t dev)
|
||||
static int
|
||||
acphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
/*
|
||||
* If we're not selected, then do nothing, just isolate and power
|
||||
* down, if changing media.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
if (cmd == MII_MEDIACHG) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO | BMCR_PDOWN);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
break;
|
||||
|
@ -109,13 +109,11 @@ amphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = amphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
#if 0
|
||||
@ -125,8 +123,7 @@ amphy_attach(device_t dev)
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
@ -138,29 +135,12 @@ amphy_attach(device_t dev)
|
||||
static int
|
||||
amphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -171,11 +151,6 @@ amphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
|
@ -113,13 +113,10 @@ atphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = atphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
sc->mii_anegticks = MII_ANEGTICKS_GIGE;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
asc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
|
||||
asc->mii_model = MII_MODEL(ma->mii_id2);
|
||||
@ -149,24 +146,9 @@ atphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
bmcr = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -224,12 +206,6 @@ atphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
|
@ -99,12 +99,12 @@ axphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = axphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
mii->mii_instance++;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
@ -122,22 +122,12 @@ axphy_attach(device_t dev)
|
||||
static int
|
||||
axphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -148,8 +138,6 @@ axphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
|
@ -147,17 +147,14 @@ bmtphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = bmtphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
@ -170,31 +167,12 @@ bmtphy_attach(device_t dev)
|
||||
static int
|
||||
bmtphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife;
|
||||
int reg;
|
||||
|
||||
ife = mii->mii_media.ifm_cur;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -205,11 +183,6 @@ bmtphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
|
@ -191,13 +191,17 @@ brgphy_attach(device_t dev)
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
/* Initialize mii_softc structure */
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = brgphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
sc->mii_anegticks = MII_ANEGTICKS_GIGE;
|
||||
|
||||
/*
|
||||
* At least some variants wedge when isolating, at least some also
|
||||
* don't support loopback.
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
|
||||
mii->mii_instance++;
|
||||
sc->mii_anegticks = MII_ANEGTICKS_GIGE;
|
||||
|
||||
/* Initialize brgphy_softc structure */
|
||||
bsc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
|
||||
@ -283,9 +287,6 @@ brgphy_attach(device_t dev)
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
/* Create an instance of Ethernet media. */
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst), BMCR_ISO);
|
||||
|
||||
/* Add the supported media types */
|
||||
if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst),
|
||||
@ -345,26 +346,12 @@ brgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct brgphy_softc *bsc = (struct brgphy_softc *)sc;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int error = 0;
|
||||
int val;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/* If we're not polling our PHY instance, just return. */
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
goto brgphy_service_exit;
|
||||
break;
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
PHY_WRITE(sc, MII_BMCR,
|
||||
PHY_READ(sc, MII_BMCR) | BMCR_ISO);
|
||||
goto brgphy_service_exit;
|
||||
}
|
||||
|
||||
/* If the interface is not up, don't do anything. */
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
break;
|
||||
@ -385,18 +372,13 @@ brgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
mii->mii_ifp->if_flags & IFF_LINK0);
|
||||
break;
|
||||
default:
|
||||
error = EINVAL;
|
||||
goto brgphy_service_exit;
|
||||
return (EINVAL);
|
||||
}
|
||||
break;
|
||||
case MII_TICK:
|
||||
/* Bail if we're not currently selected. */
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
goto brgphy_service_exit;
|
||||
|
||||
/* Bail if the interface isn't up. */
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
|
||||
goto brgphy_service_exit;
|
||||
return (0);
|
||||
|
||||
|
||||
/* Bail if autoneg isn't in process. */
|
||||
@ -465,8 +447,7 @@ brgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
}
|
||||
}
|
||||
mii_phy_update(sc, cmd);
|
||||
brgphy_service_exit:
|
||||
return (error);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@ -1182,4 +1163,3 @@ brgphy_reset(struct mii_softc *sc)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,18 +118,16 @@ ciphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = ciphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
mii->mii_instance++;
|
||||
|
||||
ciphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
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);
|
||||
device_printf(dev, " ");
|
||||
@ -148,24 +146,9 @@ ciphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -238,12 +221,6 @@ ciphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
|
@ -144,11 +144,10 @@ e1000phy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = e1000phy_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii->mii_instance++;
|
||||
|
||||
esc->mii_model = MII_MODEL(ma->mii_id2);
|
||||
ifp = sc->mii_pdata->mii_ifp;
|
||||
@ -322,24 +321,9 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, E1000_CR);
|
||||
PHY_WRITE(sc, E1000_CR, reg | E1000_CR_ISOLATE);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -416,12 +400,6 @@ e1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
done:
|
||||
break;
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
|
@ -136,24 +136,16 @@ exphy_attach(device_t dev)
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
|
||||
/*
|
||||
* The 3Com PHY can never be isolated, so never allow non-zero
|
||||
* instances!
|
||||
*/
|
||||
if (mii->mii_instance != 0) {
|
||||
device_printf(dev, "ignoring this PHY, non-zero instance\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = exphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii->mii_instance++;
|
||||
|
||||
/*
|
||||
* The 3Com PHY can never be isolated.
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
@ -163,8 +155,7 @@ exphy_attach(device_t dev)
|
||||
|
||||
exphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
@ -176,13 +167,6 @@ exphy_attach(device_t dev)
|
||||
static int
|
||||
exphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
|
||||
/*
|
||||
* We can't isolate the 3Com PHY, so it has to be the only one!
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
panic("exphy_service: can't isolate 3Com PHY");
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
|
@ -166,13 +166,11 @@ gentbi_attach(device_t dev)
|
||||
MII_OUI(ma->mii_id1, ma->mii_id2),
|
||||
MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2));
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = gentbi_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
/*
|
||||
@ -195,29 +193,12 @@ gentbi_attach(device_t dev)
|
||||
static int
|
||||
gentbi_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -228,12 +209,6 @@ gentbi_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
|
@ -141,14 +141,12 @@ icsphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = icsphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
sc->mii_anegticks = MII_ANEGTICKS;
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
mii->mii_instance++;
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
ifmedia_add(&mii->mii_media,
|
||||
IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
@ -170,20 +168,6 @@ icsphy_attach(device_t dev)
|
||||
static int
|
||||
icsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
/*
|
||||
* If we're not selected, then do nothing, just isolate, if
|
||||
* changing media.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
if (cmd == MII_MEDIACHG) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
|
@ -107,11 +107,10 @@ inphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = inphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii->mii_instance++;
|
||||
|
||||
ifmedia_add(&mii->mii_media,
|
||||
IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
@ -132,22 +131,12 @@ inphy_attach(device_t dev)
|
||||
static int
|
||||
inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -158,8 +147,6 @@ inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
|
@ -114,13 +114,12 @@ ip1000phy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = ip1000phy_service;
|
||||
sc->mii_pdata = mii;
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
mii->mii_instance++;
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
isc->model = MII_MODEL(ma->mii_id2);
|
||||
isc->revision = MII_REV(ma->mii_id2);
|
||||
@ -146,25 +145,9 @@ ip1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, IP1000PHY_MII_BMCR);
|
||||
PHY_WRITE(sc, IP1000PHY_MII_BMCR,
|
||||
reg | IP1000PHY_BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -236,11 +219,6 @@ ip1000phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
|
@ -112,13 +112,11 @@ jmphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = jmphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
jsc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
|
||||
jsc->mii_model = MII_MODEL(ma->mii_id2);
|
||||
jsc->mii_rev = MII_REV(ma->mii_id2);
|
||||
@ -143,28 +141,12 @@ static int
|
||||
jmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
uint16_t bmcr;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
bmcr = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -176,12 +158,6 @@ jmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
|
@ -135,17 +135,14 @@ lxtphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = lxtphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
|
||||
/*
|
||||
@ -177,28 +174,12 @@ static int
|
||||
lxtphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -214,11 +195,6 @@ lxtphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
|
@ -350,12 +350,28 @@ int
|
||||
mii_mediachg(struct mii_data *mii)
|
||||
{
|
||||
struct mii_softc *child;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int rv;
|
||||
|
||||
mii->mii_media_status = 0;
|
||||
mii->mii_media_active = IFM_NONE;
|
||||
|
||||
LIST_FOREACH(child, &mii->mii_phys, mii_list) {
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate this one.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != child->mii_inst) {
|
||||
if ((child->mii_flags & MIIF_NOISOLATE) != 0) {
|
||||
device_printf(child->mii_dev, "%s: "
|
||||
"can't handle non-zero PHY instance %d\n",
|
||||
__func__, child->mii_inst);
|
||||
continue;
|
||||
}
|
||||
PHY_WRITE(child, MII_BMCR, PHY_READ(child, MII_BMCR) |
|
||||
BMCR_ISO);
|
||||
continue;
|
||||
}
|
||||
rv = (*child->mii_service)(child, mii, MII_MEDIACHG);
|
||||
if (rv)
|
||||
return (rv);
|
||||
@ -370,10 +386,18 @@ void
|
||||
mii_tick(struct mii_data *mii)
|
||||
{
|
||||
struct mii_softc *child;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
|
||||
LIST_FOREACH(child, &mii->mii_phys, mii_list)
|
||||
LIST_FOREACH(child, &mii->mii_phys, mii_list) {
|
||||
/*
|
||||
* If this PHY instance isn't currently selected, just skip
|
||||
* it.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != child->mii_inst)
|
||||
continue;
|
||||
(void)(*child->mii_service)(child, mii, MII_TICK);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get media status from PHYs.
|
||||
@ -382,13 +406,20 @@ void
|
||||
mii_pollstat(struct mii_data *mii)
|
||||
{
|
||||
struct mii_softc *child;
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
|
||||
mii->mii_media_status = 0;
|
||||
mii->mii_media_active = IFM_NONE;
|
||||
|
||||
LIST_FOREACH(child, &mii->mii_phys, mii_list)
|
||||
LIST_FOREACH(child, &mii->mii_phys, mii_list) {
|
||||
/*
|
||||
* If we're not polling this PHY instance, just skip it.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != child->mii_inst)
|
||||
continue;
|
||||
(void)(*child->mii_service)(child, mii, MII_POLLSTAT);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Inform the PHYs that the interface is down.
|
||||
|
@ -146,28 +146,19 @@ mlphy_attach(dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = mlphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
#if 0 /* See above. */
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
|
||||
BMCR_ISO);
|
||||
#endif
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
BMCR_LOOP|BMCR_S100);
|
||||
|
||||
sc->mii_flags &= ~MIIF_NOISOLATE;
|
||||
mii_phy_reset(sc);
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
ma->mii_capmask = ~sc->mii_capabilities;
|
||||
device_printf(dev, " ");
|
||||
mii_add_media(sc);
|
||||
@ -216,24 +207,9 @@ mlphy_service(xsc, mii, cmd)
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -301,12 +277,6 @@ mlphy_service(xsc, mii, cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
@ -368,6 +338,7 @@ mlphy_service(xsc, mii, cmd)
|
||||
if (msc->ml_state == ML_STATE_AUTO_OTHER) {
|
||||
other_inst = other->mii_inst;
|
||||
other->mii_inst = sc->mii_inst;
|
||||
if (IFM_INST(ife->ifm_media) == other->mii_inst)
|
||||
(void)(*other->mii_service)(other, mii, MII_POLLSTAT);
|
||||
other->mii_inst = other_inst;
|
||||
sc->mii_media_active = other->mii_media_active;
|
||||
|
@ -129,13 +129,11 @@ nsgphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = nsgphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
/*
|
||||
@ -157,29 +155,12 @@ nsgphy_attach(device_t dev)
|
||||
static int
|
||||
nsgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -190,12 +171,6 @@ nsgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
|
@ -133,13 +133,11 @@ nsphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = nsphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
nic = device_get_name(device_get_parent(sc->mii_dev));
|
||||
/*
|
||||
* Am79C971 and i82557 wedge when isolating all of their
|
||||
@ -174,8 +172,7 @@ nsphy_attach(device_t dev)
|
||||
|
||||
nsphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
@ -188,29 +185,13 @@ nsphy_attach(device_t dev)
|
||||
static int
|
||||
nsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -257,11 +238,6 @@ nsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
|
@ -138,13 +138,11 @@ nsphyter_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = nsphyter_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
nic = device_get_name(device_get_parent(sc->mii_dev));
|
||||
@ -178,29 +176,12 @@ nsphyter_attach(device_t dev)
|
||||
static int
|
||||
nsphyter_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -211,11 +192,6 @@ nsphyter_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
|
@ -110,13 +110,11 @@ pnaphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = pnaphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
@ -124,8 +122,7 @@ pnaphy_attach(device_t dev)
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
|
||||
printf("no media present");
|
||||
@ -133,8 +130,6 @@ pnaphy_attach(device_t dev)
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_HPNA_1, 0, sc->mii_inst), 0);
|
||||
PRINT("HomePNA");
|
||||
}
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
|
||||
BMCR_ISO);
|
||||
|
||||
printf("\n");
|
||||
|
||||
@ -150,28 +145,12 @@ static int
|
||||
pnaphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -188,18 +167,12 @@ pnaphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
/*
|
||||
* BMCR data is stored in the ifmedia entry.
|
||||
*/
|
||||
PHY_WRITE(sc, MII_ANAR,
|
||||
mii_anar(ife->ifm_media));
|
||||
PHY_WRITE(sc, MII_ANAR, mii_anar(ife->ifm_media));
|
||||
PHY_WRITE(sc, MII_BMCR, ife->ifm_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
|
@ -133,17 +133,14 @@ qsphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = qsphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
qsphy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
@ -155,21 +152,6 @@ qsphy_attach(device_t dev)
|
||||
static int
|
||||
qsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
/*
|
||||
* If we're not selected, then do nothing, just isolate, if
|
||||
* changing media.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
if (cmd == MII_MEDIACHG) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
|
@ -122,13 +122,11 @@ rgephy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = rgephy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
rsc->mii_model = MII_MODEL(ma->mii_id2);
|
||||
rsc->mii_revision = MII_REV(ma->mii_id2);
|
||||
|
||||
@ -137,7 +135,7 @@ rgephy_attach(device_t dev)
|
||||
|
||||
#if 0
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
BMCR_LOOP|BMCR_S100);
|
||||
MII_MEDIA_100_TX);
|
||||
#endif
|
||||
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
@ -171,24 +169,9 @@ rgephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -270,12 +253,6 @@ rgephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
|
@ -139,23 +139,16 @@ rlphy_attach(device_t dev)
|
||||
if (mii_phy_dev_probe(dev, rlphys, 0) == 0)
|
||||
rsc->sc_is_RTL8201L++;
|
||||
|
||||
/*
|
||||
* The RealTek PHY can never be isolated, so never allow non-zero
|
||||
* instances!
|
||||
*/
|
||||
if (mii->mii_instance != 0) {
|
||||
device_printf(dev, "ignoring this PHY, non-zero instance\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = rlphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii->mii_instance++;
|
||||
|
||||
/*
|
||||
* The RealTek PHY can never be isolated.
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
@ -165,8 +158,7 @@ rlphy_attach(device_t dev)
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
@ -178,13 +170,6 @@ rlphy_attach(device_t dev)
|
||||
static int
|
||||
rlphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
|
||||
/*
|
||||
* We can't isolate the RealTek PHY, so it has to be the only one!
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
panic("rlphy_service: can't isolate RealTek PHY");
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
|
@ -118,36 +118,23 @@ rlswitch_attach(device_t dev)
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
|
||||
/*
|
||||
* We handle all pseudo PHY in a single instance, so never allow
|
||||
* non-zero * instances!
|
||||
*/
|
||||
if (mii->mii_instance != 0) {
|
||||
device_printf(dev, "ignoring this PHY, non-zero instance\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = rlswitch_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii->mii_instance++;
|
||||
|
||||
/*
|
||||
* We handle all pseudo PHYs in a single instance.
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
|
||||
#if 0 /* See above. */
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
|
||||
BMCR_ISO);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
BMCR_LOOP|BMCR_S100);
|
||||
MII_MEDIA_100_TX);
|
||||
#endif
|
||||
|
||||
sc->mii_capabilities = BMSR_100TXFDX & ma->mii_capmask;
|
||||
|
@ -109,33 +109,21 @@ ruephy_attach(device_t dev)
|
||||
ma = device_get_ivars(dev);
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
|
||||
/*
|
||||
* The RealTek PHY can never be isolated, so never allow non-zero
|
||||
* instances!
|
||||
*/
|
||||
if (mii->mii_instance != 0) {
|
||||
device_printf(dev, "ignoring this PHY, non-zero instance\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = ruephy_service;
|
||||
sc->mii_pdata = mii;
|
||||
mii->mii_instance++;
|
||||
|
||||
/*
|
||||
* Apparently, we can't neither isolate nor do loopback on this PHY.
|
||||
* Apparently, we can neither isolate nor do loopback on this PHY.
|
||||
*/
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
|
||||
|
||||
ruephy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
@ -150,13 +138,6 @@ ruephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
/*
|
||||
* We can't isolate the RealTek RTL8150 PHY,
|
||||
* so it has to be the only one!
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
panic("ruephy_service: can't isolate RealTek RTL8150 PHY");
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
break;
|
||||
@ -194,10 +175,8 @@ ruephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
if (reg & RUEPHY_MSR_LINK)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
if (++sc->mii_ticks <= MII_ANEGTICKS)
|
||||
/* Only retry autonegotiation every mii_anegticks seconds. */
|
||||
if (sc->mii_ticks <= sc->mii_anegticks)
|
||||
break;
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
|
@ -105,13 +105,11 @@ smcphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = smcphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
if (smcphy_reset(sc) != 0) {
|
||||
@ -142,24 +140,9 @@ smcphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -179,13 +162,6 @@ smcphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
if ((mii->mii_ifp->if_flags & IFF_UP) == 0) {
|
||||
return (0);
|
||||
}
|
||||
|
@ -116,13 +116,11 @@ tdkphy_attach(device_t dev)
|
||||
MII_OUI(ma->mii_id1, ma->mii_id2),
|
||||
MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2));
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = tdkphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
/*
|
||||
* Apparently, we can't do loopback on this PHY.
|
||||
*/
|
||||
@ -130,8 +128,7 @@ tdkphy_attach(device_t dev)
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
device_printf(dev, " ");
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
@ -143,29 +140,12 @@ tdkphy_attach(device_t dev)
|
||||
static int
|
||||
tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -176,11 +156,6 @@ tdkphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
|
@ -164,9 +164,7 @@ tlphy_attach(device_t dev)
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
sc->sc_mii.mii_flags &= ~MIIF_NOISOLATE;
|
||||
mii_phy_reset(&sc->sc_mii);
|
||||
sc->sc_mii.mii_flags |= MIIF_NOISOLATE;
|
||||
|
||||
/*
|
||||
* Note that if we're on a device that also supports 100baseTX,
|
||||
@ -218,24 +216,9 @@ tlphy_service(struct mii_softc *self, struct mii_data *mii, int cmd)
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) {
|
||||
reg = PHY_READ(&sc->sc_mii, MII_BMCR);
|
||||
PHY_WRITE(&sc->sc_mii, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -267,12 +250,6 @@ tlphy_service(struct mii_softc *self, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
|
@ -147,21 +147,17 @@ truephy_attach(device_t dev)
|
||||
ma = device_get_ivars(dev);
|
||||
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
if (sc->mii_anegticks == 0)
|
||||
sc->mii_anegticks = MII_ANEGTICKS;
|
||||
sc->mii_dev = device_get_parent(dev);
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = truephy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
if (MII_MODEL(ma->mii_id2) == MII_MODEL_AGERE_ET1011)
|
||||
mii_phy_reset(sc);
|
||||
else
|
||||
@ -175,15 +171,11 @@ truephy_attach(device_t dev)
|
||||
}
|
||||
|
||||
device_printf(dev, " ");
|
||||
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 &&
|
||||
(sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0)
|
||||
printf("no media present");
|
||||
else
|
||||
mii_phy_add_media(sc);
|
||||
printf("\n");
|
||||
|
||||
MIIBUS_MEDIAINIT(sc->mii_dev);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -194,24 +186,9 @@ truephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
bmcr = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_ISO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -238,14 +215,8 @@ truephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return 0;
|
||||
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return 0;
|
||||
return (0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -254,7 +225,7 @@ truephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
/* Callback if something changed. */
|
||||
mii_phy_update(sc, cmd);
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -130,17 +130,14 @@ ukphy_attach(device_t dev)
|
||||
MII_OUI(ma->mii_id1, ma->mii_id2),
|
||||
MII_MODEL(ma->mii_id2), MII_REV(ma->mii_id2));
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = ukphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
mii->mii_instance++;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
sc->mii_capabilities =
|
||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||
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);
|
||||
device_printf(dev, " ");
|
||||
@ -156,29 +153,12 @@ ukphy_attach(device_t dev)
|
||||
static int
|
||||
ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
{
|
||||
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
|
||||
int reg;
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -189,11 +169,6 @@ ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
if (mii_phy_tick(sc) == EJUSTRETURN)
|
||||
return (0);
|
||||
break;
|
||||
|
@ -110,26 +110,19 @@ xmphy_attach(device_t dev)
|
||||
mii = ma->mii_data;
|
||||
LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
|
||||
|
||||
sc->mii_inst = mii->mii_instance;
|
||||
sc->mii_inst = mii->mii_instance++;
|
||||
sc->mii_phy = ma->mii_phyno;
|
||||
sc->mii_service = xmphy_service;
|
||||
sc->mii_pdata = mii;
|
||||
|
||||
sc->mii_flags |= MIIF_NOISOLATE;
|
||||
mii->mii_instance++;
|
||||
sc->mii_anegticks = MII_ANEGTICKS;
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
|
||||
#define PRINT(s) printf("%s%s", sep, s); sep = ", "
|
||||
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
|
||||
BMCR_ISO);
|
||||
#if 0
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
|
||||
BMCR_LOOP|BMCR_S100);
|
||||
#endif
|
||||
|
||||
mii_phy_reset(sc);
|
||||
|
||||
device_printf(dev, " ");
|
||||
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, 0, sc->mii_inst),
|
||||
XMPHY_BMCR_FDX);
|
||||
@ -155,24 +148,9 @@ xmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
|
||||
switch (cmd) {
|
||||
case MII_POLLSTAT:
|
||||
/*
|
||||
* If we're not polling our PHY instance, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case MII_MEDIACHG:
|
||||
/*
|
||||
* If the media indicates a different PHY instance,
|
||||
* isolate ourselves.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
|
||||
reg = PHY_READ(sc, MII_BMCR);
|
||||
PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface is not up, don't do anything.
|
||||
*/
|
||||
@ -209,12 +187,6 @@ xmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
break;
|
||||
|
||||
case MII_TICK:
|
||||
/*
|
||||
* If we're not currently selected, just return.
|
||||
*/
|
||||
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Is the interface even up?
|
||||
*/
|
||||
@ -236,10 +208,8 @@ xmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
|
||||
if (reg & BMSR_LINK)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Only retry autonegotiation every 5 seconds.
|
||||
*/
|
||||
if (++sc->mii_ticks <= MII_ANEGTICKS)
|
||||
/* Only retry autonegotiation every mii_anegticks seconds. */
|
||||
if (sc->mii_ticks <= sc->mii_anegticks)
|
||||
break;
|
||||
|
||||
sc->mii_ticks = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user