summaryrefslogtreecommitdiffstats
path: root/sys/dev/mii/miivar.h
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2010-10-14 22:01:40 +0000
committermarius <marius@FreeBSD.org>2010-10-14 22:01:40 +0000
commit28e02ade01c18f957e893cb5e62b5519d89e312b (patch)
treeab370198c75c435d50cc4cef48c18ef793c3cd98 /sys/dev/mii/miivar.h
parentdb788fc15d82837c059428a54dc35ccf6e76190c (diff)
downloadFreeBSD-src-28e02ade01c18f957e893cb5e62b5519d89e312b.zip
FreeBSD-src-28e02ade01c18f957e893cb5e62b5519d89e312b.tar.gz
Add a NetBSD-compatible mii_attach(), which is intended to eventually
replace mii_phy_probe() altogether. Compared to the latter the advantages of mii_attach() are: - intended to be called multiple times in order to attach PHYs in multiple passes (f.e. in order to only use sub-ranges of the 0 to MII_NPHY - 1 range) - being able to pass along the capability mask from the NIC to the PHY drivers - being able to specify at which address (phyloc) to probe for a PHY (instead of always probing at all addresses from 0 to MII_NPHY - 1) - being able to specify which PHY instance (offloc) to attach - being able to pass along MIIF_* flags from the NIC to the PHY drivers (f.e. as required to indicated to the PHY drivers that flow control is supported by the NIC driver, which actually is the motivation for this change). While at it, I used the opportunity to get rid of some hacks in mii(4) like miibus_probe() generally doing work besides sheer probing and the "EVIL HACK" (which will vanish entirely along with mii_phy_probe()) by passing the struct ifnet pointer via an argument of mii_attach() as well as to fix some resource leaks in mii(4) in case something fails. Commits which will update the PHY drivers to honor the MII flags passed down from the NIC drivers and take advantage of mii_attach() to get rid of certain types of hacks in NIC and PHY drivers as well as a conversion of the remaining uses of mii_phy_probe() will follow shortly. Reviewed by: jhb, yongari Obtained from: NetBSD (partially)
Diffstat (limited to 'sys/dev/mii/miivar.h')
-rw-r--r--sys/dev/mii/miivar.h50
1 files changed, 39 insertions, 11 deletions
diff --git a/sys/dev/mii/miivar.h b/sys/dev/mii/miivar.h
index 6b5a121..9196f8d 100644
--- a/sys/dev/mii/miivar.h
+++ b/sys/dev/mii/miivar.h
@@ -102,7 +102,7 @@ typedef int (*mii_downcall_t)(struct mii_softc *, struct mii_data *, int);
*/
struct mii_softc {
device_t mii_dev; /* generic device glue */
-
+
LIST_ENTRY(mii_softc) mii_list; /* entry on parent's PHY list */
int mii_phy; /* our MII address */
@@ -122,16 +122,22 @@ struct mii_softc {
typedef struct mii_softc mii_softc_t;
/* mii_flags */
-#define MIIF_INITDONE 0x0001 /* has been initialized (mii_data) */
-#define MIIF_NOISOLATE 0x0002 /* do not isolate the PHY */
-#define MIIF_NOLOOP 0x0004 /* no loopback capability */
-#define MIIF_AUTOTSLEEP 0x0010 /* use tsleep(), not callout() */
-#define MIIF_HAVEFIBER 0x0020 /* from parent: has fiber interface */
-#define MIIF_HAVE_GTCR 0x0040 /* has 100base-T2/1000base-T CR */
-#define MIIF_IS_1000X 0x0080 /* is a 1000BASE-X device */
-#define MIIF_DOPAUSE 0x0100 /* advertise PAUSE capability */
-#define MIIF_IS_HPNA 0x0200 /* is a HomePNA device */
-#define MIIF_FORCEANEG 0x0400 /* force auto-negotiation */
+#define MIIF_INITDONE 0x00000001 /* has been initialized (mii_data) */
+#define MIIF_NOISOLATE 0x00000002 /* do not isolate the PHY */
+#define MIIF_NOLOOP 0x00000004 /* no loopback capability */
+#define MIIF_AUTOTSLEEP 0x00000010 /* use tsleep(), not callout() */
+#define MIIF_HAVEFIBER 0x00000020 /* from parent: has fiber interface */
+#define MIIF_HAVE_GTCR 0x00000040 /* has 100base-T2/1000base-T CR */
+#define MIIF_IS_1000X 0x00000080 /* is a 1000BASE-X device */
+#define MIIF_DOPAUSE 0x00000100 /* advertise PAUSE capability */
+#define MIIF_IS_HPNA 0x00000200 /* is a HomePNA device */
+#define MIIF_FORCEANEG 0x00000400 /* force auto-negotiation */
+#define MIIF_MACPRIV0 0x01000000 /* private to the MAC driver */
+#define MIIF_MACPRIV1 0x02000000 /* private to the MAC driver */
+#define MIIF_MACPRIV2 0x04000000 /* private to the MAC driver */
+#define MIIF_PHYPRIV0 0x10000000 /* private to the PHY driver */
+#define MIIF_PHYPRIV1 0x20000000 /* private to the PHY driver */
+#define MIIF_PHYPRIV2 0x40000000 /* private to the PHY driver */
/* Default mii_anegticks values */
#define MII_ANEGTICKS 5
@@ -140,6 +146,14 @@ typedef struct mii_softc mii_softc_t;
#define MIIF_INHERIT_MASK (MIIF_NOISOLATE|MIIF_NOLOOP|MIIF_AUTOTSLEEP)
/*
+ * Special `locators' passed to mii_attach(). If one of these is not
+ * an `any' value, we look for *that* PHY and configure it. If both
+ * are not `any', that is an error, and mii_attach() will panic.
+ */
+#define MII_OFFSET_ANY -1
+#define MII_PHY_ANY -1
+
+/*
* Used to attach a PHY to a parent.
*/
struct mii_attach_args {
@@ -192,6 +206,18 @@ struct mii_media {
#define PHY_WRITE(p, r, v) \
MIIBUS_WRITEREG((p)->mii_dev, (p)->mii_phy, (r), (v))
+enum miibus_device_ivars {
+ MIIBUS_IVAR_FLAGS
+};
+
+/*
+ * Simplified accessors for miibus
+ */
+#define MIIBUS_ACCESSOR(var, ivar, type) \
+ __BUS_ACCESSOR(miibus, var, MIIBUS, ivar, type)
+
+MIIBUS_ACCESSOR(flags, FLAGS, int)
+
extern devclass_t miibus_devclass;
extern driver_t miibus_driver;
@@ -199,6 +225,8 @@ int miibus_probe(device_t);
int miibus_attach(device_t);
int miibus_detach(device_t);
+int mii_attach(device_t, device_t *, struct ifnet *, ifm_change_cb_t,
+ ifm_stat_cb_t, int, int, int, int);
int mii_anar(int);
void mii_down(struct mii_data *);
int mii_mediachg(struct mii_data *);
OpenPOWER on IntegriCloud