Module Name:    src
Committed By:   mlelstv
Date:           Mon Aug  1 07:37:18 UTC 2022

Modified Files:
        src/sys/dev/ic: ahcisata_core.c bcmgenet.c nvmevar.h rtl8169.c tulip.c
            tulipreg.h

Log Message:
Revert last accidental commits.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/ic/ahcisata_core.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/ic/bcmgenet.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/ic/nvmevar.h
cvs rdiff -u -r1.173 -r1.174 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.206 -r1.207 src/sys/dev/ic/tulip.c
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/ic/tulipreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.106 src/sys/dev/ic/ahcisata_core.c:1.107
--- src/sys/dev/ic/ahcisata_core.c:1.106	Mon Aug  1 07:34:28 2022
+++ src/sys/dev/ic/ahcisata_core.c	Mon Aug  1 07:37:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.106 2022/08/01 07:34:28 mlelstv Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.107 2022/08/01 07:37:18 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.106 2022/08/01 07:34:28 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.107 2022/08/01 07:37:18 mlelstv Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -828,8 +828,8 @@ ahci_exec_fis(struct ata_channel *chp, i
 				 */
 				return ERROR;
 			}
-			aprint_debug("%s port %d: error 0x%x sending FIS, t %d\n",
-			    AHCINAME(sc), chp->ch_channel, is, timeout);
+			aprint_debug("%s port %d: error 0x%x sending FIS\n",
+			    AHCINAME(sc), chp->ch_channel, is);
 			return ERR_DF;
 		}
 		ata_delay(chp, 10, "ahcifis", flags);
@@ -1635,27 +1635,9 @@ ahci_channel_stop(struct ahci_softc *sc,
 		/* XXX controller reset ? */
 		return;
 	}
+
 	if (sc->sc_channel_stop)
 		sc->sc_channel_stop(sc, chp);
-	if ((AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_FRE) == 0)
-		return;
-
-	AHCI_WRITE(sc, AHCI_P_CMD(chp->ch_channel),
-	    AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & ~AHCI_P_CMD_FRE);
-	/* wait 1s for FIS receive to stop */
-	for (i = 0; i <100; i++) {
-		if ((AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_FR)
-		    == 0)
-			break;
-		if (flags & AT_WAIT)
-			tsleep(&sc, PRIBIO, "ahcistop", mstohz(10));
-		else
-			delay(10000);
-	}
-	if (AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_FR) {
-		printf("%s: channel FIS receive wouldn't stop\n", AHCINAME(sc));
-		/* XXX controller reset ? */
-	}
 }
 
 static void

Index: src/sys/dev/ic/bcmgenet.c
diff -u src/sys/dev/ic/bcmgenet.c:1.12 src/sys/dev/ic/bcmgenet.c:1.13
--- src/sys/dev/ic/bcmgenet.c:1.12	Mon Aug  1 07:34:28 2022
+++ src/sys/dev/ic/bcmgenet.c	Mon Aug  1 07:37:18 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: bcmgenet.c,v 1.12 2022/08/01 07:34:28 mlelstv Exp $ */
+/* $NetBSD: bcmgenet.c,v 1.13 2022/08/01 07:37:18 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2020 Jared McNeill <jmcne...@invisible.ca>
@@ -34,7 +34,7 @@
 #include "opt_ddb.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.12 2022/08/01 07:34:28 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.13 2022/08/01 07:37:18 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -730,8 +730,7 @@ genet_rxintr(struct genet_softc *sc, int
 			bus_dmamap_sync(sc->sc_rx.buf_tag, sc->sc_rx.buf_map[index].map,
 			    0, sc->sc_rx.buf_map[index].map->dm_mapsize,
 			    BUS_DMASYNC_POSTREAD);
-		} else
-			device_printf(sc->sc_dev, "RXINTR empty %d\n",index);
+		}
 		bus_dmamap_unload(sc->sc_rx.buf_tag, sc->sc_rx.buf_map[index].map);
 		sc->sc_rx.buf_map[index].mbuf = NULL;
 
@@ -785,19 +784,18 @@ genet_txintr(struct genet_softc *sc, int
 				bus_dmamap_sync(sc->sc_tx.buf_tag, bmap->map,
 				    0, bmap->map->dm_mapsize,
 				    BUS_DMASYNC_POSTWRITE);
-			} else
-				device_printf(sc->sc_dev, "TXINTR empty %d\n",i);
+			}
 			bus_dmamap_unload(sc->sc_tx.buf_tag, bmap->map);
 			m_freem(bmap->mbuf);
 			bmap->mbuf = NULL;
 			++pkts;
 		}
 
+		ifp->if_flags &= ~IFF_OACTIVE;
 		i = TX_NEXT(i);
 		sc->sc_tx.cidx = (sc->sc_tx.cidx + 1) & 0xffff;
 	}
 
-	ifp->if_flags &= ~IFF_OACTIVE;
 	if_statadd(ifp, if_opackets, pkts);
 
 	if (pkts != 0)

Index: src/sys/dev/ic/nvmevar.h
diff -u src/sys/dev/ic/nvmevar.h:1.25 src/sys/dev/ic/nvmevar.h:1.26
--- src/sys/dev/ic/nvmevar.h:1.25	Mon Aug  1 07:34:28 2022
+++ src/sys/dev/ic/nvmevar.h	Mon Aug  1 07:37:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmevar.h,v 1.25 2022/08/01 07:34:28 mlelstv Exp $	*/
+/*	$NetBSD: nvmevar.h,v 1.26 2022/08/01 07:37:18 mlelstv Exp $	*/
 /*	$OpenBSD: nvmevar.h,v 1.8 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -78,8 +78,6 @@ struct nvme_queue {
 	kmutex_t		q_cq_mtx;
 	struct nvme_dmamem	*q_sq_dmamem;
 	struct nvme_dmamem	*q_cq_dmamem;
-	struct nvme_dmamem	*q_nvmmu_dmamem; /* for apple m1 nvme */
-
 	bus_size_t 		q_sqtdbl; /* submission queue tail doorbell */
 	bus_size_t 		q_cqhdbl; /* completion queue head doorbell */
 	uint16_t		q_id;
@@ -104,32 +102,9 @@ struct nvme_namespace {
 #define	NVME_NS_F_OPEN	__BIT(0)
 };
 
-struct nvme_ops {
-	void		(*op_enable)(struct nvme_softc *);
-
-	int		(*op_q_alloc)(struct nvme_softc *,
-			      struct nvme_queue *);
-	void		(*op_q_free)(struct nvme_softc *,
-			      struct nvme_queue *);
-
-	uint32_t	(*op_sq_enter)(struct nvme_softc *,
-			      struct nvme_queue *, struct nvme_ccb *);
-	void		(*op_sq_leave)(struct nvme_softc *,
-			      struct nvme_queue *, struct nvme_ccb *);
-	uint32_t	(*op_sq_enter_locked)(struct nvme_softc *,
-			      struct nvme_queue *, struct nvme_ccb *);
-	void		(*op_sq_leave_locked)(struct nvme_softc *,
-			      struct nvme_queue *, struct nvme_ccb *);
-
-	void		(*op_cq_done)(struct nvme_softc *,
-			      struct nvme_queue *, struct nvme_ccb *);
-};
-
 struct nvme_softc {
 	device_t		sc_dev;
 
-	const struct nvme_ops	*sc_ops;
-
 	bus_space_tag_t		sc_iot;
 	bus_space_handle_t	sc_ioh;
 	bus_size_t		sc_ios;
@@ -143,10 +118,9 @@ struct nvme_softc {
 	void			**sc_softih;	/* softintr handlers */
 
 	u_int			sc_rdy_to;	/* RDY timeout */
-	size_t			sc_mps;		/* memory page size */
+	size_t			sc_mps;		/* memory page size */  
 	size_t			sc_mdts;	/* max data trasfer size */
 	u_int			sc_max_sgl;	/* max S/G segments */
-	u_int			sc_dstrd;
 
 	struct nvm_identify_controller
 				sc_identify;
@@ -165,9 +139,6 @@ struct nvme_softc {
 
 	uint32_t		sc_quirks;
 #define	NVME_QUIRK_DELAY_B4_CHK_RDY	__BIT(0)
-#define	NVME_QUIRK_NOMSI		__BIT(1)
-
-	char			sc_modelname[81];
 };
 
 #define	lemtoh16(p)	le16toh(*((uint16_t *)(p)))
@@ -181,46 +152,21 @@ struct nvme_attach_args {
 	uint16_t	naa_nsid;
 	uint32_t	naa_qentries;	/* total number of queue slots */
 	uint32_t	naa_maxphys;	/* maximum device transfer size */
-	const char	*naa_typename;	/* identifier */
 };
 
 int	nvme_attach(struct nvme_softc *);
 int	nvme_detach(struct nvme_softc *, int flags);
 int	nvme_rescan(device_t, const char *, const int *);
 void	nvme_childdet(device_t, device_t);
-int	nvme_suspend(struct nvme_softc *);
-int	nvme_resume(struct nvme_softc *);
 int	nvme_intr(void *);
 void	nvme_softintr_intx(void *);
 int	nvme_intr_msi(void *);
 void	nvme_softintr_msi(void *);
 
 static __inline struct nvme_queue *
-nvme_get_q(struct nvme_softc *sc, struct buf *bp, bool waitok)
+nvme_get_q(struct nvme_softc *sc)
 {
-	struct nvme_queue *q;
-	u_int cpunum;
-
-	cpunum = cpu_index(curcpu());
-
-	/* try own queue */
-	q = sc->sc_q[cpunum % sc->sc_nq];
-	if (waitok)
-		return q;
-
-	/* if busy, search for an idle queue */
-	if (SIMPLEQ_EMPTY(&q->q_ccb_list)) {
-		for (u_int qoff = 1; qoff < sc->sc_nq; qoff++) {
-			struct nvme_queue *t;
-			t = sc->sc_q[(cpunum + qoff) % sc->sc_nq];
-			if (t->q_sq_tail == t->q_cq_head) {
-				q = t;
-				break;
-			}
-		}
-	}
-
-	return q;
+	return sc->sc_q[cpu_index(curcpu()) % sc->sc_nq];
 }
 
 /*
@@ -234,26 +180,9 @@ nvme_ns_get(struct nvme_softc *sc, uint1
 	return &sc->sc_namespaces[nsid - 1];
 }
 
-#define nvme_read4(_s, _r) \
-	bus_space_read_4((_s)->sc_iot, (_s)->sc_ioh, (_r))
-#define nvme_write4(_s, _r, _v) \
-	bus_space_write_4((_s)->sc_iot, (_s)->sc_ioh, (_r), (_v))
-uint64_t
-	nvme_read8(struct nvme_softc *, bus_size_t);
-void	nvme_write8(struct nvme_softc *, bus_size_t, uint64_t);
-
-#define nvme_barrier(_s, _r, _l, _f) \
-	bus_space_barrier((_s)->sc_iot, (_s)->sc_ioh, (_r), (_l), (_f))
-
-struct nvme_dmamem *
-	nvme_dmamem_alloc(struct nvme_softc *, size_t);
-void	nvme_dmamem_free(struct nvme_softc *, struct nvme_dmamem *);
-void	nvme_dmamem_sync(struct nvme_softc *, struct nvme_dmamem *, int);
-
 int	nvme_ns_identify(struct nvme_softc *, uint16_t);
 void	nvme_ns_free(struct nvme_softc *, uint16_t);
 int	nvme_ns_dobio(struct nvme_softc *, uint16_t, void *,
     struct buf *, void *, size_t, int, daddr_t, int, nvme_nnc_done);
 int	nvme_ns_sync(struct nvme_softc *, uint16_t, int);
 int	nvme_admin_getcache(struct nvme_softc *, int *);
-int	nvme_admin_setcache(struct nvme_softc *, int);

Index: src/sys/dev/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.173 src/sys/dev/ic/rtl8169.c:1.174
--- src/sys/dev/ic/rtl8169.c:1.173	Mon Aug  1 07:34:28 2022
+++ src/sys/dev/ic/rtl8169.c	Mon Aug  1 07:37:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.173 2022/08/01 07:34:28 mlelstv Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.174 2022/08/01 07:37:18 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.173 2022/08/01 07:34:28 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.174 2022/08/01 07:37:18 mlelstv Exp $");
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -682,8 +682,8 @@ re_attach(struct rtk_softc *sc)
 		case RTK_HWREV_8168H:
 		case RTK_HWREV_8411B:
 			sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
-			    RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM |
-			    RTKQ_NOJUMBO | RTKQ_RXDV_GATED | RTKQ_TXRXEN_LATER;
+			    RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO | 
+			    RTKQ_RXDV_GATED | RTKQ_TXRXEN_LATER;
 			break;
 		case RTK_HWREV_8100E:
 		case RTK_HWREV_8100E_SPIN2:

Index: src/sys/dev/ic/tulip.c
diff -u src/sys/dev/ic/tulip.c:1.206 src/sys/dev/ic/tulip.c:1.207
--- src/sys/dev/ic/tulip.c:1.206	Mon Aug  1 07:34:28 2022
+++ src/sys/dev/ic/tulip.c	Mon Aug  1 07:37:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tulip.c,v 1.206 2022/08/01 07:34:28 mlelstv Exp $	*/
+/*	$NetBSD: tulip.c,v 1.207 2022/08/01 07:37:18 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -36,8 +36,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.206 2022/08/01 07:34:28 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.207 2022/08/01 07:37:18 mlelstv Exp $");
 
+#include "bpfilter.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -52,12 +53,16 @@ __KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.
 
 #include <machine/endian.h>
 
+#include <uvm/uvm_extern.h>
+
 #include <net/if.h>
 #include <net/if_dl.h>
 #include <net/if_media.h>
 #include <net/if_ether.h>
 
+#if NBPFILTER > 0
 #include <net/bpf.h>
+#endif
 
 #include <sys/bus.h>
 #include <sys/intr.h>
@@ -69,7 +74,7 @@ __KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.
 #include <dev/ic/tulipreg.h>
 #include <dev/ic/tulipvar.h>
 
-static const char * const tlp_chip_names[] = TULIP_CHIP_NAMES;
+const char * const tlp_chip_names[] = TULIP_CHIP_NAMES;
 
 static const struct tulip_txthresh_tab tlp_10_txthresh_tab[] =
     TLP_TXTHRESH_TAB_10;
@@ -77,6 +82,9 @@ static const struct tulip_txthresh_tab t
 static const struct tulip_txthresh_tab tlp_10_100_txthresh_tab[] =
     TLP_TXTHRESH_TAB_10_100;
 
+static const struct tulip_txthresh_tab tlp_winb_txthresh_tab[] =
+    TLP_TXTHRESH_TAB_WINB;
+
 static const struct tulip_txthresh_tab tlp_dm9102_txthresh_tab[] =
     TLP_TXTHRESH_TAB_DM9102;
 
@@ -104,21 +112,21 @@ static void	tlp_rxintr(struct tulip_soft
 static void	tlp_txintr(struct tulip_softc *);
 
 static void	tlp_mii_tick(void *);
-static void	tlp_mii_statchg(struct ifnet *);
-static void	tlp_winb_mii_statchg(struct ifnet *);
-static void	tlp_dm9102_mii_statchg(struct ifnet *);
+static void	tlp_mii_statchg(device_t);
+static void	tlp_winb_mii_statchg(device_t);
+static void	tlp_dm9102_mii_statchg(device_t);
 
 static void	tlp_mii_getmedia(struct tulip_softc *, struct ifmediareq *);
 static int	tlp_mii_setmedia(struct tulip_softc *);
 
-static int	tlp_bitbang_mii_readreg(device_t, int, int, uint16_t *);
-static int	tlp_bitbang_mii_writereg(device_t, int, int, uint16_t);
+static int	tlp_bitbang_mii_readreg(device_t, int, int);
+static void	tlp_bitbang_mii_writereg(device_t, int, int, int);
 
-static int	tlp_pnic_mii_readreg(device_t, int, int, uint16_t *);
-static int	tlp_pnic_mii_writereg(device_t, int, int, uint16_t);
+static int	tlp_pnic_mii_readreg(device_t, int, int);
+static void	tlp_pnic_mii_writereg(device_t, int, int, int);
 
-static int	tlp_al981_mii_readreg(device_t, int, int, uint16_t *);
-static int	tlp_al981_mii_writereg(device_t, int, int, uint16_t);
+static int	tlp_al981_mii_readreg(device_t, int, int);
+static void	tlp_al981_mii_writereg(device_t, int, int, int);
 
 static void	tlp_2114x_preinit(struct tulip_softc *);
 static void	tlp_2114x_mii_preinit(struct tulip_softc *);
@@ -268,7 +276,7 @@ tlp_attach(struct tulip_softc *sc, const
 	 */
 	switch (sc->sc_chip) {
 	case TULIP_CHIP_X3201_3:
-		sc->sc_setup_fsls = TDCTL_Tx_FS | TDCTL_Tx_LS;
+		sc->sc_setup_fsls = TDCTL_Tx_FS|TDCTL_Tx_LS;
 		break;
 
 	default:
@@ -391,16 +399,16 @@ tlp_attach(struct tulip_softc *sc, const
 	if ((error = bus_dmamem_alloc(sc->sc_dmat,
 	    sizeof(struct tulip_control_data), PAGE_SIZE, 0, &sc->sc_cdseg,
 	    1, &sc->sc_cdnseg, 0)) != 0) {
-		aprint_error_dev(self,
-		    "unable to allocate control data, error = %d\n", error);
+		aprint_error_dev(self, "unable to allocate control data, error = %d\n",
+		    error);
 		goto fail_0;
 	}
 
 	if ((error = bus_dmamem_map(sc->sc_dmat, &sc->sc_cdseg, sc->sc_cdnseg,
 	    sizeof(struct tulip_control_data), (void **)&sc->sc_control_data,
 	    BUS_DMA_COHERENT)) != 0) {
-		aprint_error_dev(self,
-		    "unable to map control data, error = %d\n", error);
+		aprint_error_dev(self, "unable to map control data, error = %d\n",
+		    error);
 		goto fail_1;
 	}
 
@@ -408,17 +416,15 @@ tlp_attach(struct tulip_softc *sc, const
 	    sizeof(struct tulip_control_data), 1,
 	    sizeof(struct tulip_control_data), 0, 0, &sc->sc_cddmamap)) != 0) {
 		sc->sc_cddmamap = NULL;
-		aprint_error_dev(self,
-		    "unable to create control data DMA map, error = %d\n",
-		    error);
+		aprint_error_dev(self, "unable to create control data DMA map, "
+		    "error = %d\n", error);
 		goto fail_2;
 	}
 
 	if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_cddmamap,
 	    sc->sc_control_data, sizeof(struct tulip_control_data), NULL,
 	    0)) != 0) {
-		aprint_error_dev(self,
-		    "unable to load control data DMA map, error = %d\n",
+		aprint_error_dev(self, "unable to load control data DMA map, error = %d\n",
 		    error);
 		goto fail_3;
 	}
@@ -451,9 +457,8 @@ tlp_attach(struct tulip_softc *sc, const
 		    sc->sc_ntxsegs, MCLBYTES, 0, 0,
 		    &sc->sc_txsoft[i].txs_dmamap)) != 0) {
 			sc->sc_txsoft[i].txs_dmamap = NULL;
-			aprint_error_dev(self,
-			    "unable to create tx DMA map %d, error = %d\n", i,
-			    error);
+			aprint_error_dev(self, "unable to create tx DMA map %d, "
+			    "error = %d\n", i, error);
 			goto fail_4;
 		}
 	}
@@ -464,10 +469,9 @@ tlp_attach(struct tulip_softc *sc, const
 	for (i = 0; i < TULIP_NRXDESC; i++) {
 		if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1,
 		    MCLBYTES, 0, 0, &sc->sc_rxsoft[i].rxs_dmamap)) != 0) {
-			sc->sc_rxsoft[i].rxs_dmamap = NULL;
-			aprint_error_dev(self,
-			    "unable to create rx DMA map %d, error = %d\n", i,
-			    error);
+		        sc->sc_rxsoft[i].rxs_dmamap = NULL;
+			aprint_error_dev(self, "unable to create rx DMA map %d, "
+			    "error = %d\n", i, error);
 			goto fail_5;
 		}
 		sc->sc_rxsoft[i].rxs_mbuf = NULL;
@@ -524,12 +528,12 @@ tlp_attach(struct tulip_softc *sc, const
 	 * Attach the interface.
 	 */
 	if_attach(ifp);
-	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, enaddr);
 	ether_set_ifflags_cb(&sc->sc_ethercom, tlp_ifflags_cb);
-
+#if NRND > 0
 	rnd_attach_source(&sc->sc_rnd_source, device_xname(self),
-	    RND_TYPE_NET, RND_FLAG_DEFAULT);
+	    RND_TYPE_NET, 0);
+#endif
 
 	if (pmf_device_register(self, NULL, NULL))
 		pmf_class_network_register(self, ifp);
@@ -575,14 +579,24 @@ int
 tlp_activate(device_t self, enum devact act)
 {
 	struct tulip_softc *sc = device_private(self);
+	int s, error = 0;
 
+	s = splnet();
 	switch (act) {
+	case DVACT_ACTIVATE:
+		error = EOPNOTSUPP;
+		break;
+
 	case DVACT_DEACTIVATE:
+		if (sc->sc_flags & TULIPF_HAS_MII)
+			mii_activate(&sc->sc_mii, act, MII_PHY_ANY,
+			    MII_OFFSET_ANY);
 		if_deactivate(&sc->sc_ethercom.ec_if);
-		return 0;
-	default:
-		return EOPNOTSUPP;
+		break;
 	}
+	splx(s);
+
+	return (error);
 }
 
 /*
@@ -597,36 +611,32 @@ tlp_detach(struct tulip_softc *sc)
 	struct tulip_rxsoft *rxs;
 	struct tulip_txsoft *txs;
 	device_t self = sc->sc_dev;
-	int i, s;
+	int i;
 
 	/*
 	 * Succeed now if there isn't any work to do.
 	 */
 	if ((sc->sc_flags & TULIPF_ATTACHED) == 0)
-		return 0;
-
-	s = splnet();
-	/* Stop the interface. Callouts are stopped in it. */
-	tlp_stop(ifp, 1);
-	splx(s);
+		return (0);
 
-	/* Destroy our callouts. */
-	callout_destroy(&sc->sc_nway_callout);
-	callout_destroy(&sc->sc_tick_callout);
+	/* Unhook our tick handler. */
+	if (sc->sc_tick)
+		callout_stop(&sc->sc_tick_callout);
 
 	if (sc->sc_flags & TULIPF_HAS_MII) {
 		/* Detach all PHYs */
 		mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
 	}
 
-	rnd_detach_source(&sc->sc_rnd_source);
+	/* Delete all remaining media. */
+	ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
 
+#if NRND > 0
+	rnd_detach_source(&sc->sc_rnd_source);
+#endif
 	ether_ifdetach(ifp);
 	if_detach(ifp);
 
-	/* Delete all remaining media. */
-	ifmedia_fini(&sc->sc_mii.mii_media);
-
 	for (i = 0; i < TULIP_NRXDESC; i++) {
 		rxs = &sc->sc_rxsoft[i];
 		if (rxs->rxs_mbuf != NULL) {
@@ -656,7 +666,7 @@ tlp_detach(struct tulip_softc *sc)
 	if (sc->sc_srom)
 		free(sc->sc_srom, M_DEVBUF);
 
-	return 0;
+	return (0);
 }
 
 /*
@@ -672,7 +682,6 @@ tlp_start(struct ifnet *ifp)
 	struct tulip_txsoft *txs, *last_txs = NULL;
 	bus_dmamap_t dmamap;
 	int error, firsttx, nexttx, lasttx = 1, ofree, seg;
-	struct tulip_desc *txd;
 
 	DPRINTF(sc, ("%s: tlp_start: sc_flags 0x%08x, if_flags 0x%08x\n",
 	    device_xname(sc->sc_dev), sc->sc_flags, ifp->if_flags));
@@ -683,9 +692,9 @@ tlp_start(struct ifnet *ifp)
 	 * itself into the ring.
 	 */
 	if (sc->sc_flags & TULIPF_WANT_SETUP)
-		return;
+		ifp->if_flags |= IFF_OACTIVE;
 
-	if ((ifp->if_flags & IFF_RUNNING) != IFF_RUNNING)
+	if ((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING)
 		return;
 
 	if (sc->sc_tick == tlp_2114x_nway_tick &&
@@ -733,7 +742,7 @@ tlp_start(struct ifnet *ifp)
 		 */
 		if ((sc->sc_ntxsegs == 1 && (mtod(m0, uintptr_t) & 3) != 0) ||
 		    bus_dmamap_load_mbuf(sc->sc_dmat, dmamap, m0,
-		      BUS_DMA_WRITE | BUS_DMA_NOWAIT) != 0) {
+		      BUS_DMA_WRITE|BUS_DMA_NOWAIT) != 0) {
 			MGETHDR(m, M_DONTWAIT, MT_DATA);
 			if (m == NULL) {
 				aprint_error_dev(sc->sc_dev, "unable to allocate Tx mbuf\n");
@@ -752,7 +761,7 @@ tlp_start(struct ifnet *ifp)
 			m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, void *));
 			m->m_pkthdr.len = m->m_len = m0->m_pkthdr.len;
 			error = bus_dmamap_load_mbuf(sc->sc_dmat, dmamap,
-			    m, BUS_DMA_WRITE | BUS_DMA_NOWAIT);
+			    m, BUS_DMA_WRITE|BUS_DMA_NOWAIT);
 			if (error) {
 				aprint_error_dev(sc->sc_dev,
 				    "unable to load Tx buffer, error = %d",
@@ -768,8 +777,15 @@ tlp_start(struct ifnet *ifp)
 		if (dmamap->dm_nsegs > sc->sc_txfree) {
 			/*
 			 * Not enough free descriptors to transmit this
-			 * packet.
+			 * packet.  We haven't committed to anything yet,
+			 * so just unload the DMA map, put the packet
+			 * back on the queue, and punt.  Notify the upper
+			 * layer that there are no more slots left.
+			 *
+			 * XXX We could allocate an mbuf and copy, but
+			 * XXX it is worth it?
 			 */
+			ifp->if_flags |= IFF_OACTIVE;
 			bus_dmamap_unload(sc->sc_dmat, dmamap);
 			if (m != NULL)
 				m_freem(m);
@@ -802,14 +818,13 @@ tlp_start(struct ifnet *ifp)
 			 * yet.  That could cause a race condition.
 			 * We'll do it below.
 			 */
-			txd = &sc->sc_txdescs[nexttx];
-			txd->td_status =
+			sc->sc_txdescs[nexttx].td_status =
 			    (nexttx == firsttx) ? 0 : htole32(TDSTAT_OWN);
-			txd->td_bufaddr1 =
+			sc->sc_txdescs[nexttx].td_bufaddr1 =
 			    htole32(dmamap->dm_segs[seg].ds_addr);
-			txd->td_ctl =
+			sc->sc_txdescs[nexttx].td_ctl =
 			    htole32((dmamap->dm_segs[seg].ds_len <<
-				TDCTL_SIZE1_SHIFT) | sc->sc_tdctl_ch |
+			        TDCTL_SIZE1_SHIFT) | sc->sc_tdctl_ch |
 				(nexttx == (TULIP_NTXDESC - 1) ?
 				 sc->sc_tdctl_er : 0));
 			lasttx = nexttx;
@@ -825,16 +840,15 @@ tlp_start(struct ifnet *ifp)
 		if (ifp->if_flags & IFF_DEBUG) {
 			printf("     txsoft %p transmit chain:\n", txs);
 			for (seg = sc->sc_txnext;; seg = TULIP_NEXTTX(seg)) {
-				txd = &sc->sc_txdescs[seg];
 				printf("     descriptor %d:\n", seg);
 				printf("       td_status:   0x%08x\n",
-				    le32toh(txd->td_status));
+				    le32toh(sc->sc_txdescs[seg].td_status));
 				printf("       td_ctl:      0x%08x\n",
-				    le32toh(txd->td_ctl));
+				    le32toh(sc->sc_txdescs[seg].td_ctl));
 				printf("       td_bufaddr1: 0x%08x\n",
-				    le32toh(txd->td_bufaddr1));
+				    le32toh(sc->sc_txdescs[seg].td_bufaddr1));
 				printf("       td_bufaddr2: 0x%08x\n",
-				    le32toh(txd->td_bufaddr2));
+				    le32toh(sc->sc_txdescs[seg].td_bufaddr2));
 				if (seg == lasttx)
 					break;
 			}
@@ -843,7 +857,7 @@ tlp_start(struct ifnet *ifp)
 
 		/* Sync the descriptors we're using. */
 		TULIP_CDTXSYNC(sc, sc->sc_txnext, dmamap->dm_nsegs,
-		    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+		    BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
 
 		/*
 		 * Store a pointer to the packet so we can free it later,
@@ -864,10 +878,18 @@ tlp_start(struct ifnet *ifp)
 
 		last_txs = txs;
 
+#if NBPFILTER > 0
 		/*
 		 * Pass the packet to any BPF listeners.
 		 */
-		bpf_mtap(ifp, m0, BPF_D_OUT);
+		if (ifp->if_bpf)
+			bpf_mtap(ifp->if_bpf, m0);
+#endif /* NBPFILTER > 0 */
+	}
+
+	if (txs == NULL || sc->sc_txfree == 0) {
+		/* No more slots left; notify upper layer. */
+		ifp->if_flags |= IFF_OACTIVE;
 	}
 
 	if (sc->sc_txfree != ofree) {
@@ -879,7 +901,7 @@ tlp_start(struct ifnet *ifp)
 		 */
 		sc->sc_txdescs[lasttx].td_ctl |= htole32(TDCTL_Tx_IC);
 		TULIP_CDTXSYNC(sc, lasttx, 1,
-		    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+		    BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
 
 		/*
 		 * Some clone chips want IC on the *first* segment in
@@ -891,7 +913,7 @@ tlp_start(struct ifnet *ifp)
 			sc->sc_txdescs[last_txs->txs_firstdesc].td_ctl |=
 			    htole32(TDCTL_Tx_IC);
 			TULIP_CDTXSYNC(sc, last_txs->txs_firstdesc, 1,
-			    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+			    BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
 		}
 
 		/*
@@ -900,7 +922,7 @@ tlp_start(struct ifnet *ifp)
 		 */
 		sc->sc_txdescs[firsttx].td_status |= htole32(TDSTAT_OWN);
 		TULIP_CDTXSYNC(sc, firsttx, 1,
-		    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+		    BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
 
 		/* Wake up the transmitter. */
 		/* XXX USE AUTOPOLLING? */
@@ -926,17 +948,15 @@ tlp_watchdog(struct ifnet *ifp)
 	doing_transmit = (! SIMPLEQ_EMPTY(&sc->sc_txdirtyq));
 
 	if (doing_setup && doing_transmit) {
-		printf("%s: filter setup and transmit timeout\n",
-		    device_xname(sc->sc_dev));
-		if_statinc(ifp, if_oerrors);
+		printf("%s: filter setup and transmit timeout\n", device_xname(sc->sc_dev));
+		ifp->if_oerrors++;
 	} else if (doing_transmit) {
 		printf("%s: transmit timeout\n", device_xname(sc->sc_dev));
-		if_statinc(ifp, if_oerrors);
+		ifp->if_oerrors++;
 	} else if (doing_setup)
 		printf("%s: filter setup timeout\n", device_xname(sc->sc_dev));
 	else
-		printf("%s: spurious watchdog timeout\n",
-		    device_xname(sc->sc_dev));
+		printf("%s: spurious watchdog timeout\n", device_xname(sc->sc_dev));
 
 	(void) tlp_init(ifp);
 
@@ -953,9 +973,9 @@ tlp_ifflags_cb(struct ethercom *ec)
 {
 	struct ifnet *ifp = &ec->ec_if;
 	struct tulip_softc *sc = ifp->if_softc;
-	u_short change = ifp->if_flags ^ sc->sc_if_flags;
+	int change = ifp->if_flags ^ sc->sc_if_flags;
 
-	if ((change & ~(IFF_CANTCHANGE | IFF_DEBUG)) != 0)
+	if ((change & ~(IFF_CANTCHANGE|IFF_DEBUG)) != 0)
 		return ENETRESET;
 	if ((change & IFF_PROMISC) != 0)
 		(*sc->sc_filter_setup)(sc);
@@ -971,11 +991,16 @@ static int
 tlp_ioctl(struct ifnet *ifp, u_long cmd, void *data)
 {
 	struct tulip_softc *sc = ifp->if_softc;
+	struct ifreq *ifr = (struct ifreq *)data;
 	int s, error;
 
 	s = splnet();
 
 	switch (cmd) {
+	case SIOCSIFMEDIA:
+	case SIOCGIFMEDIA:
+		error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd);
+		break;
 	default:
 		error = ether_ioctl(ifp, cmd, data);
 		if (error == ENETRESET) {
@@ -997,7 +1022,7 @@ tlp_ioctl(struct ifnet *ifp, u_long cmd,
 
 	sc->sc_if_flags = ifp->if_flags;
 	splx(s);
-	return error;
+	return (error);
 }
 
 /*
@@ -1010,7 +1035,7 @@ tlp_intr(void *arg)
 {
 	struct tulip_softc *sc = arg;
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
-	uint32_t status, rxstatus, txstatus, rndstatus = 0;
+	uint32_t status, rxstatus, txstatus;
 	int handled = 0, txthresh;
 
 	DPRINTF(sc, ("%s: tlp_intr\n", device_xname(sc->sc_dev)));
@@ -1026,7 +1051,7 @@ tlp_intr(void *arg)
 	 */
 	if ((ifp->if_flags & IFF_RUNNING) == 0 ||
 	    !device_is_active(sc->sc_dev))
-		return 0;
+		return (0);
 
 	/* Disable interrupts on the DM9102 (interrupt edge bug). */
 	switch (sc->sc_chip) {
@@ -1042,10 +1067,8 @@ tlp_intr(void *arg)
 
 	for (;;) {
 		status = TULIP_READ(sc, CSR_STATUS);
-		if (status) {
+		if (status)
 			TULIP_WRITE(sc, CSR_STATUS, status);
-			rndstatus = status;
-		}
 
 		if ((status & sc->sc_inten) == 0)
 			break;
@@ -1120,7 +1143,7 @@ tlp_intr(void *arg)
 			}
 		}
 
-		if (status & (STATUS_TPS | STATUS_RPS)) {
+		if (status & (STATUS_TPS|STATUS_RPS)) {
 			if (status & STATUS_TPS)
 				printf("%s: transmit process stopped\n",
 				    device_xname(sc->sc_dev));
@@ -1150,8 +1173,8 @@ tlp_intr(void *arg)
 				str = "unknown error";
 				break;
 			}
-			aprint_error_dev(sc->sc_dev,
-			    "fatal system error: %s\n", str);
+			aprint_error_dev(sc->sc_dev, "fatal system error: %s\n",
+			    str);
 			(void) tlp_init(ifp);
 			break;
 		}
@@ -1185,12 +1208,13 @@ tlp_intr(void *arg)
 	}
 
 	/* Try to get more packets going. */
-	if_schedule_deferred_start(ifp);
+	tlp_start(ifp);
 
+#if NRND > 0
 	if (handled)
-		rnd_add_uint32(&sc->sc_rnd_source, rndstatus);
-
-	return handled;
+		rnd_add_uint32(&sc->sc_rnd_source, status);
+#endif
+	return (handled);
 }
 
 /*
@@ -1212,7 +1236,7 @@ tlp_rxintr(struct tulip_softc *sc)
 		rxs = &sc->sc_rxsoft[i];
 
 		TULIP_CDRXSYNC(sc, i,
-		    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+		    BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
 
 		rxstat = le32toh(sc->sc_rxdescs[i].td_status);
 
@@ -1229,8 +1253,8 @@ tlp_rxintr(struct tulip_softc *sc)
 		 * has an awful receive engine bug, which may require
 		 * a very icky work-around.
 		 */
-		if ((rxstat & (TDSTAT_Rx_FS | TDSTAT_Rx_LS)) !=
-		    (TDSTAT_Rx_FS | TDSTAT_Rx_LS)) {
+		if ((rxstat & (TDSTAT_Rx_FS|TDSTAT_Rx_LS)) !=
+		    (TDSTAT_Rx_FS|TDSTAT_Rx_LS)) {
 			printf("%s: incoming packet spilled, resetting\n",
 			    device_xname(sc->sc_dev));
 			(void) tlp_init(ifp);
@@ -1241,7 +1265,7 @@ tlp_rxintr(struct tulip_softc *sc)
 		 * If any collisions were seen on the wire, count one.
 		 */
 		if (rxstat & TDSTAT_Rx_CS)
-			if_statinc(ifp, if_collisions);
+			ifp->if_collisions++;
 
 		/*
 		 * If an error occurred, update stats, clear the status
@@ -1267,9 +1291,9 @@ tlp_rxintr(struct tulip_softc *sc)
 			rxstat &= errors;
 #define	PRINTERR(bit, str)						\
 			if (rxstat & (bit))				\
-				aprint_error_dev(sc->sc_dev,		\
-				    "receive error: %s\n", str)
-			if_statinc(ifp, if_ierrors);
+				aprint_error_dev(sc->sc_dev, "receive error: %s\n",	\
+				    str)
+			ifp->if_ierrors++;
 			PRINTERR(TDSTAT_Rx_DE, "descriptor error");
 			PRINTERR(TDSTAT_Rx_RF, "runt frame");
 			PRINTERR(TDSTAT_Rx_TL, "frame too long");
@@ -1298,7 +1322,7 @@ tlp_rxintr(struct tulip_softc *sc)
 		 */
 		m = rxs->rxs_mbuf;
 		if (tlp_add_rxbuf(sc, i) != 0) {
-			if_statinc(ifp, if_ierrors);
+			ifp->if_ierrors++;
 			TULIP_INIT_RXDESC(sc, i);
 			bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0,
 			    rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
@@ -1314,7 +1338,7 @@ tlp_rxintr(struct tulip_softc *sc)
 		MGETHDR(m, M_DONTWAIT, MT_DATA);
 		if (m == NULL) {
  dropit:
-			if_statinc(ifp, if_ierrors);
+			ifp->if_ierrors++;
 			TULIP_INIT_RXDESC(sc, i);
 			bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0,
 			    rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
@@ -1342,8 +1366,9 @@ tlp_rxintr(struct tulip_softc *sc)
 		    rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
 #endif /* __NO_STRICT_ALIGNMENT */
 
+		ifp->if_ipackets++;
 		eh = mtod(m, struct ether_header *);
-		m_set_rcvif(m, ifp);
+		m->m_pkthdr.rcvif = ifp;
 		m->m_pkthdr.len = m->m_len = len;
 
 		/*
@@ -1366,6 +1391,15 @@ tlp_rxintr(struct tulip_softc *sc)
 				    ETHER_MAX_FRAME(ifp, etype, 0);
 		}
 
+#if NBPFILTER > 0
+		/*
+		 * Pass this up to any BPF listeners, but only
+		 * pass it up the stack if it's for us.
+		 */
+		if (ifp->if_bpf)
+			bpf_mtap(ifp->if_bpf, m);
+#endif /* NBPFILTER > 0 */
+
 		/*
 		 * We sometimes have to run the 21140 in Hash-Only
 		 * mode.  If we're in that mode, and not in promiscuous
@@ -1382,7 +1416,7 @@ tlp_rxintr(struct tulip_softc *sc)
 		}
 
 		/* Pass it on. */
-		if_percpuq_enqueue(ifp->if_percpuq, m);
+		(*ifp->if_input)(ifp, m);
 	}
 
 	/* Update the receive pointer. */
@@ -1404,28 +1438,29 @@ tlp_txintr(struct tulip_softc *sc)
 	DPRINTF(sc, ("%s: tlp_txintr: sc_flags 0x%08x\n",
 	    device_xname(sc->sc_dev), sc->sc_flags));
 
+	ifp->if_flags &= ~IFF_OACTIVE;
+
 	/*
 	 * Go through our Tx list and free mbufs for those
 	 * frames that have been transmitted.
 	 */
 	while ((txs = SIMPLEQ_FIRST(&sc->sc_txdirtyq)) != NULL) {
-		TULIP_CDTXSYNC(sc, txs->txs_lastdesc, txs->txs_ndescs,
-		    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+		TULIP_CDTXSYNC(sc, txs->txs_lastdesc,
+		    txs->txs_ndescs,
+		    BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
 
 #ifdef TLP_DEBUG
 		if (ifp->if_flags & IFF_DEBUG) {
 			int i;
-			struct tulip_desc *txd;
 			printf("    txsoft %p transmit chain:\n", txs);
 			for (i = txs->txs_firstdesc;; i = TULIP_NEXTTX(i)) {
-				txd = &sc->sc_txdescs[i];
 				printf("     descriptor %d:\n", i);
 				printf("       td_status:   0x%08x\n",
-				    le32toh(txd->td_status));
+				    le32toh(sc->sc_txdescs[i].td_status));
 				printf("       td_ctl:      0x%08x\n",
-				    le32toh(txd->td_ctl));
+				    le32toh(sc->sc_txdescs[i].td_ctl));
 				printf("       td_bufaddr1: 0x%08x\n",
-				    le32toh(txd->td_bufaddr1));
+				    le32toh(sc->sc_txdescs[i].td_bufaddr1));
 				printf("       td_bufaddr2: 0x%08x\n",
 				    le32toh(sc->sc_txdescs[i].td_bufaddr2));
 				if (i == txs->txs_lastdesc)
@@ -1479,20 +1514,18 @@ tlp_txintr(struct tulip_softc *sc)
 		if (txstat & TDSTAT_Tx_LC)
 			sc->sc_stats.ts_tx_lc++;
 #endif
-		net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
-		if (txstat & (TDSTAT_Tx_UF | TDSTAT_Tx_TO))
-			if_statinc_ref(nsr, if_oerrors);
+
+		if (txstat & (TDSTAT_Tx_UF|TDSTAT_Tx_TO))
+			ifp->if_oerrors++;
 
 		if (txstat & TDSTAT_Tx_EC)
-			if_statadd_ref(nsr, if_collisions, 16);
+			ifp->if_collisions += 16;
 		else
-			if_statadd_ref(nsr, if_collisions,
-			    TDSTAT_Tx_COLLISIONS(txstat));
+			ifp->if_collisions += TDSTAT_Tx_COLLISIONS(txstat);
 		if (txstat & TDSTAT_Tx_LC)
-			if_statinc_ref(nsr, if_collisions);
+			ifp->if_collisions++;
 
-		if_statinc_ref(nsr, if_opackets);
-		IF_STAT_PUTREF(ifp);
+		ifp->if_opackets++;
 	}
 
 	/*
@@ -1768,13 +1801,13 @@ tlp_init(struct ifnet *ifp)
 	 */
 	memset(sc->sc_txdescs, 0, sizeof(sc->sc_txdescs));
 	for (i = 0; i < TULIP_NTXDESC; i++) {
-		struct tulip_desc *txd = &sc->sc_txdescs[i];
-		txd->td_ctl = htole32(sc->sc_tdctl_ch);
-		txd->td_bufaddr2 = htole32(TULIP_CDTXADDR(sc, TULIP_NEXTTX(i)));
+		sc->sc_txdescs[i].td_ctl = htole32(sc->sc_tdctl_ch);
+		sc->sc_txdescs[i].td_bufaddr2 =
+		    htole32(TULIP_CDTXADDR(sc, TULIP_NEXTTX(i)));
 	}
 	sc->sc_txdescs[TULIP_NTXDESC - 1].td_ctl |= htole32(sc->sc_tdctl_er);
 	TULIP_CDTXSYNC(sc, 0, TULIP_NTXDESC,
-	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+	    BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
 	sc->sc_txfree = TULIP_NTXDESC;
 	sc->sc_txnext = 0;
 
@@ -1797,9 +1830,9 @@ tlp_init(struct ifnet *ifp)
 		rxs = &sc->sc_rxsoft[i];
 		if (rxs->rxs_mbuf == NULL) {
 			if ((error = tlp_add_rxbuf(sc, i)) != 0) {
-				aprint_error_dev(sc->sc_dev,
-				    "unable to allocate or map rx "
-				    "buffer %d, error = %d\n", i, error);
+				aprint_error_dev(sc->sc_dev, "unable to allocate or map rx "
+				    "buffer %d, error = %d\n",
+				    i, error);
 				/*
 				 * XXX Should attempt to run with fewer receive
 				 * XXX buffers instead of just failing.
@@ -1816,14 +1849,14 @@ tlp_init(struct ifnet *ifp)
 	 * Initialize the interrupt mask and enable interrupts.
 	 */
 	/* normal interrupts */
-	sc->sc_inten = STATUS_TI | STATUS_TU | STATUS_RI | STATUS_NIS;
+	sc->sc_inten =  STATUS_TI | STATUS_TU | STATUS_RI | STATUS_NIS;
 
 	/* abnormal interrupts */
 	sc->sc_inten |= STATUS_TPS | STATUS_TJT | STATUS_UNF |
 	    STATUS_RU | STATUS_RPS | STATUS_RWT | STATUS_SE | STATUS_AIS;
 
-	sc->sc_rxint_mask = STATUS_RI | STATUS_RU | STATUS_RWT;
-	sc->sc_txint_mask = STATUS_TI | STATUS_UNF | STATUS_TJT;
+	sc->sc_rxint_mask = STATUS_RI|STATUS_RU|STATUS_RWT;
+	sc->sc_txint_mask = STATUS_TI|STATUS_UNF|STATUS_TJT;
 
 	switch (sc->sc_chip) {
 	case TULIP_CHIP_WB89C840F:
@@ -1831,7 +1864,7 @@ tlp_init(struct ifnet *ifp)
 		 * Clear bits that we don't want that happen to
 		 * overlap or don't exist.
 		 */
-		sc->sc_inten &= ~(STATUS_WINB_REI | STATUS_RWT);
+		sc->sc_inten &= ~(STATUS_WINB_REI|STATUS_RWT);
 		break;
 
 	default:
@@ -1875,9 +1908,9 @@ tlp_init(struct ifnet *ifp)
 		const uint8_t *enaddr = CLLADDR(ifp->if_sadl);
 
 		reg = enaddr[0] |
-		    (enaddr[1] << 8) |
-		    (enaddr[2] << 16) |
-		    ((uint32_t)enaddr[3] << 24);
+		      (enaddr[1] << 8) |
+		      (enaddr[2] << 16) |
+		      (enaddr[3] << 24);
 		bus_space_write_4(sc->sc_st, sc->sc_sh, CSR_ADM_PAR0, reg);
 
 		reg = enaddr[4] |
@@ -1893,9 +1926,9 @@ tlp_init(struct ifnet *ifp)
 		const uint8_t *enaddr = CLLADDR(ifp->if_sadl);
 
 		reg = enaddr[0] |
-		    (enaddr[1] << 8) |
-		    (enaddr[2] << 16) |
-		    ((uint32_t)enaddr[3] << 24);
+		      (enaddr[1] << 8) |
+		      (enaddr[2] << 16) |
+		      (enaddr[3] << 24);
 		TULIP_WRITE(sc, CSR_AX_FILTIDX, AX_FILTIDX_PAR0);
 		TULIP_WRITE(sc, CSR_AX_FILTDATA, reg);
 
@@ -1919,7 +1952,7 @@ tlp_init(struct ifnet *ifp)
 	/*
 	 * Set the current media.
 	 */
-	(void)(*sc->sc_mediasw->tmsw_set)(sc);
+	(void) (*sc->sc_mediasw->tmsw_set)(sc);
 
 	/*
 	 * Start the receive process.
@@ -1935,15 +1968,16 @@ tlp_init(struct ifnet *ifp)
 	 * Note that the interface is now running.
 	 */
 	ifp->if_flags |= IFF_RUNNING;
+	ifp->if_flags &= ~IFF_OACTIVE;
 	sc->sc_if_flags = ifp->if_flags;
 
  out:
 	if (error) {
-		ifp->if_flags &= ~IFF_RUNNING;
+		ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
 		ifp->if_timer = 0;
 		printf("%s: interface not running\n", device_xname(sc->sc_dev));
 	}
-	return error;
+	return (error);
 }
 
 /*
@@ -1958,11 +1992,11 @@ tlp_enable(struct tulip_softc *sc)
 	if (TULIP_IS_ENABLED(sc) == 0 && sc->sc_enable != NULL) {
 		if ((*sc->sc_enable)(sc) != 0) {
 			aprint_error_dev(sc->sc_dev, "device enable failed\n");
-			return EIO;
+			return (EIO);
 		}
 		sc->sc_flags |= TULIPF_ENABLED;
 	}
-	return 0;
+	return (0);
 }
 
 /*
@@ -2044,12 +2078,12 @@ tlp_stop(struct ifnet *ifp, int disable)
 		SIMPLEQ_INSERT_TAIL(&sc->sc_txfreeq, txs, txs_q);
 	}
 
-	sc->sc_flags &= ~(TULIPF_WANT_SETUP | TULIPF_DOING_SETUP);
+	sc->sc_flags &= ~(TULIPF_WANT_SETUP|TULIPF_DOING_SETUP);
 
 	/*
 	 * Mark the interface down and cancel the watchdog timer.
 	 */
-	ifp->if_flags &= ~IFF_RUNNING;
+	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
 	sc->sc_if_flags = ifp->if_flags;
 	ifp->if_timer = 0;
 
@@ -2090,12 +2124,12 @@ tlp_srom_idle(struct tulip_softc *sc)
 	miirom |= MIIROM_SROMCS;
 	SROM_EMIT(sc, miirom);
 
-	SROM_EMIT(sc, miirom | MIIROM_SROMSK);
+	SROM_EMIT(sc, miirom|MIIROM_SROMSK);
 
 	/* Strobe the clock 32 times. */
 	for (i = 0; i < 32; i++) {
 		SROM_EMIT(sc, miirom);
-		SROM_EMIT(sc, miirom | MIIROM_SROMSK);
+		SROM_EMIT(sc, miirom|MIIROM_SROMSK);
 	}
 
 	SROM_EMIT(sc, miirom);
@@ -2135,7 +2169,7 @@ tlp_srom_size(struct tulip_softc *sc)
 		else
 			miirom &= ~MIIROM_SROMDI;
 		SROM_EMIT(sc, miirom);
-		SROM_EMIT(sc, miirom | MIIROM_SROMSK);
+		SROM_EMIT(sc, miirom|MIIROM_SROMSK);
 		SROM_EMIT(sc, miirom);
 	}
 
@@ -2143,7 +2177,7 @@ tlp_srom_size(struct tulip_softc *sc)
 	for (x = 1; x <= 12; x++) {
 		miirom &= ~MIIROM_SROMDI;
 		SROM_EMIT(sc, miirom);
-		SROM_EMIT(sc, miirom | MIIROM_SROMSK);
+		SROM_EMIT(sc, miirom|MIIROM_SROMSK);
 		if (!TULIP_ISSET(sc, CSR_MIIROM, MIIROM_SROMDO))
 			break;
 		SROM_EMIT(sc, miirom);
@@ -2157,14 +2191,14 @@ tlp_srom_size(struct tulip_softc *sc)
 	SROM_EMIT(sc, 0);
 
 	if (x < 4 || x > 12) {
-		aprint_debug_dev(sc->sc_dev, "broken MicroWire interface "
-		    "detected; setting SROM size to 1Kb\n");
-		return 6;
+		aprint_debug_dev(sc->sc_dev, "broken MicroWire interface detected; "
+		    "setting SROM size to 1Kb\n");
+		return (6);
 	} else {
 		if (tlp_srom_debug)
 			printf("%s: SROM size is 2^%d*16 bits (%d bytes)\n",
 			    device_xname(sc->sc_dev), x, (1 << (x + 4)) >> 3);
-		return x;
+		return (x);
 	}
 }
 
@@ -2185,9 +2219,9 @@ tlp_read_srom(struct tulip_softc *sc)
 
 	sc->sc_srom_addrbits = tlp_srom_size(sc);
 	if (sc->sc_srom_addrbits == 0)
-		return 0;
+		return (0);
 	size = TULIP_ROM_SIZE(sc->sc_srom_addrbits);
-	sc->sc_srom = malloc(size, M_DEVBUF, M_WAITOK);
+	sc->sc_srom = malloc(size, M_DEVBUF, M_NOWAIT);
 
 	/* Select the SROM. */
 	miirom = MIIROM_SR;
@@ -2208,7 +2242,7 @@ tlp_read_srom(struct tulip_softc *sc)
 			else
 				miirom &= ~MIIROM_SROMDI;
 			SROM_EMIT(sc, miirom);
-			SROM_EMIT(sc, miirom | MIIROM_SROMSK);
+			SROM_EMIT(sc, miirom|MIIROM_SROMSK);
 			SROM_EMIT(sc, miirom);
 		}
 
@@ -2219,7 +2253,7 @@ tlp_read_srom(struct tulip_softc *sc)
 			else
 				miirom &= ~MIIROM_SROMDI;
 			SROM_EMIT(sc, miirom);
-			SROM_EMIT(sc, miirom | MIIROM_SROMSK);
+			SROM_EMIT(sc, miirom|MIIROM_SROMSK);
 			SROM_EMIT(sc, miirom);
 		}
 
@@ -2227,7 +2261,7 @@ tlp_read_srom(struct tulip_softc *sc)
 		miirom &= ~MIIROM_SROMDI;
 		datain = 0;
 		for (x = 16; x > 0; x--) {
-			SROM_EMIT(sc, miirom | MIIROM_SROMSK);
+			SROM_EMIT(sc, miirom|MIIROM_SROMSK);
 			if (TULIP_ISSET(sc, CSR_MIIROM, MIIROM_SROMDO))
 				datain |= (1 << (x - 1));
 			SROM_EMIT(sc, miirom);
@@ -2256,7 +2290,7 @@ tlp_read_srom(struct tulip_softc *sc)
 		printf("\n");
 	}
 
-	return 1;
+	return (1);
 }
 
 #undef SROM_EMIT
@@ -2275,13 +2309,13 @@ tlp_add_rxbuf(struct tulip_softc *sc, in
 
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (m == NULL)
-		return ENOBUFS;
+		return (ENOBUFS);
 
 	MCLAIM(m, &sc->sc_ethercom.ec_rx_mowner);
 	MCLGET(m, M_DONTWAIT);
 	if ((m->m_flags & M_EXT) == 0) {
 		m_freem(m);
-		return ENOBUFS;
+		return (ENOBUFS);
 	}
 
 	if (rxs->rxs_mbuf != NULL)
@@ -2291,10 +2325,10 @@ tlp_add_rxbuf(struct tulip_softc *sc, in
 
 	error = bus_dmamap_load(sc->sc_dmat, rxs->rxs_dmamap,
 	    m->m_ext.ext_buf, m->m_ext.ext_size, NULL,
-	    BUS_DMA_READ | BUS_DMA_NOWAIT);
+	    BUS_DMA_READ|BUS_DMA_NOWAIT);
 	if (error) {
-		aprint_error_dev(sc->sc_dev,
-		    "can't load rx DMA map %d, error = %d\n", idx, error);
+		aprint_error_dev(sc->sc_dev, "can't load rx DMA map %d, error = %d\n",
+		    idx, error);
 		panic("tlp_add_rxbuf");	/* XXX */
 	}
 
@@ -2303,7 +2337,7 @@ tlp_add_rxbuf(struct tulip_softc *sc, in
 
 	TULIP_INIT_RXDESC(sc, idx);
 
-	return 0;
+	return (0);
 }
 
 /*
@@ -2319,7 +2353,7 @@ tlp_srom_crcok(const uint8_t *romdata)
 	crc = ether_crc32_le(romdata, TULIP_ROM_CRC32_CHECKSUM);
 	crc = (crc & 0xffff) ^ 0xffff;
 	if (crc == TULIP_ROM_GETW(romdata, TULIP_ROM_CRC32_CHECKSUM))
-		return 1;
+		return (1);
 
 	/*
 	 * Try an alternate checksum.
@@ -2327,9 +2361,9 @@ tlp_srom_crcok(const uint8_t *romdata)
 	crc = ether_crc32_le(romdata, TULIP_ROM_CRC32_CHECKSUM1);
 	crc = (crc & 0xffff) ^ 0xffff;
 	if (crc == TULIP_ROM_GETW(romdata, TULIP_ROM_CRC32_CHECKSUM1))
-		return 1;
+		return (1);
 
-	return 0;
+	return (0);
 }
 
 /*
@@ -2347,7 +2381,7 @@ tlp_isv_srom(const uint8_t *romdata)
 		/*
 		 * SROM CRC checks out; must be in the new format.
 		 */
-		return 1;
+		return (1);
 	}
 
 	cksum = TULIP_ROM_GETW(romdata, TULIP_ROM_CRC32_CHECKSUM);
@@ -2359,16 +2393,16 @@ tlp_isv_srom(const uint8_t *romdata)
 		 */
 		for (i = 0; i < TULIP_ROM_SROM_FORMAT_VERION; i++) {
 			if (romdata[i] != 0)
-				return 0;
+				return (0);
 		}
 		if (romdata[TULIP_ROM_SROM_FORMAT_VERION] != 1)
-			return 0;
+			return (0);
 		if (romdata[TULIP_ROM_CHIP_COUNT] == 0)
-			return 0;
-		return 1;
+			return (0);
+		return (1);
 	}
 
-	return 0;
+	return (0);
 }
 
 /*
@@ -2382,7 +2416,7 @@ tlp_isv_srom_enaddr(struct tulip_softc *
 	int i, devcnt;
 
 	if (tlp_isv_srom(sc->sc_srom) == 0)
-		return 0;
+		return (0);
 
 	devcnt = sc->sc_srom[TULIP_ROM_CHIP_COUNT];
 	for (i = 0; i < devcnt; i++) {
@@ -2394,13 +2428,13 @@ tlp_isv_srom_enaddr(struct tulip_softc *
 	}
 
 	if (i == devcnt)
-		return 0;
+		return (0);
 
 	memcpy(enaddr, &sc->sc_srom[TULIP_ROM_IEEE_NETWORK_ADDRESS],
 	    ETHER_ADDR_LEN);
 	enaddr[5] += i;
 
-	return 1;
+	return (1);
 }
 
 /*
@@ -2433,7 +2467,7 @@ tlp_parse_old_srom(struct tulip_softc *s
 				enaddr[i] = sc->sc_srom[i + 1];
 				enaddr[i + 1] = sc->sc_srom[i];
 			}
-			return 1;
+			return (1);
 		}
 
 		/*
@@ -2450,7 +2484,7 @@ tlp_parse_old_srom(struct tulip_softc *s
 				enaddr[i] = sc->sc_srom[20 + i + 1];
 				enaddr[i + 1] = sc->sc_srom[20 + i];
 			}
-			return 1;
+			return (1);
 		}
 
 		/*
@@ -2462,7 +2496,7 @@ tlp_parse_old_srom(struct tulip_softc *s
 		    sc->sc_srom[1] == 0x10 &&
 		    sc->sc_srom[2] == 0xe0) {
 			memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN);
-			return 1;
+			return (1);
 		}
 
 		/*
@@ -2474,7 +2508,7 @@ tlp_parse_old_srom(struct tulip_softc *s
 		for (i = 8; i < 32; i++) {
 			if (sc->sc_srom[i] != 0xff &&
 			    sc->sc_srom[i] != 0)
-				return 0;
+				return (0);
 		}
 
 		/*
@@ -2485,13 +2519,13 @@ tlp_parse_old_srom(struct tulip_softc *s
 		 *	- Make sure it has a non-0 OUI
 		 */
 		if (sc->sc_srom[0] & 3)
-			return 0;
+			return (0);
 		if (sc->sc_srom[0] == 0 && sc->sc_srom[1] == 0 &&
 		    sc->sc_srom[2] == 0)
-			return 0;
+			return (0);
 
 		memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN);
-		return 1;
+		return (1);
 	}
 
 	/*
@@ -2499,11 +2533,11 @@ tlp_parse_old_srom(struct tulip_softc *s
 	 */
 
 	if (memcmp(&sc->sc_srom[24], testpat, 8) != 0)
-		return 0;
+		return (0);
 
 	for (i = 0; i < 8; i++) {
 		if (sc->sc_srom[i] != sc->sc_srom[15 - i])
-			return 0;
+			return (0);
 	}
 
 	memcpy(enaddr, sc->sc_srom, ETHER_ADDR_LEN);
@@ -2527,9 +2561,9 @@ tlp_parse_old_srom(struct tulip_softc *s
 		cksum -= 0xffff;
 
 	if (cksum != *(uint16_t *) &sc->sc_srom[6])
-		return 0;
+		return (0);
 
-	return 1;
+	return (1);
 }
 
 /*
@@ -2546,7 +2580,6 @@ tlp_filter_setup(struct tulip_softc *sc)
 	struct ether_multistep step;
 	volatile uint32_t *sp;
 	struct tulip_txsoft *txs;
-	struct tulip_desc *txd;
 	uint8_t enaddr[ETHER_ADDR_LEN];
 	uint32_t hash, hashsize;
 	int cnt, nexttx;
@@ -2585,9 +2618,9 @@ tlp_filter_setup(struct tulip_softc *sc)
 	 * in motion.
 	 */
 	if (ifp->if_flags & IFF_RUNNING)
-		tlp_idle(sc, OPMODE_ST | OPMODE_SR);
+		tlp_idle(sc, OPMODE_ST|OPMODE_SR);
 
-	sc->sc_opmode &= ~(OPMODE_PR | OPMODE_PM);
+	sc->sc_opmode &= ~(OPMODE_PR|OPMODE_PM);
 
 	if (ifp->if_flags & IFF_PROMISC) {
 		sc->sc_opmode |= OPMODE_PR;
@@ -2602,7 +2635,6 @@ tlp_filter_setup(struct tulip_softc *sc)
 	sp = TULIP_CDSP(sc);
 	memset(TULIP_CDSP(sc), 0, TULIP_SETUP_PACKET_LEN);
 	cnt = 0;
-	ETHER_LOCK(ec);
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
 		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
@@ -2614,7 +2646,6 @@ tlp_filter_setup(struct tulip_softc *sc)
 			 * ranges is for IP multicast routing, for which the
 			 * range is big enough to require all bits set.)
 			 */
-			ETHER_UNLOCK(ec);
 			goto allmulti;
 		}
 		if (cnt == (TULIP_MAXADDRS - 2)) {
@@ -2623,7 +2654,6 @@ tlp_filter_setup(struct tulip_softc *sc)
 			 * our station address and broadcast).  Go to
 			 * Hash-Perfect mode.
 			 */
-			ETHER_UNLOCK(ec);
 			goto hashperfect;
 		}
 		cnt++;
@@ -2632,7 +2662,6 @@ tlp_filter_setup(struct tulip_softc *sc)
 		*sp++ = htole32(TULIP_SP_FIELD(enm->enm_addrlo, 2));
 		ETHER_NEXT_MULTI(step, enm);
 	}
-	ETHER_UNLOCK(ec);
 
 	if (ifp->if_flags & IFF_BROADCAST) {
 		/* ...and the broadcast address. */
@@ -2667,7 +2696,6 @@ tlp_filter_setup(struct tulip_softc *sc)
 		sc->sc_filtmode = TDCTL_Tx_FT_HASH;
 	sp = TULIP_CDSP(sc);
 	memset(TULIP_CDSP(sc), 0, TULIP_SETUP_PACKET_LEN);
-	ETHER_LOCK(ec);
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
 		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
@@ -2679,14 +2707,12 @@ tlp_filter_setup(struct tulip_softc *sc)
 			 * ranges is for IP multicast routing, for which the
 			 * range is big enough to require all bits set.)
 			 */
-			ETHER_UNLOCK(ec);
 			goto allmulti;
 		}
 		hash = tlp_mchash(enm->enm_addrlo, hashsize);
 		sp[hash >> 4] |= htole32(1 << (hash & 0xf));
 		ETHER_NEXT_MULTI(step, enm);
 	}
-	ETHER_UNLOCK(ec);
 
 	if (ifp->if_flags & IFF_BROADCAST) {
 		/* ...and the broadcast address. */
@@ -2751,32 +2777,34 @@ tlp_filter_setup(struct tulip_softc *sc)
 	txs->txs_mbuf = NULL;
 
 	nexttx = sc->sc_txnext;
-	txd = &sc->sc_txdescs[nexttx];
-	txd->td_status = 0;
-	txd->td_bufaddr1 = htole32(TULIP_CDSPADDR(sc));
-	txd->td_ctl = htole32((TULIP_SETUP_PACKET_LEN << TDCTL_SIZE1_SHIFT) |
+	sc->sc_txdescs[nexttx].td_status = 0;
+	sc->sc_txdescs[nexttx].td_bufaddr1 = htole32(TULIP_CDSPADDR(sc));
+	sc->sc_txdescs[nexttx].td_ctl =
+	    htole32((TULIP_SETUP_PACKET_LEN << TDCTL_SIZE1_SHIFT) |
 	    sc->sc_filtmode | TDCTL_Tx_SET | sc->sc_setup_fsls |
 	    TDCTL_Tx_IC | sc->sc_tdctl_ch |
 	    (nexttx == (TULIP_NTXDESC - 1) ? sc->sc_tdctl_er : 0));
 	TULIP_CDTXSYNC(sc, nexttx, 1,
-	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+	    BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
 
 #ifdef TLP_DEBUG
 	if (ifp->if_flags & IFF_DEBUG) {
 		printf("     filter_setup %p transmit chain:\n", txs);
 		printf("     descriptor %d:\n", nexttx);
-		printf("       td_status:   0x%08x\n", le32toh(txd->td_status));
-		printf("       td_ctl:      0x%08x\n", le32toh(txd->td_ctl));
+		printf("       td_status:   0x%08x\n",
+		    le32toh(sc->sc_txdescs[nexttx].td_status));
+		printf("       td_ctl:      0x%08x\n",
+		    le32toh(sc->sc_txdescs[nexttx].td_ctl));
 		printf("       td_bufaddr1: 0x%08x\n",
-		    le32toh(txd->td_bufaddr1));
+		    le32toh(sc->sc_txdescs[nexttx].td_bufaddr1));
 		printf("       td_bufaddr2: 0x%08x\n",
-		    le32toh(txd->td_bufaddr2));
+		    le32toh(sc->sc_txdescs[nexttx].td_bufaddr2));
 	}
 #endif
 
-	txd->td_status = htole32(TDSTAT_OWN);
+	sc->sc_txdescs[nexttx].td_status = htole32(TDSTAT_OWN);
 	TULIP_CDTXSYNC(sc, nexttx, 1,
-	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+	    BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
 
 	/* Advance the tx pointer. */
 	sc->sc_txfree -= 1;
@@ -2803,8 +2831,7 @@ tlp_filter_setup(struct tulip_softc *sc)
 	/* Set up a watchdog timer in case the chip flakes out. */
 	ifp->if_timer = 5;
 
-	DPRINTF(sc, ("%s: tlp_filter_setup: returning\n",
-		device_xname(sc->sc_dev)));
+	DPRINTF(sc, ("%s: tlp_filter_setup: returning\n", device_xname(sc->sc_dev)));
 }
 
 /*
@@ -2824,7 +2851,7 @@ tlp_winb_filter_setup(struct tulip_softc
 	DPRINTF(sc, ("%s: tlp_winb_filter_setup: sc_flags 0x%08x\n",
 	    device_xname(sc->sc_dev), sc->sc_flags));
 
-	sc->sc_opmode &= ~(OPMODE_WINB_APP | OPMODE_WINB_AMP |OPMODE_WINB_ABP);
+	sc->sc_opmode &= ~(OPMODE_WINB_APP|OPMODE_WINB_AMP|OPMODE_WINB_ABP);
 
 	if (ifp->if_flags & IFF_MULTICAST)
 		sc->sc_opmode |= OPMODE_WINB_AMP;
@@ -2906,7 +2933,7 @@ tlp_al981_filter_setup(struct tulip_soft
 	DPRINTF(sc, ("%s: tlp_al981_filter_setup: sc_flags 0x%08x\n",
 	    device_xname(sc->sc_dev), sc->sc_flags));
 
-	sc->sc_opmode &= ~(OPMODE_PR | OPMODE_PM);
+	sc->sc_opmode &= ~(OPMODE_PR|OPMODE_PM);
 
 	if (ifp->if_flags & IFF_PROMISC) {
 		sc->sc_opmode |= OPMODE_PR;
@@ -2915,7 +2942,6 @@ tlp_al981_filter_setup(struct tulip_soft
 
 	mchash[0] = mchash[1] = 0;
 
-	ETHER_LOCK(ec);
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
 		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
@@ -2927,15 +2953,13 @@ tlp_al981_filter_setup(struct tulip_soft
 			 * ranges is for IP multicast routing, for which the
 			 * range is big enough to require all bits set.)
 			 */
-			ETHER_UNLOCK(ec);
 			goto allmulti;
 		}
 
 		hash = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN) & 0x3f;
-		mchash[hash >> 5] |= __BIT(hash & 0x1f);
+		mchash[hash >> 5] |= 1 << (hash & 0x1f);
 		ETHER_NEXT_MULTI(step, enm);
 	}
-	ETHER_UNLOCK(ec);
 	ifp->if_flags &= ~IFF_ALLMULTI;
 	goto setit;
 
@@ -2954,7 +2978,7 @@ tlp_al981_filter_setup(struct tulip_soft
 /*
  * tlp_asix_filter_setup:
  *
- * 	Set the ASIX AX8814x receive filter.
+ * 	Set the ASIX AX8814x recieve filter.
  */
 static void
 tlp_asix_filter_setup(struct tulip_softc *sc)
@@ -2968,7 +2992,7 @@ tlp_asix_filter_setup(struct tulip_softc
 	DPRINTF(sc, ("%s: tlp_asix_filter_setup: sc_flags 0x%08x\n",
 		device_xname(sc->sc_dev), sc->sc_flags));
 
-	sc->sc_opmode &= ~(OPMODE_PM | OPMODE_AX_RB | OPMODE_PR);
+	sc->sc_opmode &= ~(OPMODE_PM|OPMODE_AX_RB|OPMODE_PR);
 
 	if (ifp->if_flags & IFF_MULTICAST)
 		sc->sc_opmode |= OPMODE_PM;
@@ -2983,7 +3007,6 @@ tlp_asix_filter_setup(struct tulip_softc
 
 	mchash[0] = mchash[1] = 0;
 
-	ETHER_LOCK(ec);
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
 		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
@@ -2995,7 +3018,6 @@ tlp_asix_filter_setup(struct tulip_softc
 			 * ranges is for IP multicast routing, for which the
 			 * range is big enough to require all bits set.)
 			 */
-			ETHER_UNLOCK(ec);
 			goto allmulti;
 		}
 		hash = (ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26)
@@ -3006,7 +3028,6 @@ tlp_asix_filter_setup(struct tulip_softc
 			mchash[1] |= (1 << (hash - 32));
 		ETHER_NEXT_MULTI(step, enm);
 	}
-	ETHER_UNLOCK(ec);
 	ifp->if_flags &= ~IFF_ALLMULTI;
 	goto setit;
 
@@ -3177,8 +3198,8 @@ tlp_mediachange(struct ifnet *ifp)
 	struct tulip_softc *sc = ifp->if_softc;
 
 	if ((ifp->if_flags & IFF_UP) == 0)
-		return 0;
-	return (*sc->sc_mediasw->tmsw_set)(sc);
+		return (0);
+	return ((*sc->sc_mediasw->tmsw_set)(sc));
 }
 
 /*****************************************************************************
@@ -3212,14 +3233,14 @@ tlp_mii_tick(void *arg)
  *	Callback from PHY when media changes.
  */
 static void
-tlp_mii_statchg(struct ifnet *ifp)
+tlp_mii_statchg(device_t self)
 {
-	struct tulip_softc *sc = ifp->if_softc;
+	struct tulip_softc *sc = device_private(self);
 
 	/* Idle the transmit and receive processes. */
-	tlp_idle(sc, OPMODE_ST | OPMODE_SR);
+	tlp_idle(sc, OPMODE_ST|OPMODE_SR);
 
-	sc->sc_opmode &= ~(OPMODE_TTM | OPMODE_FD | OPMODE_HBD);
+	sc->sc_opmode &= ~(OPMODE_TTM|OPMODE_FD|OPMODE_HBD);
 
 	if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) == IFM_10_T)
 		sc->sc_opmode |= OPMODE_TTM;
@@ -3227,7 +3248,7 @@ tlp_mii_statchg(struct ifnet *ifp)
 		sc->sc_opmode |= OPMODE_HBD;
 
 	if (sc->sc_mii.mii_media_active & IFM_FDX)
-		sc->sc_opmode |= OPMODE_FD | OPMODE_HBD;
+		sc->sc_opmode |= OPMODE_FD|OPMODE_HBD;
 
 	/*
 	 * Write new OPMODE bits.  This also restarts the transmit
@@ -3243,14 +3264,14 @@ tlp_mii_statchg(struct ifnet *ifp)
  *	for the Winbond 89C840F, which has different OPMODE bits.
  */
 static void
-tlp_winb_mii_statchg(struct ifnet *ifp)
+tlp_winb_mii_statchg(device_t self)
 {
-	struct tulip_softc *sc = ifp->if_softc;
+	struct tulip_softc *sc = device_private(self);
 
 	/* Idle the transmit and receive processes. */
-	tlp_idle(sc, OPMODE_ST | OPMODE_SR);
+	tlp_idle(sc, OPMODE_ST|OPMODE_SR);
 
-	sc->sc_opmode &= ~(OPMODE_WINB_FES | OPMODE_FD);
+	sc->sc_opmode &= ~(OPMODE_WINB_FES|OPMODE_FD);
 
 	if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) == IFM_100_TX)
 		sc->sc_opmode |= OPMODE_WINB_FES;
@@ -3272,15 +3293,15 @@ tlp_winb_mii_statchg(struct ifnet *ifp)
  *	for the DM9102.
  */
 static void
-tlp_dm9102_mii_statchg(struct ifnet *ifp)
+tlp_dm9102_mii_statchg(device_t self)
 {
-	struct tulip_softc *sc = ifp->if_softc;
+	struct tulip_softc *sc = device_private(self);
 
 	/*
 	 * Don't idle the transmit and receive processes, here.  It
 	 * seems to fail, and just causes excess noise.
 	 */
-	sc->sc_opmode &= ~(OPMODE_TTM | OPMODE_FD);
+	sc->sc_opmode &= ~(OPMODE_TTM|OPMODE_FD);
 
 	if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) != IFM_100_TX)
 		sc->sc_opmode |= OPMODE_TTM;
@@ -3302,11 +3323,10 @@ tlp_dm9102_mii_statchg(struct ifnet *ifp
 static void
 tlp_mii_getmedia(struct tulip_softc *sc, struct ifmediareq *ifmr)
 {
-	struct mii_data * const mii = &sc->sc_mii;
 
-	mii_pollstat(mii);
-	ifmr->ifm_status = mii->mii_media_status;
-	ifmr->ifm_active = mii->mii_media_active;
+	mii_pollstat(&sc->sc_mii);
+	ifmr->ifm_status = sc->sc_mii.mii_media_status;
+	ifmr->ifm_active = sc->sc_mii.mii_media_active;
 }
 
 /*
@@ -3344,11 +3364,11 @@ tlp_mii_setmedia(struct tulip_softc *sc)
  *	Read a PHY register via bit-bang'ing the MII.
  */
 static int
-tlp_bitbang_mii_readreg(device_t self, int phy, int reg, uint16_t *val)
+tlp_bitbang_mii_readreg(device_t self, int phy, int reg)
 {
 	struct tulip_softc *sc = device_private(self);
 
-	return mii_bitbang_readreg(self, sc->sc_bitbang_ops, phy, reg, val);
+	return (mii_bitbang_readreg(self, sc->sc_bitbang_ops, phy, reg));
 }
 
 /*
@@ -3356,12 +3376,12 @@ tlp_bitbang_mii_readreg(device_t self, i
  *
  *	Write a PHY register via bit-bang'ing the MII.
  */
-static int
-tlp_bitbang_mii_writereg(device_t self, int phy, int reg, uint16_t val)
+static void
+tlp_bitbang_mii_writereg(device_t self, int phy, int reg, int val)
 {
 	struct tulip_softc *sc = device_private(self);
 
-	return mii_bitbang_writereg(self, sc->sc_bitbang_ops, phy, reg, val);
+	mii_bitbang_writereg(self, sc->sc_bitbang_ops, phy, reg, val);
 }
 
 /*
@@ -3374,7 +3394,7 @@ tlp_sio_mii_bitbang_read(device_t self)
 {
 	struct tulip_softc *sc = device_private(self);
 
-	return TULIP_READ(sc, CSR_MIIROM);
+	return (TULIP_READ(sc, CSR_MIIROM));
 }
 
 /*
@@ -3396,10 +3416,10 @@ tlp_sio_mii_bitbang_write(device_t self,
  *	Read a PHY register on the Lite-On PNIC.
  */
 static int
-tlp_pnic_mii_readreg(device_t self, int phy, int reg, uint16_t *val)
+tlp_pnic_mii_readreg(device_t self, int phy, int reg)
 {
 	struct tulip_softc *sc = device_private(self);
-	uint32_t data;
+	uint32_t val;
 	int i;
 
 	TULIP_WRITE(sc, CSR_PNIC_MII,
@@ -3409,18 +3429,16 @@ tlp_pnic_mii_readreg(device_t self, int 
 
 	for (i = 0; i < 1000; i++) {
 		delay(10);
-		data = TULIP_READ(sc, CSR_PNIC_MII);
-		if ((data & PNIC_MII_BUSY) == 0) {
-			if ((data & PNIC_MII_DATA) == PNIC_MII_DATA)
-				return -1;
-			else {
-				*val = data & PNIC_MII_DATA;
-				return 0;
-			}
+		val = TULIP_READ(sc, CSR_PNIC_MII);
+		if ((val & PNIC_MII_BUSY) == 0) {
+			if ((val & PNIC_MII_DATA) == PNIC_MII_DATA)
+				return (0);
+			else
+				return (val & PNIC_MII_DATA);
 		}
 	}
 	printf("%s: MII read timed out\n", device_xname(sc->sc_dev));
-	return ETIMEDOUT;
+	return (0);
 }
 
 /*
@@ -3428,8 +3446,8 @@ tlp_pnic_mii_readreg(device_t self, int 
  *
  *	Write a PHY register on the Lite-On PNIC.
  */
-static int
-tlp_pnic_mii_writereg(device_t self, int phy, int reg, uint16_t val)
+static void
+tlp_pnic_mii_writereg(device_t self, int phy, int reg, int val)
 {
 	struct tulip_softc *sc = device_private(self);
 	int i;
@@ -3442,10 +3460,9 @@ tlp_pnic_mii_writereg(device_t self, int
 	for (i = 0; i < 1000; i++) {
 		delay(10);
 		if (TULIP_ISSET(sc, CSR_PNIC_MII, PNIC_MII_BUSY) == 0)
-			return 0;
+			return;
 	}
 	printf("%s: MII write timed out\n", device_xname(sc->sc_dev));
-	return ETIMEDOUT;
 }
 
 static const bus_addr_t tlp_al981_phy_regmap[] = {
@@ -3471,20 +3488,19 @@ static const int tlp_al981_phy_regmap_si
  *	Read a PHY register on the ADMtek AL981.
  */
 static int
-tlp_al981_mii_readreg(device_t self, int phy, int reg, uint16_t *val)
+tlp_al981_mii_readreg(device_t self, int phy, int reg)
 {
 	struct tulip_softc *sc = device_private(self);
 
 	/* AL981 only has an internal PHY. */
 	if (phy != 0)
-		return -1;
+		return (0);
 
 	if (reg >= tlp_al981_phy_regmap_size)
-		return -1;
+		return (0);
 
-	*val = bus_space_read_4(sc->sc_st, sc->sc_sh,
-	    tlp_al981_phy_regmap[reg]) & 0xffff;
-	return 0;
+	return (bus_space_read_4(sc->sc_st, sc->sc_sh,
+	    tlp_al981_phy_regmap[reg]) & 0xffff);
 }
 
 /*
@@ -3492,22 +3508,20 @@ tlp_al981_mii_readreg(device_t self, int
  *
  *	Write a PHY register on the ADMtek AL981.
  */
-static int
-tlp_al981_mii_writereg(device_t self, int phy, int reg, uint16_t val)
+static void
+tlp_al981_mii_writereg(device_t self, int phy, int reg, int val)
 {
 	struct tulip_softc *sc = device_private(self);
 
 	/* AL981 only has an internal PHY. */
 	if (phy != 0)
-		return -1;
+		return;
 
 	if (reg >= tlp_al981_phy_regmap_size)
-		return -1;
+		return;
 
 	bus_space_write_4(sc->sc_st, sc->sc_sh,
 	    tlp_al981_phy_regmap[reg], val);
-
-	return 0;
 }
 
 /*****************************************************************************
@@ -3551,7 +3565,7 @@ tlp_2114x_mii_preinit(struct tulip_softc
 	 * Always set the Must-Be-One bit, and Port Select (to select MII).
 	 * We'll never be called during a media change.
 	 */
-	sc->sc_opmode |= OPMODE_MBO | OPMODE_PS;
+	sc->sc_opmode |= OPMODE_MBO|OPMODE_PS;
 	TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode);
 }
 
@@ -3591,7 +3605,7 @@ tlp_asix_preinit(struct tulip_softc *sc)
 		case TULIP_CHIP_AX88140:
 		case TULIP_CHIP_AX88141:
 			/* XXX Handle PHY. */
-			sc->sc_opmode |= OPMODE_HBD | OPMODE_PS;
+			sc->sc_opmode |= OPMODE_HBD|OPMODE_PS;
 			break;
 		default:
 			/* Nothing */
@@ -3612,7 +3626,7 @@ tlp_dm9102_preinit(struct tulip_softc *s
 
 	switch (sc->sc_chip) {
 	case TULIP_CHIP_DM9102:
-		sc->sc_opmode |= OPMODE_MBO | OPMODE_HBD | OPMODE_PS;
+		sc->sc_opmode |= OPMODE_MBO|OPMODE_HBD|OPMODE_PS;
 		break;
 
 	case TULIP_CHIP_DM9102A:
@@ -3620,7 +3634,7 @@ tlp_dm9102_preinit(struct tulip_softc *s
 		 * XXX Figure out how to actually deal with the HomePNA
 		 * XXX portion of the DM9102A.
 		 */
-		sc->sc_opmode |= OPMODE_MBO | OPMODE_HBD;
+		sc->sc_opmode |= OPMODE_MBO|OPMODE_HBD;
 		break;
 
 	default:
@@ -3644,7 +3658,7 @@ tlp_21140_reset(struct tulip_softc *sc)
 	int i;
 
 	/* First, set the direction on the GPIO pins. */
-	TULIP_WRITE(sc, CSR_GPP, GPP_GPC | sc->sc_gp_dir);
+	TULIP_WRITE(sc, CSR_GPP, GPP_GPC|sc->sc_gp_dir);
 
 	/* Now, issue the reset sequence. */
 	for (i = 0; i < tm->tm_reset_length; i++) {
@@ -3744,7 +3758,7 @@ static void
 tlp_dm9102_reset(struct tulip_softc *sc)
 {
 
-	TULIP_WRITE(sc, CSR_DM_PHYSTAT, DM_PHYSTAT_GEPC | DM_PHYSTAT_GPED);
+	TULIP_WRITE(sc, CSR_DM_PHYSTAT, DM_PHYSTAT_GEPC|DM_PHYSTAT_GPED);
 	delay(100);
 	TULIP_WRITE(sc, CSR_DM_PHYSTAT, 0);
 }
@@ -3814,7 +3828,7 @@ static const struct tulip_srom_to_ifmedi
 
 	{ TULIP_ROM_MB_MEDIA_100TX,	IFM_100_TX,	0,
 	  "100baseTX",
-	  OPMODE_PS | OPMODE_PCS | OPMODE_SCR | OPMODE_HBD,
+	  OPMODE_PS|OPMODE_PCS|OPMODE_SCR|OPMODE_HBD,
 	  BMSR_100TXHDX,
 	  { 0,
 	    0,
@@ -3830,7 +3844,7 @@ static const struct tulip_srom_to_ifmedi
 
 	{ TULIP_ROM_MB_MEDIA_TP_FDX,	IFM_10_T,	IFM_FDX,
 	  "10baseT-FDX",
-	  OPMODE_TTM | OPMODE_FD | OPMODE_HBD,
+	  OPMODE_TTM|OPMODE_FD|OPMODE_HBD,
 	  BMSR_10TFDX,
 	  { SIACONN_21040_10BASET_FDX,
 	    SIATXRX_21040_10BASET_FDX,
@@ -3846,7 +3860,7 @@ static const struct tulip_srom_to_ifmedi
 
 	{ TULIP_ROM_MB_MEDIA_100TX_FDX,	IFM_100_TX,	IFM_FDX,
 	  "100baseTX-FDX",
-	  OPMODE_PS | OPMODE_PCS | OPMODE_SCR | OPMODE_FD | OPMODE_HBD,
+	  OPMODE_PS|OPMODE_PCS|OPMODE_SCR|OPMODE_FD|OPMODE_HBD,
 	  BMSR_100TXFDX,
 	  { 0,
 	    0,
@@ -3862,7 +3876,7 @@ static const struct tulip_srom_to_ifmedi
 
 	{ TULIP_ROM_MB_MEDIA_100T4,	IFM_100_T4,	0,
 	  "100baseT4",
-	  OPMODE_PS | OPMODE_PCS | OPMODE_SCR | OPMODE_HBD,
+	  OPMODE_PS|OPMODE_PCS|OPMODE_SCR|OPMODE_HBD,
 	  BMSR_100T4,
 	  { 0,
 	    0,
@@ -3878,7 +3892,7 @@ static const struct tulip_srom_to_ifmedi
 
 	{ TULIP_ROM_MB_MEDIA_100FX,	IFM_100_FX,	0,
 	  "100baseFX",
-	  OPMODE_PS | OPMODE_PCS | OPMODE_HBD,
+	  OPMODE_PS|OPMODE_PCS|OPMODE_HBD,
 	  0,
 	  { 0,
 	    0,
@@ -3894,7 +3908,7 @@ static const struct tulip_srom_to_ifmedi
 
 	{ TULIP_ROM_MB_MEDIA_100FX_FDX,	IFM_100_FX,	IFM_FDX,
 	  "100baseFX-FDX",
-	  OPMODE_PS | OPMODE_PCS | OPMODE_FD | OPMODE_HBD,
+	  OPMODE_PS|OPMODE_PCS|OPMODE_FD|OPMODE_HBD,
 	  0,
 	  { 0,
 	    0,
@@ -3944,10 +3958,10 @@ tlp_srom_to_ifmedia(uint8_t sm)
 	for (tsti = tulip_srom_to_ifmedia_table;
 	     tsti->tsti_name != NULL; tsti++) {
 		if (tsti->tsti_srom == sm)
-			return tsti;
+			return (tsti);
 	}
 
-	return NULL;
+	return (NULL);
 }
 
 static void
@@ -3998,7 +4012,7 @@ tlp_add_srom_media(struct tulip_softc *s
 
 	for (i = 0; i < cnt; i++) {
 		tsti = tlp_srom_to_ifmedia(list[i]);
-		tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK | M_ZERO);
+		tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
 		tlp_srom_media_info(sc, tsti, tm);
 		tm->tm_type = type;
 		tm->tm_get = get;
@@ -4088,7 +4102,7 @@ tlp_sia_update_link(struct tulip_softc *
 	ife = TULIP_CURRENT_MEDIA(sc);
 	tm = ife->ifm_aux;
 
-	sc->sc_flags &= ~(TULIPF_LINK_UP | TULIPF_LINK_VALID);
+	sc->sc_flags &= ~(TULIPF_LINK_UP|TULIPF_LINK_VALID);
 
 	siastat = TULIP_READ(sc, CSR_SIASTAT);
 
@@ -4212,7 +4226,7 @@ static int
 tlp_sia_set(struct tulip_softc *sc)
 {
 
-	return tlp_sia_media(sc, TULIP_CURRENT_MEDIA(sc));
+	return (tlp_sia_media(sc, TULIP_CURRENT_MEDIA(sc)));
 }
 
 static int
@@ -4230,7 +4244,7 @@ tlp_sia_media(struct tulip_softc *sc, st
 	/*
 	 * Idle the chip.
 	 */
-	tlp_idle(sc, OPMODE_ST | OPMODE_SR);
+	tlp_idle(sc, OPMODE_ST|OPMODE_SR);
 
 	/*
 	 * Program the SIA.  It's important to write in this order,
@@ -4260,7 +4274,7 @@ tlp_sia_media(struct tulip_softc *sc, st
 	sc->sc_opmode = (sc->sc_opmode & ~OPMODE_MEDIA_BITS) | tm->tm_opmode;
 	TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode);
 
-	return 0;
+	return (0);
 }
 
 /*
@@ -4277,7 +4291,7 @@ tlp_21140_gpio_update_link(struct tulip_
 	ife = TULIP_CURRENT_MEDIA(sc);
 	tm = ife->ifm_aux;
 
-	sc->sc_flags &= ~(TULIPF_LINK_UP | TULIPF_LINK_VALID);
+	sc->sc_flags &= ~(TULIPF_LINK_UP|TULIPF_LINK_VALID);
 
 	if (tm->tm_actmask != 0) {
 		sc->sc_flags |= TULIPF_LINK_VALID;
@@ -4317,13 +4331,13 @@ tlp_21140_gpio_set(struct tulip_softc *s
 	/*
 	 * Idle the chip.
 	 */
-	tlp_idle(sc, OPMODE_ST | OPMODE_SR);
+	tlp_idle(sc, OPMODE_ST|OPMODE_SR);
 
 	/*
 	 * Set the GPIO pins for this media, to flip any
 	 * relays, etc.
 	 */
-	TULIP_WRITE(sc, CSR_GPP, GPP_GPC | sc->sc_gp_dir);
+	TULIP_WRITE(sc, CSR_GPP, GPP_GPC|sc->sc_gp_dir);
 	delay(10);
 	TULIP_WRITE(sc, CSR_GPP, tm->tm_gpdata);
 
@@ -4334,7 +4348,7 @@ tlp_21140_gpio_set(struct tulip_softc *s
 	sc->sc_opmode = (sc->sc_opmode & ~OPMODE_MEDIA_BITS) | tm->tm_opmode;
 	TULIP_WRITE(sc, CSR_OPMODE, sc->sc_opmode);
 
-	return 0;
+	return (0);
 }
 
 /*
@@ -4364,7 +4378,6 @@ const struct tulip_mediasw tlp_21041_med
 static void
 tlp_21040_tmsw_init(struct tulip_softc *sc)
 {
-	struct mii_data * const mii = &sc->sc_mii;
 	static const uint8_t media[] = {
 		TULIP_ROM_MB_MEDIA_TP,
 		TULIP_ROM_MB_MEDIA_TP_FDX,
@@ -4372,21 +4385,21 @@ tlp_21040_tmsw_init(struct tulip_softc *
 	};
 	struct tulip_21x4x_media *tm;
 
-	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, tlp_mediachange, tlp_mediastatus);
+	ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+	    tlp_mediastatus);
 
 	tlp_add_srom_media(sc, 0, NULL, NULL, media, 3);
 
 	/*
 	 * No SROM type for External SIA.
 	 */
-	tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK | M_ZERO);
+	tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
 	tm->tm_name = "manual";
 	tm->tm_opmode = 0;
 	tm->tm_siaconn = SIACONN_21040_EXTSIA;
 	tm->tm_siatxrx = SIATXRX_21040_EXTSIA;
 	tm->tm_siagen  = SIAGEN_21040_EXTSIA;
-	ifmedia_add(&mii->mii_media,
+	ifmedia_add(&sc->sc_mii.mii_media,
 	    IFM_MAKEWORD(IFM_ETHER, IFM_MANUAL, 0, sc->sc_tlp_minst), 0, tm);
 
 	/*
@@ -4394,7 +4407,7 @@ tlp_21040_tmsw_init(struct tulip_softc *
 	 */
 
 	/* XXX This should be auto-sense. */
-	ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_10_5);
+	ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_T);
 
 	tlp_print_media(sc);
 }
@@ -4402,18 +4415,17 @@ tlp_21040_tmsw_init(struct tulip_softc *
 static void
 tlp_21040_tp_tmsw_init(struct tulip_softc *sc)
 {
-	struct mii_data * const mii = &sc->sc_mii;
 	static const uint8_t media[] = {
 		TULIP_ROM_MB_MEDIA_TP,
 		TULIP_ROM_MB_MEDIA_TP_FDX,
 	};
 
-	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, tlp_mediachange, tlp_mediastatus);
+	ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+	    tlp_mediastatus);
 
 	tlp_add_srom_media(sc, 0, NULL, NULL, media, 2);
 
-	ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_10_T);
+	ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_T);
 
 	tlp_print_media(sc);
 }
@@ -4421,17 +4433,16 @@ tlp_21040_tp_tmsw_init(struct tulip_soft
 static void
 tlp_21040_auibnc_tmsw_init(struct tulip_softc *sc)
 {
-	struct mii_data * const mii = &sc->sc_mii;
 	static const uint8_t media[] = {
 		TULIP_ROM_MB_MEDIA_AUI,
 	};
 
-	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, tlp_mediachange, tlp_mediastatus);
+	ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+	    tlp_mediastatus);
 
 	tlp_add_srom_media(sc, 0, NULL, NULL, media, 1);
 
-	ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_10_5);
+	ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_5);
 
 	tlp_print_media(sc);
 }
@@ -4439,7 +4450,6 @@ tlp_21040_auibnc_tmsw_init(struct tulip_
 static void
 tlp_21041_tmsw_init(struct tulip_softc *sc)
 {
-	struct mii_data * const mii = &sc->sc_mii;
 	static const uint8_t media[] = {
 		TULIP_ROM_MB_MEDIA_TP,
 		TULIP_ROM_MB_MEDIA_TP_FDX,
@@ -4452,8 +4462,8 @@ tlp_21041_tmsw_init(struct tulip_softc *
 	uint16_t romdef;
 	uint8_t mb;
 
-	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, tlp_mediachange, tlp_mediastatus);
+	ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+	    tlp_mediastatus);
 
 	if (tlp_isv_srom(sc->sc_srom) == 0) {
  not_isv_srom:
@@ -4469,7 +4479,7 @@ tlp_21041_tmsw_init(struct tulip_softc *
 		 */
 
 		/* XXX This should be auto-sense. */
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_10_T);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_T);
 
 		tlp_print_media(sc);
 		return;
@@ -4495,7 +4505,7 @@ tlp_21041_tmsw_init(struct tulip_softc *
 	for (; m_cnt != 0;
 	     m_cnt--, mb_offset += TULIP_ROM_MB_SIZE(mb)) {
 		mb = sc->sc_srom[mb_offset];
-		tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK | M_ZERO);
+		tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
 		switch (mb & TULIP_ROM_MB_MEDIA_CODE) {
 		case TULIP_ROM_MB_MEDIA_TP_FDX:
 		case TULIP_ROM_MB_MEDIA_TP:
@@ -4519,7 +4529,7 @@ tlp_21041_tmsw_init(struct tulip_softc *
 				    mb_offset + TULIP_ROM_MB_CSR15);
 			}
 
-			ifmedia_add(&mii->mii_media,
+			ifmedia_add(&sc->sc_mii.mii_media,
 			    IFM_MAKEWORD(IFM_ETHER, tsti->tsti_subtype,
 			    tsti->tsti_options, sc->sc_tlp_minst), 0, tm);
 			break;
@@ -4542,24 +4552,24 @@ tlp_21041_tmsw_init(struct tulip_softc *
 	case SELECT_CONN_TYPE_TP:
 	case SELECT_CONN_TYPE_TP_AUTONEG:
 	case SELECT_CONN_TYPE_TP_NOLINKPASS:
-		defmedia = IFM_ETHER | IFM_10_T;
+		defmedia = IFM_ETHER|IFM_10_T;
 		break;
 
 	case SELECT_CONN_TYPE_TP_FDX:
-		defmedia = IFM_ETHER | IFM_10_T | IFM_FDX;
+		defmedia = IFM_ETHER|IFM_10_T|IFM_FDX;
 		break;
 
 	case SELECT_CONN_TYPE_BNC:
-		defmedia = IFM_ETHER | IFM_10_2;
+		defmedia = IFM_ETHER|IFM_10_2;
 		break;
 
 	case SELECT_CONN_TYPE_AUI:
-		defmedia = IFM_ETHER | IFM_10_5;
+		defmedia = IFM_ETHER|IFM_10_5;
 		break;
 #if 0 /* XXX */
 	case SELECT_CONN_TYPE_ASENSE:
 	case SELECT_CONN_TYPE_ASENSE_AUTONEG:
-		defmedia = IFM_ETHER | IFM_AUTO;
+		defmedia = IFM_ETHER|IFM_AUTO;
 		break;
 #endif
 	default:
@@ -4570,10 +4580,10 @@ tlp_21041_tmsw_init(struct tulip_softc *
 		/*
 		 * XXX We should default to auto-sense.
 		 */
-		defmedia = IFM_ETHER | IFM_10_T;
+		defmedia = IFM_ETHER|IFM_10_T;
 	}
 
-	ifmedia_set(&mii->mii_media, defmedia);
+	ifmedia_set(&sc->sc_mii.mii_media, defmedia);
 
 	tlp_print_media(sc);
 }
@@ -4593,7 +4603,7 @@ const struct tulip_mediasw tlp_2114x_isv
 static void	tlp_2114x_nway_get(struct tulip_softc *, struct ifmediareq *);
 static int	tlp_2114x_nway_set(struct tulip_softc *);
 
-static void	tlp_2114x_nway_statchg(struct ifnet *);
+static void	tlp_2114x_nway_statchg(device_t);
 static int	tlp_2114x_nway_service(struct tulip_softc *, int);
 static void	tlp_2114x_nway_auto(struct tulip_softc *);
 static void	tlp_2114x_nway_status(struct tulip_softc *);
@@ -4602,7 +4612,6 @@ static void
 tlp_2114x_isv_tmsw_init(struct tulip_softc *sc)
 {
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
-	struct mii_data * const mii = &sc->sc_mii;
 	struct ifmedia_entry *ife;
 	struct mii_softc *phy;
 	struct tulip_21x4x_media *tm;
@@ -4614,11 +4623,10 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 
 	defmedia = miidef = 0;
 
-	mii->mii_ifp = ifp;
-	mii->mii_readreg = tlp_bitbang_mii_readreg;
-	mii->mii_writereg = tlp_bitbang_mii_writereg;
-	mii->mii_statchg = sc->sc_statchg;
-	sc->sc_ethercom.ec_mii = mii;
+	sc->sc_mii.mii_ifp = ifp;
+	sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg;
+	sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg;
+	sc->sc_mii.mii_statchg = sc->sc_statchg;
 
 	/*
 	 * Ignore `instance'; we may get a mixture of SIA and MII
@@ -4626,7 +4634,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 	 * PHY on the MII as appropriate.  Note that duplicate media
 	 * are disallowed, so ignoring `instance' is safe.
 	 */
-	ifmedia_init(&mii->mii_media, IFM_IMASK, tlp_mediachange,
+	ifmedia_init(&sc->sc_mii.mii_media, IFM_IMASK, tlp_mediachange,
 	    tlp_mediastatus);
 
 	devcnt = sc->sc_srom[TULIP_ROM_CHIP_COUNT];
@@ -4639,8 +4647,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 	}
 
 	if (i == devcnt) {
-		aprint_error_dev(sc->sc_dev,
-		    "unable to locate info leaf in SROM\n");
+		aprint_error_dev(sc->sc_dev, "unable to locate info leaf in SROM\n");
 		return;
 	}
 
@@ -4703,7 +4710,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 			tlp_get_minst(sc);
 			sc->sc_media_seen |= 1 << TULIP_ROM_MB_21140_GPR;
 
-			tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK | M_ZERO);
+			tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
 
 			tm->tm_type = TULIP_ROM_MB_21140_GPR;
 			tm->tm_get = tlp_21140_gpio_get;
@@ -4740,7 +4747,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 				    0 : tm->tm_actmask;
 			}
 
-			ifmedia_add(&mii->mii_media,
+			ifmedia_add(&sc->sc_mii.mii_media,
 			    IFM_MAKEWORD(IFM_ETHER, tsti->tsti_subtype,
 			    tsti->tsti_options, sc->sc_tlp_minst), 0, tm);
 			break;
@@ -4748,7 +4755,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 		case TULIP_ROM_MB_21140_MII:
 			sc->sc_media_seen |= 1 << TULIP_ROM_MB_21140_MII;
 
-			tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK | M_ZERO);
+			tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
 
 			tm->tm_type = TULIP_ROM_MB_21140_MII;
 			tm->tm_get = tlp_mii_getmedia;
@@ -4790,7 +4797,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 			 */
 
 			/* Set the direction of the pins... */
-			TULIP_WRITE(sc, CSR_GPP, GPP_GPC | sc->sc_gp_dir);
+			TULIP_WRITE(sc, CSR_GPP, GPP_GPC|sc->sc_gp_dir);
 
 			for (i = 0; i < tm->tm_reset_length; i++) {
 				delay(10);
@@ -4816,7 +4823,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 			 * particularly care; the MII code just likes to
 			 * search the whole thing anyhow.
 			 */
-			mii_attach(sc->sc_dev, mii, 0xffffffff,
+			mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff,
 			    MII_PHY_ANY, tm->tm_phyno, 0);
 
 			/*
@@ -4825,13 +4832,12 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 			 * kernel, we lose.  The PHY's default media always
 			 * takes priority.
 			 */
-			LIST_FOREACH(phy, &mii->mii_phys, mii_list) {
+			LIST_FOREACH(phy, &sc->sc_mii.mii_phys, mii_list) {
 				if (phy->mii_offset == tm->tm_phyno)
 					break;
 			}
 			if (phy == NULL) {
-				aprint_error_dev(sc->sc_dev,
-				    "unable to configure MII\n");
+				aprint_error_dev(sc->sc_dev, "unable to configure MII\n");
 				break;
 			}
 
@@ -4850,7 +4856,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 			 * We do this by looking for media with our
 			 * PHY's `instance'.
 			 */
-			TAILQ_FOREACH(ife, &mii->mii_media.ifm_list,
+			TAILQ_FOREACH(ife, &sc->sc_mii.mii_media.ifm_list,
 			      ifm_list) {
 				if (IFM_INST(ife->ifm_media) != phy->mii_inst)
 					continue;
@@ -4862,7 +4868,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 			tlp_get_minst(sc);
 			sc->sc_media_seen |= 1 << TULIP_ROM_MB_21142_SIA;
 
-			tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK | M_ZERO);
+			tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
 
 			tm->tm_type = TULIP_ROM_MB_21142_SIA;
 			tm->tm_get = tlp_sia_get;
@@ -4896,7 +4902,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 			tm->tm_gpctl  = TULIP_ROM_GETW(cp, 0) << 16;
 			tm->tm_gpdata = TULIP_ROM_GETW(cp, 2) << 16;
 
-			ifmedia_add(&mii->mii_media,
+			ifmedia_add(&sc->sc_mii.mii_media,
 			    IFM_MAKEWORD(IFM_ETHER, tsti->tsti_subtype,
 			    tsti->tsti_options, sc->sc_tlp_minst), 0, tm);
 			break;
@@ -4904,7 +4910,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 		case TULIP_ROM_MB_21142_MII:
 			sc->sc_media_seen |= 1 << TULIP_ROM_MB_21142_MII;
 
-			tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK | M_ZERO);
+			tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
 
 			tm->tm_type = TULIP_ROM_MB_21142_MII;
 			tm->tm_get = tlp_mii_getmedia;
@@ -4972,7 +4978,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 			 * particularly care; the MII code just likes to
 			 * search the whole thing anyhow.
 			 */
-			mii_attach(sc->sc_dev, mii, 0xffffffff,
+			mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff,
 			    MII_PHY_ANY, tm->tm_phyno, 0);
 
 			/*
@@ -4981,13 +4987,12 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 			 * kernel, we lose.  The PHY's default media always
 			 * takes priority.
 			 */
-			LIST_FOREACH(phy, &mii->mii_phys, mii_list) {
+			LIST_FOREACH(phy, &sc->sc_mii.mii_phys, mii_list) {
 				if (phy->mii_offset == tm->tm_phyno)
 					break;
 			}
 			if (phy == NULL) {
-				aprint_error_dev(sc->sc_dev,
-				    "unable to configure MII\n");
+				aprint_error_dev(sc->sc_dev, "unable to configure MII\n");
 				break;
 			}
 
@@ -5006,7 +5011,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 			 * We do this by looking for media with our
 			 * PHY's `instance'.
 			 */
-			TAILQ_FOREACH(ife, &mii->mii_media.ifm_list,
+			TAILQ_FOREACH(ife, &sc->sc_mii.mii_media.ifm_list,
 			      ifm_list) {
 				if (IFM_INST(ife->ifm_media) != phy->mii_inst)
 					continue;
@@ -5018,7 +5023,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 			tlp_get_minst(sc);
 			sc->sc_media_seen |= 1 << TULIP_ROM_MB_21143_SYM;
 
-			tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK | M_ZERO);
+			tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
 
 			tm->tm_type = TULIP_ROM_MB_21143_SYM;
 			tm->tm_get = tlp_sia_get;
@@ -5056,7 +5061,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 				    0 : tm->tm_actmask;
 			}
 
-			ifmedia_add(&mii->mii_media,
+			ifmedia_add(&sc->sc_mii.mii_media,
 			    IFM_MAKEWORD(IFM_ETHER, tsti->tsti_subtype,
 			    tsti->tsti_options, sc->sc_tlp_minst), 0, tm);
 			break;
@@ -5074,10 +5079,10 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 	/*
 	 * Deal with the case where no media is configured.
 	 */
-	if (TAILQ_FIRST(&mii->mii_media.ifm_list) == NULL) {
+	if (TAILQ_FIRST(&sc->sc_mii.mii_media.ifm_list) == NULL) {
 		aprint_error_dev(sc->sc_dev, "no media found!\n");
-		ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL);
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_NONE);
+		ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
 		return;
 	}
 
@@ -5092,13 +5097,13 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 		case TULIP_CHIP_21140A:
 			/* XXX should come from SROM */
 			defmedia = IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, 0);
-			if (ifmedia_match(&mii->mii_media, defmedia,
-				mii->mii_media.ifm_mask) == NULL) {
+			if (ifmedia_match(&sc->sc_mii.mii_media, defmedia,
+				sc->sc_mii.mii_media.ifm_mask) == NULL) {
 				/*
 				 * There is not a 10baseT media.
 				 * Fall back to the first found one.
 				 */
-				ife = TAILQ_FIRST(&mii->mii_media.ifm_list);
+				ife = TAILQ_FIRST(&sc->sc_mii.mii_media.ifm_list);
 				defmedia = ife->ifm_media;
 			}
 			break;
@@ -5110,13 +5115,13 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 		case TULIP_CHIP_MX98715A:
 		case TULIP_CHIP_MX98715AEC_X:
 		case TULIP_CHIP_MX98725:
-			tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK | M_ZERO);
+			tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
 			tm->tm_name = "auto";
 			tm->tm_get = tlp_2114x_nway_get;
 			tm->tm_set = tlp_2114x_nway_set;
 
 			defmedia = IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, 0);
-			ifmedia_add(&mii->mii_media, defmedia, 0, tm);
+			ifmedia_add(&sc->sc_mii.mii_media, defmedia, 0, tm);
 
 			sc->sc_statchg = tlp_2114x_nway_statchg;
 			sc->sc_tick = tlp_2114x_nway_tick;
@@ -5128,7 +5133,7 @@ tlp_2114x_isv_tmsw_init(struct tulip_sof
 		}
 	}
 
-	ifmedia_set(&mii->mii_media, defmedia);
+	ifmedia_set(&sc->sc_mii.mii_media, defmedia);
 
 	/*
 	 * Display any non-MII media we've located.
@@ -5153,13 +5158,13 @@ static int
 tlp_2114x_nway_set(struct tulip_softc *sc)
 {
 
-	return tlp_2114x_nway_service(sc, MII_MEDIACHG);
+	return (tlp_2114x_nway_service(sc, MII_MEDIACHG));
 }
 
 static void
-tlp_2114x_nway_statchg(struct ifnet *ifp)
+tlp_2114x_nway_statchg(device_t self)
 {
-	struct tulip_softc *sc = ifp->if_softc;
+	struct tulip_softc *sc = device_private(self);
 	struct mii_data *mii = &sc->sc_mii;
 	struct ifmedia_entry *ife;
 
@@ -5218,7 +5223,7 @@ tlp_2114x_nway_service(struct tulip_soft
 	struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
 
 	if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
-		return 0;
+		return (0);
 
 	switch (cmd) {
 	case MII_POLLSTAT:
@@ -5232,7 +5237,7 @@ tlp_2114x_nway_service(struct tulip_soft
 		default:
 			/* Manual setting doesn't go through here. */
 			printf("tlp_2114x_nway_service: oops!\n");
-			return EINVAL;
+			return (EINVAL);
 		}
 		break;
 
@@ -5276,10 +5281,10 @@ tlp_2114x_nway_service(struct tulip_soft
 	 */
 	if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO &&
 	    ife->ifm_data != mii->mii_media_active) {
-		(*sc->sc_statchg)(mii->mii_ifp);
+		(*sc->sc_statchg)(sc->sc_dev);
 		ife->ifm_data = mii->mii_media_active;
 	}
-	return 0;
+	return (0);
 }
 
 static void
@@ -5287,10 +5292,10 @@ tlp_2114x_nway_auto(struct tulip_softc *
 {
 	uint32_t siastat, siatxrx;
 
-	tlp_idle(sc, OPMODE_ST | OPMODE_SR);
+	tlp_idle(sc, OPMODE_ST|OPMODE_SR);
 
-	sc->sc_opmode &= ~(OPMODE_PS | OPMODE_PCS | OPMODE_SCR | OPMODE_FD);
-	sc->sc_opmode |= OPMODE_TTM | OPMODE_HBD;
+	sc->sc_opmode &= ~(OPMODE_PS|OPMODE_PCS|OPMODE_SCR|OPMODE_FD);
+	sc->sc_opmode |= OPMODE_TTM|OPMODE_HBD;
 	siatxrx = 0xffbf;		/* XXX magic number */
 
 	/* Compute the link code word to advertise. */
@@ -5313,8 +5318,8 @@ tlp_2114x_nway_auto(struct tulip_softc *
 	TULIP_WRITE(sc, CSR_SIACONN, SIACONN_SRL);
 
 	siastat = TULIP_READ(sc, CSR_SIASTAT);
-	siastat &= ~(SIASTAT_ANS | SIASTAT_LPC | SIASTAT_TRA | SIASTAT_ARA |
-		     SIASTAT_LS100 | SIASTAT_LS10 | SIASTAT_MRA);
+	siastat &= ~(SIASTAT_ANS|SIASTAT_LPC|SIASTAT_TRA|SIASTAT_ARA|
+		     SIASTAT_LS100|SIASTAT_LS10|SIASTAT_MRA);
 	siastat |= SIASTAT_ANS_TXDIS;
 	TULIP_WRITE(sc, CSR_SIASTAT, siastat);
 }
@@ -5351,13 +5356,13 @@ tlp_2114x_nway_status(struct tulip_softc
 				mii->mii_media_active |= IFM_100_T4;
 			else if (anlpar & ANLPAR_TX_FD &&
 				 sc->sc_sia_cap & BMSR_100TXFDX)
-				mii->mii_media_active |= IFM_100_TX | IFM_FDX;
+				mii->mii_media_active |= IFM_100_TX|IFM_FDX;
 			else if (anlpar & ANLPAR_TX &&
 				 sc->sc_sia_cap & BMSR_100TXHDX)
 				mii->mii_media_active |= IFM_100_TX;
 			else if (anlpar & ANLPAR_10_FD &&
 				 sc->sc_sia_cap & BMSR_10TFDX)
-				mii->mii_media_active |= IFM_10_T | IFM_FDX;
+				mii->mii_media_active |= IFM_10_T|IFM_FDX;
 			else if (anlpar & ANLPAR_10 &&
 				 sc->sc_sia_cap & BMSR_10THDX)
 				mii->mii_media_active |= IFM_10_T;
@@ -5413,9 +5418,9 @@ tlp_2114x_isv_tmsw_set(struct tulip_soft
 	 * time through.
 	 */
 	if (TULIP_MEDIA_NEEDSRESET(sc, tm->tm_opmode))
-		return tlp_init(&sc->sc_ethercom.ec_if);
+		return (tlp_init(&sc->sc_ethercom.ec_if));
 
-	return (*tm->tm_set)(sc);
+	return ((*tm->tm_set)(sc));
 }
 
 /*
@@ -5431,7 +5436,6 @@ static void
 tlp_sio_mii_tmsw_init(struct tulip_softc *sc)
 {
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
-	struct mii_data * const mii = &sc->sc_mii;
 
 	/*
 	 * We don't attach any media info structures to the ifmedia
@@ -5441,21 +5445,21 @@ tlp_sio_mii_tmsw_init(struct tulip_softc
 	if (sc->sc_preinit == tlp_2114x_preinit)
 		sc->sc_preinit = tlp_2114x_mii_preinit;
 
-	mii->mii_ifp = ifp;
-	mii->mii_readreg = tlp_bitbang_mii_readreg;
-	mii->mii_writereg = tlp_bitbang_mii_writereg;
-	mii->mii_statchg = sc->sc_statchg;
-	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, tlp_mediachange, tlp_mediastatus);
-	mii_attach(sc->sc_dev, mii, 0xffffffff, MII_PHY_ANY,
+	sc->sc_mii.mii_ifp = ifp;
+	sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg;
+	sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg;
+	sc->sc_mii.mii_statchg = sc->sc_statchg;
+	ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+	    tlp_mediastatus);
+	mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
 	    MII_OFFSET_ANY, 0);
-	if (LIST_FIRST(&mii->mii_phys) == NULL) {
-		ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL);
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_NONE);
+	if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
+		ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
 	} else {
 		sc->sc_flags |= TULIPF_HAS_MII;
 		sc->sc_tick = tlp_mii_tick;
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
 	}
 }
 
@@ -5470,7 +5474,7 @@ const struct tulip_mediasw tlp_pnic_medi
 	tlp_pnic_tmsw_init, tlp_pnic_tmsw_get, tlp_pnic_tmsw_set
 };
 
-static void	tlp_pnic_nway_statchg(struct ifnet *);
+static void	tlp_pnic_nway_statchg(device_t);
 static void	tlp_pnic_nway_tick(void *);
 static int	tlp_pnic_nway_service(struct tulip_softc *, int);
 static void	tlp_pnic_nway_reset(struct tulip_softc *);
@@ -5482,59 +5486,58 @@ static void	tlp_pnic_nway_acomp(struct t
 static void
 tlp_pnic_tmsw_init(struct tulip_softc *sc)
 {
-	struct mii_data * const mii = &sc->sc_mii;
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
 	const char *sep = "";
 
-#define	ADD(m, c)	ifmedia_add(&mii->mii_media, (m), (c), NULL)
+#define	ADD(m, c)	ifmedia_add(&sc->sc_mii.mii_media, (m), (c), NULL)
 #define	PRINT(str)	aprint_normal("%s%s", sep, str); sep = ", "
 
-	mii->mii_ifp = ifp;
-	mii->mii_readreg = tlp_pnic_mii_readreg;
-	mii->mii_writereg = tlp_pnic_mii_writereg;
-	mii->mii_statchg = sc->sc_statchg;
-	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, tlp_mediachange, tlp_mediastatus);
-	mii_attach(sc->sc_dev, mii, 0xffffffff, MII_PHY_ANY,
+	sc->sc_mii.mii_ifp = ifp;
+	sc->sc_mii.mii_readreg = tlp_pnic_mii_readreg;
+	sc->sc_mii.mii_writereg = tlp_pnic_mii_writereg;
+	sc->sc_mii.mii_statchg = sc->sc_statchg;
+	ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+	    tlp_mediastatus);
+	mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
 	    MII_OFFSET_ANY, 0);
-	if (LIST_FIRST(&mii->mii_phys) == NULL) {
+	if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
 		/* XXX What about AUI/BNC support? */
 		aprint_normal_dev(sc->sc_dev, "");
 
 		tlp_pnic_nway_reset(sc);
 
 		ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, 0),
-		    PNIC_NWAY_TW | PNIC_NWAY_CAP10T);
+		    PNIC_NWAY_TW|PNIC_NWAY_CAP10T);
 		PRINT("10baseT");
 
 		ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_FDX, 0),
-		    PNIC_NWAY_TW | PNIC_NWAY_FD | PNIC_NWAY_CAP10TFDX);
+		    PNIC_NWAY_TW|PNIC_NWAY_FD|PNIC_NWAY_CAP10TFDX);
 		PRINT("10baseT-FDX");
 
 		ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, 0, 0),
-		    PNIC_NWAY_TW | PNIC_NWAY_100 | PNIC_NWAY_CAP100TX);
+		    PNIC_NWAY_TW|PNIC_NWAY_100|PNIC_NWAY_CAP100TX);
 		PRINT("100baseTX");
 
 		ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_FDX, 0),
-		    PNIC_NWAY_TW | PNIC_NWAY_100 | PNIC_NWAY_FD |
+		    PNIC_NWAY_TW|PNIC_NWAY_100|PNIC_NWAY_FD|
 		    PNIC_NWAY_CAP100TXFDX);
 		PRINT("100baseTX-FDX");
 
 		ADD(IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, 0),
-		    PNIC_NWAY_TW | PNIC_NWAY_RN | PNIC_NWAY_NW |
-		    PNIC_NWAY_CAP10T | PNIC_NWAY_CAP10TFDX |
-		    PNIC_NWAY_CAP100TXFDX | PNIC_NWAY_CAP100TX);
+		    PNIC_NWAY_TW|PNIC_NWAY_RN|PNIC_NWAY_NW|
+		    PNIC_NWAY_CAP10T|PNIC_NWAY_CAP10TFDX|
+		    PNIC_NWAY_CAP100TXFDX|PNIC_NWAY_CAP100TX);
 		PRINT("auto");
 
 		aprint_normal("\n");
 
 		sc->sc_statchg = tlp_pnic_nway_statchg;
 		sc->sc_tick = tlp_pnic_nway_tick;
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
 	} else {
 		sc->sc_flags |= TULIPF_HAS_MII;
 		sc->sc_tick = tlp_mii_tick;
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
 	}
 
 #undef ADD
@@ -5552,8 +5555,8 @@ tlp_pnic_tmsw_get(struct tulip_softc *sc
 		mii->mii_media_status = 0;
 		mii->mii_media_active = IFM_NONE;
 		tlp_pnic_nway_service(sc, MII_POLLSTAT);
-		ifmr->ifm_status = mii->mii_media_status;
-		ifmr->ifm_active = mii->mii_media_active;
+		ifmr->ifm_status = sc->sc_mii.mii_media_status;
+		ifmr->ifm_active = sc->sc_mii.mii_media_active;
 	}
 }
 
@@ -5569,28 +5572,28 @@ tlp_pnic_tmsw_set(struct tulip_softc *sc
 		 */
 		TULIP_WRITE(sc, CSR_PNIC_ENDEC, PNIC_ENDEC_JDIS);
 
-		return tlp_mii_setmedia(sc);
+		return (tlp_mii_setmedia(sc));
 	}
 
 	if (ifp->if_flags & IFF_UP) {
 		mii->mii_media_status = 0;
 		mii->mii_media_active = IFM_NONE;
-		return tlp_pnic_nway_service(sc, MII_MEDIACHG);
+		return (tlp_pnic_nway_service(sc, MII_MEDIACHG));
 	}
 
-	return 0;
+	return (0);
 }
 
 static void
-tlp_pnic_nway_statchg(struct ifnet *ifp)
+tlp_pnic_nway_statchg(device_t self)
 {
-	struct tulip_softc *sc = ifp->if_softc;
+	struct tulip_softc *sc = device_private(self);
 
 	/* Idle the transmit and receive processes. */
-	tlp_idle(sc, OPMODE_ST | OPMODE_SR);
+	tlp_idle(sc, OPMODE_ST|OPMODE_SR);
 
-	sc->sc_opmode &= ~(OPMODE_TTM | OPMODE_FD | OPMODE_PS | OPMODE_PCS |
-	    OPMODE_SCR | OPMODE_HBD);
+	sc->sc_opmode &= ~(OPMODE_TTM|OPMODE_FD|OPMODE_PS|OPMODE_PCS|
+	    OPMODE_SCR|OPMODE_HBD);
 
 	if (IFM_SUBTYPE(sc->sc_mii.mii_media_active) == IFM_10_T) {
 		sc->sc_opmode |= OPMODE_TTM;
@@ -5598,14 +5601,14 @@ tlp_pnic_nway_statchg(struct ifnet *ifp)
 		    GPP_PNIC_OUT(GPP_PNIC_PIN_SPEED_RLY, 0) |
 		    GPP_PNIC_OUT(GPP_PNIC_PIN_100M_LPKB, 1));
 	} else {
-		sc->sc_opmode |= OPMODE_PS |OPMODE_PCS |OPMODE_SCR |OPMODE_HBD;
+		sc->sc_opmode |= OPMODE_PS|OPMODE_PCS|OPMODE_SCR|OPMODE_HBD;
 		TULIP_WRITE(sc, CSR_GPP,
 		    GPP_PNIC_OUT(GPP_PNIC_PIN_SPEED_RLY, 1) |
 		    GPP_PNIC_OUT(GPP_PNIC_PIN_100M_LPKB, 1));
 	}
 
 	if (sc->sc_mii.mii_media_active & IFM_FDX)
-		sc->sc_opmode |= OPMODE_FD | OPMODE_HBD;
+		sc->sc_opmode |= OPMODE_FD|OPMODE_HBD;
 
 	/*
 	 * Write new OPMODE bits.  This also restarts the transmit
@@ -5642,7 +5645,7 @@ tlp_pnic_nway_service(struct tulip_softc
 	struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
 
 	if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
-		return 0;
+		return (0);
 
 	switch (cmd) {
 	case MII_POLLSTAT:
@@ -5658,7 +5661,7 @@ tlp_pnic_nway_service(struct tulip_softc
 			/*
 			 * XXX Not supported as a manual setting right now.
 			 */
-			return EINVAL;
+			return (EINVAL);
 		default:
 			/*
 			 * NWAY register data is stored in the ifmedia entry.
@@ -5672,25 +5675,25 @@ tlp_pnic_nway_service(struct tulip_softc
 		 * Only used for autonegotiation.
 		 */
 		if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
-			return 0;
+			return (0);
 
 		/*
 		 * Check to see if we have link.  If we do, we don't
 		 * need to restart the autonegotiation process.
 		 */
 		if (sc->sc_flags & TULIPF_LINK_UP)
-			return 0;
+			return (0);
 
 		/*
 		 * Only retry autonegotiation every 5 seconds.
 		 */
 		if (++sc->sc_nway_ticks != 5)
-			return 0;
+			return (0);
 
 		sc->sc_nway_ticks = 0;
 		tlp_pnic_nway_reset(sc);
 		if (tlp_pnic_nway_auto(sc, 0) == EJUSTRETURN)
-			return 0;
+			return (0);
 		break;
 	}
 
@@ -5701,10 +5704,10 @@ tlp_pnic_nway_service(struct tulip_softc
 	if ((sc->sc_nway_active == NULL ||
 	     sc->sc_nway_active->ifm_media != mii->mii_media_active) ||
 	    cmd == MII_MEDIACHG) {
-		(*sc->sc_statchg)(mii->mii_ifp);
+		(*sc->sc_statchg)(sc->sc_dev);
 		tlp_nway_activate(sc, mii->mii_media_active);
 	}
-	return 0;
+	return (0);
 }
 
 static void
@@ -5733,14 +5736,13 @@ tlp_pnic_nway_auto(struct tulip_softc *s
 			reg = TULIP_READ(sc, CSR_PNIC_NWAY);
 			if (reg & PNIC_NWAY_LPAR_MASK) {
 				tlp_pnic_nway_acomp(sc);
-				return 0;
+				return (0);
 			}
 			delay(1000);
 		}
 #if 0
 		if ((reg & PNIC_NWAY_LPAR_MASK) == 0)
-			aprint_error_dev(sc->sc_dev,
-			    "autonegotiation failed to complete\n");
+			aprint_error_dev(sc->sc_dev, "autonegotiation failed to complete\n");
 #endif
 
 		/*
@@ -5748,7 +5750,7 @@ tlp_pnic_nway_auto(struct tulip_softc *s
 		 * If that's set, a timeout is pending, and it will
 		 * clear the flag.
 		 */
-		return EIO;
+		return (EIO);
 	}
 
 	/*
@@ -5761,30 +5763,28 @@ tlp_pnic_nway_auto(struct tulip_softc *s
 		callout_reset(&sc->sc_nway_callout, hz >> 1,
 		    tlp_pnic_nway_auto_timeout, sc);
 	}
-	return EJUSTRETURN;
+	return (EJUSTRETURN);
 }
 
 static void
 tlp_pnic_nway_auto_timeout(void *arg)
 {
 	struct tulip_softc *sc = arg;
-	/* uint32_t reg; */
+	uint32_t reg;
 	int s;
 
 	s = splnet();
 	sc->sc_flags &= ~TULIPF_DOINGAUTO;
-	/* reg = */
-	TULIP_READ(sc, CSR_PNIC_NWAY);
+	reg = TULIP_READ(sc, CSR_PNIC_NWAY);
 #if 0
 	if ((reg & PNIC_NWAY_LPAR_MASK) == 0)
-		aprint_error_dev(sc->sc_dev,
-		    "autonegotiation failed to complete\n");
+		aprint_error_dev(sc->sc_dev, "autonegotiation failed to complete\n");
 #endif
 
 	tlp_pnic_nway_acomp(sc);
 
 	/* Update the media status. */
-	(void)tlp_pnic_nway_service(sc, MII_POLLSTAT);
+	(void) tlp_pnic_nway_service(sc, MII_POLLSTAT);
 	splx(s);
 }
 
@@ -5815,11 +5815,11 @@ tlp_pnic_nway_status(struct tulip_softc 
 		else
 #endif
 		if (reg & PNIC_NWAY_LPAR100TXFDX)
-			mii->mii_media_active |= IFM_100_TX | IFM_FDX;
+			mii->mii_media_active |= IFM_100_TX|IFM_FDX;
 		else if (reg & PNIC_NWAY_LPAR100TX)
 			mii->mii_media_active |= IFM_100_TX;
 		else if (reg & PNIC_NWAY_LPAR10TFDX)
-			mii->mii_media_active |= IFM_10_T | IFM_FDX;
+			mii->mii_media_active |= IFM_10_T|IFM_FDX;
 		else if (reg & PNIC_NWAY_LPAR10T)
 			mii->mii_media_active |= IFM_10_T;
 		else
@@ -5840,11 +5840,11 @@ tlp_pnic_nway_acomp(struct tulip_softc *
 	uint32_t reg;
 
 	reg = TULIP_READ(sc, CSR_PNIC_NWAY);
-	reg &= ~(PNIC_NWAY_FD | PNIC_NWAY_100 | PNIC_NWAY_RN);
+	reg &= ~(PNIC_NWAY_FD|PNIC_NWAY_100|PNIC_NWAY_RN);
 
-	if (reg & (PNIC_NWAY_LPAR100TXFDX | PNIC_NWAY_LPAR100TX))
+	if (reg & (PNIC_NWAY_LPAR100TXFDX|PNIC_NWAY_LPAR100TX))
 		reg |= PNIC_NWAY_100;
-	if (reg & (PNIC_NWAY_LPAR10TFDX | PNIC_NWAY_LPAR100TXFDX))
+	if (reg & (PNIC_NWAY_LPAR10TFDX|PNIC_NWAY_LPAR100TXFDX))
 		reg |= PNIC_NWAY_FD;
 
 	TULIP_WRITE(sc, CSR_PNIC_NWAY, reg);
@@ -5877,7 +5877,6 @@ const struct tulip_mediasw tlp_pmac_mii_
 static void
 tlp_pmac_tmsw_init(struct tulip_softc *sc)
 {
-	struct mii_data * const mii = &sc->sc_mii;
 	static const uint8_t media[] = {
 		TULIP_ROM_MB_MEDIA_TP,
 		TULIP_ROM_MB_MEDIA_TP_FDX,
@@ -5887,22 +5886,23 @@ tlp_pmac_tmsw_init(struct tulip_softc *s
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
 	struct tulip_21x4x_media *tm;
 
-	mii->mii_ifp = ifp;
-	mii->mii_readreg = tlp_bitbang_mii_readreg;
-	mii->mii_writereg = tlp_bitbang_mii_writereg;
-	mii->mii_statchg = sc->sc_statchg;
-	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, tlp_mediachange, tlp_mediastatus);
+	sc->sc_mii.mii_ifp = ifp;
+	sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg;
+	sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg;
+	sc->sc_mii.mii_statchg = sc->sc_statchg;
+	ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+	    tlp_mediastatus);
 	if (sc->sc_chip == TULIP_CHIP_MX98713 ||
 	    sc->sc_chip == TULIP_CHIP_MX98713A) {
-		mii_attach(sc->sc_dev, mii, 0xffffffff,
+		mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff,
 		    MII_PHY_ANY, MII_OFFSET_ANY, 0);
-		if (LIST_FIRST(&mii->mii_phys) != NULL) {
+		if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL) {
 			sc->sc_flags |= TULIPF_HAS_MII;
 			sc->sc_tick = tlp_mii_tick;
 			sc->sc_preinit = tlp_2114x_mii_preinit;
 			sc->sc_mediasw = &tlp_pmac_mii_mediasw;
-			ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
+			ifmedia_set(&sc->sc_mii.mii_media,
+			    IFM_ETHER|IFM_AUTO);
 			return;
 		}
 	}
@@ -5916,7 +5916,7 @@ tlp_pmac_tmsw_init(struct tulip_softc *s
 		 * XXX Should implement auto-sense for this someday,
 		 * XXX when we do the same for the 21140.
 		 */
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_10_T);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_10_T);
 		break;
 
 	default:
@@ -5925,14 +5925,14 @@ tlp_pmac_tmsw_init(struct tulip_softc *s
 		tlp_add_srom_media(sc, TULIP_ROM_MB_21143_SYM,
 		    tlp_sia_get, tlp_sia_set, media + 2, 2);
 
-		tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK | M_ZERO);
+		tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
 		tm->tm_name = "auto";
 		tm->tm_get = tlp_2114x_nway_get;
 		tm->tm_set = tlp_2114x_nway_set;
-		ifmedia_add(&mii->mii_media,
+		ifmedia_add(&sc->sc_mii.mii_media,
 		    IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, 0), 0, tm);
 
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
 		sc->sc_statchg = tlp_2114x_nway_statchg;
 		sc->sc_tick = tlp_2114x_nway_tick;
 		break;
@@ -5960,23 +5960,22 @@ static void
 tlp_al981_tmsw_init(struct tulip_softc *sc)
 {
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
-	struct mii_data * const mii = &sc->sc_mii;
 
-	mii->mii_ifp = ifp;
-	mii->mii_readreg = tlp_al981_mii_readreg;
-	mii->mii_writereg = tlp_al981_mii_writereg;
-	mii->mii_statchg = sc->sc_statchg;
-	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, tlp_mediachange, tlp_mediastatus);
-	mii_attach(sc->sc_dev, mii, 0xffffffff, MII_PHY_ANY,
+	sc->sc_mii.mii_ifp = ifp;
+	sc->sc_mii.mii_readreg = tlp_al981_mii_readreg;
+	sc->sc_mii.mii_writereg = tlp_al981_mii_writereg;
+	sc->sc_mii.mii_statchg = sc->sc_statchg;
+	ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+	    tlp_mediastatus);
+	mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
 	    MII_OFFSET_ANY, 0);
-	if (LIST_FIRST(&mii->mii_phys) == NULL) {
-		ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL);
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_NONE);
+	if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
+		ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
 	} else {
 		sc->sc_flags |= TULIPF_HAS_MII;
 		sc->sc_tick = tlp_mii_tick;
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
 	}
 }
 
