diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2004-11-18 16:15:34 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2004-11-18 16:15:34 +0000 |
commit | fca3745fc9c6315be0c7272a65cc81bb8d70f64a (patch) | |
tree | 446b69f16eeffa36dedc205f7434ea81dc7deced | |
parent | 0c5b0b96eef875c118009d1d198dad39099d15b6 (diff) |
add mii_phy_match() for table-driven lookup.
From NetBSD
-rw-r--r-- | sys/dev/mii/mii_physubr.c | 14 | ||||
-rw-r--r-- | sys/dev/mii/miivar.h | 14 |
2 files changed, 26 insertions, 2 deletions
diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c index 42351ab959b..de21e2be9fb 100644 --- a/sys/dev/mii/mii_physubr.c +++ b/sys/dev/mii/mii_physubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mii_physubr.c,v 1.21 2004/10/09 02:17:03 brad Exp $ */ +/* $OpenBSD: mii_physubr.c,v 1.22 2004/11/18 16:15:33 brad Exp $ */ /* $NetBSD: mii_physubr.c,v 1.20 2001/04/13 23:30:09 thorpej Exp $ */ /*- @@ -511,6 +511,18 @@ mii_phy_detach(struct device *self, int flags) return (0); } +const struct mii_phydesc * +mii_phy_match(const struct mii_attach_args *ma, const struct mii_phydesc *mpd) +{ + + for (; mpd->mpd_name != NULL; mpd++) { + if (MII_OUI(ma->mii_id1, ma->mii_id2) == mpd->mpd_oui && + MII_MODEL(ma->mii_id2) == mpd->mpd_model) + return (mpd); + } + return (NULL); +} + /* * Given an ifmedia word, return the corresponding ANAR value. */ diff --git a/sys/dev/mii/miivar.h b/sys/dev/mii/miivar.h index be53ab4cbc1..ac1ccf09121 100644 --- a/sys/dev/mii/miivar.h +++ b/sys/dev/mii/miivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: miivar.h,v 1.20 2004/09/27 18:25:48 brad Exp $ */ +/* $OpenBSD: miivar.h,v 1.21 2004/11/18 16:15:33 brad Exp $ */ /* $NetBSD: miivar.h,v 1.17 2000/03/06 20:56:57 thorpej Exp $ */ /*- @@ -179,6 +179,15 @@ struct mii_attach_args { typedef struct mii_attach_args mii_attach_args_t; /* + * Used to match a PHY. + */ +struct mii_phydesc { + u_int32_t mpd_oui; /* the PHY's OUI */ + u_int32_t mpd_model; /* the PHY's model */ + const char *mpd_name; /* the PHY's name */ +}; + +/* * An array of these structures map MII media types to BMCR/ANAR settings. */ struct mii_media { @@ -234,6 +243,9 @@ void mii_down(struct mii_data *); int mii_phy_activate(struct device *, enum devact); int mii_phy_detach(struct device *, int); +const struct mii_phydesc *mii_phy_match(const struct mii_attach_args *, + const struct mii_phydesc *); + void mii_phy_add_media(struct mii_softc *); void mii_phy_delete_media(struct mii_softc *); |