[haiku-commits] haiku: hrev51561 - in src/add-ons/kernel/drivers/network: ipro100/dev/fxp pcnet/dev/le pcnet/dev/pcn pcnet/dev/mii

  • From: jerome.duval@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 18 Nov 2017 19:15:07 +0100 (CET)

hrev51561 adds 4 changesets to branch 'master'
old head: f57e467bd8941ef70c31063f12c8d649b69100e4
new head: dcdad04383dd2a5ee386805667f5c767138d1130
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=dcdad04383dd+%5Ef57e467bd894

----------------------------------------------------------------------------

5dc915bd4dcc: freebsd11_network: adapt code based on needs of the ipro100 R11.1 
driver.

45b4110c1c32: ipro100: Update with the 11.1 release of the fxp driver.
  
  * switch compat layer.
  * tested on Qemu, model=i82557b.

ad7432f214d3: freebsd11_network: adapt code based on needs of the pcnet R11.1 
driver.

dcdad04383dd: pcnet: Update with the 11.1 release of the le/pcn driver.
  
  * switch compat layer.
  * tested on Qemu, model=pcnet.

                                   [ Jérôme Duval <jerome.duval@xxxxxxxxx> ]

----------------------------------------------------------------------------

20 files changed, 309 insertions(+), 319 deletions(-)
.../drivers/network/ipro100/dev/fxp/Jamfile      |   8 +-
.../drivers/network/ipro100/dev/fxp/if_fxp.c     | 456 +++++++++----------
.../drivers/network/ipro100/dev/fxp/if_fxpreg.h  |   2 -
.../drivers/network/ipro100/dev/fxp/if_fxpvar.h  |   5 +-
.../drivers/network/ipro100/dev/fxp/inphy.c      |   3 +-
.../drivers/network/ipro100/dev/fxp/rcvbundl.h   |   2 +-
.../kernel/drivers/network/pcnet/dev/le/Jamfile  |   6 +-
.../kernel/drivers/network/pcnet/dev/le/am7990.c |  30 +-
.../drivers/network/pcnet/dev/le/am79900.c       |  30 +-
.../drivers/network/pcnet/dev/le/if_le_ledma.c   |   3 +-
.../kernel/drivers/network/pcnet/dev/le/lance.c  |  11 +-
.../kernel/drivers/network/pcnet/dev/mii/Jamfile |   6 +-
.../kernel/drivers/network/pcnet/dev/mii/nsphy.c |  13 +-
.../drivers/network/pcnet/dev/mii/nsphyter.c     |   6 -
.../kernel/drivers/network/pcnet/dev/mii/ukphy.c |   6 -
.../kernel/drivers/network/pcnet/dev/pcn/Jamfile |   2 +-
.../drivers/network/pcnet/dev/pcn/if_pcn.c       |  26 +-
.../compat/freebsd11_network/compat/sys/mbuf.h   |   2 +-
src/libs/compat/freebsd11_network/if.c           |   8 +
src/libs/compat/freebsd11_network/mbuf.c         |   3 +-

############################################################################

Commit:      5dc915bd4dccb0e30d12766a23aae3ec06532382
URL:         http://cgit.haiku-os.org/haiku/commit/?id=5dc915bd4dcc
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Sat Nov 18 17:13:33 2017 UTC

freebsd11_network: adapt code based on needs of the ipro100 R11.1 driver.

----------------------------------------------------------------------------

diff --git a/src/libs/compat/freebsd11_network/if.c 
b/src/libs/compat/freebsd11_network/if.c
index e609912..723f0dc 100644
--- a/src/libs/compat/freebsd11_network/if.c
+++ b/src/libs/compat/freebsd11_network/if.c
@@ -18,6 +18,7 @@
 #include <compat/sys/kernel.h>
 #include <compat/sys/taskqueue.h>
 
+#include <compat/net/bpf.h>
 #include <compat/net/ethernet.h>
 #include <compat/net/if.h>
 #include <compat/net/if_arp.h>
@@ -1310,6 +1311,13 @@ if_gethandle(u_char type)
        return (if_alloc(type));
 }
 
+void
+if_bpfmtap(if_t ifh, struct mbuf *m)
+{
+       struct ifnet *ifp = (struct ifnet *)ifh;
+
+       BPF_MTAP(ifp, m);
+}
 
 void
 if_etherbpfmtap(if_t ifh, struct mbuf *m)

############################################################################

Commit:      45b4110c1c32b28f054288abc84d540d24609384
URL:         http://cgit.haiku-os.org/haiku/commit/?id=45b4110c1c32
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Sat Nov 18 17:14:11 2017 UTC

ipro100: Update with the 11.1 release of the fxp driver.

* switch compat layer.
* tested on Qemu, model=i82557b.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/Jamfile 
b/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/Jamfile
index 7900525..979b108 100644
--- a/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/Jamfile
+++ b/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/Jamfile
@@ -1,7 +1,7 @@
 SubDir HAIKU_TOP src add-ons kernel drivers network ipro100 dev fxp ;
 
 UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ;
-UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : 
true ;
+UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_network compat ] 
: true ;
 
 UsePrivateHeaders net system ;
 UsePrivateKernelHeaders ;
@@ -12,10 +12,10 @@ KernelAddon ipro100 :
        if_fxp.c
        glue.c
        inphy.c
-       : libfreebsd_network.a
+       : libfreebsd11_network.a
        ;
 
 ObjectHdrs [ FGristFiles inphy$(SUFOBJ) ]
        : [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR_$(TARGET_PACKAGING_ARCH)) 
libs
-               compat freebsd_network ] ;
-Includes [ FGristFiles inphy.c ] : <src!libs!compat!freebsd_network>miidevs.h ;
+               compat freebsd11_network ] ;
+Includes [ FGristFiles inphy.c ] : 
<src!libs!compat!freebsd11_network>miidevs.h ;
diff --git a/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxp.c 
b/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxp.c
index 36581ab..543eba9 100644
--- a/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxp.c
+++ b/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxp.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/mbuf.h>
 #include <sys/lock.h>
+#include <sys/malloc.h>
 #include <sys/module.h>
 #include <sys/mutex.h>
 #include <sys/rman.h>
@@ -55,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include <net/bpf.h>
 #include <net/ethernet.h>
 #include <net/if.h>
+#include <net/if_var.h>
 #include <net/if_arp.h>
 #include <net/if_dl.h>
 #include <net/if_media.h>
