git: 2e6a8c1ae3ce - main - Mechanically convert etherswitch drivers to IfAPI

From: Justin Hibbits <jhibbits_at_FreeBSD.org>
Date: Tue, 24 Jan 2023 20:48:20 UTC
The branch main has been updated by jhibbits:

URL: https://cgit.FreeBSD.org/src/commit/?id=2e6a8c1ae3ce1efe5510eef495829b2b5c47f16f

commit 2e6a8c1ae3ce1efe5510eef495829b2b5c47f16f
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2022-05-30 19:40:45 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2023-01-24 19:36:29 +0000

    Mechanically convert etherswitch drivers to IfAPI
    
    Reviewed by:    kd
    Sponsored by:   Juniper Networks, Inc.
    Differential Revision: https://reviews.freebsd.org/D37813
---
 sys/dev/etherswitch/ar40xx/ar40xx_main.c     |  2 +-
 sys/dev/etherswitch/ar40xx/ar40xx_phy.c      | 18 ++++++++--------
 sys/dev/etherswitch/ar40xx/ar40xx_phy.h      |  2 +-
 sys/dev/etherswitch/ar40xx/ar40xx_var.h      |  2 +-
 sys/dev/etherswitch/arswitch/arswitch.c      | 26 +++++++++++-----------
 sys/dev/etherswitch/arswitch/arswitchvar.h   |  2 +-
 sys/dev/etherswitch/e6000sw/e6000sw.c        | 24 ++++++++++-----------
 sys/dev/etherswitch/e6000sw/e6060sw.c        | 24 ++++++++++-----------
 sys/dev/etherswitch/felix/felix.c            | 22 +++++++++----------
 sys/dev/etherswitch/felix/felix_var.h        |  2 +-
 sys/dev/etherswitch/infineon/adm6996fc.c     | 24 ++++++++++-----------
 sys/dev/etherswitch/ip17x/ip17x.c            | 30 +++++++++++++-------------
 sys/dev/etherswitch/ip17x/ip17x_var.h        |  2 +-
 sys/dev/etherswitch/micrel/ksz8995ma.c       | 24 ++++++++++-----------
 sys/dev/etherswitch/mtkswitch/mtkswitch.c    | 20 ++++++++---------
 sys/dev/etherswitch/mtkswitch/mtkswitchvar.h |  2 +-
 sys/dev/etherswitch/rtl8366/rtl8366rb.c      | 24 ++++++++++-----------
 sys/dev/etherswitch/ukswitch/ukswitch.c      | 32 ++++++++++++++--------------
 18 files changed, 141 insertions(+), 141 deletions(-)

diff --git a/sys/dev/etherswitch/ar40xx/ar40xx_main.c b/sys/dev/etherswitch/ar40xx/ar40xx_main.c
index 0d5fbf65fa79..cebb24bf07cd 100644
--- a/sys/dev/etherswitch/ar40xx/ar40xx_main.c
+++ b/sys/dev/etherswitch/ar40xx/ar40xx_main.c
@@ -627,7 +627,7 @@ ar40xx_setport(device_t dev, etherswitch_port_t *p)
 	struct ar40xx_softc *sc = device_get_softc(dev);
 	struct ifmedia *ifm;
 	struct mii_data *mii;
-	struct ifnet *ifp;
+	if_t ifp;
 	int ret;
 
 	if (p->es_port < 0 || p->es_port > sc->sc_info.es_nports)
diff --git a/sys/dev/etherswitch/ar40xx/ar40xx_phy.c b/sys/dev/etherswitch/ar40xx/ar40xx_phy.c
index 9c9b7e9e5733..581eead59bfd 100644
--- a/sys/dev/etherswitch/ar40xx/ar40xx_phy.c
+++ b/sys/dev/etherswitch/ar40xx/ar40xx_phy.c
@@ -147,7 +147,7 @@ ar40xx_phy_miiforport(struct ar40xx_softc *sc, int port)
 	return (device_get_softc(sc->sc_phys.miibus[phy]));
 }
 
-struct ifnet *
+if_t 
 ar40xx_phy_ifpforport(struct ar40xx_softc *sc, int port)
 {
 	int phy;
@@ -159,13 +159,13 @@ ar40xx_phy_ifpforport(struct ar40xx_softc *sc, int port)
 }
 
 static int
-ar40xx_ifmedia_upd(struct ifnet *ifp)
+ar40xx_ifmedia_upd(if_t ifp)
 {
-	struct ar40xx_softc *sc = ifp->if_softc;
-	struct mii_data *mii = ar40xx_phy_miiforport(sc, ifp->if_dunit);
+	struct ar40xx_softc *sc = if_getsoftc(ifp);
+	struct mii_data *mii = ar40xx_phy_miiforport(sc, ifp->if_dunit); /* XXX - DRVAPI */
 
 	AR40XX_DPRINTF(sc, AR40XX_DBG_PORT_STATUS, "%s: called, PHY %d\n",
-	    __func__, ifp->if_dunit);
+	    __func__, ifp->if_dunit); /* XXX - DRVAPI */
 
 	if (mii == NULL)
 		return (ENXIO);
@@ -174,13 +174,13 @@ ar40xx_ifmedia_upd(struct ifnet *ifp)
 }
 
 static void
-ar40xx_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+ar40xx_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
-	struct ar40xx_softc *sc = ifp->if_softc;
-	struct mii_data *mii = ar40xx_phy_miiforport(sc, ifp->if_dunit);
+	struct ar40xx_softc *sc = if_getsoftc(ifp);
+	struct mii_data *mii = ar40xx_phy_miiforport(sc, ifp->if_dunit); /* XXX - DRVAPI */
 
 	AR40XX_DPRINTF(sc, AR40XX_DBG_PORT_STATUS, "%s: called, PHY %d\n",
-	    __func__, ifp->if_dunit);
+	    __func__, ifp->if_dunit); /* XXX - DRVAPI */
 
 	if (mii == NULL)
 		return;
diff --git a/sys/dev/etherswitch/ar40xx/ar40xx_phy.h b/sys/dev/etherswitch/ar40xx/ar40xx_phy.h
index cb42ed7c1ed5..257f90a9d37e 100644
--- a/sys/dev/etherswitch/ar40xx/ar40xx_phy.h
+++ b/sys/dev/etherswitch/ar40xx/ar40xx_phy.h
@@ -32,7 +32,7 @@ extern	int ar40xx_attach_phys(struct ar40xx_softc *sc);
 extern	int ar40xx_hw_phy_get_ids(struct ar40xx_softc *sc);
 extern	struct mii_data * ar40xx_phy_miiforport(struct ar40xx_softc *sc,
 	    int port);
-extern	struct ifnet * ar40xx_phy_ifpforport(struct ar40xx_softc *sc,
+extern	if_t  ar40xx_phy_ifpforport(struct ar40xx_softc *sc,
 	    int port);
 
 #endif	/* __AR40XX_PHY_H__ */
diff --git a/sys/dev/etherswitch/ar40xx/ar40xx_var.h b/sys/dev/etherswitch/ar40xx/ar40xx_var.h
index 2befe41b5952..93db9f417a2a 100644
--- a/sys/dev/etherswitch/ar40xx/ar40xx_var.h
+++ b/sys/dev/etherswitch/ar40xx/ar40xx_var.h
@@ -120,7 +120,7 @@ struct ar40xx_softc {
 	struct {
 		char *ifname[AR40XX_NUM_PHYS];
 		device_t miibus[AR40XX_NUM_PHYS];
-		struct ifnet *ifp[AR40XX_NUM_PHYS];
+		if_t ifp[AR40XX_NUM_PHYS];
 	} sc_phys;
 
 	/* ATU (address table unit) support */
diff --git a/sys/dev/etherswitch/arswitch/arswitch.c b/sys/dev/etherswitch/arswitch/arswitch.c
index 04d1d9143075..1f3d05611f0f 100644
--- a/sys/dev/etherswitch/arswitch/arswitch.c
+++ b/sys/dev/etherswitch/arswitch/arswitch.c
@@ -85,8 +85,8 @@ static int led_pattern_table[] = {
 
 static inline int arswitch_portforphy(int phy);
 static void arswitch_tick(void *arg);
-static int arswitch_ifmedia_upd(struct ifnet *);
-static void arswitch_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int arswitch_ifmedia_upd(if_t );
+static void arswitch_ifmedia_sts(if_t , struct ifmediareq *);
 static int ar8xxx_port_vlan_setup(struct arswitch_softc *sc,
     etherswitch_port_t *p);
 static int ar8xxx_port_vlan_get(struct arswitch_softc *sc,
@@ -183,9 +183,9 @@ arswitch_attach_phys(struct arswitch_softc *sc)
 			break;
 		}
 
-		sc->ifp[phy]->if_softc = sc;
-		sc->ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST |
-		    IFF_DRV_RUNNING | IFF_SIMPLEX;
+		if_setsoftc(sc->ifp[phy], sc);
+		if_setflagbits(sc->ifp[phy], IFF_UP | IFF_BROADCAST |
+		    IFF_DRV_RUNNING | IFF_SIMPLEX, 0);
 		sc->ifname[phy] = malloc(strlen(name)+1, M_DEVBUF, M_WAITOK);
 		bcopy(name, sc->ifname[phy], strlen(name)+1);
 		if_initname(sc->ifp[phy], sc->ifname[phy],
@@ -748,7 +748,7 @@ arswitch_miiforport(struct arswitch_softc *sc, int port)
 	return (device_get_softc(sc->miibus[phy]));
 }
 
-static inline struct ifnet *
+static inline if_t 
 arswitch_ifpforport(struct arswitch_softc *sc, int port)
 {
 	int phy = port-1;
@@ -1052,7 +1052,7 @@ arswitch_setport(device_t dev, etherswitch_port_t *p)
 	struct arswitch_softc *sc;
 	struct ifmedia *ifm;
 	struct mii_data *mii;
-	struct ifnet *ifp;
+	if_t ifp;
 
 	sc = device_get_softc(dev);
 	if (p->es_port < 0 || p->es_port > sc->info.es_nports)
@@ -1122,10 +1122,10 @@ arswitch_statchg(device_t dev)
 }
 
 static int
-arswitch_ifmedia_upd(struct ifnet *ifp)
+arswitch_ifmedia_upd(if_t ifp)
 {
-	struct arswitch_softc *sc = ifp->if_softc;
-	struct mii_data *mii = arswitch_miiforport(sc, ifp->if_dunit);
+	struct arswitch_softc *sc = if_getsoftc(ifp);
+	struct mii_data *mii = arswitch_miiforport(sc, if_getdunit(ifp));
 
 	if (mii == NULL)
 		return (ENXIO);
@@ -1134,10 +1134,10 @@ arswitch_ifmedia_upd(struct ifnet *ifp)
 }
 
 static void
-arswitch_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+arswitch_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
-	struct arswitch_softc *sc = ifp->if_softc;
-	struct mii_data *mii = arswitch_miiforport(sc, ifp->if_dunit);
+	struct arswitch_softc *sc = if_getsoftc(ifp);
+	struct mii_data *mii = arswitch_miiforport(sc, if_getdunit(ifp));
 
 	DPRINTF(sc, ARSWITCH_DBG_POLL, "%s\n", __func__);
 
diff --git a/sys/dev/etherswitch/arswitch/arswitchvar.h b/sys/dev/etherswitch/arswitch/arswitchvar.h
index ff92536358ac..5e628e9243ff 100644
--- a/sys/dev/etherswitch/arswitch/arswitchvar.h
+++ b/sys/dev/etherswitch/arswitch/arswitchvar.h
@@ -76,7 +76,7 @@ struct arswitch_softc {
 	/* should be the max of both pre-AR8327 and AR8327 ports */
 	char		*ifname[ARSWITCH_NUM_PHYS];
 	device_t	miibus[ARSWITCH_NUM_PHYS];
-	struct ifnet	*ifp[ARSWITCH_NUM_PHYS];
+	if_t ifp[ARSWITCH_NUM_PHYS];
 	struct arswitch_dev_led	dev_led[ARSWITCH_NUM_PHYS][ARSWITCH_NUM_LEDS];
 	struct callout	callout_tick;
 	etherswitch_info_t info;
diff --git a/sys/dev/etherswitch/e6000sw/e6000sw.c b/sys/dev/etherswitch/e6000sw/e6000sw.c
index 72ed8f8471d9..812c004a37c3 100644
--- a/sys/dev/etherswitch/e6000sw/e6000sw.c
+++ b/sys/dev/etherswitch/e6000sw/e6000sw.c
@@ -77,7 +77,7 @@ typedef struct e6000sw_softc {
 	phandle_t		node;
 
 	struct sx		sx;
-	struct ifnet		*ifp[E6000SW_MAX_PORTS];
+	if_t ifp[E6000SW_MAX_PORTS];
 	char			*ifname[E6000SW_MAX_PORTS];
 	device_t		miibus[E6000SW_MAX_PORTS];
 	struct taskqueue	*sc_tq;
@@ -136,8 +136,8 @@ static int e6000sw_vtu_flush(e6000sw_softc_t *);
 static int e6000sw_vtu_update(e6000sw_softc_t *, int, int, int, int, int);
 static __inline void e6000sw_writereg(e6000sw_softc_t *, int, int, int);
 static __inline uint32_t e6000sw_readreg(e6000sw_softc_t *, int, int);
-static int e6000sw_ifmedia_upd(struct ifnet *);
-static void e6000sw_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int e6000sw_ifmedia_upd(if_t );
+static void e6000sw_ifmedia_sts(if_t , struct ifmediareq *);
 static int e6000sw_atu_mac_table(device_t, e6000sw_softc_t *, struct atu_opt *,
     int);
 static int e6000sw_get_pvid(e6000sw_softc_t *, int, int *);
@@ -368,9 +368,9 @@ e6000sw_init_interface(e6000sw_softc_t *sc, int port)
 	sc->ifp[port] = if_alloc(IFT_ETHER);
 	if (sc->ifp[port] == NULL)
 		return (ENOMEM);
-	sc->ifp[port]->if_softc = sc;
-	sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST |
-	    IFF_DRV_RUNNING | IFF_SIMPLEX;
+	if_setsoftc(sc->ifp[port], sc);
+	if_setflagbits(sc->ifp[port], IFF_UP | IFF_BROADCAST |
+	    IFF_DRV_RUNNING | IFF_SIMPLEX, 0);
 	sc->ifname[port] = malloc(strlen(name) + 1, M_E6000SW, M_NOWAIT);
 	if (sc->ifname[port] == NULL) {
 		if_free(sc->ifp[port]);
@@ -1280,13 +1280,13 @@ e6000sw_miiforphy(e6000sw_softc_t *sc, unsigned int phy)
 }
 
 static int
-e6000sw_ifmedia_upd(struct ifnet *ifp)
+e6000sw_ifmedia_upd(if_t ifp)
 {
 	e6000sw_softc_t *sc;
 	struct mii_data *mii;
 
-	sc = ifp->if_softc;
-	mii = e6000sw_miiforphy(sc, ifp->if_dunit);
+	sc = if_getsoftc(ifp);
+	mii = e6000sw_miiforphy(sc, if_getdunit(ifp));
 	if (mii == NULL)
 		return (ENXIO);
 	mii_mediachg(mii);
@@ -1295,13 +1295,13 @@ e6000sw_ifmedia_upd(struct ifnet *ifp)
 }
 
 static void
-e6000sw_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+e6000sw_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
 	e6000sw_softc_t *sc;
 	struct mii_data *mii;
 
-	sc = ifp->if_softc;
-	mii = e6000sw_miiforphy(sc, ifp->if_dunit);
+	sc = if_getsoftc(ifp);
+	mii = e6000sw_miiforphy(sc, if_getdunit(ifp));
 
 	if (mii == NULL)
 		return;
diff --git a/sys/dev/etherswitch/e6000sw/e6060sw.c b/sys/dev/etherswitch/e6000sw/e6060sw.c
index a61de3d2b418..f53cca80c0a0 100644
--- a/sys/dev/etherswitch/e6000sw/e6060sw.c
+++ b/sys/dev/etherswitch/e6000sw/e6060sw.c
@@ -120,7 +120,7 @@ struct e6060sw_softc {
 	int		*portphy;
 	char		**ifname;
 	device_t	**miibus;
-	struct ifnet	**ifp;
+	if_t *ifp;
 	struct callout	callout_tick;
 	etherswitch_info_t	info;
 	int		smi_offset;
@@ -150,8 +150,8 @@ struct e6060sw_softc {
 
 static inline int e6060sw_portforphy(struct e6060sw_softc *, int);
 static void e6060sw_tick(void *);
-static int e6060sw_ifmedia_upd(struct ifnet *);
-static void e6060sw_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int e6060sw_ifmedia_upd(if_t );
+static void e6060sw_ifmedia_sts(if_t , struct ifmediareq *);
 
 static void e6060sw_setup(device_t dev);
 static int e6060sw_read_vtu(device_t dev, int num, int *data1, int *data2);
@@ -300,7 +300,7 @@ e6060sw_attach(device_t dev)
 
 	e6060sw_setup(dev);
 
-	sc->ifp = malloc(sizeof(struct ifnet *) * sc->numports, M_E6060SW,
+	sc->ifp = malloc(sizeof(if_t ) * sc->numports, M_E6060SW,
 	    M_WAITOK | M_ZERO);
 	sc->ifname = malloc(sizeof(char *) * sc->numports, M_E6060SW,
 	    M_WAITOK | M_ZERO);
@@ -383,7 +383,7 @@ e6060sw_miiforport(struct e6060sw_softc *sc, int port)
 	return (device_get_softc(*sc->miibus[port]));
 }
 
-static inline struct ifnet *
+static inline if_t 
 e6060sw_ifpforport(struct e6060sw_softc *sc, int port)
 {
 
@@ -516,7 +516,7 @@ e6060sw_setport(device_t dev, etherswitch_port_t *p)
 	struct e6060sw_softc *sc;
 	struct ifmedia *ifm;
 	struct mii_data *mii;
-	struct ifnet *ifp;
+	if_t ifp;
 	int err;
 	int data;
 
@@ -883,13 +883,13 @@ e6060sw_statchg(device_t dev)
 }
 
 static int
-e6060sw_ifmedia_upd(struct ifnet *ifp)
+e6060sw_ifmedia_upd(if_t ifp)
 {
 	struct e6060sw_softc *sc;
 	struct mii_data *mii;
 
-	sc = ifp->if_softc;
-	mii = e6060sw_miiforport(sc, ifp->if_dunit);
+	sc = if_getsoftc(ifp);
+	mii = e6060sw_miiforport(sc, ifp->if_dunit); /* XXX - DRVAPI */
 
 	DPRINTF(sc->sc_dev, "%s\n", __func__);
 	if (mii == NULL)
@@ -899,13 +899,13 @@ e6060sw_ifmedia_upd(struct ifnet *ifp)
 }
 
 static void
-e6060sw_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+e6060sw_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
 	struct e6060sw_softc *sc;
 	struct mii_data *mii;
 
-	sc = ifp->if_softc;
-	mii = e6060sw_miiforport(sc, ifp->if_dunit);
+	sc = if_getsoftc(ifp);
+	mii = e6060sw_miiforport(sc, ifp->if_dunit); /* XXX - DRVAPI */
 
 	DPRINTF(sc->sc_dev, "%s\n", __func__);
 
diff --git a/sys/dev/etherswitch/felix/felix.c b/sys/dev/etherswitch/felix/felix.c
index 466d26f247d7..fc846da32aa2 100644
--- a/sys/dev/etherswitch/felix/felix.c
+++ b/sys/dev/etherswitch/felix/felix.c
@@ -88,8 +88,8 @@ static int felix_setup(felix_softc_t);
 static void felix_setup_port(felix_softc_t, int);
 
 static void felix_tick(void *);
-static int felix_ifmedia_upd(struct ifnet *);
-static void felix_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int felix_ifmedia_upd(if_t );
+static void felix_ifmedia_sts(if_t , struct ifmediareq *);
 
 static void felix_get_port_cfg(felix_softc_t, etherswitch_port_t *);
 static void felix_set_port_cfg(felix_softc_t, etherswitch_port_t *);
@@ -246,9 +246,9 @@ felix_init_interface(felix_softc_t sc, int port)
 	if (sc->ports[port].ifp == NULL)
 		return (ENOMEM);
 
-	sc->ports[port].ifp->if_softc = sc;
-	sc->ports[port].ifp->if_flags = IFF_UP | IFF_BROADCAST | IFF_MULTICAST |
-	    IFF_DRV_RUNNING | IFF_SIMPLEX;
+	if_setsoftc(sc->ports[port].ifp, sc);
+	if_setflags(sc->ports[port].ifp, IFF_UP | IFF_BROADCAST | IFF_MULTICAST |
+	    IFF_DRV_RUNNING | IFF_SIMPLEX);
 	sc->ports[port].ifname = malloc(strlen(name) + 1, M_FELIX, M_NOWAIT);
 	if (sc->ports[port].ifname == NULL) {
 		if_free(sc->ports[port].ifp);
@@ -964,13 +964,13 @@ felix_tick(void *arg)
 }
 
 static int
-felix_ifmedia_upd(struct ifnet *ifp)
+felix_ifmedia_upd(if_t ifp)
 {
 	struct mii_data *mii;
 	felix_softc_t sc;
 
-	sc = ifp->if_softc;
-	mii = felix_miiforport(sc, ifp->if_dunit);
+	sc = if_getsoftc(ifp);
+	mii = felix_miiforport(sc, ifp->if_dunit); /* XXX - DRVAPI */
 	if (mii == NULL)
 		return (ENXIO);
 
@@ -979,13 +979,13 @@ felix_ifmedia_upd(struct ifnet *ifp)
 }
 
 static void
-felix_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+felix_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
 	felix_softc_t sc;
 	struct mii_data *mii;
 
-	sc = ifp->if_softc;
-	mii = felix_miiforport(sc, ifp->if_dunit);
+	sc = if_getsoftc(ifp);
+	mii = felix_miiforport(sc, ifp->if_dunit); /* XXX - DRVAPI */
 	if (mii == NULL)
 		return;
 
diff --git a/sys/dev/etherswitch/felix/felix_var.h b/sys/dev/etherswitch/felix/felix_var.h
index 15f43ec6a3d2..10b29802cd43 100644
--- a/sys/dev/etherswitch/felix/felix_var.h
+++ b/sys/dev/etherswitch/felix/felix_var.h
@@ -79,7 +79,7 @@ struct felix_pci_id {
 };
 
 struct felix_port {
-	struct ifnet            *ifp;
+	if_t			ifp;
 	device_t                miibus;
 	char                    *ifname;
 
diff --git a/sys/dev/etherswitch/infineon/adm6996fc.c b/sys/dev/etherswitch/infineon/adm6996fc.c
index 0199b53736b3..ec6f7c98b015 100644
--- a/sys/dev/etherswitch/infineon/adm6996fc.c
+++ b/sys/dev/etherswitch/infineon/adm6996fc.c
@@ -100,7 +100,7 @@ struct adm6996fc_softc {
 	int		*portphy;
 	char		**ifname;
 	device_t	**miibus;
-	struct ifnet	**ifp;
+	if_t *ifp;
 	struct callout	callout_tick;
 	etherswitch_info_t	info;
 };
@@ -122,8 +122,8 @@ struct adm6996fc_softc {
 
 static inline int adm6996fc_portforphy(struct adm6996fc_softc *, int);
 static void adm6996fc_tick(void *);
-static int adm6996fc_ifmedia_upd(struct ifnet *);
-static void adm6996fc_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int adm6996fc_ifmedia_upd(if_t );
+static void adm6996fc_ifmedia_sts(if_t , struct ifmediareq *);
 
 #define	ADM6996FC_READREG(dev, x)					\
 	MDIO_READREG(dev, ((x) >> 5), ((x) & 0x1f));
@@ -254,7 +254,7 @@ adm6996fc_attach(device_t dev)
 	sc->info.es_nvlangroups = 16;
 	sc->info.es_vlan_caps = ETHERSWITCH_VLAN_PORT | ETHERSWITCH_VLAN_DOT1Q;
 
-	sc->ifp = malloc(sizeof(struct ifnet *) * sc->numports, M_ADM6996FC,
+	sc->ifp = malloc(sizeof(if_t ) * sc->numports, M_ADM6996FC,
 	    M_WAITOK | M_ZERO);
 	sc->ifname = malloc(sizeof(char *) * sc->numports, M_ADM6996FC,
 	    M_WAITOK | M_ZERO);
@@ -355,7 +355,7 @@ adm6996fc_miiforport(struct adm6996fc_softc *sc, int port)
 	return (device_get_softc(*sc->miibus[port]));
 }
 
-static inline struct ifnet *
+static inline if_t 
 adm6996fc_ifpforport(struct adm6996fc_softc *sc, int port)
 {
 
@@ -504,7 +504,7 @@ adm6996fc_setport(device_t dev, etherswitch_port_t *p)
 	struct adm6996fc_softc	*sc;
 	struct ifmedia		*ifm;
 	struct mii_data		*mii;
-	struct ifnet		*ifp;
+	if_t ifp;
 	device_t		 parent;
 	int 			 err;
 	int			 data;
@@ -721,13 +721,13 @@ adm6996fc_statchg(device_t dev)
 }
 
 static int
-adm6996fc_ifmedia_upd(struct ifnet *ifp)
+adm6996fc_ifmedia_upd(if_t ifp)
 {
 	struct adm6996fc_softc *sc;
 	struct mii_data *mii;
 
-	sc = ifp->if_softc;
-	mii = adm6996fc_miiforport(sc, ifp->if_dunit);
+	sc = if_getsoftc(ifp);
+	mii = adm6996fc_miiforport(sc, ifp->if_dunit); /* XXX - DRVAPI */
 
 	DPRINTF(sc->sc_dev, "%s\n", __func__);
 	if (mii == NULL)
@@ -737,13 +737,13 @@ adm6996fc_ifmedia_upd(struct ifnet *ifp)
 }
 
 static void
-adm6996fc_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+adm6996fc_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
 	struct adm6996fc_softc *sc;
 	struct mii_data *mii;
 
-	sc = ifp->if_softc;
-	mii = adm6996fc_miiforport(sc, ifp->if_dunit);
+	sc = if_getsoftc(ifp);
+	mii = adm6996fc_miiforport(sc, ifp->if_dunit); /* XXX - DRVAPI */
 
 	DPRINTF(sc->sc_dev, "%s\n", __func__);
 
diff --git a/sys/dev/etherswitch/ip17x/ip17x.c b/sys/dev/etherswitch/ip17x/ip17x.c
index d900eef9bd37..7c6d253e7964 100644
--- a/sys/dev/etherswitch/ip17x/ip17x.c
+++ b/sys/dev/etherswitch/ip17x/ip17x.c
@@ -79,8 +79,8 @@ MALLOC_DECLARE(M_IP17X);
 MALLOC_DEFINE(M_IP17X, "ip17x", "ip17x data structures");
 
 static void ip17x_tick(void *);
-static int ip17x_ifmedia_upd(struct ifnet *);
-static void ip17x_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int ip17x_ifmedia_upd(if_t );
+static void ip17x_ifmedia_sts(if_t , struct ifmediareq *);
 
 static void
 ip17x_identify(driver_t *driver, device_t parent)
@@ -180,9 +180,9 @@ ip17x_attach_phys(struct ip17x_softc *sc)
 			break;
 		}
 
-		sc->ifp[port]->if_softc = sc;
-		sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST |
-		    IFF_DRV_RUNNING | IFF_SIMPLEX;
+		if_setsoftc(sc->ifp[port], sc);
+		if_setflags(sc->ifp[port], IFF_UP | IFF_BROADCAST |
+		    IFF_DRV_RUNNING | IFF_SIMPLEX);
 		if_initname(sc->ifp[port], name, port);
 		sc->miibus[port] = malloc(sizeof(device_t), M_IP17X,
 		    M_WAITOK | M_ZERO);
@@ -191,7 +191,7 @@ ip17x_attach_phys(struct ip17x_softc *sc)
 		    BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0);
 		DPRINTF(sc->sc_dev, "%s attached to pseudo interface %s\n",
 		    device_get_nameunit(*sc->miibus[port]),
-		    sc->ifp[port]->if_xname);
+		    if_name(sc->ifp[port]));
 		if (err != 0) {
 			device_printf(sc->sc_dev,
 			    "attaching PHY %d failed\n",
@@ -240,7 +240,7 @@ ip17x_attach(device_t dev)
 	/* Always attach the cpu port. */
 	sc->phymask |= (1 << sc->cpuport);
 
-	sc->ifp = malloc(sizeof(struct ifnet *) * sc->numports, M_IP17X,
+	sc->ifp = malloc(sizeof(if_t ) * sc->numports, M_IP17X,
 	    M_WAITOK | M_ZERO);
 	sc->pvid = malloc(sizeof(uint32_t) * sc->numports, M_IP17X,
 	    M_WAITOK | M_ZERO);
@@ -324,7 +324,7 @@ ip17x_miiforport(struct ip17x_softc *sc, int port)
 	return (device_get_softc(*sc->miibus[port]));
 }
 
-static inline struct ifnet *
+static inline if_t 
 ip17x_ifpforport(struct ip17x_softc *sc, int port)
 {
 
@@ -459,7 +459,7 @@ ip17x_setport(device_t dev, etherswitch_port_t *p)
 {
 	struct ip17x_softc *sc;
 	struct ifmedia *ifm;
-	struct ifnet *ifp;
+	if_t ifp;
 	struct mii_data *mii;
 	int phy;
 
@@ -524,14 +524,14 @@ ip17x_statchg(device_t dev)
 }
 
 static int
-ip17x_ifmedia_upd(struct ifnet *ifp)
+ip17x_ifmedia_upd(if_t ifp)
 {
 	struct ip17x_softc *sc;
 	struct mii_data *mii;
 
- 	sc = ifp->if_softc;
+ 	sc = if_getsoftc(ifp);
 	DPRINTF(sc->sc_dev, "%s\n", __func__);
- 	mii = ip17x_miiforport(sc, ifp->if_dunit);
+ 	mii = ip17x_miiforport(sc, if_getdunit(ifp));
 	if (mii == NULL)
 		return (ENXIO);
 	mii_mediachg(mii);
@@ -540,14 +540,14 @@ ip17x_ifmedia_upd(struct ifnet *ifp)
 }
 
 static void
-ip17x_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+ip17x_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
 	struct ip17x_softc *sc;
 	struct mii_data *mii;
 
- 	sc = ifp->if_softc;
+ 	sc = if_getsoftc(ifp);
 	DPRINTF(sc->sc_dev, "%s\n", __func__);
-	mii = ip17x_miiforport(sc, ifp->if_dunit);
+	mii = ip17x_miiforport(sc, if_getdunit(ifp));
 	if (mii == NULL)
 		return;
 	mii_pollstat(mii);
diff --git a/sys/dev/etherswitch/ip17x/ip17x_var.h b/sys/dev/etherswitch/ip17x/ip17x_var.h
index 9573a18a1875..8664c3e0f63f 100644
--- a/sys/dev/etherswitch/ip17x/ip17x_var.h
+++ b/sys/dev/etherswitch/ip17x/ip17x_var.h
@@ -59,7 +59,7 @@ struct ip17x_softc {
 	etherswitch_info_t	info;
 	ip17x_switch_type	sc_switchtype;
 	struct callout	callout_tick;
-	struct ifnet	**ifp;
+	if_t *ifp;
 	struct mtx	sc_mtx;		/* serialize access to softc */
 
 	struct ip17x_vlan	vlan[IP17X_MAX_VLANS];
diff --git a/sys/dev/etherswitch/micrel/ksz8995ma.c b/sys/dev/etherswitch/micrel/ksz8995ma.c
index 386bd9ebd436..c7d3806fb558 100644
--- a/sys/dev/etherswitch/micrel/ksz8995ma.c
+++ b/sys/dev/etherswitch/micrel/ksz8995ma.c
@@ -151,7 +151,7 @@ struct ksz8995ma_softc {
 	int		*portphy;
 	char		**ifname;
 	device_t	**miibus;
-	struct ifnet	**ifp;
+	if_t *ifp;
 	struct callout	callout_tick;
 	etherswitch_info_t	info;
 };
@@ -173,8 +173,8 @@ struct ksz8995ma_softc {
 
 static inline int ksz8995ma_portforphy(struct ksz8995ma_softc *, int);
 static void ksz8995ma_tick(void *);
-static int ksz8995ma_ifmedia_upd(struct ifnet *);
-static void ksz8995ma_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int ksz8995ma_ifmedia_upd(if_t );
+static void ksz8995ma_ifmedia_sts(if_t , struct ifmediareq *);
 static int ksz8995ma_readreg(device_t dev, int addr);
 static int ksz8995ma_writereg(device_t dev, int addr, int value);
 static void ksz8995ma_portvlanreset(device_t dev);
@@ -304,7 +304,7 @@ ksz8995ma_attach(device_t dev)
 	sc->info.es_nvlangroups = 16;
 	sc->info.es_vlan_caps = ETHERSWITCH_VLAN_PORT | ETHERSWITCH_VLAN_DOT1Q;
 
-	sc->ifp = malloc(sizeof(struct ifnet *) * sc->numports, M_KSZ8995MA,
+	sc->ifp = malloc(sizeof(if_t ) * sc->numports, M_KSZ8995MA,
 	    M_WAITOK | M_ZERO);
 	sc->ifname = malloc(sizeof(char *) * sc->numports, M_KSZ8995MA,
 	    M_WAITOK | M_ZERO);
@@ -413,7 +413,7 @@ ksz8995ma_miiforport(struct ksz8995ma_softc *sc, int port)
 	return (device_get_softc(*sc->miibus[port]));
 }
 
-static inline struct ifnet *
+static inline if_t 
 ksz8995ma_ifpforport(struct ksz8995ma_softc *sc, int port)
 {
 
@@ -565,7 +565,7 @@ ksz8995ma_setport(device_t dev, etherswitch_port_t *p)
 	struct ksz8995ma_softc *sc;
 	struct mii_data *mii;
         struct ifmedia *ifm;
-        struct ifnet *ifp;
+        if_t ifp;
 	int phy, err;
 	int portreg;
 
@@ -771,13 +771,13 @@ ksz8995ma_statchg(device_t dev)
 }
 
 static int
-ksz8995ma_ifmedia_upd(struct ifnet *ifp)
+ksz8995ma_ifmedia_upd(if_t ifp)
 {
 	struct ksz8995ma_softc *sc;
 	struct mii_data *mii;
 
-	sc = ifp->if_softc;
-	mii = ksz8995ma_miiforport(sc, ifp->if_dunit);
+	sc = if_getsoftc(ifp);
+	mii = ksz8995ma_miiforport(sc, ifp->if_dunit); /* XXX - DRVAPI */
 
 	DPRINTF(sc->sc_dev, "%s\n", __func__);
 	if (mii == NULL)
@@ -787,13 +787,13 @@ ksz8995ma_ifmedia_upd(struct ifnet *ifp)
 }
 
 static void
-ksz8995ma_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+ksz8995ma_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
 	struct ksz8995ma_softc *sc;
 	struct mii_data *mii;
 
-	sc = ifp->if_softc;
-	mii = ksz8995ma_miiforport(sc, ifp->if_dunit);
+	sc = if_getsoftc(ifp);
+	mii = ksz8995ma_miiforport(sc, ifp->if_dunit); /* XXX - DRVAPI */
 
 	DPRINTF(sc->sc_dev, "%s\n", __func__);
 
diff --git a/sys/dev/etherswitch/mtkswitch/mtkswitch.c b/sys/dev/etherswitch/mtkswitch/mtkswitch.c
index fc496ba63ce5..c10c34c4c21c 100644
--- a/sys/dev/etherswitch/mtkswitch/mtkswitch.c
+++ b/sys/dev/etherswitch/mtkswitch/mtkswitch.c
@@ -69,8 +69,8 @@ static SYSCTL_NODE(_debug, OID_AUTO, mtkswitch, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
 #endif
 
 static inline int mtkswitch_portforphy(int phy);
-static int mtkswitch_ifmedia_upd(struct ifnet *ifp);
-static void mtkswitch_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr);
+static int mtkswitch_ifmedia_upd(if_t ifp);
+static void mtkswitch_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr);
 static void mtkswitch_tick(void *arg);
 
 static const struct ofw_compat_data compat_data[] = {
@@ -303,7 +303,7 @@ mtkswitch_miiforport(struct mtkswitch_softc *sc, int port)
 	return (device_get_softc(sc->miibus[phy]));
 }
 
-static inline struct ifnet *
+static inline if_t 
 mtkswitch_ifpforport(struct mtkswitch_softc *sc, int port)
 {
 	int phy = mtkswitch_phyforport(port);
@@ -484,7 +484,7 @@ mtkswitch_setport(device_t dev, etherswitch_port_t *p)
 	struct mtkswitch_softc *sc;
 	struct ifmedia *ifm;
 	struct mii_data *mii;
-	struct ifnet *ifp;
+	if_t ifp;
 
 	sc = device_get_softc(dev);
 	if (p->es_port < 0 || p->es_port > sc->info.es_nports)
@@ -519,10 +519,10 @@ mtkswitch_statchg(device_t dev)
 }
 
 static int
-mtkswitch_ifmedia_upd(struct ifnet *ifp)
+mtkswitch_ifmedia_upd(if_t ifp)
 {
-	struct mtkswitch_softc *sc = ifp->if_softc;
-	struct mii_data *mii = mtkswitch_miiforport(sc, ifp->if_dunit);
+	struct mtkswitch_softc *sc = if_getsoftc(ifp);
+	struct mii_data *mii = mtkswitch_miiforport(sc, ifp->if_dunit); /* XXX - DRVAPI */
         
 	if (mii == NULL)
 		return (ENXIO);
@@ -531,10 +531,10 @@ mtkswitch_ifmedia_upd(struct ifnet *ifp)
 }
 
 static void
-mtkswitch_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+mtkswitch_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
-	struct mtkswitch_softc *sc = ifp->if_softc;
-	struct mii_data *mii = mtkswitch_miiforport(sc, ifp->if_dunit);
+	struct mtkswitch_softc *sc = if_getsoftc(ifp);
+	struct mii_data *mii = mtkswitch_miiforport(sc, ifp->if_dunit); /* XXX - DRVAPI */
 
 	DPRINTF(sc->sc_dev, "%s\n", __func__);
 
diff --git a/sys/dev/etherswitch/mtkswitch/mtkswitchvar.h b/sys/dev/etherswitch/mtkswitch/mtkswitchvar.h
index b13e35b7bede..c37affd0bb85 100644
--- a/sys/dev/etherswitch/mtkswitch/mtkswitchvar.h
+++ b/sys/dev/etherswitch/mtkswitch/mtkswitchvar.h
@@ -68,7 +68,7 @@ struct mtkswitch_softc {
 	mtk_switch_type	sc_switchtype;
 	char		*ifname[MTKSWITCH_MAX_PHYS];
 	device_t	miibus[MTKSWITCH_MAX_PHYS];
-	struct ifnet	*ifp[MTKSWITCH_MAX_PHYS];
+	if_t ifp[MTKSWITCH_MAX_PHYS];
 	struct callout	callout_tick;
 	etherswitch_info_t info;
 
diff --git a/sys/dev/etherswitch/rtl8366/rtl8366rb.c b/sys/dev/etherswitch/rtl8366/rtl8366rb.c
index 2ea34f4292a3..f171bbe25e31 100644
--- a/sys/dev/etherswitch/rtl8366/rtl8366rb.c
+++ b/sys/dev/etherswitch/rtl8366/rtl8366rb.c
@@ -75,7 +75,7 @@ struct rtl8366rb_softc {
 	int		vid[RTL8366_NUM_VLANS];
 	char		*ifname[RTL8366_NUM_PHYS];
 	device_t	miibus[RTL8366_NUM_PHYS];
-	struct ifnet	*ifp[RTL8366_NUM_PHYS];
+	if_t ifp[RTL8366_NUM_PHYS];
 	struct callout	callout_tick;
 	etherswitch_info_t	info;
 	int		chip_type;
@@ -126,8 +126,8 @@ static int smi_read(device_t dev, uint16_t addr, uint16_t *data, int sleep);
 static int smi_write(device_t dev, uint16_t addr, uint16_t data, int sleep);
 static int smi_rmw(device_t dev, uint16_t addr, uint16_t mask, uint16_t data, int sleep);
 static void rtl8366rb_tick(void *arg);
-static int rtl8366rb_ifmedia_upd(struct ifnet *);
-static void rtl8366rb_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int rtl8366rb_ifmedia_upd(if_t );
+static void rtl8366rb_ifmedia_sts(if_t , struct ifmediareq *);
 
 static void
 rtl8366rb_identify(driver_t *driver, device_t parent)
@@ -246,9 +246,9 @@ rtl8366rb_attach(device_t dev)
 			break;
 		}
 
-		sc->ifp[i]->if_softc = sc;
-		sc->ifp[i]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING
-			| IFF_SIMPLEX;
+		if_setsoftc(sc->ifp[i], sc);
+		if_setflagbits(sc->ifp[i], IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING
+			| IFF_SIMPLEX, 0);
 		snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(dev));
 		sc->ifname[i] = malloc(strlen(name)+1, M_DEVBUF, M_WAITOK);
 		bcopy(name, sc->ifname[i], strlen(name)+1);
@@ -895,26 +895,26 @@ rtl_writephy(device_t dev, int phy, int reg, int data)
 }
 
 static int
-rtl8366rb_ifmedia_upd(struct ifnet *ifp)
+rtl8366rb_ifmedia_upd(if_t ifp)
 {
 	struct rtl8366rb_softc *sc;
 	struct mii_data *mii;
 	
-	sc = ifp->if_softc;
-	mii = device_get_softc(sc->miibus[ifp->if_dunit]);
+	sc = if_getsoftc(ifp);
+	mii = device_get_softc(sc->miibus[if_getdunit(ifp)]);
 	
 	mii_mediachg(mii);
 	return (0);
 }
 
 static void
-rtl8366rb_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+rtl8366rb_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
 	struct rtl8366rb_softc *sc;
 	struct mii_data *mii;
 
-	sc = ifp->if_softc;
-	mii = device_get_softc(sc->miibus[ifp->if_dunit]);
+	sc = if_getsoftc(ifp);
+	mii = device_get_softc(sc->miibus[if_getdunit(ifp)]);
 
 	mii_pollstat(mii);
 	ifmr->ifm_active = mii->mii_media_active;
diff --git a/sys/dev/etherswitch/ukswitch/ukswitch.c b/sys/dev/etherswitch/ukswitch/ukswitch.c
index ee9415e0584b..5ec3a0db0d1e 100644
--- a/sys/dev/etherswitch/ukswitch/ukswitch.c
+++ b/sys/dev/etherswitch/ukswitch/ukswitch.c
@@ -75,7 +75,7 @@ struct ukswitch_softc {
 	int		*portphy;
 	char		**ifname;
 	device_t	**miibus;
-	struct ifnet	**ifp;
+	if_t *ifp;
 	struct callout	callout_tick;
 	etherswitch_info_t	info;
 };
@@ -97,8 +97,8 @@ struct ukswitch_softc {
 
 static inline int ukswitch_portforphy(struct ukswitch_softc *, int);
 static void ukswitch_tick(void *);
-static int ukswitch_ifmedia_upd(struct ifnet *);
-static void ukswitch_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+static int ukswitch_ifmedia_upd(if_t );
+static void ukswitch_ifmedia_sts(if_t , struct ifmediareq *);
 
 static int
 ukswitch_probe(device_t dev)
@@ -132,9 +132,9 @@ ukswitch_attach_phys(struct ukswitch_softc *sc)
 			break;
 		}
 
-		sc->ifp[port]->if_softc = sc;
-		sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST |
-		    IFF_DRV_RUNNING | IFF_SIMPLEX;
+		if_setsoftc(sc->ifp[port], sc);
+		if_setflags(sc->ifp[port], IFF_UP | IFF_BROADCAST |
+		    IFF_DRV_RUNNING | IFF_SIMPLEX);
 		sc->ifname[port] = malloc(strlen(name)+1, M_UKSWITCH, M_WAITOK);
 		bcopy(name, sc->ifname[port], strlen(name)+1);
 		if_initname(sc->ifp[port], sc->ifname[port], port);
@@ -145,7 +145,7 @@ ukswitch_attach_phys(struct ukswitch_softc *sc)
 		    BMSR_DEFCAPMASK, phy + sc->phyoffset, MII_OFFSET_ANY, 0);
 		DPRINTF(sc->sc_dev, "%s attached to pseudo interface %s\n",
 		    device_get_nameunit(*sc->miibus[port]),
-		    sc->ifp[port]->if_xname);
+		    if_name(sc->ifp[port]));
 		if (err != 0) {
 			device_printf(sc->sc_dev,
 			    "attaching PHY %d failed\n",
@@ -201,7 +201,7 @@ ukswitch_attach(device_t dev)
 	/* We do not support any vlan groups. */
 	sc->info.es_nvlangroups = 0;
 
-	sc->ifp = malloc(sizeof(struct ifnet *) * sc->numports, M_UKSWITCH,
+	sc->ifp = malloc(sizeof(if_t ) * sc->numports, M_UKSWITCH,
 	    M_WAITOK | M_ZERO);
 	sc->ifname = malloc(sizeof(char *) * sc->numports, M_UKSWITCH,
 	    M_WAITOK | M_ZERO);
@@ -280,7 +280,7 @@ ukswitch_miiforport(struct ukswitch_softc *sc, int port)
 	return (device_get_softc(*sc->miibus[port]));
 }
 
-static inline struct ifnet *
+static inline if_t 
 ukswitch_ifpforport(struct ukswitch_softc *sc, int port)
 {
 
@@ -396,7 +396,7 @@ ukswitch_setport(device_t dev, etherswitch_port_t *p)
 	struct ukswitch_softc *sc = device_get_softc(dev);
 	struct ifmedia *ifm;
 	struct mii_data *mii;
-	struct ifnet *ifp;
+	if_t ifp;
 	int err;
 
 	if (p->es_port < 0 || p->es_port >= sc->numports)
@@ -444,10 +444,10 @@ ukswitch_statchg(device_t dev)
 }
 
 static int
-ukswitch_ifmedia_upd(struct ifnet *ifp)
+ukswitch_ifmedia_upd(if_t ifp)
 {
-	struct ukswitch_softc *sc = ifp->if_softc;
-	struct mii_data *mii = ukswitch_miiforport(sc, ifp->if_dunit);
+	struct ukswitch_softc *sc = if_getsoftc(ifp);
+	struct mii_data *mii = ukswitch_miiforport(sc, if_getdunit(ifp));
 
 	DPRINTF(sc->sc_dev, "%s\n", __func__);
 	if (mii == NULL)
@@ -457,10 +457,10 @@ ukswitch_ifmedia_upd(struct ifnet *ifp)
 }
 
 static void
-ukswitch_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+ukswitch_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
-	struct ukswitch_softc *sc = ifp->if_softc;
-	struct mii_data *mii = ukswitch_miiforport(sc, ifp->if_dunit);
+	struct ukswitch_softc *sc = if_getsoftc(ifp);
+	struct mii_data *mii = ukswitch_miiforport(sc, if_getdunit(ifp));
 
 	DPRINTF(sc->sc_dev, "%s\n", __func__);