@@ -5996,22 +5995,22 @@ static void
 tlp_an985_tmsw_init(struct tulip_softc *sc)
 {
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
-	struct mii_data * const mii = &sc->sc_mii;
 
-	mii->mii_ifp = ifp;
-	mii->mii_readreg = tlp_bitbang_mii_readreg;
-	mii->mii_writereg = tlp_bitbang_mii_writereg;
-	mii->mii_statchg = sc->sc_statchg;
-	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, tlp_mediachange, tlp_mediastatus);
-	mii_attach(sc->sc_dev, mii, 0xffffffff, 1, MII_OFFSET_ANY, 0);
-	if (LIST_FIRST(&mii->mii_phys) == NULL) {
-		ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL);
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_NONE);
+	sc->sc_mii.mii_ifp = ifp;
+	sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg;
+	sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg;
+	sc->sc_mii.mii_statchg = sc->sc_statchg;
+	ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+	    tlp_mediastatus);
+	mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, 1,
+	    MII_OFFSET_ANY, 0);
+	if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
+		ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
 	} else {
 		sc->sc_flags |= TULIPF_HAS_MII;
 		sc->sc_tick = tlp_mii_tick;
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
 	}
 }
 
@@ -6032,15 +6031,14 @@ static void
 tlp_dm9102_tmsw_init(struct tulip_softc *sc)
 {
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
-	struct mii_data * const mii = &sc->sc_mii;
 	uint32_t opmode;
 
-	mii->mii_ifp = ifp;
-	mii->mii_readreg = tlp_bitbang_mii_readreg;
-	mii->mii_writereg = tlp_bitbang_mii_writereg;
-	mii->mii_statchg = sc->sc_statchg;
-	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, tlp_mediachange, tlp_mediastatus);
+	sc->sc_mii.mii_ifp = ifp;
+	sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg;
+	sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg;
+	sc->sc_mii.mii_statchg = sc->sc_statchg;
+	ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+	    tlp_mediastatus);
 
 	/* PHY block already reset via tlp_reset(). */
 
@@ -6049,11 +6047,11 @@ tlp_dm9102_tmsw_init(struct tulip_softc 
 	 */
 	switch (sc->sc_chip) {
 	case TULIP_CHIP_DM9102:
-		opmode = OPMODE_MBO | OPMODE_HBD | OPMODE_PS;
+		opmode = OPMODE_MBO|OPMODE_HBD|OPMODE_PS;
 		break;
 
 	case TULIP_CHIP_DM9102A:
-		opmode = OPMODE_MBO | OPMODE_HBD;
+		opmode = OPMODE_MBO|OPMODE_HBD;
 		break;
 
 	default:
@@ -6064,7 +6062,7 @@ tlp_dm9102_tmsw_init(struct tulip_softc 
 	TULIP_WRITE(sc, CSR_OPMODE, opmode);
 
 	/* Now, probe the internal MII for the internal PHY. */
-	mii_attach(sc->sc_dev, mii, 0xffffffff, MII_PHY_ANY,
+	mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
 	    MII_OFFSET_ANY, 0);
 
 	/*
@@ -6073,12 +6071,12 @@ tlp_dm9102_tmsw_init(struct tulip_softc 
 	 */
 
 	if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
-		ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL);
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_NONE);
+		ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
 	} else {
 		sc->sc_flags |= TULIPF_HAS_MII;
 		sc->sc_tick = tlp_mii_tick;
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
 	}
 }
 
@@ -6095,7 +6093,7 @@ tlp_dm9102_tmsw_setmedia(struct tulip_so
 {
 
 	/* XXX HomePNA on DM9102A. */
-	return tlp_mii_setmedia(sc);
+	return (tlp_mii_setmedia(sc));
 }
 
 /*
@@ -6116,15 +6114,14 @@ static void
 tlp_asix_tmsw_init(struct tulip_softc *sc)
 {
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
-	struct mii_data * const mii = &sc->sc_mii;
 	uint32_t opmode;
 
-	mii->mii_ifp = ifp;
-	mii->mii_readreg = tlp_bitbang_mii_readreg;
-	mii->mii_writereg = tlp_bitbang_mii_writereg;
-	mii->mii_statchg = sc->sc_statchg;
-	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, tlp_mediachange, tlp_mediastatus);
+	sc->sc_mii.mii_ifp = ifp;
+        sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg;
+        sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg;
+	sc->sc_mii.mii_statchg = sc->sc_statchg;
+	ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+            tlp_mediastatus);
 
 	/*
 	 * Configure OPMODE properly for the internal MII interface.
@@ -6132,28 +6129,28 @@ tlp_asix_tmsw_init(struct tulip_softc *s
 	switch (sc->sc_chip) {
 	case TULIP_CHIP_AX88140:
 	case TULIP_CHIP_AX88141:
-		opmode = OPMODE_HBD | OPMODE_PS;
+		opmode = OPMODE_HBD|OPMODE_PS;
 		break;
-	default:
-		opmode = 0;
-		break;
-	}
+        default:
+                opmode = 0;
+                break;
+        }
 
 	TULIP_WRITE(sc, CSR_OPMODE, opmode);
 
 	/* Now, probe the internal MII for the internal PHY. */
-	mii_attach(sc->sc_dev, mii, 0xffffffff, MII_PHY_ANY,
+	mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY,
 	    MII_OFFSET_ANY, 0);
 
 	/* XXX Figure how to handle the PHY. */
 
-	if (LIST_FIRST(&mii->mii_phys) == NULL) {
-		ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL);
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_NONE);
+	if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
+		ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
 	} else {
 		sc->sc_flags |= TULIPF_HAS_MII;
 		sc->sc_tick = tlp_mii_tick;
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
 	}
 
 
@@ -6172,7 +6169,7 @@ tlp_asix_tmsw_setmedia(struct tulip_soft
 {
 
 	/* XXX PHY handling. */
-	return tlp_mii_setmedia(sc);
+	return (tlp_mii_setmedia(sc));
 }
 
 /*
@@ -6189,7 +6186,6 @@ void
 tlp_rs7112_tmsw_init(struct tulip_softc *sc)
 {
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
-	struct mii_data * const mii = &sc->sc_mii;
 
 	/*
 	 * We don't attach any media info structures to the ifmedia
@@ -6199,35 +6195,26 @@ tlp_rs7112_tmsw_init(struct tulip_softc 
 	if (sc->sc_preinit == tlp_2114x_preinit)
 		sc->sc_preinit = tlp_2114x_mii_preinit;
 
-	mii->mii_ifp = ifp;
-	mii->mii_readreg = tlp_bitbang_mii_readreg;
-	mii->mii_writereg = tlp_bitbang_mii_writereg;
-	mii->mii_statchg = sc->sc_statchg;
-	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, tlp_mediachange, tlp_mediastatus);
+	sc->sc_mii.mii_ifp = ifp;
+	sc->sc_mii.mii_readreg = tlp_bitbang_mii_readreg;
+	sc->sc_mii.mii_writereg = tlp_bitbang_mii_writereg;
+	sc->sc_mii.mii_statchg = sc->sc_statchg;
+	ifmedia_init(&sc->sc_mii.mii_media, 0, tlp_mediachange,
+	    tlp_mediastatus);
 
 	/*
 	 * The RS7112 reports a PHY at 0 (possibly HomePNA?)
 	 * and 1 (ethernet). We attach ethernet only.
 	 */
-	mii_attach(sc->sc_dev, mii, 0xffffffff, 1, MII_OFFSET_ANY, 0);
+	mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, 1,
+	    MII_OFFSET_ANY, 0);
 
-	if (LIST_FIRST(&mii->mii_phys) == NULL) {
-		ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL);
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_NONE);
+	if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) {
+		ifmedia_add(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE, 0, NULL);
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_NONE);
 	} else {
 		sc->sc_flags |= TULIPF_HAS_MII;
 		sc->sc_tick = tlp_mii_tick;
-		ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
-	}
-}
-
-const char *
-tlp_chip_name(tulip_chip_t t) {
-	if ((int)t < 0 || (int)t >= __arraycount(tlp_chip_names)) {
-		static char buf[256];
-		(void)snprintf(buf, sizeof(buf), "[unknown 0x%x]", t);
-		return buf;
+		ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO);
 	}
-	return tlp_chip_names[t];
 }

Index: src/sys/dev/ic/tulipreg.h
diff -u src/sys/dev/ic/tulipreg.h:1.42 src/sys/dev/ic/tulipreg.h:1.43
--- src/sys/dev/ic/tulipreg.h:1.42	Mon Aug  1 07:34:28 2022
+++ src/sys/dev/ic/tulipreg.h	Mon Aug  1 07:37:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tulipreg.h,v 1.42 2022/08/01 07:34:28 mlelstv Exp $	*/
+/*	$NetBSD: tulipreg.h,v 1.43 2022/08/01 07:37:18 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -938,19 +938,19 @@ struct tulip_desc {
 
 
 /* SIA configuration for 10base-T (from the 21040 manual) */
-#define	SIACONN_21040_10BASET	0x00008f01
+#define	SIACONN_21040_10BASET	0x0000ef01
 #define	SIATXRX_21040_10BASET	0x0000ffff
 #define	SIAGEN_21040_10BASET	0x00000000
 
 
 /* SIA configuration for 10base-T full-duplex (from the 21040 manual) */
-#define	SIACONN_21040_10BASET_FDX 0x00008f01
+#define	SIACONN_21040_10BASET_FDX 0x0000ef01
 #define	SIATXRX_21040_10BASET_FDX 0x0000fffd
 #define	SIAGEN_21040_10BASET_FDX  0x00000000
 
 
 /* SIA configuration for 10base-5 (from the 21040 manual) */
-#define	SIACONN_21040_AUI	0x00008f09
+#define	SIACONN_21040_AUI	0x0000ef09
 #define	SIATXRX_21040_AUI	0x00000705
 #define	SIAGEN_21040_AUI	0x00000006
 

Reply via email to