@@ -156,52 +158,52 @@ static const u_char fxp_cb_config_template[] = {
  * them.
  */
 static const struct fxp_ident fxp_ident_table[] = {
-    { 0x1029,  -1,     0, "Intel 82559 PCI/CardBus Pro/100" },
-    { 0x1030,  -1,     0, "Intel 82559 Pro/100 Ethernet" },
-    { 0x1031,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
-    { 0x1032,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
-    { 0x1033,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
-    { 0x1034,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
-    { 0x1035,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
-    { 0x1036,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
-    { 0x1037,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
-    { 0x1038,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
-    { 0x1039,  -1,     4, "Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
-    { 0x103A,  -1,     4, "Intel 82801DB (ICH4) Pro/100 Ethernet" },
-    { 0x103B,  -1,     4, "Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
-    { 0x103C,  -1,     4, "Intel 82801DB (ICH4) Pro/100 Ethernet" },
-    { 0x103D,  -1,     4, "Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
-    { 0x103E,  -1,     4, "Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
-    { 0x1050,  -1,     5, "Intel 82801BA (D865) Pro/100 VE Ethernet" },
-    { 0x1051,  -1,     5, "Intel 82562ET (ICH5/ICH5R) Pro/100 VE Ethernet" },
-    { 0x1059,  -1,     0, "Intel 82551QM Pro/100 M Mobile Connection" },
-    { 0x1064,  -1,     6, "Intel 82562EZ (ICH6)" },
-    { 0x1065,  -1,     6, "Intel 82562ET/EZ/GT/GZ PRO/100 VE Ethernet" },
-    { 0x1068,  -1,     6, "Intel 82801FBM (ICH6-M) Pro/100 VE Ethernet" },
-    { 0x1069,  -1,     6, "Intel 82562EM/EX/GX Pro/100 Ethernet" },
-    { 0x1091,  -1,     7, "Intel 82562GX Pro/100 Ethernet" },
-    { 0x1092,  -1,     7, "Intel Pro/100 VE Network Connection" },
-    { 0x1093,  -1,     7, "Intel Pro/100 VM Network Connection" },
-    { 0x1094,  -1,     7, "Intel Pro/100 946GZ (ICH7) Network Connection" },
-    { 0x1209,  -1,     0, "Intel 82559ER Embedded 10/100 Ethernet" },
-    { 0x1229,  0x01,   0, "Intel 82557 Pro/100 Ethernet" },
-    { 0x1229,  0x02,   0, "Intel 82557 Pro/100 Ethernet" },
-    { 0x1229,  0x03,   0, "Intel 82557 Pro/100 Ethernet" },
-    { 0x1229,  0x04,   0, "Intel 82558 Pro/100 Ethernet" },
-    { 0x1229,  0x05,   0, "Intel 82558 Pro/100 Ethernet" },
-    { 0x1229,  0x06,   0, "Intel 82559 Pro/100 Ethernet" },
-    { 0x1229,  0x07,   0, "Intel 82559 Pro/100 Ethernet" },
-    { 0x1229,  0x08,   0, "Intel 82559 Pro/100 Ethernet" },
-    { 0x1229,  0x09,   0, "Intel 82559ER Pro/100 Ethernet" },
-    { 0x1229,  0x0c,   0, "Intel 82550 Pro/100 Ethernet" },
-    { 0x1229,  0x0d,   0, "Intel 82550C Pro/100 Ethernet" },
-    { 0x1229,  0x0e,   0, "Intel 82550 Pro/100 Ethernet" },
-    { 0x1229,  0x0f,   0, "Intel 82551 Pro/100 Ethernet" },
-    { 0x1229,  0x10,   0, "Intel 82551 Pro/100 Ethernet" },
-    { 0x1229,  -1,     0, "Intel 82557/8/9 Pro/100 Ethernet" },
-    { 0x2449,  -1,     2, "Intel 82801BA/CAM (ICH2/3) Pro/100 Ethernet" },
-    { 0x27dc,  -1,     7, "Intel 82801GB (ICH7) 10/100 Ethernet" },
-    { 0,       -1,     0, NULL },
+    { 0x8086, 0x1029,  -1,     0, "Intel 82559 PCI/CardBus Pro/100" },
+    { 0x8086, 0x1030,  -1,     0, "Intel 82559 Pro/100 Ethernet" },
+    { 0x8086, 0x1031,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 VE Ethernet" 
},
+    { 0x8086, 0x1032,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 VE Ethernet" 
},
+    { 0x8086, 0x1033,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" 
},
+    { 0x8086, 0x1034,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" 
},
+    { 0x8086, 0x1035,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
+    { 0x8086, 0x1036,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
+    { 0x8086, 0x1037,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
+    { 0x8086, 0x1038,  -1,     3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" 
},
+    { 0x8086, 0x1039,  -1,     4, "Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
+    { 0x8086, 0x103A,  -1,     4, "Intel 82801DB (ICH4) Pro/100 Ethernet" },
+    { 0x8086, 0x103B,  -1,     4, "Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
+    { 0x8086, 0x103C,  -1,     4, "Intel 82801DB (ICH4) Pro/100 Ethernet" },
+    { 0x8086, 0x103D,  -1,     4, "Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
+    { 0x8086, 0x103E,  -1,     4, "Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
+    { 0x8086, 0x1050,  -1,     5, "Intel 82801BA (D865) Pro/100 VE Ethernet" },
+    { 0x8086, 0x1051,  -1,     5, "Intel 82562ET (ICH5/ICH5R) Pro/100 VE 
Ethernet" },
+    { 0x8086, 0x1059,  -1,     0, "Intel 82551QM Pro/100 M Mobile Connection" 
},
+    { 0x8086, 0x1064,  -1,     6, "Intel 82562EZ (ICH6)" },
+    { 0x8086, 0x1065,  -1,     6, "Intel 82562ET/EZ/GT/GZ PRO/100 VE Ethernet" 
},
+    { 0x8086, 0x1068,  -1,     6, "Intel 82801FBM (ICH6-M) Pro/100 VE 
Ethernet" },
+    { 0x8086, 0x1069,  -1,     6, "Intel 82562EM/EX/GX Pro/100 Ethernet" },
+    { 0x8086, 0x1091,  -1,     7, "Intel 82562GX Pro/100 Ethernet" },
+    { 0x8086, 0x1092,  -1,     7, "Intel Pro/100 VE Network Connection" },
+    { 0x8086, 0x1093,  -1,     7, "Intel Pro/100 VM Network Connection" },
+    { 0x8086, 0x1094,  -1,     7, "Intel Pro/100 946GZ (ICH7) Network 
Connection" },
+    { 0x8086, 0x1209,  -1,     0, "Intel 82559ER Embedded 10/100 Ethernet" },
+    { 0x8086, 0x1229,  0x01,   0, "Intel 82557 Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x02,   0, "Intel 82557 Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x03,   0, "Intel 82557 Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x04,   0, "Intel 82558 Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x05,   0, "Intel 82558 Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x06,   0, "Intel 82559 Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x07,   0, "Intel 82559 Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x08,   0, "Intel 82559 Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x09,   0, "Intel 82559ER Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x0c,   0, "Intel 82550 Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x0d,   0, "Intel 82550C Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x0e,   0, "Intel 82550 Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x0f,   0, "Intel 82551 Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  0x10,   0, "Intel 82551 Pro/100 Ethernet" },
+    { 0x8086, 0x1229,  -1,     0, "Intel 82557/8/9 Pro/100 Ethernet" },
+    { 0x8086, 0x2449,  -1,     2, "Intel 82801BA/CAM (ICH2/3) Pro/100 
Ethernet" },
+    { 0x8086, 0x27dc,  -1,     7, "Intel 82801GB (ICH7) 10/100 Ethernet" },
+    { 0,      0,       -1,     0, NULL },
 };
 
 #ifdef FXP_IP_CSUM_WAR
@@ -219,20 +221,20 @@ static int                fxp_resume(device_t dev);
 
 static const struct fxp_ident *fxp_find_ident(device_t dev);
 static void            fxp_intr(void *xsc);
-static void            fxp_rxcsum(struct fxp_softc *sc, struct ifnet *ifp,
+static void            fxp_rxcsum(struct fxp_softc *sc, if_t ifp,
                            struct mbuf *m, uint16_t status, int pos);
-static int             fxp_intr_body(struct fxp_softc *sc, struct ifnet *ifp,
+static int             fxp_intr_body(struct fxp_softc *sc, if_t ifp,
                            uint8_t statack, int count);
 static void            fxp_init(void *xsc);
 static void            fxp_init_body(struct fxp_softc *sc, int);
 static void            fxp_tick(void *xsc);
-static void            fxp_start(struct ifnet *ifp);
-static void            fxp_start_body(struct ifnet *ifp);
+static void            fxp_start(if_t ifp);
+static void            fxp_start_body(if_t ifp);
 static int             fxp_encap(struct fxp_softc *sc, struct mbuf **m_head);
 static void            fxp_txeof(struct fxp_softc *sc);
 static void            fxp_stop(struct fxp_softc *sc);
 static void            fxp_release(struct fxp_softc *sc);
-static int             fxp_ioctl(struct ifnet *ifp, u_long command,
+static int             fxp_ioctl(if_t ifp, u_long command,
                            caddr_t data);
 static void            fxp_watchdog(struct fxp_softc *sc);
 static void            fxp_add_rfabuf(struct fxp_softc *sc,
@@ -253,11 +255,11 @@ static void               fxp_read_eeprom(struct 
fxp_softc *sc, u_short *data,
                            int offset, int words);
 static void            fxp_write_eeprom(struct fxp_softc *sc, u_short *data,
                            int offset, int words);
-static int             fxp_ifmedia_upd(struct ifnet *ifp);
-static void            fxp_ifmedia_sts(struct ifnet *ifp,
+static int             fxp_ifmedia_upd(if_t ifp);
+static void            fxp_ifmedia_sts(if_t ifp,
                            struct ifmediareq *ifmr);
-static int             fxp_serial_ifmedia_upd(struct ifnet *ifp);
-static void            fxp_serial_ifmedia_sts(struct ifnet *ifp,
+static int             fxp_serial_ifmedia_upd(if_t ifp);
+static void            fxp_serial_ifmedia_sts(if_t ifp,
                            struct ifmediareq *ifmr);
 static int             fxp_miibus_readreg(device_t dev, int phy, int reg);
 static int             fxp_miibus_writereg(device_t dev, int phy, int reg,
@@ -373,18 +375,18 @@ fxp_dma_wait(struct fxp_softc *sc, volatile uint16_t 
*status,
 static const struct fxp_ident *
 fxp_find_ident(device_t dev)
 {
-       uint16_t devid;
+       uint16_t vendor;
+       uint16_t device;
        uint8_t revid;
        const struct fxp_ident *ident;
 
-       if (pci_get_vendor(dev) == FXP_VENDORID_INTEL) {
-               devid = pci_get_device(dev);
-               revid = pci_get_revid(dev);
-               for (ident = fxp_ident_table; ident->name != NULL; ident++) {
-                       if (ident->devid == devid &&
-                           (ident->revid == revid || ident->revid == -1)) {
-                               return (ident);
-                       }
+       vendor = pci_get_vendor(dev);
+       device = pci_get_device(dev);
+       revid = pci_get_revid(dev);
+       for (ident = fxp_ident_table; ident->name != NULL; ident++) {
+               if (ident->vendor == vendor && ident->device == device &&
+                   (ident->revid == revid || ident->revid == -1)) {
+                       return (ident);
                }
        }
        return (NULL);
@@ -426,7 +428,7 @@ fxp_attach(device_t dev)
        struct fxp_cb_tx *tcbp;
        struct fxp_tx *txp;
        struct fxp_rx *rxp;
-       struct ifnet *ifp;
+       if_t ifp;
        uint32_t val;
        uint16_t data;
        u_char eaddr[ETHER_ADDR_LEN];
@@ -441,8 +443,8 @@ fxp_attach(device_t dev)
        ifmedia_init(&sc->sc_media, 0, fxp_serial_ifmedia_upd,
            fxp_serial_ifmedia_sts);
 
-       ifp = sc->ifp = if_alloc(IFT_ETHER);
-       if (ifp == NULL) {
+       ifp = sc->ifp = if_gethandle(IFT_ETHER);
+       if (ifp == (void *)NULL) {
                device_printf(dev, "can not if_alloc()\n");
                error = ENOSPC;
                goto fail;
@@ -627,7 +629,7 @@ fxp_attach(device_t dev)
        /* For 82559 or later chips, Rx checksum offload is supported. */
        if (sc->revision >= FXP_REV_82559_A0) {
                /* 82559ER does not support Rx checksum offloading. */
-               if (sc->ident->devid != 0x1209)
+               if (sc->ident->device != 0x1209)
                        sc->flags |= FXP_FLAG_82559_RXCSUM;
        }
        /*
@@ -826,9 +828,10 @@ fxp_attach(device_t dev)
                flags = MIIF_NOISOLATE;
                if (sc->revision >= FXP_REV_82558_A4)
                        flags |= MIIF_DOPAUSE;
-               error = mii_attach(dev, &sc->miibus, ifp, fxp_ifmedia_upd,
-                   fxp_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY,
-                   MII_OFFSET_ANY, flags);
+               error = mii_attach(dev, &sc->miibus, ifp,
+                   (ifm_change_cb_t)fxp_ifmedia_upd,
+                   (ifm_stat_cb_t)fxp_ifmedia_sts, BMSR_DEFCAPMASK,
+                   MII_PHY_ANY, MII_OFFSET_ANY, flags);
                if (error != 0) {
                        device_printf(dev, "attaching PHYs failed\n");
                        goto fail;
@@ -836,34 +839,36 @@ fxp_attach(device_t dev)
        }
 
        if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-       ifp->if_init = fxp_init;
-       ifp->if_softc = sc;
-       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-       ifp->if_ioctl = fxp_ioctl;
-       ifp->if_start = fxp_start;
+       if_setdev(ifp, dev);
+       if_setinitfn(ifp, fxp_init);
+       if_setsoftc(ifp, sc);
+       if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
+       if_setioctlfn(ifp, fxp_ioctl);
+       if_setstartfn(ifp, fxp_start);
 
-       ifp->if_capabilities = ifp->if_capenable = 0;
+       if_setcapabilities(ifp, 0);
+       if_setcapenable(ifp, 0);
 
        /* Enable checksum offload/TSO for 82550 or better chips */
        if (sc->flags & FXP_FLAG_EXT_RFA) {
-               ifp->if_hwassist = FXP_CSUM_FEATURES | CSUM_TSO;
-               ifp->if_capabilities |= IFCAP_HWCSUM | IFCAP_TSO4;
-               ifp->if_capenable |= IFCAP_HWCSUM | IFCAP_TSO4;
+               if_sethwassist(ifp, FXP_CSUM_FEATURES | CSUM_TSO);
+               if_setcapabilitiesbit(ifp, IFCAP_HWCSUM | IFCAP_TSO4, 0);
+               if_setcapenablebit(ifp, IFCAP_HWCSUM | IFCAP_TSO4, 0);
        }
 
        if (sc->flags & FXP_FLAG_82559_RXCSUM) {
-               ifp->if_capabilities |= IFCAP_RXCSUM;
-               ifp->if_capenable |= IFCAP_RXCSUM;
+               if_setcapabilitiesbit(ifp, IFCAP_RXCSUM, 0);
+               if_setcapenablebit(ifp, IFCAP_RXCSUM, 0);
        }
 
        if (sc->flags & FXP_FLAG_WOLCAP) {
-               ifp->if_capabilities |= IFCAP_WOL_MAGIC;
-               ifp->if_capenable |= IFCAP_WOL_MAGIC;
+               if_setcapabilitiesbit(ifp, IFCAP_WOL_MAGIC, 0);
+               if_setcapenablebit(ifp, IFCAP_WOL_MAGIC, 0);
        }
 
 #ifdef DEVICE_POLLING
        /* Inform the world we support polling. */
-       ifp->if_capabilities |= IFCAP_POLLING;
+       if_setcapabilitiesbit(ifp, IFCAP_POLLING, 0);
 #endif
 
        /*
@@ -876,23 +881,22 @@ fxp_attach(device_t dev)
         * Must appear after the call to ether_ifattach() because
         * ether_ifattach() sets ifi_hdrlen to the default value.
         */
-       ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
-       ifp->if_capabilities |= IFCAP_VLAN_MTU;
-       ifp->if_capenable |= IFCAP_VLAN_MTU; /* the hw bits already set */
+       if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));
+       if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0);
+       if_setcapenablebit(ifp, IFCAP_VLAN_MTU, 0);
        if ((sc->flags & FXP_FLAG_EXT_RFA) != 0) {
-               ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING |
-                   IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO;
-               ifp->if_capenable |= IFCAP_VLAN_HWTAGGING |
-                   IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO;
+               if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWTAGGING |
+                   IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO, 0);
+               if_setcapenablebit(ifp, IFCAP_VLAN_HWTAGGING |
+                   IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO, 0);
        }
 
        /*
         * Let the system queue as many packets as we have available
         * TX descriptors.
         */
-       IFQ_SET_MAXLEN(&ifp->if_snd, FXP_NTXCB - 1);
-       ifp->if_snd.ifq_drv_maxlen = FXP_NTXCB - 1;
-       IFQ_SET_READY(&ifp->if_snd);
+       if_setsendqlen(ifp, FXP_NTXCB - 1);
+       if_setsendqready(ifp);
 
        /*
         * Hook our interrupt after all initialization is complete.
@@ -1004,7 +1008,7 @@ fxp_detach(device_t dev)
        struct fxp_softc *sc = device_get_softc(dev);
 
 #ifdef DEVICE_POLLING
-       if (sc->ifp->if_capenable & IFCAP_POLLING)
+       if (if_getcapenable(sc->ifp) & IFCAP_POLLING)
                ether_poll_deregister(sc->ifp);
 #endif
 
@@ -1060,7 +1064,7 @@ static int
 fxp_suspend(device_t dev)
 {
        struct fxp_softc *sc = device_get_softc(dev);
-       struct ifnet *ifp;
+       if_t ifp;
        int pmc;
        uint16_t pmstat;
 
@@ -1070,12 +1074,12 @@ fxp_suspend(device_t dev)
        if (pci_find_cap(sc->dev, PCIY_PMG, &pmc) == 0) {
                pmstat = pci_read_config(sc->dev, pmc + PCIR_POWER_STATUS, 2);
                pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
-               if ((ifp->if_capenable & IFCAP_WOL_MAGIC) != 0) {
+               if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) != 0) {
                        /* Request PME. */
                        pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
                        sc->flags |= FXP_FLAG_WOL;
                        /* Reconfigure hardware to accept magic frames. */
-                       ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+                       if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
                        fxp_init_body(sc, 0);
                }
                pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2);
@@ -1096,7 +1100,7 @@ static int
 fxp_resume(device_t dev)
 {
        struct fxp_softc *sc = device_get_softc(dev);
-       struct ifnet *ifp = sc->ifp;
+       if_t ifp = sc->ifp;
        int pmc;
        uint16_t pmstat;
 
@@ -1117,7 +1121,7 @@ fxp_resume(device_t dev)
        DELAY(10);
 
        /* reinitialize interface if necessary */
-       if (ifp->if_flags & IFF_UP)
+       if (if_getflags(ifp) & IFF_UP)
                fxp_init_body(sc, 1);
 
        sc->suspended = 0;
@@ -1259,7 +1263,7 @@ fxp_eeprom_putword(struct fxp_softc *sc, int offset, 
uint16_t data)
  *
  * 559's can have either 64-word or 256-word EEPROMs, the 558
  * datasheet only talks about 64-word EEPROMs, and the 557 datasheet
- * talks about the existance of 16 to 256 word EEPROMs.
+ * talks about the existence of 16 to 256 word EEPROMs.
  *
  * The only known sizes are 64 and 256, where the 256 version is used
  * by CardBus cards to store CIS information.
@@ -1322,9 +1326,9 @@ fxp_load_eeprom(struct fxp_softc *sc)
  * Grab the softc lock and call the real fxp_start_body() routine
  */
 static void
-fxp_start(struct ifnet *ifp)
+fxp_start(if_t ifp)
 {
-       struct fxp_softc *sc = ifp->if_softc;
+       struct fxp_softc *sc = if_getsoftc(ifp);
 
        FXP_LOCK(sc);
        fxp_start_body(ifp);
@@ -1337,15 +1341,15 @@ fxp_start(struct ifnet *ifp)
  * internal entry point only.
  */
 static void
-fxp_start_body(struct ifnet *ifp)
+fxp_start_body(if_t ifp)
 {
-       struct fxp_softc *sc = ifp->if_softc;
+       struct fxp_softc *sc = if_getsoftc(ifp);
        struct mbuf *mb_head;
        int txqueued;
 
        FXP_LOCK_ASSERT(sc, MA_OWNED);
 
-       if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
+       if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
            IFF_DRV_RUNNING)
                return;
 
@@ -1358,27 +1362,26 @@ fxp_start_body(struct ifnet *ifp)
         *       a NOP command when needed.
         */
        txqueued = 0;
-       while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd) &&
-           sc->tx_queued < FXP_NTXCB - 1) {
+       while (!if_sendq_empty(ifp) && sc->tx_queued < FXP_NTXCB - 1) {
 
                /*
                 * Grab a packet to transmit.
                 */
-               IFQ_DRV_DEQUEUE(&ifp->if_snd, mb_head);
+               mb_head = if_dequeue(ifp);
                if (mb_head == NULL)
                        break;
 
                if (fxp_encap(sc, &mb_head)) {
                        if (mb_head == NULL)
                                break;
-                       IFQ_DRV_PREPEND(&ifp->if_snd, mb_head);
-                       ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+                       if_sendq_prepend(ifp, mb_head);
+                       if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
                }
                txqueued++;
                /*
                 * Pass packet to bpf if there is a listener.
                 */
-               BPF_MTAP(ifp, mb_head);
+               if_bpfmtap(ifp, mb_head);
        }
 
        /*
@@ -1401,7 +1404,7 @@ fxp_start_body(struct ifnet *ifp)
 static int
 fxp_encap(struct fxp_softc *sc, struct mbuf **m_head)
 {
-       struct ifnet *ifp;
+       if_t ifp;
        struct mbuf *m;
        struct fxp_tx *txp;
        struct fxp_cb_tx *cbp;
@@ -1671,14 +1674,14 @@ fxp_encap(struct fxp_softc *sc, struct mbuf **m_head)
 static poll_handler_t fxp_poll;
 
 static int
-fxp_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
+fxp_poll(if_t ifp, enum poll_cmd cmd, int count)
 {
-       struct fxp_softc *sc = ifp->if_softc;
+       struct fxp_softc *sc = if_getsoftc(ifp);
        uint8_t statack;
        int rx_npkts = 0;
 
        FXP_LOCK(sc);
-       if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
+       if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) {
                FXP_UNLOCK(sc);
                return (rx_npkts);
        }
@@ -1712,7 +1715,7 @@ static void
 fxp_intr(void *xsc)
 {
        struct fxp_softc *sc = xsc;
-       struct ifnet *ifp = sc->ifp;
+       if_t ifp = sc->ifp;
        uint8_t statack;
 
        FXP_LOCK(sc);
@@ -1722,7 +1725,7 @@ fxp_intr(void *xsc)
        }
 
 #ifdef DEVICE_POLLING
-       if (ifp->if_capenable & IFCAP_POLLING) {
+       if (if_getcapenable(ifp) & IFCAP_POLLING) {
                FXP_UNLOCK(sc);
                return;
        }
@@ -1743,7 +1746,7 @@ fxp_intr(void *xsc)
                 * First ACK all the interrupts in this pass.
                 */
                CSR_WRITE_1(sc, FXP_CSR_SCB_STATACK, statack);
-               if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+               if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
                        fxp_intr_body(sc, ifp, statack, -1);
        }
        FXP_UNLOCK(sc);
@@ -1752,7 +1755,7 @@ fxp_intr(void *xsc)
 static void
 fxp_txeof(struct fxp_softc *sc)
 {
-       struct ifnet *ifp;
+       if_t ifp;
        struct fxp_tx *txp;
 
        ifp = sc->ifp;
@@ -1771,7 +1774,7 @@ fxp_txeof(struct fxp_softc *sc)
                        txp->tx_cb->tbd[0].tb_addr = 0;
                }
                sc->tx_queued--;
-               ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+               if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
        }
        sc->fxp_desc.tx_first = txp;
        bus_dmamap_sync(sc->cbl_tag, sc->cbl_map,
@@ -1781,7 +1784,7 @@ fxp_txeof(struct fxp_softc *sc)
 }
 
 static void
-fxp_rxcsum(struct fxp_softc *sc, struct ifnet *ifp, struct mbuf *m,
+fxp_rxcsum(struct fxp_softc *sc, if_t ifp, struct mbuf *m,
     uint16_t status, int pos)
 {
        struct ether_header *eh;
@@ -1859,7 +1862,7 @@ fxp_rxcsum(struct fxp_softc *sc, struct ifnet *ifp, 
struct mbuf *m,
 }
 
 static int
-fxp_intr_body(struct fxp_softc *sc, struct ifnet *ifp, uint8_t statack,
+fxp_intr_body(struct fxp_softc *sc, if_t ifp, uint8_t statack,
     int count)
 {
        struct mbuf *m;
@@ -1901,7 +1904,7 @@ fxp_intr_body(struct fxp_softc *sc, struct ifnet *ifp, 
uint8_t statack,
        /*
         * Try to start more packets transmitting.
         */
-       if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+       if (!if_sendq_empty(ifp))
                fxp_start_body(ifp);
 
        /*
@@ -1968,7 +1971,7 @@ fxp_intr_body(struct fxp_softc *sc, struct ifnet *ifp, 
uint8_t statack,
                         */
                        total_len = le16toh(rfa->actual_size) & 0x3fff;
                        if ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0 &&
-                           (ifp->if_capenable & IFCAP_RXCSUM) != 0) {
+                           (if_getcapenable(ifp) & IFCAP_RXCSUM) != 0) {
                                /* Adjust for appended checksum bytes. */
                                total_len -= 2;
                        }
@@ -1983,12 +1986,12 @@ fxp_intr_body(struct fxp_softc *sc, struct ifnet *ifp, 
uint8_t statack,
                        }
 
                        m->m_pkthdr.len = m->m_len = total_len;
-                       m->m_pkthdr.rcvif = ifp;
+                       if_setrcvif(m, ifp);
 
                         /* Do IP checksum checking. */
-                       if ((ifp->if_capenable & IFCAP_RXCSUM) != 0)
+                       if ((if_getcapenable(ifp) & IFCAP_RXCSUM) != 0)
                                fxp_rxcsum(sc, ifp, m, status, total_len);
-                       if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0 &&
+                       if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) != 0 
&&
                            (status & FXP_RFA_STATUS_VLAN) != 0) {
                                m->m_pkthdr.ether_vtag =
                                    ntohs(rfa->rfax_vlan_id);
@@ -2003,14 +2006,14 @@ fxp_intr_body(struct fxp_softc *sc, struct ifnet *ifp, 
uint8_t statack,
                         * calling if_input() on each one.
                         */
                        FXP_UNLOCK(sc);
-                       (*ifp->if_input)(ifp, m);
+                       if_input(ifp, m);
                        FXP_LOCK(sc);
                        rx_npkts++;
-                       if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+                       if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
                                return (rx_npkts);
                } else {
                        /* Reuse RFA and loaded DMA map. */
-                       ifp->if_iqdrops++;
+                       if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
                        fxp_discard_rfabuf(sc, rxp);
                }
                fxp_add_rfabuf(sc, rxp);
@@ -2027,7 +2030,7 @@ fxp_intr_body(struct fxp_softc *sc, struct ifnet *ifp, 
uint8_t statack,
 static void
 fxp_update_stats(struct fxp_softc *sc)
 {
-       struct ifnet *ifp = sc->ifp;
+       if_t ifp = sc->ifp;
        struct fxp_stats *sp = sc->fxp_stats;
        struct fxp_hwstats *hsp;
        uint32_t *status;
@@ -2068,10 +2071,12 @@ fxp_update_stats(struct fxp_softc *sc)
                hsp->tx_tco += le16toh(sp->tx_tco);
                hsp->rx_tco += le16toh(sp->rx_tco);
 
-               ifp->if_opackets += le32toh(sp->tx_good);
-               ifp->if_collisions += le32toh(sp->tx_total_collisions);
+               if_inc_counter(ifp, IFCOUNTER_OPACKETS, le32toh(sp->tx_good));
+               if_inc_counter(ifp, IFCOUNTER_COLLISIONS,
+                   le32toh(sp->tx_total_collisions));
                if (sp->rx_good) {
-                       ifp->if_ipackets += le32toh(sp->rx_good);
+                       if_inc_counter(ifp, IFCOUNTER_IPACKETS,
+                           le32toh(sp->rx_good));
                        sc->rx_idle_secs = 0;
                } else if (sc->flags & FXP_FLAG_RXBUG) {
                        /*
@@ -2079,17 +2084,18 @@ fxp_update_stats(struct fxp_softc *sc)
                         */
                        sc->rx_idle_secs++;
                }
-               ifp->if_ierrors +=
+               if_inc_counter(ifp, IFCOUNTER_IERRORS,
                    le32toh(sp->rx_crc_errors) +
                    le32toh(sp->rx_alignment_errors) +
                    le32toh(sp->rx_rnr_errors) +
-                   le32toh(sp->rx_overrun_errors);
+                   le32toh(sp->rx_overrun_errors));
                /*
-                * If any transmit underruns occured, bump up the transmit
+                * If any transmit underruns occurred, bump up the transmit
                 * threshold by another 512 bytes (64 * 8).
                 */
                if (sp->tx_underruns) {
-                       ifp->if_oerrors += le32toh(sp->tx_underruns);
+                       if_inc_counter(ifp, IFCOUNTER_OERRORS,
+                           le32toh(sp->tx_underruns));
                        if (tx_threshold < 192)
                                tx_threshold += 64;
                }
@@ -2114,7 +2120,7 @@ static void
 fxp_tick(void *xsc)
 {
        struct fxp_softc *sc = xsc;
-       struct ifnet *ifp = sc->ifp;
+       if_t ifp = sc->ifp;
 
        FXP_LOCK_ASSERT(sc, MA_OWNED);
 
@@ -2135,15 +2141,15 @@ fxp_tick(void *xsc)
         * then assume the receiver has locked up and attempt to clear
         * the condition by reprogramming the multicast filter. This is
         * a work-around for a bug in the 82557 where the receiver locks
-        * up if it gets certain types of garbage in the syncronization
+        * up if it gets certain types of garbage in the synchronization
         * bits prior to the packet header. This bug is supposed to only
         * occur in 10Mbps mode, but has been seen to occur in 100Mbps
         * mode as well (perhaps due to a 10/100 speed transition).
         */
        if (sc->rx_idle_secs > FXP_MAX_RX_IDLE) {
                sc->rx_idle_secs = 0;
-               if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
-                       ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+               if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
+                       if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
                        fxp_init_body(sc, 1);
                }
                return;
@@ -2179,11 +2185,11 @@ fxp_tick(void *xsc)
 static void
 fxp_stop(struct fxp_softc *sc)
 {
-       struct ifnet *ifp = sc->ifp;
+       if_t ifp = sc->ifp;
        struct fxp_tx *txp;
        int i;
 
-       ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
+       if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
        sc->watchdog_timer = 0;
 
        /*
@@ -2234,6 +2240,7 @@ fxp_stop(struct fxp_softc *sc)
 static void
 fxp_watchdog(struct fxp_softc *sc)
 {
+       if_t ifp = sc->ifp;
 
        FXP_LOCK_ASSERT(sc, MA_OWNED);
 
@@ -2241,9 +2248,9 @@ fxp_watchdog(struct fxp_softc *sc)
                return;
 
        device_printf(sc->dev, "device timeout\n");
-       sc->ifp->if_oerrors++;
+       if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
 
-       sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+       if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
        fxp_init_body(sc, 1);
 }
 
@@ -2269,7 +2276,7 @@ fxp_init(void *xsc)
 static void
 fxp_init_body(struct fxp_softc *sc, int setmedia)
 {
-       struct ifnet *ifp = sc->ifp;
+       if_t ifp = sc->ifp;
        struct mii_data *mii;
        struct fxp_cb_config *cbp;
        struct fxp_cb_ias *cb_ias;
@@ -2279,7 +2286,7 @@ fxp_init_body(struct fxp_softc *sc, int setmedia)
 
        FXP_LOCK_ASSERT(sc, MA_OWNED);
 
-       if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+       if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
                return;
 
        /*
@@ -2294,7 +2301,7 @@ fxp_init_body(struct fxp_softc *sc, int setmedia)
        CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SOFTWARE_RESET);
        DELAY(50);
 
-       prm = (ifp->if_flags & IFF_PROMISC) ? 1 : 0;
+       prm = (if_getflags(ifp) & IFF_PROMISC) ? 1 : 0;
 
        /*
         * Initialize base of CBL and RFA memory. Loading with zero
@@ -2321,7 +2328,7 @@ fxp_init_body(struct fxp_softc *sc, int setmedia)
         * For ICH based controllers do not load microcode.
         */
        if (sc->ident->ich == 0) {
-               if (ifp->if_flags & IFF_LINK0 &&
+               if (if_getflags(ifp) & IFF_LINK0 &&
                    (sc->flags & FXP_FLAG_UCODE) == 0)
                        fxp_load_ucode(sc);
        }
@@ -2377,7 +2384,7 @@ fxp_init_body(struct fxp_softc *sc, int setmedia)
        cbp->mediatype =        sc->flags & FXP_FLAG_SERIAL_MEDIA ? 0 : 1;
        cbp->csma_dis =         0;      /* (don't) disable link */
        cbp->tcp_udp_cksum =    ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0 &&
-           (ifp->if_capenable & IFCAP_RXCSUM) != 0) ? 1 : 0;
+           (if_getcapenable(ifp) & IFCAP_RXCSUM) != 0) ? 1 : 0;
        cbp->vlan_tco =         0;      /* (don't) enable vlan wakeup */
        cbp->link_wake_en =     0;      /* (don't) assert PME# on link change */
        cbp->arp_wake_en =      0;      /* (don't) assert PME# on arp */
@@ -2404,10 +2411,10 @@ fxp_init_body(struct fxp_softc *sc, int setmedia)
        cbp->force_fdx =        0;      /* (don't) force full duplex */
        cbp->fdx_pin_en =       1;      /* (enable) FDX# pin */
        cbp->multi_ia =         0;      /* (don't) accept multiple IAs */
-       cbp->mc_all =           ifp->if_flags & IFF_ALLMULTI ? 1 : prm;
+       cbp->mc_all =           if_getflags(ifp) & IFF_ALLMULTI ? 1 : prm;
        cbp->gamla_rx =         sc->flags & FXP_FLAG_EXT_RFA ? 1 : 0;
        cbp->vlan_strip_en =    ((sc->flags & FXP_FLAG_EXT_RFA) != 0 &&
-           (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0) ? 1 : 0;
+           (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) != 0) ? 1 : 0;
 
        if (sc->revision == FXP_REV_82557) {
                /*
@@ -2486,7 +2493,7 @@ fxp_init_body(struct fxp_softc *sc, int setmedia)
        cb_ias->cb_status = 0;
        cb_ias->cb_command = htole16(FXP_CB_COMMAND_IAS | FXP_CB_COMMAND_EL);
        cb_ias->link_addr = 0xffffffff;
-       bcopy(IF_LLADDR(sc->ifp), cb_ias->macaddr, ETHER_ADDR_LEN);
+       bcopy(if_getlladdr(sc->ifp), cb_ias->macaddr, ETHER_ADDR_LEN);
 
        /*
         * Start the IAS (Individual Address Setup) command/DMA.
@@ -2548,8 +2555,7 @@ fxp_init_body(struct fxp_softc *sc, int setmedia)
        if (sc->miibus != NULL && setmedia != 0)
                mii_mediachg(device_get_softc(sc->miibus));
 
-       ifp->if_drv_flags |= IFF_DRV_RUNNING;
-       ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+       if_setdrvflagbits(ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE);
 
        /*
         * Enable interrupts.
@@ -2559,7 +2565,7 @@ fxp_init_body(struct fxp_softc *sc, int setmedia)
         * ... but only do that if we are not polling. And because (presumably)
         * the default is interrupts on, we need to disable them explicitly!
         */
-       if (ifp->if_capenable & IFCAP_POLLING )
+       if (if_getcapenable(ifp) & IFCAP_POLLING )
                CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, FXP_SCB_INTR_DISABLE);
        else
 #endif /* DEVICE_POLLING */
@@ -2572,14 +2578,14 @@ fxp_init_body(struct fxp_softc *sc, int setmedia)
 }
 
 static int
-fxp_serial_ifmedia_upd(struct ifnet *ifp)
+fxp_serial_ifmedia_upd(if_t ifp)
 {
 
        return (0);
 }
 
 static void
-fxp_serial_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+fxp_serial_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
 
        ifmr->ifm_active = IFM_ETHER|IFM_MANUAL;
@@ -2589,11 +2595,11 @@ fxp_serial_ifmedia_sts(struct ifnet *ifp, struct 
ifmediareq *ifmr)
  * Change media according to request.
  */
 static int
-fxp_ifmedia_upd(struct ifnet *ifp)
+fxp_ifmedia_upd(if_t ifp)
 {
-       struct fxp_softc *sc = ifp->if_softc;
+       struct fxp_softc *sc = if_getsoftc(ifp);
        struct mii_data *mii;
-               struct mii_softc        *miisc;
+       struct mii_softc        *miisc;
 
        mii = device_get_softc(sc->miibus);
        FXP_LOCK(sc);
@@ -2608,9 +2614,9 @@ fxp_ifmedia_upd(struct ifnet *ifp)
  * Notify the world which media we're using.
  */
 static void
-fxp_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+fxp_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
 {
-       struct fxp_softc *sc = ifp->if_softc;
+       struct fxp_softc *sc = if_getsoftc(ifp);
        struct mii_data *mii;
 
        mii = device_get_softc(sc->miibus);
@@ -2799,13 +2805,13 @@ fxp_miibus_statchg(device_t dev)
 {
        struct fxp_softc *sc;
        struct mii_data *mii;
-       struct ifnet *ifp;
+       if_t ifp;
 
        sc = device_get_softc(dev);
        mii = device_get_softc(sc->miibus);
        ifp = sc->ifp;
-       if (mii == NULL || ifp == NULL ||
-           (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ||
+       if (mii == NULL || ifp == (void *)NULL ||
+           (if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0 ||
            (mii->mii_media_status & (IFM_AVALID | IFM_ACTIVE)) !=
            (IFM_AVALID | IFM_ACTIVE))
                return;
@@ -2821,14 +2827,14 @@ fxp_miibus_statchg(device_t dev)
         */
        if (sc->revision == FXP_REV_82557)
                return;
-       ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+       if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
        fxp_init_body(sc, 0);
 }
 
 static int
-fxp_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
+fxp_ioctl(if_t ifp, u_long command, caddr_t data)
 {
-       struct fxp_softc *sc = ifp->if_softc;
+       struct fxp_softc *sc = if_getsoftc(ifp);
        struct ifreq *ifr = (struct ifreq *)data;
        struct mii_data *mii;
        int flag, mask, error = 0, reinit;
@@ -2842,27 +2848,27 @@ fxp_ioctl(struct ifnet *ifp, u_long command, caddr_t 
data)
                 * XXX If it's up then re-initialize it. This is so flags
                 * such as IFF_PROMISC are handled.
                 */
-               if (ifp->if_flags & IFF_UP) {
-                       if (((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) &&
-                           ((ifp->if_flags ^ sc->if_flags) &
+               if (if_getflags(ifp) & IFF_UP) {
+                       if (((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) &&
+                           ((if_getflags(ifp) ^ sc->if_flags) &
                            (IFF_PROMISC | IFF_ALLMULTI | IFF_LINK0)) != 0) {
-                               ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+                               if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
                                fxp_init_body(sc, 0);
-                       } else if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+                       } else if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
                                fxp_init_body(sc, 1);
                } else {
-                       if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+                       if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)
                                fxp_stop(sc);
                }
-               sc->if_flags = ifp->if_flags;
+               sc->if_flags = if_getflags(ifp);
                FXP_UNLOCK(sc);
                break;
 
        case SIOCADDMULTI:
        case SIOCDELMULTI:
                FXP_LOCK(sc);
-               if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
-                       ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+               if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
+                       if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
                        fxp_init_body(sc, 0);
                }
                FXP_UNLOCK(sc);
@@ -2881,7 +2887,7 @@ fxp_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 
        case SIOCSIFCAP:
                reinit = 0;
-               mask = ifp->if_capenable ^ ifr->ifr_reqcap;
+               mask = if_getcapenable(ifp) ^ ifr->ifr_reqcap;
 #ifdef DEVICE_POLLING
                if (mask & IFCAP_POLLING) {
                        if (ifr->ifr_reqcap & IFCAP_POLLING) {
@@ -2891,75 +2897,76 @@ fxp_ioctl(struct ifnet *ifp, u_long command, caddr_t 
data)
                                FXP_LOCK(sc);
                                CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL,
                                    FXP_SCB_INTR_DISABLE);
-                               ifp->if_capenable |= IFCAP_POLLING;
+                               if_setcapenablebit(ifp, IFCAP_POLLING, 0);
                                FXP_UNLOCK(sc);
                        } else {
                                error = ether_poll_deregister(ifp);
                                /* Enable interrupts in any case */
                                FXP_LOCK(sc);
                                CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, 0);
-                               ifp->if_capenable &= ~IFCAP_POLLING;
+                               if_setcapenablebit(ifp, 0, IFCAP_POLLING);
                                FXP_UNLOCK(sc);
                        }
                }
 #endif
                FXP_LOCK(sc);
                if ((mask & IFCAP_TXCSUM) != 0 &&
-                   (ifp->if_capabilities & IFCAP_TXCSUM) != 0) {
-                       ifp->if_capenable ^= IFCAP_TXCSUM;
-                       if ((ifp->if_capenable & IFCAP_TXCSUM) != 0)
-                               ifp->if_hwassist |= FXP_CSUM_FEATURES;
+                   (if_getcapabilities(ifp) & IFCAP_TXCSUM) != 0) {
+                       if_togglecapenable(ifp, IFCAP_TXCSUM);
+                       if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0)
+                               if_sethwassistbits(ifp, FXP_CSUM_FEATURES, 0);
                        else
-                               ifp->if_hwassist &= ~FXP_CSUM_FEATURES;
+                               if_sethwassistbits(ifp, 0, FXP_CSUM_FEATURES);
                }
                if ((mask & IFCAP_RXCSUM) != 0 &&
-                   (ifp->if_capabilities & IFCAP_RXCSUM) != 0) {
-                       ifp->if_capenable ^= IFCAP_RXCSUM;
+                   (if_getcapabilities(ifp) & IFCAP_RXCSUM) != 0) {
+                       if_togglecapenable(ifp, IFCAP_RXCSUM);
                        if ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0)
                                reinit++;
                }
                if ((mask & IFCAP_TSO4) != 0 &&
-                   (ifp->if_capabilities & IFCAP_TSO4) != 0) {
-                       ifp->if_capenable ^= IFCAP_TSO4;
-                       if ((ifp->if_capenable & IFCAP_TSO4) != 0)
-                               ifp->if_hwassist |= CSUM_TSO;
+                   (if_getcapabilities(ifp) & IFCAP_TSO4) != 0) {
+                       if_togglecapenable(ifp, IFCAP_TSO4);
+                       if ((if_getcapenable(ifp) & IFCAP_TSO4) != 0)
+                               if_sethwassistbits(ifp, CSUM_TSO, 0);
                        else
-                               ifp->if_hwassist &= ~CSUM_TSO;
+                               if_sethwassistbits(ifp, 0, CSUM_TSO);
                }
                if ((mask & IFCAP_WOL_MAGIC) != 0 &&
-                   (ifp->if_capabilities & IFCAP_WOL_MAGIC) != 0)
-                       ifp->if_capenable ^= IFCAP_WOL_MAGIC;
+                   (if_getcapabilities(ifp) & IFCAP_WOL_MAGIC) != 0)
+                       if_togglecapenable(ifp, IFCAP_WOL_MAGIC);
                if ((mask & IFCAP_VLAN_MTU) != 0 &&
-                   (ifp->if_capabilities & IFCAP_VLAN_MTU) != 0) {
-                       ifp->if_capenable ^= IFCAP_VLAN_MTU;
+                   (if_getcapabilities(ifp) & IFCAP_VLAN_MTU) != 0) {
+                       if_togglecapenable(ifp, IFCAP_VLAN_MTU);
                        if (sc->revision != FXP_REV_82557)
                                flag = FXP_FLAG_LONG_PKT_EN;
                        else /* a hack to get long frames on the old chip */
                                flag = FXP_FLAG_SAVE_BAD;
                        sc->flags ^= flag;
-                       if (ifp->if_flags & IFF_UP)
+                       if (if_getflags(ifp) & IFF_UP)
                                reinit++;
                }
                if ((mask & IFCAP_VLAN_HWCSUM) != 0 &&
-                   (ifp->if_capabilities & IFCAP_VLAN_HWCSUM) != 0)
-                       ifp->if_capenable ^= IFCAP_VLAN_HWCSUM;
+                   (if_getcapabilities(ifp) & IFCAP_VLAN_HWCSUM) != 0)
+                       if_togglecapenable(ifp, IFCAP_VLAN_HWCSUM);
                if ((mask & IFCAP_VLAN_HWTSO) != 0 &&
-                   (ifp->if_capabilities & IFCAP_VLAN_HWTSO) != 0)
-                       ifp->if_capenable ^= IFCAP_VLAN_HWTSO;
+                   (if_getcapabilities(ifp) & IFCAP_VLAN_HWTSO) != 0)
+                       if_togglecapenable(ifp, IFCAP_VLAN_HWTSO);
                if ((mask & IFCAP_VLAN_HWTAGGING) != 0 &&
-                   (ifp->if_capabilities & IFCAP_VLAN_HWTAGGING) != 0) {
-                       ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
-                       if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) == 0)
-                               ifp->if_capenable &=
-                                   ~(IFCAP_VLAN_HWTSO | IFCAP_VLAN_HWCSUM);
+                   (if_getcapabilities(ifp) & IFCAP_VLAN_HWTAGGING) != 0) {
+                       if_togglecapenable(ifp, IFCAP_VLAN_HWTAGGING);
+                       if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) == 0)
+                               if_setcapenablebit(ifp, 0, IFCAP_VLAN_HWTSO |
+                                   IFCAP_VLAN_HWCSUM);
                        reinit++;
                }
-               if (reinit > 0 && (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
-                       ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+               if (reinit > 0 &&
+                   (if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
+                       if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
                        fxp_init_body(sc, 0);
                }
                FXP_UNLOCK(sc);
-               VLAN_CAPABILITIES(ifp);
+               if_vlancap(ifp);
                break;
 
        default:
@@ -2975,24 +2982,15 @@ static int
 fxp_mc_addrs(struct fxp_softc *sc)
 {
        struct fxp_cb_mcs *mcsp = sc->mcsp;
-       struct ifnet *ifp = sc->ifp;
-       struct ifmultiaddr *ifma;
-       int nmcasts;
+       if_t ifp = sc->ifp;
+       int nmcasts = 0;
 
-       nmcasts = 0;
-       if ((ifp->if_flags & IFF_ALLMULTI) == 0) {
+       if ((if_getflags(ifp) & IFF_ALLMULTI) == 0) {
                if_maddr_rlock(ifp);
-               TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-                       if (ifma->ifma_addr->sa_family != AF_LINK)
-                               continue;
-                       if (nmcasts >= MAXMCADDR) {
-                               ifp->if_flags |= IFF_ALLMULTI;
-                               nmcasts = 0;
-                               break;
-                       }
-                       bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-                           &sc->mcsp->mc_addr[nmcasts][0], ETHER_ADDR_LEN);
-                       nmcasts++;
+               if_setupmultiaddr(ifp, mcsp->mc_addr, &nmcasts, MAXMCADDR);
+               if (nmcasts >= MAXMCADDR) {
+                       if_setflagbits(ifp, IFF_ALLMULTI, 0);
+                       nmcasts = 0;
                }
                if_maddr_runlock(ifp);
        }
diff --git a/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxpreg.h 
b/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxpreg.h
index 7fd60af..7ee8588 100644
--- a/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxpreg.h
+++ b/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxpreg.h
@@ -28,8 +28,6 @@
  * $FreeBSD$
  */
 
-#define FXP_VENDORID_INTEL     0x8086
-
 #define FXP_PCI_MMBA   0x10
 #define FXP_PCI_IOBA   0x14
 
diff --git a/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxpvar.h 
b/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxpvar.h
index 253c4ff..78200ce 100644
--- a/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxpvar.h
+++ b/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/if_fxpvar.h
@@ -143,7 +143,8 @@ struct fxp_desc_list {
 };
 
 struct fxp_ident {
-       uint16_t        devid;
+       uint16_t        vendor;
+       uint16_t        device;
        int16_t         revid;          /* -1 matches anything */
        uint8_t         ich;
        const char      *name;
@@ -178,7 +179,7 @@ struct fxp_hwstats {
  *      for functional grouping.
  */
 struct fxp_softc {
-       struct ifnet *ifp;              /* per-interface network data */
+       void *ifp;                      /* per-interface network data */
        struct resource *fxp_res[2];    /* I/O and IRQ resources */
        struct resource_spec *fxp_spec; /* the resource spec we used */
        void *ih;                       /* interrupt handler cookie */
diff --git a/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/inphy.c 
b/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/inphy.c
index 587f3fd..8a9a60c 100644
--- a/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/inphy.c
+++ b/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/inphy.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 
 #include <net/if.h>
+#include <net/if_var.h>
 #include <net/if_media.h>
 
 #include <dev/mii/mii.h>
@@ -121,7 +122,7 @@ inphy_service(struct mii_softc *sc, struct mii_data *mii, 
int cmd)
                /*
                 * If the interface is not up, don't do anything.
                 */
-               if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
+               if ((if_getflags(mii->mii_ifp) & IFF_UP) == 0)
                        break;
 
                mii_phy_setmedia(sc);
diff --git a/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/rcvbundl.h 
b/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/rcvbundl.h
index 2510f42..dac793d 100644
--- a/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/rcvbundl.h
+++ b/src/add-ons/kernel/drivers/network/ipro100/dev/fxp/rcvbundl.h
@@ -62,7 +62,7 @@ rcvbundl.h file given above).
 *  driver can change algorithm.
 *
 *  CPUSAVER_DWORD - This is the location of the instruction that loads
-*    the dead-man timer with its inital value.  By writing a 16-bit
+*    the dead-man timer with its initial value.  By writing a 16-bit
 *    value to the low word of this instruction, the driver can change
 *    the timer value.  The current default is either x600 or x800;
 *    experiments show that the value probably should stay within the

############################################################################

Commit:      ad7432f214d3813d32d73adb4543e041fabf82d9
URL:         http://cgit.haiku-os.org/haiku/commit/?id=ad7432f214d3
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Sat Nov 18 17:44:18 2017 UTC

freebsd11_network: adapt code based on needs of the pcnet R11.1 driver.

----------------------------------------------------------------------------

diff --git a/src/libs/compat/freebsd11_network/compat/sys/mbuf.h 
b/src/libs/compat/freebsd11_network/compat/sys/mbuf.h
index 8c6e6c5..e5eb5b2 100644
--- a/src/libs/compat/freebsd11_network/compat/sys/mbuf.h
+++ b/src/libs/compat/freebsd11_network/compat/sys/mbuf.h
@@ -151,7 +151,7 @@ void                        m_adj(struct mbuf*, int);
 void                   m_align(struct mbuf*, int);
 int                            m_append(struct mbuf*, int, c_caddr_t);
 void                   m_cat(struct mbuf*, struct mbuf*);
-void                   m_clget(struct mbuf*, int);
+int                            m_clget(struct mbuf*, int);
 void*                  m_cljget(struct mbuf*, int, int);
 struct mbuf*   m_collapse(struct mbuf*, int, int);
 void                   m_copyback(struct mbuf*, int, int, caddr_t);
diff --git a/src/libs/compat/freebsd11_network/mbuf.c 
b/src/libs/compat/freebsd11_network/mbuf.c
index 22e30ef..aa0eca4 100644
--- a/src/libs/compat/freebsd11_network/mbuf.c
+++ b/src/libs/compat/freebsd11_network/mbuf.c
@@ -177,12 +177,13 @@ m_getjcl(int how, short type, int flags, int size)
 }
 
 
-void
+int
 m_clget(struct mbuf *memoryBuffer, int how)
 {
        memoryBuffer->m_ext.ext_buf = NULL;
        /* called checks for errors by looking for M_EXT */
        construct_ext_mbuf(memoryBuffer, how);
+       return memoryBuffer->m_flags & M_EXT;
 }
 
 

############################################################################

Revision:    hrev51561
Commit:      dcdad04383dd2a5ee386805667f5c767138d1130
URL:         http://cgit.haiku-os.org/haiku/commit/?id=dcdad04383dd
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Sat Nov 18 17:45:37 2017 UTC

pcnet: Update with the 11.1 release of the le/pcn driver.

* switch compat layer.
* tested on Qemu, model=pcnet.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/drivers/network/pcnet/dev/le/Jamfile 
b/src/add-ons/kernel/drivers/network/pcnet/dev/le/Jamfile
index e9b3c36..77a23ba 100644
--- a/src/add-ons/kernel/drivers/network/pcnet/dev/le/Jamfile
+++ b/src/add-ons/kernel/drivers/network/pcnet/dev/le/Jamfile
@@ -1,8 +1,8 @@
 SubDir HAIKU_TOP src add-ons kernel drivers network pcnet dev le ;
 
 UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ;
-UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network ] : true ;
-UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : 
true ;
+UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_network ] : true ;
+UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_network compat ] 
: true ;
 
 UsePrivateHeaders net system ;
 UsePrivateKernelHeaders ;
@@ -15,5 +15,5 @@ KernelAddon pcnet :
        if_le_pci.c
        lance.c
        glue.c
-       : libfreebsd_network.a pcnet_pcn.a pcnet_mii.a
+       : pcnet_pcn.a pcnet_mii.a libfreebsd11_network.a
        ;
diff --git a/src/add-ons/kernel/drivers/network/pcnet/dev/le/am7990.c 
b/src/add-ons/kernel/drivers/network/pcnet/dev/le/am7990.c
index d74d3b8..32c2e1e 100644
--- a/src/add-ons/kernel/drivers/network/pcnet/dev/le/am7990.c
+++ b/src/add-ons/kernel/drivers/network/pcnet/dev/le/am7990.c
@@ -272,7 +272,7 @@ am7990_rint(struct lance_softc *sc)
                        bix = 0;
 
                if (m != NULL) {
-                       ifp->if_ipackets++;
+                       if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
 
 #ifdef LANCE_REVC_BUG
                        /*
@@ -296,7 +296,7 @@ am7990_rint(struct lance_softc *sc)
                        (*ifp->if_input)(ifp, m);
                        LE_LOCK(sc);
                } else
-                       ifp->if_ierrors++;
+                       if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
        }
 
        sc->sc_last_rd = bix;
@@ -352,22 +352,22 @@ am7990_tint(struct lance_softc *sc)
                                        if_printf(ifp, "lost carrier\n");
                        }
                        if (tmd.tmd3 & LE_T3_LCOL)
-                               ifp->if_collisions++;
+                               if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
                        if (tmd.tmd3 & LE_T3_RTRY) {
 #ifdef LEDEBUG
                                if_printf(ifp, "excessive collisions, tdr %d\n",
                                    tmd.tmd3 & LE_T3_TDR_MASK);
 #endif
-                               ifp->if_collisions += 16;
+                               if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 16);
                        }
-                       ifp->if_oerrors++;
+                       if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
                } else {
                        if (tmd.tmd1_bits & LE_T1_ONE)
-                               ifp->if_collisions++;
+                               if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
                        else if (tmd.tmd1_bits & LE_T1_MORE)
                                /* Real number is unknown. */
-                               ifp->if_collisions += 2;
-                       ifp->if_opackets++;
+                               if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 2);
+                       if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
                }
 
                if (++bix == sc->sc_ntbuf)
@@ -394,7 +394,7 @@ am7990_intr(void *arg)
        LE_LOCK(sc);
 
        if (sc->sc_hwintr && (*sc->sc_hwintr)(sc) == -1) {
-               ifp->if_ierrors++;
+               if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
                lance_init_locked(sc);
                LE_UNLOCK(sc);
                return;
@@ -426,19 +426,19 @@ am7990_intr(void *arg)
 #ifdef LEDEBUG
                        if_printf(ifp, "babble\n");
 #endif
-                       ifp->if_oerrors++;
+                       if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
                }
 #if 0
                if (isr & LE_C0_CERR) {
                        if_printf(ifp, "collision error\n");
-                       ifp->if_collisions++;
+                       if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
                }
 #endif
                if (isr & LE_C0_MISS) {
 #ifdef LEDEBUG
                        if_printf(ifp, "missed packet\n");
 #endif
-                       ifp->if_ierrors++;
+                       if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
                }
                if (isr & LE_C0_MERR) {
                        if_printf(ifp, "memory error\n");
@@ -450,14 +450,14 @@ am7990_intr(void *arg)
 
        if ((isr & LE_C0_RXON) == 0) {
                if_printf(ifp, "receiver disabled\n");
-               ifp->if_ierrors++;
+               if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
                lance_init_locked(sc);
                LE_UNLOCK(sc);
                return;
        }
        if ((isr & LE_C0_TXON) == 0) {
                if_printf(ifp, "transmitter disabled\n");
-               ifp->if_oerrors++;
+               if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
                lance_init_locked(sc);
                LE_UNLOCK(sc);
                return;
@@ -519,7 +519,7 @@ am7990_start_locked(struct lance_softc *sc)
                }
 
                IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
-               if (m == 0)
+               if (m == NULL)
                        break;
 
                /*
diff --git a/src/add-ons/kernel/drivers/network/pcnet/dev/le/am79900.c 
b/src/add-ons/kernel/drivers/network/pcnet/dev/le/am79900.c
index a31fe70..a423be6 100644
--- a/src/add-ons/kernel/drivers/network/pcnet/dev/le/am79900.c
+++ b/src/add-ons/kernel/drivers/network/pcnet/dev/le/am79900.c
@@ -313,7 +313,7 @@ am79900_rint(struct lance_softc *sc)
                        bix = 0;
 
                if (m != NULL) {
-                       ifp->if_ipackets++;
+                       if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
 
 #if defined(__i386__) && !defined(PC98)
                        /*
@@ -333,7 +333,7 @@ am79900_rint(struct lance_softc *sc)
                        (*ifp->if_input)(ifp, m);
                        LE_LOCK(sc);
                } else
-                       ifp->if_ierrors++;
+                       if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
        }
 
        sc->sc_last_rd = bix;
@@ -391,21 +391,21 @@ am79900_tint(struct lance_softc *sc)
                                        if_printf(ifp, "lost carrier\n");
                        }
                        if (tmd2 & LE_T2_LCOL)
-                               ifp->if_collisions++;
+                               if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
                        if (tmd2 & LE_T2_RTRY) {
 #ifdef LEDEBUG
                                if_printf(ifp, "excessive collisions\n");
 #endif
-                               ifp->if_collisions += 16;
+                               if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 16);
                        }
-                       ifp->if_oerrors++;
+                       if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
                } else {
                        if (tmd1 & LE_T1_ONE)
-                               ifp->if_collisions++;
+                               if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
                        else if (tmd1 & LE_T1_MORE)
                                /* Real number is unknown. */
-                               ifp->if_collisions += 2;
-                       ifp->if_opackets++;
+                               if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 2);
+                       if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
                }
 
                if (++bix == sc->sc_ntbuf)
@@ -432,7 +432,7 @@ am79900_intr(void *arg)
        LE_LOCK(sc);
 
        if (sc->sc_hwintr && (*sc->sc_hwintr)(sc) == -1) {
-               ifp->if_ierrors++;
+               if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
                lance_init_locked(sc);
                LE_UNLOCK(sc);
                return;
@@ -474,19 +474,19 @@ am79900_intr(void *arg)
 #ifdef LEDEBUG
                        if_printf(ifp, "babble\n");
 #endif
-                       ifp->if_oerrors++;
+                       if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
                }
 #if 0
                if (isr & LE_C0_CERR) {
                        if_printf(ifp, "collision error\n");
-                       ifp->if_collisions++;
+                       if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
                }
 #endif
                if (isr & LE_C0_MISS) {
 #ifdef LEDEBUG
                        if_printf(ifp, "missed packet\n");
 #endif
-                       ifp->if_ierrors++;
+                       if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
                }
                if (isr & LE_C0_MERR) {
                        if_printf(ifp, "memory error\n");
@@ -498,14 +498,14 @@ am79900_intr(void *arg)
 
        if ((isr & LE_C0_RXON) == 0) {
                if_printf(ifp, "receiver disabled\n");
-               ifp->if_ierrors++;
+               if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
                lance_init_locked(sc);
                LE_UNLOCK(sc);
                return;
        }
        if ((isr & LE_C0_TXON) == 0) {
                if_printf(ifp, "transmitter disabled\n");
-               ifp->if_oerrors++;
+               if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
                lance_init_locked(sc);
                LE_UNLOCK(sc);
                return;
@@ -567,7 +567,7 @@ am79900_start_locked(struct lance_softc *sc)
                }
 
                IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
-               if (m == 0)
+               if (m == NULL)
                        break;
 
                /*
diff --git a/src/add-ons/kernel/drivers/network/pcnet/dev/le/if_le_ledma.c 
b/src/add-ons/kernel/drivers/network/pcnet/dev/le/if_le_ledma.c
index 7b09366..e86f947 100644
--- a/src/add-ons/kernel/drivers/network/pcnet/dev/le/if_le_ledma.c
+++ b/src/add-ons/kernel/drivers/network/pcnet/dev/le/if_le_ledma.c
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
 
 #include <net/ethernet.h>
 #include <net/if.h>
+#include <net/if_var.h>
 #include <net/if_media.h>
 
 #include <sparc64/sbus/lsi64854reg.h>
@@ -387,7 +388,7 @@ le_dma_attach(device_t dev)
        sc->sc_mediachange = le_dma_supmediachange;
        sc->sc_mediastatus = le_dma_supmediastatus;
        sc->sc_supmedia = le_dma_supmedia;
-       sc->sc_nsupmedia = sizeof(le_dma_supmedia) / sizeof(le_dma_supmedia[0]);
+       sc->sc_nsupmedia = nitems(le_dma_supmedia);
        sc->sc_defaultmedia = le_dma_supmedia[0];
 
        OF_getetheraddr(dev, sc->sc_enaddr);
diff --git a/src/add-ons/kernel/drivers/network/pcnet/dev/le/lance.c 
b/src/add-ons/kernel/drivers/network/pcnet/dev/le/lance.c
index da433a7..2eee7af 100644
--- a/src/add-ons/kernel/drivers/network/pcnet/dev/le/lance.c
+++ b/src/add-ons/kernel/drivers/network/pcnet/dev/le/lance.c
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/endian.h>
 #include <sys/lock.h>
 #include <sys/kernel.h>
+#include <sys/malloc.h>
 #include <sys/mbuf.h>
 #include <sys/mutex.h>
 #include <sys/socket.h>
@@ -79,6 +80,7 @@ __FBSDID("$FreeBSD$");
 
 #include <net/ethernet.h>
 #include <net/if.h>
+#include <net/if_var.h>
 #include <net/if_arp.h>
 #include <net/if_dl.h>
 #include <net/if_media.h>
@@ -195,7 +197,7 @@ lance_attach(struct lance_softc *sc)
        ether_ifattach(ifp, sc->sc_enaddr);
 
        /* Claim 802.1q capability. */
-       ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
+       ifp->if_hdrlen = sizeof(struct ether_vlan_header);
        ifp->if_capabilities |= IFCAP_VLAN_MTU;
        ifp->if_capenable |= IFCAP_VLAN_MTU;
 }
@@ -397,8 +399,7 @@ lance_get(struct lance_softc *sc, int boff, int totlen)
 
        while (totlen > 0) {
                if (totlen >= MINCLSIZE) {
-                       MCLGET(m, M_NOWAIT);
-                       if ((m->m_flags & M_EXT) == 0)
+                       if (!(MCLGET(m, M_NOWAIT)))
                                goto bad;
                        len = MCLBYTES;
                }
@@ -417,7 +418,7 @@ lance_get(struct lance_softc *sc, int boff, int totlen)
                totlen -= len;
                if (totlen > 0) {
                        MGET(newm, M_NOWAIT, MT_DATA);
-                       if (newm == 0)
+                       if (newm == NULL)
                                goto bad;
                        len = MLEN;
                        m = m->m_next = newm;
@@ -445,7 +446,7 @@ lance_watchdog(void *xsc)
        }
 
        if_printf(ifp, "device timeout\n");
-       ++ifp->if_oerrors;
+       if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
        lance_init_locked(sc);
 }
 
diff --git a/src/add-ons/kernel/drivers/network/pcnet/dev/mii/Jamfile 
b/src/add-ons/kernel/drivers/network/pcnet/dev/mii/Jamfile
index 00cd28b..4b5bb38 100644
--- a/src/add-ons/kernel/drivers/network/pcnet/dev/mii/Jamfile
+++ b/src/add-ons/kernel/drivers/network/pcnet/dev/mii/Jamfile
@@ -1,7 +1,7 @@
 SubDir HAIKU_TOP src add-ons kernel drivers network pcnet dev mii ;
 
 UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ;
-UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : 
true ;
+UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_network compat ] 
: true ;
 
 UsePrivateHeaders net system ;
 UsePrivateKernelHeaders ;
@@ -18,6 +18,6 @@ KernelStaticLibrary pcnet_mii.a
 
 ObjectHdrs [ FGristFiles nsphy$(SUFOBJ) nsphyter$(SUFOBJ) ]
        : [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR_$(TARGET_PACKAGING_ARCH)) 
libs
-               compat freebsd_network ] ;
+               compat freebsd11_network ] ;
 Includes [ FGristFiles nsphy.c nsphyter.c ]
-       : <src!libs!compat!freebsd_network>miidevs.h ;
+       : <src!libs!compat!freebsd11_network>miidevs.h ;
diff --git a/src/add-ons/kernel/drivers/network/pcnet/dev/mii/nsphy.c 
b/src/add-ons/kernel/drivers/network/pcnet/dev/mii/nsphy.c
index 01cd31d..748e02a 100644
--- a/src/add-ons/kernel/drivers/network/pcnet/dev/mii/nsphy.c
+++ b/src/add-ons/kernel/drivers/network/pcnet/dev/mii/nsphy.c
@@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 
 #include <net/if.h>
+#include <net/if_var.h>
 #include <net/if_media.h>
 
 #include <dev/mii/mii.h>
@@ -128,15 +129,13 @@ nsphy_probe(device_t dev)
 static int
 nsphy_attach(device_t dev)
 {
-       const char *nic;
        u_int flags;
 
-       nic = device_get_name(device_get_parent(device_get_parent(dev)));
        flags = MIIF_NOMANPAUSE;
        /*
         * Am79C971 wedge when isolating all of their external PHYs.
         */
-       if (strcmp(nic, "pcn") == 0)
+       if (mii_dev_mac_match(dev,"pcn"))
                flags |= MIIF_NOISOLATE;
        mii_phy_dev_attach(dev, flags, &nsphy_funcs, 1);
        return (0);
@@ -152,12 +151,6 @@ nsphy_service(struct mii_softc *sc, struct mii_data *mii, 
int cmd)
                break;
 
        case MII_MEDIACHG:
-               /*
-                * If the interface is not up, don't do anything.
-                */
-               if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
-                       break;
-
                reg = PHY_READ(sc, MII_NSPHY_PCR);
 
                /*
@@ -191,7 +184,7 @@ nsphy_service(struct mii_softc *sc, struct mii_data *mii, 
int cmd)
                 */
                reg |= 0x0100 | 0x0400;
 
-               if (strcmp(mii->mii_ifp->if_dname, "fxp") == 0)
+               if (mii_phy_mac_match(sc, "fxp"))
                        PHY_WRITE(sc, MII_NSPHY_PCR, reg);
 
                mii_phy_setmedia(sc);
diff --git a/src/add-ons/kernel/drivers/network/pcnet/dev/mii/nsphyter.c 
b/src/add-ons/kernel/drivers/network/pcnet/dev/mii/nsphyter.c
index dabb156..00c0550 100644
--- a/src/add-ons/kernel/drivers/network/pcnet/dev/mii/nsphyter.c
+++ b/src/add-ons/kernel/drivers/network/pcnet/dev/mii/nsphyter.c
@@ -149,12 +149,6 @@ nsphyter_service(struct mii_softc *sc, struct mii_data 
*mii, int cmd)
                break;
 
        case MII_MEDIACHG:
-               /*
-                * If the interface is not up, don't do anything.
-                */
-               if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
-                       break;
-
                mii_phy_setmedia(sc);
                break;
 
diff --git a/src/add-ons/kernel/drivers/network/pcnet/dev/mii/ukphy.c 
b/src/add-ons/kernel/drivers/network/pcnet/dev/mii/ukphy.c
index 9d52eb5..45addcb 100644
--- a/src/add-ons/kernel/drivers/network/pcnet/dev/mii/ukphy.c
+++ b/src/add-ons/kernel/drivers/network/pcnet/dev/mii/ukphy.c
@@ -140,12 +140,6 @@ ukphy_service(struct mii_softc *sc, struct mii_data *mii, 
int cmd)
                break;
 
        case MII_MEDIACHG:
-               /*
-                * If the interface is not up, don't do anything.
-                */
-               if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
-                       break;
-
                mii_phy_setmedia(sc);
                break;
 
diff --git a/src/add-ons/kernel/drivers/network/pcnet/dev/pcn/Jamfile 
b/src/add-ons/kernel/drivers/network/pcnet/dev/pcn/Jamfile
index c99ef08..2e26dc6 100644
--- a/src/add-ons/kernel/drivers/network/pcnet/dev/pcn/Jamfile
+++ b/src/add-ons/kernel/drivers/network/pcnet/dev/pcn/Jamfile
@@ -1,7 +1,7 @@
 SubDir HAIKU_TOP src add-ons kernel drivers network pcnet dev pcn ;
 
 UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ;
-UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : 
true ;
+UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_network compat ] 
: true ;
 
 UsePrivateHeaders net system ;
 UsePrivateKernelHeaders ;
diff --git a/src/add-ons/kernel/drivers/network/pcnet/dev/pcn/if_pcn.c 
b/src/add-ons/kernel/drivers/network/pcnet/dev/pcn/if_pcn.c
index d7e3d2e..d63d4aa 100644
--- a/src/add-ons/kernel/drivers/network/pcnet/dev/pcn/if_pcn.c
+++ b/src/add-ons/kernel/drivers/network/pcnet/dev/pcn/if_pcn.c
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/socket.h>
 
 #include <net/if.h>
+#include <net/if_var.h>
 #include <net/if_arp.h>
 #include <net/ethernet.h>
 #include <net/if_dl.h>
@@ -802,8 +803,7 @@ pcn_newbuf(sc, idx, m)
                if (m_new == NULL)
                        return(ENOBUFS);
 
-               MCLGET(m_new, M_NOWAIT);
-               if (!(m_new->m_flags & M_EXT)) {
+               if (!(MCLGET(m_new, M_NOWAIT))) {
                        m_freem(m_new);
                        return(ENOBUFS);
                }
@@ -855,7 +855,7 @@ pcn_rxeof(sc)
                 * comes up in the ring.
                 */
                if (cur_rx->pcn_rxstat & PCN_RXSTAT_ERR) {
-                       ifp->if_ierrors++;
+                       if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
                        pcn_newbuf(sc, i, m);
                        PCN_INC(i, PCN_RX_LIST_CNT);
                        continue;
@@ -864,7 +864,7 @@ pcn_rxeof(sc)
                if (pcn_newbuf(sc, i, NULL)) {
                        /* Ran out of mbufs; recycle this one. */
                        pcn_newbuf(sc, i, m);
-                       ifp->if_ierrors++;
+                       if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
                        PCN_INC(i, PCN_RX_LIST_CNT);
                        continue;
                }
@@ -872,7 +872,7 @@ pcn_rxeof(sc)
                PCN_INC(i, PCN_RX_LIST_CNT);
 
                /* No errors; receive the packet. */
-               ifp->if_ipackets++;
+               if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
                m->m_len = m->m_pkthdr.len =
                    cur_rx->pcn_rxlen - ETHER_CRC_LEN;
                m->m_pkthdr.rcvif = ifp;
@@ -920,17 +920,17 @@ pcn_txeof(sc)
                }
 
                if (cur_tx->pcn_txctl & PCN_TXCTL_ERR) {
-                       ifp->if_oerrors++;
+                       if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
                        if (cur_tx->pcn_txstat & PCN_TXSTAT_EXDEF)
-                               ifp->if_collisions++;
+                               if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
                        if (cur_tx->pcn_txstat & PCN_TXSTAT_RTRY)
-                               ifp->if_collisions++;
+                               if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
                }
 
-               ifp->if_collisions +=
-                   cur_tx->pcn_txstat & PCN_TXSTAT_TRC;
+               if_inc_counter(ifp, IFCOUNTER_COLLISIONS,
+                   cur_tx->pcn_txstat & PCN_TXSTAT_TRC);
 
-               ifp->if_opackets++;
+               if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
                if (sc->pcn_cdata.pcn_tx_chain[idx] != NULL) {
                        m_freem(sc->pcn_cdata.pcn_tx_chain[idx]);
                        sc->pcn_cdata.pcn_tx_chain[idx] = NULL;
@@ -966,7 +966,7 @@ pcn_tick(xsc)
        mii_tick(mii);
 
        /* link just died */
-       if (sc->pcn_link & !(mii->mii_media_status & IFM_ACTIVE))
+       if (sc->pcn_link && !(mii->mii_media_status & IFM_ACTIVE))
                sc->pcn_link = 0;
 
        /* link just came up, restart */
@@ -1435,7 +1435,7 @@ pcn_watchdog(struct pcn_softc *sc)
        PCN_LOCK_ASSERT(sc);
        ifp = sc->pcn_ifp;
 
-       ifp->if_oerrors++;
+       if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
        if_printf(ifp, "watchdog timeout\n");
 
        pcn_stop(sc);


Other related posts: