diff options
Diffstat (limited to 'sys/dev/mii/miivar.h')
-rw-r--r-- | sys/dev/mii/miivar.h | 84 |
1 files changed, 57 insertions, 27 deletions
diff --git a/sys/dev/mii/miivar.h b/sys/dev/mii/miivar.h index d9eab72..9af5b4e 100644 --- a/sys/dev/mii/miivar.h +++ b/sys/dev/mii/miivar.h @@ -38,7 +38,7 @@ #include <sys/queue.h> /* - * Media Independent Interface configuration defintions. + * Media Independent Interface data structure defintions */ struct mii_softc; @@ -65,13 +65,13 @@ struct mii_data { * request is made. */ LIST_HEAD(mii_listhead, mii_softc) mii_phys; - int mii_instance; + u_int mii_instance; /* * PHY driver fills this in with active media status. */ - int mii_media_status; - int mii_media_active; + u_int mii_media_status; + u_int mii_media_active; /* * Calls from MII layer into network interface driver. @@ -83,10 +83,13 @@ struct mii_data { typedef struct mii_data mii_data_t; /* - * This call is used by the MII layer to call into the PHY driver - * to perform a `service request'. + * Functions provided by the PHY to perform various functions. */ -typedef int (*mii_downcall_t)(struct mii_softc *, struct mii_data *, int); +struct mii_phy_funcs { + int (*pf_service)(struct mii_softc *, struct mii_data *, int); + void (*pf_status)(struct mii_softc *); + void (*pf_reset)(struct mii_softc *); +}; /* * Requests that can be made to the downcall. @@ -105,26 +108,35 @@ struct mii_softc { LIST_ENTRY(mii_softc) mii_list; /* entry on parent's PHY list */ - int mii_phy; /* our MII address */ - int mii_inst; /* instance for ifmedia */ + uint32_t mii_mpd_oui; /* the PHY's OUI (MII_OUI())*/ + uint32_t mii_mpd_model; /* the PHY's model (MII_MODEL())*/ + uint32_t mii_mpd_rev; /* the PHY's revision (MII_REV())*/ + u_int mii_capmask; /* capability mask for BMSR */ + u_int mii_phy; /* our MII address */ + u_int mii_offset; /* first PHY, second PHY, etc. */ + u_int mii_inst; /* instance for ifmedia */ + + /* Our PHY functions. */ + const struct mii_phy_funcs *mii_funcs; - mii_downcall_t mii_service; /* our downcall */ struct mii_data *mii_pdata; /* pointer to parent's mii_data */ - int mii_flags; /* misc. flags; see below */ - int mii_capabilities; /* capabilities from BMSR */ - int mii_extcapabilities; /* extended capabilities */ - int mii_ticks; /* MII_TICK counter */ - int mii_anegticks; /* ticks before retrying aneg */ - int mii_media_active; /* last active media */ - int mii_media_status; /* last active status */ + u_int mii_flags; /* misc. flags; see below */ + u_int mii_capabilities; /* capabilities from BMSR */ + u_int mii_extcapabilities; /* extended capabilities */ + u_int mii_ticks; /* MII_TICK counter */ + u_int mii_anegticks; /* ticks before retrying aneg */ + u_int mii_media_active; /* last active media */ + u_int mii_media_status; /* last active status */ }; typedef struct mii_softc mii_softc_t; /* mii_flags */ #define MIIF_INITDONE 0x00000001 /* has been initialized (mii_data) */ #define MIIF_NOISOLATE 0x00000002 /* do not isolate the PHY */ +#if 0 #define MIIF_NOLOOP 0x00000004 /* no loopback capability */ +#endif #define MIIF_DOINGAUTO 0x00000008 /* doing autonegotiation (mii_softc) */ #define MIIF_AUTOTSLEEP 0x00000010 /* use tsleep(), not callout() */ #define MIIF_HAVEFIBER 0x00000020 /* from parent: has fiber interface */ @@ -161,10 +173,11 @@ typedef struct mii_softc mii_softc_t; */ struct mii_attach_args { struct mii_data *mii_data; /* pointer to parent data */ - int mii_phyno; /* MII address */ - int mii_id1; /* PHY ID register 1 */ - int mii_id2; /* PHY ID register 2 */ - int mii_capmask; /* capability mask from BMSR */ + u_int mii_phyno; /* MII address */ + u_int mii_offset; /* first PHY, second PHY, etc. */ + uint32_t mii_id1; /* PHY ID register 1 */ + uint32_t mii_id2; /* PHY ID register 2 */ + u_int mii_capmask; /* capability mask for BMSR */ }; typedef struct mii_attach_args mii_attach_args_t; @@ -172,8 +185,8 @@ 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 */ + uint32_t mpd_oui; /* the PHY's OUI */ + uint32_t mpd_model; /* the PHY's model */ const char *mpd_name; /* the PHY's name */ }; #define MII_PHY_DESC(a, b) { MII_OUI_ ## a, MII_MODEL_ ## a ## _ ## b, \ @@ -184,9 +197,9 @@ struct mii_phydesc { * An array of these structures map MII media types to BMCR/ANAR settings. */ struct mii_media { - int mm_bmcr; /* BMCR settings for this media */ - int mm_anar; /* ANAR settings for this media */ - int mm_gtcr; /* 100base-T2 or 1000base-T CR */ + u_int mm_bmcr; /* BMCR settings for this media */ + u_int mm_anar; /* ANAR settings for this media */ + u_int mm_gtcr; /* 100base-T2 or 1000base-T CR */ }; #define MII_MEDIA_NONE 0 @@ -209,6 +222,15 @@ struct mii_media { #define PHY_WRITE(p, r, v) \ MIIBUS_WRITEREG((p)->mii_dev, (p)->mii_phy, (r), (v)) +#define PHY_SERVICE(p, d, o) \ + (*(p)->mii_funcs->pf_service)((p), (d), (o)) + +#define PHY_STATUS(p) \ + (*(p)->mii_funcs->pf_status)(p) + +#define PHY_RESET(p) \ + (*(p)->mii_funcs->pf_reset)(p) + enum miibus_device_ivars { MIIBUS_IVAR_FLAGS }; @@ -219,7 +241,7 @@ enum miibus_device_ivars { #define MIIBUS_ACCESSOR(var, ivar, type) \ __BUS_ACCESSOR(miibus, var, MIIBUS, ivar, type) -MIIBUS_ACCESSOR(flags, FLAGS, int) +MIIBUS_ACCESSOR(flags, FLAGS, u_int) extern devclass_t miibus_devclass; extern driver_t miibus_driver; @@ -250,8 +272,16 @@ const struct mii_phydesc * mii_phy_match(const struct mii_attach_args *ma, const struct mii_phydesc * mii_phy_match_gen(const struct mii_attach_args *ma, const struct mii_phydesc *mpd, size_t endlen); int mii_phy_dev_probe(device_t dev, const struct mii_phydesc *mpd, int mrv); +void mii_phy_dev_attach(device_t dev, u_int flags, + const struct mii_phy_funcs *mpf, int add_media); void ukphy_status(struct mii_softc *); + +u_int mii_oui(u_int, u_int); +#define MII_OUI(id1, id2) mii_oui(id1, id2) +#define MII_MODEL(id2) (((id2) & IDR2_MODEL) >> 4) +#define MII_REV(id2) ((id2) & IDR2_REV) + #endif /* _KERNEL */ #endif /* _DEV_MII_MIIVAR_H_ */ |