summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/dev/e1000/if_em.c445
-rw-r--r--sys/dev/e1000/if_em.h2
-rw-r--r--sys/dev/e1000/if_lem.c371
-rw-r--r--sys/dev/e1000/if_lem.h2
4 files changed, 373 insertions, 447 deletions
diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 428612a..3ac5245 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -202,20 +202,20 @@ static int em_shutdown(device_t);
static int em_suspend(device_t);
static int em_resume(device_t);
#ifdef EM_MULTIQUEUE
-static int em_mq_start(struct ifnet *, struct mbuf *);
-static int em_mq_start_locked(struct ifnet *,
+static int em_mq_start(if_t, struct mbuf *);
+static int em_mq_start_locked(if_t,
struct tx_ring *, struct mbuf *);
-static void em_qflush(struct ifnet *);
+static void em_qflush(if_t);
#else
-static void em_start(struct ifnet *);
-static void em_start_locked(struct ifnet *, struct tx_ring *);
+static void em_start(if_t);
+static void em_start_locked(if_t, struct tx_ring *);
#endif
-static int em_ioctl(struct ifnet *, u_long, caddr_t);
+static int em_ioctl(if_t, u_long, caddr_t);
static void em_init(void *);
static void em_init_locked(struct adapter *);
static void em_stop(void *);
-static void em_media_status(struct ifnet *, struct ifmediareq *);
-static int em_media_change(struct ifnet *);
+static void em_media_status(if_t, struct ifmediareq *);
+static int em_media_change(if_t);
static void em_identify_hardware(struct adapter *);
static int em_allocate_pci_resources(struct adapter *);
static int em_allocate_legacy(struct adapter *);
@@ -258,8 +258,8 @@ static void em_disable_promisc(struct adapter *);
static void em_set_multi(struct adapter *);
static void em_update_link_status(struct adapter *);
static void em_refresh_mbufs(struct rx_ring *, int);
-static void em_register_vlan(void *, struct ifnet *, u16);
-static void em_unregister_vlan(void *, struct ifnet *, u16);
+static void em_register_vlan(void *, if_t, u16);
+static void em_unregister_vlan(void *, if_t, u16);
static void em_setup_vlan_hw_support(struct adapter *);
static int em_xmit(struct tx_ring *, struct mbuf **);
static int em_dma_malloc(struct adapter *, bus_size_t,
@@ -302,7 +302,7 @@ static int em_sysctl_eee(SYSCTL_HANDLER_ARGS);
static __inline void em_rx_discard(struct rx_ring *, int);
#ifdef DEVICE_POLLING
-static poll_handler_t em_poll;
+static poll_handler_drv_t em_poll;
#endif /* POLLING */
/*********************************************************************
@@ -738,8 +738,7 @@ em_attach(device_t dev)
em_get_hw_control(adapter);
/* Tell the stack that the interface is not active */
- adapter->ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
- adapter->ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+ if_setdrvflagbits(adapter->ifp, IFF_DRV_OACTIVE, IFF_DRV_RUNNING);
adapter->led_dev = led_create(em_led_func, adapter,
device_get_nameunit(dev));
@@ -755,8 +754,8 @@ err_late:
em_free_transmit_structures(adapter);
em_free_receive_structures(adapter);
em_release_hw_control(adapter);
- if (adapter->ifp != NULL)
- if_free(adapter->ifp);
+ if (adapter->ifp != (void *)NULL)
+ if_free_drv(adapter->ifp);
err_pci:
em_free_pci_resources(adapter);
free(adapter->mta, M_DEVBUF);
@@ -779,19 +778,19 @@ static int
em_detach(device_t dev)
{
struct adapter *adapter = device_get_softc(dev);
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
INIT_DEBUGOUT("em_detach: begin");
/* Make sure VLANS are not using driver */
- if (adapter->ifp->if_vlantrunk != NULL) {
+ if (if_vlantrunkinuse(ifp)) {
device_printf(dev,"Vlan in use, detach first\n");
return (EBUSY);
}
#ifdef DEVICE_POLLING
- if (ifp->if_capenable & IFCAP_POLLING)
- ether_poll_deregister(ifp);
+ if (if_getcapenable(ifp) & IFCAP_POLLING)
+ ether_poll_deregister_drv(ifp);
#endif
if (adapter->led_dev != NULL)
@@ -814,7 +813,7 @@ em_detach(device_t dev)
if (adapter->vlan_detach != NULL)
EVENTHANDLER_DEREGISTER(vlan_unconfig, adapter->vlan_detach);
- ether_ifdetach(adapter->ifp);
+ ether_ifdetach_drv(adapter->ifp);
callout_drain(&adapter->timer);
#ifdef DEV_NETMAP
@@ -823,7 +822,7 @@ em_detach(device_t dev)
em_free_pci_resources(adapter);
bus_generic_detach(dev);
- if_free(ifp);
+ if_free_drv(ifp);
em_free_transmit_structures(adapter);
em_free_receive_structures(adapter);
@@ -870,7 +869,7 @@ em_resume(device_t dev)
{
struct adapter *adapter = device_get_softc(dev);
struct tx_ring *txr = adapter->tx_rings;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
EM_CORE_LOCK(adapter);
if (adapter->hw.mac.type == e1000_pch2lan)
@@ -878,15 +877,15 @@ em_resume(device_t dev)
em_init_locked(adapter);
em_init_manageability(adapter);
- if ((ifp->if_flags & IFF_UP) &&
- (ifp->if_drv_flags & IFF_DRV_RUNNING) && adapter->link_active) {
+ if ((if_getflags(ifp) & IFF_UP) &&
+ (if_getdrvflags(ifp) & IFF_DRV_RUNNING) && adapter->link_active) {
for (int i = 0; i < adapter->num_queues; i++, txr++) {
EM_TX_LOCK(txr);
#ifdef EM_MULTIQUEUE
if (!drbr_empty(ifp, txr->br))
em_mq_start_locked(ifp, txr, NULL);
#else
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if (!if_sendq_empty(ifp))
em_start_locked(ifp, txr);
#endif
EM_TX_UNLOCK(txr);
@@ -908,13 +907,13 @@ em_resume(device_t dev)
* in this driver, rather than also having multiple tx queues.
**********************************************************************/
static int
-em_mq_start_locked(struct ifnet *ifp, struct tx_ring *txr, struct mbuf *m)
+em_mq_start_locked(if_t ifp, struct tx_ring *txr, struct mbuf *m)
{
struct adapter *adapter = txr->adapter;
struct mbuf *next;
int err = 0, enq = 0;
- if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
+ if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING || adapter->link_active == 0) {
if (m != NULL)
err = drbr_enqueue(ifp, txr->br, m);
@@ -939,11 +938,11 @@ em_mq_start_locked(struct ifnet *ifp, struct tx_ring *txr, struct mbuf *m)
}
drbr_advance(ifp, txr->br);
enq++;
- ifp->if_obytes += next->m_pkthdr.len;
+ if_incobytes(ifp, next->m_pkthdr.len);
if (next->m_flags & M_MCAST)
- ifp->if_omcasts++;
- ETHER_BPF_MTAP(ifp, next);
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+ if_incomcasts(ifp, 1);
+ if_etherbpfmtap(ifp, next);
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
break;
}
@@ -956,7 +955,7 @@ em_mq_start_locked(struct ifnet *ifp, struct tx_ring *txr, struct mbuf *m)
if (txr->tx_avail < EM_MAX_SCATTER)
em_txeof(txr);
if (txr->tx_avail < EM_MAX_SCATTER)
- ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, IFF_DRV_OACTIVE,0);
return (err);
}
@@ -964,9 +963,9 @@ em_mq_start_locked(struct ifnet *ifp, struct tx_ring *txr, struct mbuf *m)
** Multiqueue capable stack interface
*/
static int
-em_mq_start(struct ifnet *ifp, struct mbuf *m)
+em_mq_start(if_t ifp, struct mbuf *m)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
struct tx_ring *txr = adapter->tx_rings;
int error;
@@ -983,9 +982,9 @@ em_mq_start(struct ifnet *ifp, struct mbuf *m)
** Flush all ring buffers
*/
static void
-em_qflush(struct ifnet *ifp)
+em_qflush(if_t ifp)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
struct tx_ring *txr = adapter->tx_rings;
struct mbuf *m;
@@ -1000,29 +999,29 @@ em_qflush(struct ifnet *ifp)
#else /* !EM_MULTIQUEUE */
static void
-em_start_locked(struct ifnet *ifp, struct tx_ring *txr)
+em_start_locked(if_t ifp, struct tx_ring *txr)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
struct mbuf *m_head;
EM_TX_LOCK_ASSERT(txr);
- 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;
if (!adapter->link_active)
return;
- while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) {
+ while (!if_sendq_empty(ifp)) {
/* Call cleanup if number of TX descriptors low */
if (txr->tx_avail <= EM_TX_CLEANUP_THRESHOLD)
em_txeof(txr);
if (txr->tx_avail < EM_MAX_SCATTER) {
- ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp,IFF_DRV_OACTIVE, 0);
break;
}
- IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head);
+ m_head = if_dequeue(ifp);
if (m_head == NULL)
break;
/*
@@ -1032,12 +1031,12 @@ em_start_locked(struct ifnet *ifp, struct tx_ring *txr)
if (em_xmit(txr, &m_head)) {
if (m_head == NULL)
break;
- IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
+ if_sendq_prepend(ifp, m_head);
break;
}
/* Send a copy of the frame to the BPF listener */
- ETHER_BPF_MTAP(ifp, m_head);
+ if_etherbpfmtap(ifp, m_head);
/* Set timeout in case hardware has problems transmitting. */
txr->watchdog_time = ticks;
@@ -1048,12 +1047,12 @@ em_start_locked(struct ifnet *ifp, struct tx_ring *txr)
}
static void
-em_start(struct ifnet *ifp)
+em_start(if_t ifp)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
struct tx_ring *txr = adapter->tx_rings;
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
EM_TX_LOCK(txr);
em_start_locked(ifp, txr);
EM_TX_UNLOCK(txr);
@@ -1072,9 +1071,9 @@ em_start(struct ifnet *ifp)
**********************************************************************/
static int
-em_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
+em_ioctl(if_t ifp, u_long command, caddr_t data)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
struct ifreq *ifr = (struct ifreq *)data;
#if defined(INET) || defined(INET6)
struct ifaddr *ifa = (struct ifaddr *)data;
@@ -1100,15 +1099,15 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
** so we avoid doing it when possible.
*/
if (avoid_reset) {
- ifp->if_flags |= IFF_UP;
- if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
+ if_setflagbits(ifp,IFF_UP,0);
+ if (!(if_getdrvflags(ifp)& IFF_DRV_RUNNING))
em_init(adapter);
#ifdef INET
- if (!(ifp->if_flags & IFF_NOARP))
- arp_ifinit(ifp, ifa);
+ if (!(if_getflags(ifp) & IFF_NOARP))
+ arp_ifinit_drv(ifp, ifa);
#endif
} else
- error = ether_ioctl(ifp, command, data);
+ error = ether_ioctl_drv(ifp, command, data);
break;
case SIOCSIFMTU:
{
@@ -1146,9 +1145,9 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
break;
}
- ifp->if_mtu = ifr->ifr_mtu;
+ if_setmtu(ifp, ifr->ifr_mtu);
adapter->hw.mac.max_frame_size =
- ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+ if_getmtu(ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN;
em_init_locked(adapter);
EM_CORE_UNLOCK(adapter);
break;
@@ -1157,9 +1156,9 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
IOCTL_DEBUGOUT("ioctl rcv'd:\
SIOCSIFFLAGS (Set Interface Flags)");
EM_CORE_LOCK(adapter);
- if (ifp->if_flags & IFF_UP) {
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) {
- if ((ifp->if_flags ^ adapter->if_flags) &
+ if (if_getflags(ifp) & IFF_UP) {
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
+ if ((if_getflags(ifp) ^ adapter->if_flags) &
(IFF_PROMISC | IFF_ALLMULTI)) {
em_disable_promisc(adapter);
em_set_promisc(adapter);
@@ -1167,20 +1166,20 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
} else
em_init_locked(adapter);
} else
- if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
em_stop(adapter);
- adapter->if_flags = ifp->if_flags;
+ adapter->if_flags = if_getflags(ifp);
EM_CORE_UNLOCK(adapter);
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
IOCTL_DEBUGOUT("ioctl rcv'd: SIOC(ADD|DEL)MULTI");
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
EM_CORE_LOCK(adapter);
em_disable_intr(adapter);
em_set_multi(adapter);
#ifdef DEVICE_POLLING
- if (!(ifp->if_capenable & IFCAP_POLLING))
+ if (!(if_getcapenable(ifp) & IFCAP_POLLING))
#endif
em_enable_intr(adapter);
EM_CORE_UNLOCK(adapter);
@@ -1200,7 +1199,7 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
case SIOCGIFMEDIA:
IOCTL_DEBUGOUT("ioctl rcv'd: \
SIOCxIFMEDIA (Get/Set Interface Media)");
- error = ifmedia_ioctl(ifp, ifr, &adapter->media, command);
+ error = ifmedia_ioctl_drv(ifp, ifr, &adapter->media, command);
break;
case SIOCSIFCAP:
{
@@ -1208,62 +1207,62 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFCAP (Set Capabilities)");
reinit = 0;
- mask = ifr->ifr_reqcap ^ ifp->if_capenable;
+ mask = ifr->ifr_reqcap ^ if_getcapenable(ifp);
#ifdef DEVICE_POLLING
if (mask & IFCAP_POLLING) {
if (ifr->ifr_reqcap & IFCAP_POLLING) {
- error = ether_poll_register(em_poll, ifp);
+ error = ether_poll_register_drv(em_poll, ifp);
if (error)
return (error);
EM_CORE_LOCK(adapter);
em_disable_intr(adapter);
- ifp->if_capenable |= IFCAP_POLLING;
+ if_setcapenablebit(ifp, IFCAP_POLLING, 0);
EM_CORE_UNLOCK(adapter);
} else {
- error = ether_poll_deregister(ifp);
+ error = ether_poll_deregister_drv(ifp);
/* Enable interrupt even in error case */
EM_CORE_LOCK(adapter);
em_enable_intr(adapter);
- ifp->if_capenable &= ~IFCAP_POLLING;
+ if_setcapenablebit(ifp, 0, IFCAP_POLLING);
EM_CORE_UNLOCK(adapter);
}
}
#endif
if (mask & IFCAP_HWCSUM) {
- ifp->if_capenable ^= IFCAP_HWCSUM;
+ if_togglecapenable(ifp,IFCAP_HWCSUM);
reinit = 1;
}
if (mask & IFCAP_TSO4) {
- ifp->if_capenable ^= IFCAP_TSO4;
+ if_togglecapenable(ifp,IFCAP_TSO4);
reinit = 1;
}
if (mask & IFCAP_VLAN_HWTAGGING) {
- ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
+ if_togglecapenable(ifp,IFCAP_VLAN_HWTAGGING);
reinit = 1;
}
if (mask & IFCAP_VLAN_HWFILTER) {
- ifp->if_capenable ^= IFCAP_VLAN_HWFILTER;
+ if_togglecapenable(ifp, IFCAP_VLAN_HWFILTER);
reinit = 1;
}
if (mask & IFCAP_VLAN_HWTSO) {
- ifp->if_capenable ^= IFCAP_VLAN_HWTSO;
+ if_togglecapenable(ifp, IFCAP_VLAN_HWTSO);
reinit = 1;
}
if ((mask & IFCAP_WOL) &&
- (ifp->if_capabilities & IFCAP_WOL) != 0) {
+ (if_getcapabilities(ifp) & IFCAP_WOL) != 0) {
if (mask & IFCAP_WOL_MCAST)
- ifp->if_capenable ^= IFCAP_WOL_MCAST;
+ if_togglecapenable(ifp, IFCAP_WOL_MCAST);
if (mask & IFCAP_WOL_MAGIC)
- ifp->if_capenable ^= IFCAP_WOL_MAGIC;
+ if_togglecapenable(ifp, IFCAP_WOL_MAGIC);
}
- if (reinit && (ifp->if_drv_flags & IFF_DRV_RUNNING))
+ if (reinit && (if_getdrvflags(ifp) & IFF_DRV_RUNNING))
em_init(adapter);
- VLAN_CAPABILITIES(ifp);
+ if_vlancap(ifp);
break;
}
default:
- error = ether_ioctl(ifp, command, data);
+ error = ether_ioctl_drv(ifp, command, data);
break;
}
@@ -1285,7 +1284,7 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
static void
em_init_locked(struct adapter *adapter)
{
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
device_t dev = adapter->dev;
INIT_DEBUGOUT("em_init: begin");
@@ -1296,7 +1295,7 @@ em_init_locked(struct adapter *adapter)
callout_stop(&adapter->timer);
/* Get the latest mac address, User can use a LAA */
- bcopy(IF_LLADDR(adapter->ifp), adapter->hw.mac.addr,
+ bcopy(if_getlladdr(adapter->ifp), adapter->hw.mac.addr,
ETHER_ADDR_LEN);
/* Put the address into the Receive Address Array */
@@ -1322,11 +1321,11 @@ em_init_locked(struct adapter *adapter)
E1000_WRITE_REG(&adapter->hw, E1000_VET, ETHERTYPE_VLAN);
/* Set hardware offload abilities */
- ifp->if_hwassist = 0;
- if (ifp->if_capenable & IFCAP_TXCSUM)
- ifp->if_hwassist |= (CSUM_TCP | CSUM_UDP);
- if (ifp->if_capenable & IFCAP_TSO4)
- ifp->if_hwassist |= CSUM_TSO;
+ if_clearhwassist(ifp);
+ if (if_getcapenable(ifp) & IFCAP_TXCSUM)
+ if_sethwassistbits(ifp, CSUM_TCP | CSUM_UDP, 0);
+ if (if_getcapenable(ifp) & IFCAP_TSO4)
+ if_sethwassistbits(ifp, CSUM_TSO, 0);
/* Configure for OS presence */
em_init_manageability(adapter);
@@ -1358,8 +1357,8 @@ em_init_locked(struct adapter *adapter)
em_initialize_receive_unit(adapter);
/* Use real VLAN Filter support? */
- if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) {
- if (ifp->if_capenable & IFCAP_VLAN_HWFILTER)
+ if (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) {
+ if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER)
/* Use real VLAN Filter support */
em_setup_vlan_hw_support(adapter);
else {
@@ -1374,8 +1373,7 @@ em_init_locked(struct adapter *adapter)
em_set_promisc(adapter);
/* Set the interface as ACTIVE */
- ifp->if_drv_flags |= IFF_DRV_RUNNING;
- ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE);
callout_reset(&adapter->timer, hz, em_local_timer, adapter);
e1000_clear_hw_cntrs_base_generic(&adapter->hw);
@@ -1395,7 +1393,7 @@ em_init_locked(struct adapter *adapter)
* Only enable interrupts if we are not polling, make sure
* they are off otherwise.
*/
- if (ifp->if_capenable & IFCAP_POLLING)
+ if (if_getcapenable(ifp) & IFCAP_POLLING)
em_disable_intr(adapter);
else
#endif /* DEVICE_POLLING */
@@ -1424,16 +1422,16 @@ em_init(void *arg)
*
*********************************************************************/
static int
-em_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
+em_poll(if_t ifp, enum poll_cmd cmd, int count)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
struct tx_ring *txr = adapter->tx_rings;
struct rx_ring *rxr = adapter->rx_rings;
u32 reg_icr;
int rx_done;
EM_CORE_LOCK(adapter);
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) {
EM_CORE_UNLOCK(adapter);
return (0);
}
@@ -1458,7 +1456,7 @@ em_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
if (!drbr_empty(ifp, txr->br))
em_mq_start_locked(ifp, txr, NULL);
#else
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if (!if_sendq_empty(ifp))
em_start_locked(ifp, txr);
#endif
EM_TX_UNLOCK(txr);
@@ -1477,7 +1475,7 @@ static int
em_irq_fast(void *arg)
{
struct adapter *adapter = arg;
- struct ifnet *ifp;
+ if_t ifp;
u32 reg_icr;
ifp = adapter->ifp;
@@ -1519,12 +1517,12 @@ static void
em_handle_que(void *context, int pending)
{
struct adapter *adapter = context;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
struct tx_ring *txr = adapter->tx_rings;
struct rx_ring *rxr = adapter->rx_rings;
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
bool more = em_rxeof(rxr, adapter->rx_process_limit, NULL);
EM_TX_LOCK(txr);
em_txeof(txr);
@@ -1532,7 +1530,7 @@ em_handle_que(void *context, int pending)
if (!drbr_empty(ifp, txr->br))
em_mq_start_locked(ifp, txr, NULL);
#else
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if (!if_sendq_empty(ifp))
em_start_locked(ifp, txr);
#endif
EM_TX_UNLOCK(txr);
@@ -1557,7 +1555,7 @@ em_msix_tx(void *arg)
{
struct tx_ring *txr = arg;
struct adapter *adapter = txr->adapter;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
++txr->tx_irq;
EM_TX_LOCK(txr);
@@ -1566,7 +1564,7 @@ em_msix_tx(void *arg)
if (!drbr_empty(ifp, txr->br))
em_mq_start_locked(ifp, txr, NULL);
#else
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if (!if_sendq_empty(ifp))
em_start_locked(ifp, txr);
#endif
/* Reenable this interrupt */
@@ -1589,7 +1587,7 @@ em_msix_rx(void *arg)
bool more;
++rxr->rx_irq;
- if (!(adapter->ifp->if_drv_flags & IFF_DRV_RUNNING))
+ if (!(if_getdrvflags(adapter->ifp) & IFF_DRV_RUNNING))
return;
more = em_rxeof(rxr, adapter->rx_process_limit, NULL);
if (more)
@@ -1643,7 +1641,7 @@ em_handle_tx(void *context, int pending)
{
struct tx_ring *txr = context;
struct adapter *adapter = txr->adapter;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
EM_TX_LOCK(txr);
em_txeof(txr);
@@ -1651,7 +1649,7 @@ em_handle_tx(void *context, int pending)
if (!drbr_empty(ifp, txr->br))
em_mq_start_locked(ifp, txr, NULL);
#else
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if (!if_sendq_empty(ifp))
em_start_locked(ifp, txr);
#endif
E1000_WRITE_REG(&adapter->hw, E1000_IMS, txr->ims);
@@ -1663,9 +1661,9 @@ em_handle_link(void *context, int pending)
{
struct adapter *adapter = context;
struct tx_ring *txr = adapter->tx_rings;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
- if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
+ if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING))
return;
EM_CORE_LOCK(adapter);
@@ -1681,7 +1679,7 @@ em_handle_link(void *context, int pending)
if (!drbr_empty(ifp, txr->br))
em_mq_start_locked(ifp, txr, NULL);
#else
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if (if_sendq_empty(ifp))
em_start_locked(ifp, txr);
#endif
EM_TX_UNLOCK(txr);
@@ -1700,9 +1698,9 @@ em_handle_link(void *context, int pending)
*
**********************************************************************/
static void
-em_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
+em_media_status(if_t ifp, struct ifmediareq *ifmr)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
u_char fiber_type = IFM_1000_SX;
INIT_DEBUGOUT("em_media_status: begin");
@@ -1752,9 +1750,9 @@ em_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
*
**********************************************************************/
static int
-em_media_change(struct ifnet *ifp)
+em_media_change(if_t ifp)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
struct ifmedia *ifm = &adapter->media;
INIT_DEBUGOUT("em_media_change: begin");
@@ -2018,8 +2016,7 @@ retry:
if (m_head->m_flags & M_VLANTAG) {
/* Set the vlan id. */
- txd_upper |=
- (htole16(m_head->m_pkthdr.ether_vtag) << 16);
+ txd_upper |= htole16((if_getvtag(m_head)) << 16);
/* Tell hardware to add tag */
txd_lower |= htole32(E1000_TXD_CMD_VLE);
}
@@ -2122,18 +2119,18 @@ retry:
static void
em_set_promisc(struct adapter *adapter)
{
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
u32 reg_rctl;
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
- if (ifp->if_flags & IFF_PROMISC) {
+ if (if_getflags(ifp) & IFF_PROMISC) {
reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
/* Turn this on if you want to see bad packets */
if (em_debug_sbp)
reg_rctl |= E1000_RCTL_SBP;
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
- } else if (ifp->if_flags & IFF_ALLMULTI) {
+ } else if (if_getflags(ifp) & IFF_ALLMULTI) {
reg_rctl |= E1000_RCTL_MPE;
reg_rctl &= ~E1000_RCTL_UPE;
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
@@ -2143,34 +2140,16 @@ em_set_promisc(struct adapter *adapter)
static void
em_disable_promisc(struct adapter *adapter)
{
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
u32 reg_rctl;
int mcnt = 0;
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
reg_rctl &= (~E1000_RCTL_UPE);
- if (ifp->if_flags & IFF_ALLMULTI)
+ if (if_getflags(ifp) & IFF_ALLMULTI)
mcnt = MAX_NUM_MULTICAST_ADDRESSES;
- else {
- struct ifmultiaddr *ifma;
-#if __FreeBSD_version < 800000
- IF_ADDR_LOCK(ifp);
-#else
- if_maddr_rlock(ifp);
-#endif
- TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- if (mcnt == MAX_NUM_MULTICAST_ADDRESSES)
- break;
- mcnt++;
- }
-#if __FreeBSD_version < 800000
- IF_ADDR_UNLOCK(ifp);
-#else
- if_maddr_runlock(ifp);
-#endif
- }
+ else
+ mcnt = if_multiaddr_count(ifp, MAX_NUM_MULTICAST_ADDRESSES);
/* Don't disable if in MAX groups */
if (mcnt < MAX_NUM_MULTICAST_ADDRESSES)
reg_rctl &= (~E1000_RCTL_MPE);
@@ -2189,8 +2168,7 @@ em_disable_promisc(struct adapter *adapter)
static void
em_set_multi(struct adapter *adapter)
{
- struct ifnet *ifp = adapter->ifp;
- struct ifmultiaddr *ifma;
+ if_t ifp = adapter->ifp;
u32 reg_rctl = 0;
u8 *mta; /* Multicast array memory */
int mcnt = 0;
@@ -2210,27 +2188,8 @@ em_set_multi(struct adapter *adapter)
msec_delay(5);
}
-#if __FreeBSD_version < 800000
- IF_ADDR_LOCK(ifp);
-#else
- if_maddr_rlock(ifp);
-#endif
- TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
-
- if (mcnt == MAX_NUM_MULTICAST_ADDRESSES)
- break;
+ if_multiaddr_array(ifp, mta, &mcnt, MAX_NUM_MULTICAST_ADDRESSES);
- bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
- &mta[mcnt * ETH_ADDR_LEN], ETH_ADDR_LEN);
- mcnt++;
- }
-#if __FreeBSD_version < 800000
- IF_ADDR_UNLOCK(ifp);
-#else
- if_maddr_runlock(ifp);
-#endif
if (mcnt >= MAX_NUM_MULTICAST_ADDRESSES) {
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
reg_rctl |= E1000_RCTL_MPE;
@@ -2261,7 +2220,7 @@ static void
em_local_timer(void *arg)
{
struct adapter *adapter = arg;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
struct tx_ring *txr = adapter->tx_rings;
struct rx_ring *rxr = adapter->rx_rings;
u32 trigger;
@@ -2313,7 +2272,7 @@ hung:
device_printf(adapter->dev,"TX(%d) desc avail = %d,"
"Next TX to Clean = %d\n",
txr->me, txr->tx_avail, txr->next_to_clean);
- ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING);
adapter->watchdog_events++;
adapter->pause_frames = 0;
em_init_locked(adapter);
@@ -2324,7 +2283,7 @@ static void
em_update_link_status(struct adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
device_t dev = adapter->dev;
struct tx_ring *txr = adapter->tx_rings;
u32 link_check = 0;
@@ -2375,10 +2334,11 @@ em_update_link_status(struct adapter *adapter)
"Full Duplex" : "Half Duplex"));
adapter->link_active = 1;
adapter->smartspeed = 0;
- ifp->if_baudrate = adapter->link_speed * 1000000;
- if_link_state_change(ifp, LINK_STATE_UP);
+ if_setbaudrate(ifp, adapter->link_speed * 1000000);
+ if_linkstate_change_drv(ifp, LINK_STATE_UP);
} else if (!link_check && (adapter->link_active == 1)) {
- ifp->if_baudrate = adapter->link_speed = 0;
+ if_setbaudrate(ifp, 0);
+ adapter->link_speed = 0;
adapter->link_duplex = 0;
if (bootverbose)
device_printf(dev, "Link is Down\n");
@@ -2386,7 +2346,7 @@ em_update_link_status(struct adapter *adapter)
/* Link down, disable watchdog */
for (int i = 0; i < adapter->num_queues; i++, txr++)
txr->queue_status = EM_QUEUE_IDLE;
- if_link_state_change(ifp, LINK_STATE_DOWN);
+ if_linkstate_change_drv(ifp, LINK_STATE_DOWN);
}
}
@@ -2403,7 +2363,7 @@ static void
em_stop(void *arg)
{
struct adapter *adapter = arg;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
struct tx_ring *txr = adapter->tx_rings;
EM_CORE_LOCK_ASSERT(adapter);
@@ -2414,8 +2374,7 @@ em_stop(void *arg)
callout_stop(&adapter->timer);
/* Tell the stack that the interface is no longer active */
- ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
- ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, IFF_DRV_RUNNING);
/* Unarm watchdog timer. */
for (int i = 0; i < adapter->num_queues; i++, txr++) {
@@ -2813,7 +2772,7 @@ static void
em_reset(struct adapter *adapter)
{
device_t dev = adapter->dev;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
struct e1000_hw *hw = &adapter->hw;
u16 rx_buffer_size;
u32 pba;
@@ -2911,7 +2870,7 @@ em_reset(struct adapter *adapter)
/* Workaround: no TX flow ctrl for PCH */
hw->fc.requested_mode = e1000_fc_rx_pause;
hw->fc.pause_time = 0xFFFF; /* override */
- if (ifp->if_mtu > ETHERMTU) {
+ if (if_getmtu(ifp) > ETHERMTU) {
hw->fc.high_water = 0x3500;
hw->fc.low_water = 0x1500;
} else {
@@ -2927,14 +2886,14 @@ em_reset(struct adapter *adapter)
hw->fc.pause_time = 0x0650;
hw->fc.refresh_time = 0x0400;
/* Jumbos need adjusted PBA */
- if (ifp->if_mtu > ETHERMTU)
+ if (if_getmtu(ifp) > ETHERMTU)
E1000_WRITE_REG(hw, E1000_PBA, 12);
else
E1000_WRITE_REG(hw, E1000_PBA, 26);
break;
case e1000_ich9lan:
case e1000_ich10lan:
- if (ifp->if_mtu > ETHERMTU) {
+ if (if_getmtu(ifp) > ETHERMTU) {
hw->fc.high_water = 0x2800;
hw->fc.low_water = hw->fc.high_water - 8;
break;
@@ -2970,47 +2929,47 @@ em_reset(struct adapter *adapter)
static int
em_setup_interface(device_t dev, struct adapter *adapter)
{
- struct ifnet *ifp;
+ if_t ifp;
INIT_DEBUGOUT("em_setup_interface: begin");
- ifp = adapter->ifp = if_alloc(IFT_ETHER);
- if (ifp == NULL) {
+ ifp = adapter->ifp = if_gethandle(IFT_ETHER);
+ if (ifp == 0) {
device_printf(dev, "can not allocate ifnet structure\n");
return (-1);
}
- if_initname(ifp, device_get_name(dev), device_get_unit(dev));
- ifp->if_init = em_init;
- ifp->if_softc = adapter;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = em_ioctl;
+ if_initname_drv(ifp, device_get_name(dev), device_get_unit(dev));
+ if_setdev(ifp, dev);
+ if_setinitfn(ifp, em_init);
+ if_setsoftc(ifp, adapter);
+ if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
+ if_setioctlfn(ifp, em_ioctl);
#ifdef EM_MULTIQUEUE
/* Multiqueue stack interface */
- ifp->if_transmit = em_mq_start;
- ifp->if_qflush = em_qflush;
+ if_settransmitfn(ifp, em_mq_start);
+ if_setqflushfn(ifp, em_qflush);
#else
- ifp->if_start = em_start;
- IFQ_SET_MAXLEN(&ifp->if_snd, adapter->num_tx_desc - 1);
- ifp->if_snd.ifq_drv_maxlen = adapter->num_tx_desc - 1;
- IFQ_SET_READY(&ifp->if_snd);
+ if_setstartfn(ifp, em_start);
+ if_setsendqlen(ifp, adapter->num_tx_desc - 1);
+ if_setsendqready(ifp);
#endif
- ether_ifattach(ifp, adapter->hw.mac.addr);
+ ether_ifattach_drv(ifp, adapter->hw.mac.addr);
- ifp->if_capabilities = ifp->if_capenable = 0;
+ if_setcapabilities(ifp, 0);
+ if_setcapenable(ifp, 0);
- ifp->if_capabilities |= IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM;
- ifp->if_capabilities |= IFCAP_TSO4;
+ if_setcapabilitiesbit(ifp, IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM |
+ IFCAP_TSO4, 0);
/*
* Tell the upper layer(s) we
* support full VLAN capability
*/
- ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
- ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING
- | IFCAP_VLAN_HWTSO
- | IFCAP_VLAN_MTU;
- ifp->if_capenable = ifp->if_capabilities;
+ if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));
+ if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_HWTSO |
+ IFCAP_VLAN_MTU, 0);
+ if_setcapenable(ifp, if_getcapabilities(ifp));
/*
** Don't turn this on by default, if vlans are
@@ -3020,23 +2979,23 @@ em_setup_interface(device_t dev, struct adapter *adapter)
** using vlans directly on the em driver you can
** enable this and get full hardware tag filtering.
*/
- ifp->if_capabilities |= IFCAP_VLAN_HWFILTER;
+ if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWFILTER,0);
#ifdef DEVICE_POLLING
- ifp->if_capabilities |= IFCAP_POLLING;
+ if_setcapabilitiesbit(ifp, IFCAP_POLLING,0);
#endif
/* Enable only WOL MAGIC by default */
if (adapter->wol) {
- ifp->if_capabilities |= IFCAP_WOL;
- ifp->if_capenable |= IFCAP_WOL_MAGIC;
+ if_setcapabilitiesbit(ifp, IFCAP_WOL, 0);
+ if_setcapenablebit(ifp, IFCAP_WOL_MAGIC, 0);
}
/*
* Specify the media types supported by this adapter and register
* callbacks to update media and link information
*/
- ifmedia_init(&adapter->media, IFM_IMASK,
+ ifmedia_init_drv(&adapter->media, IFM_IMASK,
em_media_change, em_media_status);
if ((adapter->hw.phy.media_type == e1000_media_type_fiber) ||
(adapter->hw.phy.media_type == e1000_media_type_internal_serdes)) {
@@ -3351,8 +3310,8 @@ em_setup_transmit_ring(struct tx_ring *txr)
struct em_buffer *txbuf;
int i;
#ifdef DEV_NETMAP
- struct netmap_adapter *na = NA(adapter->ifp);
struct netmap_slot *slot;
+ struct netmap_adapter *na = netmap_getna(adapter->ifp);
#endif /* DEV_NETMAP */
/* Clear the old descriptor contents */
@@ -3832,7 +3791,7 @@ em_txeof(struct tx_ring *txr)
int first, last, done, processed;
struct em_buffer *tx_buffer;
struct e1000_tx_desc *tx_desc, *eop_desc;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
EM_TX_LOCK_ASSERT(txr);
#ifdef DEV_NETMAP
@@ -3893,7 +3852,7 @@ em_txeof(struct tx_ring *txr)
tx_buffer = &txr->tx_buffers[first];
tx_desc = &txr->tx_base[first];
}
- ++ifp->if_opackets;
+ if_incopackets(ifp, 1);
/* See if we can continue to the next packet */
last = tx_buffer->next_eop;
if (last != -1) {
@@ -3927,7 +3886,7 @@ em_txeof(struct tx_ring *txr)
* sanity.
*/
if (txr->tx_avail >= EM_MAX_SCATTER)
- ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
/* Disable watchdog if all clean */
if (txr->tx_avail == adapter->num_tx_desc) {
@@ -4088,8 +4047,8 @@ em_setup_receive_ring(struct rx_ring *rxr)
bus_dma_segment_t seg[1];
int rsize, nsegs, error = 0;
#ifdef DEV_NETMAP
- struct netmap_adapter *na = NA(adapter->ifp);
struct netmap_slot *slot;
+ struct netmap_adapter *na = netmap_getna(adapter->ifp);
#endif
@@ -4282,7 +4241,7 @@ static void
em_initialize_receive_unit(struct adapter *adapter)
{
struct rx_ring *rxr = adapter->rx_rings;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
struct e1000_hw *hw = &adapter->hw;
u64 bus_addr;
u32 rctl, rxcsum;
@@ -4319,7 +4278,7 @@ em_initialize_receive_unit(struct adapter *adapter)
}
rxcsum = E1000_READ_REG(hw, E1000_RXCSUM);
- if (ifp->if_capenable & IFCAP_RXCSUM)
+ if (if_getcapenable(ifp) & IFCAP_RXCSUM)
rxcsum |= E1000_RXCSUM_TUOFL;
else
rxcsum &= ~E1000_RXCSUM_TUOFL;
@@ -4351,8 +4310,10 @@ em_initialize_receive_unit(struct adapter *adapter)
* an init() while a netmap client is active must
* preserve the rx buffers passed to userspace.
*/
- if (ifp->if_capenable & IFCAP_NETMAP)
- rdt -= nm_kr_rxspace(&NA(adapter->ifp)->rx_rings[i]);
+ if (if_getcapenable(ifp) & IFCAP_NETMAP) {
+ struct netmap_adapter *na = netmap_getna(adapter->ifp);
+ rdt -= nm_kr_rxspace(&na->rx_rings[i]);
+ }
#endif /* DEV_NETMAP */
E1000_WRITE_REG(hw, E1000_RDT(i), rdt);
}
@@ -4361,13 +4322,13 @@ em_initialize_receive_unit(struct adapter *adapter)
if (((adapter->hw.mac.type == e1000_ich9lan) ||
(adapter->hw.mac.type == e1000_pch2lan) ||
(adapter->hw.mac.type == e1000_ich10lan)) &&
- (ifp->if_mtu > ETHERMTU)) {
+ (if_getmtu(ifp) > ETHERMTU)) {
u32 rxdctl = E1000_READ_REG(hw, E1000_RXDCTL(0));
E1000_WRITE_REG(hw, E1000_RXDCTL(0), rxdctl | 3);
}
if (adapter->hw.mac.type >= e1000_pch2lan) {
- if (ifp->if_mtu > ETHERMTU)
+ if (if_getmtu(ifp) > ETHERMTU)
e1000_lv_jumbo_workaround_ich8lan(hw, TRUE);
else
e1000_lv_jumbo_workaround_ich8lan(hw, FALSE);
@@ -4393,7 +4354,7 @@ em_initialize_receive_unit(struct adapter *adapter)
else if (adapter->rx_mbuf_sz > MJUMPAGESIZE)
rctl |= E1000_RCTL_SZ_8192 | E1000_RCTL_BSEX;
- if (ifp->if_mtu > ETHERMTU)
+ if (if_getmtu(ifp) > ETHERMTU)
rctl |= E1000_RCTL_LPE;
else
rctl &= ~E1000_RCTL_LPE;
@@ -4420,7 +4381,7 @@ static bool
em_rxeof(struct rx_ring *rxr, int count, int *done)
{
struct adapter *adapter = rxr->adapter;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
struct mbuf *mp, *sendmp;
u8 status = 0;
u16 len;
@@ -4439,7 +4400,7 @@ em_rxeof(struct rx_ring *rxr, int count, int *done)
for (i = rxr->next_to_check, processed = 0; count != 0;) {
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
break;
bus_dmamap_sync(rxr->rxdma.dma_tag, rxr->rxdma.dma_map,
@@ -4490,8 +4451,8 @@ em_rxeof(struct rx_ring *rxr, int count, int *done)
if (eop) {
--count;
sendmp = rxr->fmp;
- sendmp->m_pkthdr.rcvif = ifp;
- ifp->if_ipackets++;
+ if_setrcvif(sendmp, ifp);
+ if_incipackets(ifp, 1);
em_receive_checksum(cur, sendmp);
#ifndef __NO_STRICT_ALIGNMENT
if (adapter->hw.mac.max_frame_size >
@@ -4500,8 +4461,8 @@ em_rxeof(struct rx_ring *rxr, int count, int *done)
goto skip;
#endif
if (status & E1000_RXD_STAT_VP) {
- sendmp->m_pkthdr.ether_vtag =
- le16toh(cur->special);
+ if_setvtag(sendmp,
+ le16toh(cur->special));
sendmp->m_flags |= M_VLANTAG;
}
#ifndef __NO_STRICT_ALIGNMENT
@@ -4523,7 +4484,7 @@ next_desc:
if (sendmp != NULL) {
rxr->next_to_check = i;
EM_RX_UNLOCK(rxr);
- (*ifp->if_input)(ifp, sendmp);
+ if_input(ifp, sendmp);
EM_RX_LOCK(rxr);
i = rxr->next_to_check;
}
@@ -4657,12 +4618,12 @@ em_receive_checksum(struct e1000_rx_desc *rx_desc, struct mbuf *mp)
* config EVENT
*/
static void
-em_register_vlan(void *arg, struct ifnet *ifp, u16 vtag)
+em_register_vlan(void *arg, if_t ifp, u16 vtag)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
u32 index, bit;
- if (ifp->if_softc != arg) /* Not our event */
+ if ((void*)adapter != arg) /* Not our event */
return;
if ((vtag == 0) || (vtag > 4095)) /* Invalid ID */
@@ -4674,7 +4635,7 @@ em_register_vlan(void *arg, struct ifnet *ifp, u16 vtag)
adapter->shadow_vfta[index] |= (1 << bit);
++adapter->num_vlans;
/* Re-init to load the changes */
- if (ifp->if_capenable & IFCAP_VLAN_HWFILTER)
+ if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER)
em_init_locked(adapter);
EM_CORE_UNLOCK(adapter);
}
@@ -4684,12 +4645,12 @@ em_register_vlan(void *arg, struct ifnet *ifp, u16 vtag)
* unconfig EVENT
*/
static void
-em_unregister_vlan(void *arg, struct ifnet *ifp, u16 vtag)
+em_unregister_vlan(void *arg, if_t ifp, u16 vtag)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
u32 index, bit;
- if (ifp->if_softc != arg)
+ if (adapter != arg)
return;
if ((vtag == 0) || (vtag > 4095)) /* Invalid */
@@ -4701,7 +4662,7 @@ em_unregister_vlan(void *arg, struct ifnet *ifp, u16 vtag)
adapter->shadow_vfta[index] &= ~(1 << bit);
--adapter->num_vlans;
/* Re-init to load the changes */
- if (ifp->if_capenable & IFCAP_VLAN_HWFILTER)
+ if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER)
em_init_locked(adapter);
EM_CORE_UNLOCK(adapter);
}
@@ -4955,7 +4916,7 @@ static void
em_enable_wakeup(device_t dev)
{
struct adapter *adapter = device_get_softc(dev);
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
u32 pmc, ctrl, ctrl_ext, rctl;
u16 status;
@@ -4986,10 +4947,10 @@ em_enable_wakeup(device_t dev)
** Determine type of Wakeup: note that wol
** is set with all bits on by default.
*/
- if ((ifp->if_capenable & IFCAP_WOL_MAGIC) == 0)
+ if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) == 0)
adapter->wol &= ~E1000_WUFC_MAG;
- if ((ifp->if_capenable & IFCAP_WOL_MCAST) == 0)
+ if ((if_getcapenable(ifp) & IFCAP_WOL_MCAST) == 0)
adapter->wol &= ~E1000_WUFC_MC;
else {
rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
@@ -5012,7 +4973,7 @@ em_enable_wakeup(device_t dev)
/* Request PME */
status = pci_read_config(dev, pmc + PCIR_POWER_STATUS, 2);
status &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
- if (ifp->if_capenable & IFCAP_WOL)
+ if (if_getcapenable(ifp) & IFCAP_WOL)
status |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
pci_write_config(dev, pmc + PCIR_POWER_STATUS, status, 2);
@@ -5148,7 +5109,7 @@ em_disable_aspm(struct adapter *adapter)
static void
em_update_stats_counters(struct adapter *adapter)
{
- struct ifnet *ifp;
+ if_t ifp;
if(adapter->hw.phy.media_type == e1000_media_type_copper ||
(E1000_READ_REG(&adapter->hw, E1000_STATUS) & E1000_STATUS_LU)) {
@@ -5242,17 +5203,17 @@ em_update_stats_counters(struct adapter *adapter)
}
ifp = adapter->ifp;
- ifp->if_collisions = adapter->stats.colc;
+ if_setcollisions(ifp, adapter->stats.colc);
/* Rx Errors */
- ifp->if_ierrors = adapter->dropped_pkts + adapter->stats.rxerrc +
+ if_setierrors(ifp, adapter->dropped_pkts + adapter->stats.rxerrc +
adapter->stats.crcerrs + adapter->stats.algnerrc +
adapter->stats.ruc + adapter->stats.roc +
- adapter->stats.mpc + adapter->stats.cexterr;
+ adapter->stats.mpc + adapter->stats.cexterr);
/* Tx Errors */
- ifp->if_oerrors = adapter->stats.ecol +
- adapter->stats.latecol + adapter->watchdog_events;
+ if_setoerrors(ifp, adapter->stats.ecol + adapter->stats.latecol +
+ adapter->watchdog_events);
}
/* Export a single 32-bit register via a read-only sysctl. */
@@ -5773,12 +5734,12 @@ em_print_debug_info(struct adapter *adapter)
struct tx_ring *txr = adapter->tx_rings;
struct rx_ring *rxr = adapter->rx_rings;
- if (adapter->ifp->if_drv_flags & IFF_DRV_RUNNING)
+ if (if_getdrvflags(adapter->ifp) & IFF_DRV_RUNNING)
printf("Interface is RUNNING ");
else
printf("Interface is NOT RUNNING\n");
- if (adapter->ifp->if_drv_flags & IFF_DRV_OACTIVE)
+ if (if_getdrvflags(adapter->ifp) & IFF_DRV_OACTIVE)
printf("and INACTIVE\n");
else
printf("and ACTIVE\n");
diff --git a/sys/dev/e1000/if_em.h b/sys/dev/e1000/if_em.h
index 09d81d2..a739815 100644
--- a/sys/dev/e1000/if_em.h
+++ b/sys/dev/e1000/if_em.h
@@ -345,7 +345,7 @@ struct rx_ring {
/* Our adapter structure */
struct adapter {
- struct ifnet *ifp;
+ if_t ifp;
struct e1000_hw hw;
/* FreeBSD operating-system-specific structures. */
diff --git a/sys/dev/e1000/if_lem.c b/sys/dev/e1000/if_lem.c
index 8014a0f..e2dc62f 100644
--- a/sys/dev/e1000/if_lem.c
+++ b/sys/dev/e1000/if_lem.c
@@ -41,6 +41,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/buf_ring.h>
#include <sys/bus.h>
#include <sys/endian.h>
#include <sys/kernel.h>
@@ -167,14 +168,14 @@ static int lem_detach(device_t);
static int lem_shutdown(device_t);
static int lem_suspend(device_t);
static int lem_resume(device_t);
-static void lem_start(struct ifnet *);
-static void lem_start_locked(struct ifnet *ifp);
-static int lem_ioctl(struct ifnet *, u_long, caddr_t);
+static void lem_start(if_t);
+static void lem_start_locked(if_t ifp);
+static int lem_ioctl(if_t, u_long, caddr_t);
static void lem_init(void *);
static void lem_init_locked(struct adapter *);
static void lem_stop(void *);
-static void lem_media_status(struct ifnet *, struct ifmediareq *);
-static int lem_media_change(struct ifnet *);
+static void lem_media_status(if_t, struct ifmediareq *);
+static int lem_media_change(if_t);
static void lem_identify_hardware(struct adapter *);
static int lem_allocate_pci_resources(struct adapter *);
static int lem_allocate_irq(struct adapter *adapter);
@@ -209,8 +210,8 @@ static void lem_disable_promisc(struct adapter *);
static void lem_set_multi(struct adapter *);
static void lem_update_link_status(struct adapter *);
static int lem_get_buf(struct adapter *, int);
-static void lem_register_vlan(void *, struct ifnet *, u16);
-static void lem_unregister_vlan(void *, struct ifnet *, u16);
+static void lem_register_vlan(void *, if_t, u16);
+static void lem_unregister_vlan(void *, if_t, u16);
static void lem_setup_vlan_hw_support(struct adapter *);
static int lem_xmit(struct adapter *, struct mbuf **);
static void lem_smartspeed(struct adapter *);
@@ -249,7 +250,7 @@ static void lem_add_rx_process_limit(struct adapter *, const char *,
const char *, int *, int);
#ifdef DEVICE_POLLING
-static poll_handler_t lem_poll;
+static poll_handler_drv_t lem_poll;
#endif /* POLLING */
/*********************************************************************
@@ -653,7 +654,7 @@ lem_attach(device_t dev)
lem_get_hw_control(adapter);
/* Tell the stack that the interface is not active */
- adapter->ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
+ if_setdrvflagbits(adapter->ifp, 0, IFF_DRV_OACTIVE | IFF_DRV_RUNNING);
adapter->led_dev = led_create(lem_led_func, adapter,
device_get_nameunit(dev));
@@ -675,8 +676,8 @@ err_rx_desc:
lem_dma_free(adapter, &adapter->txdma);
err_tx_desc:
err_pci:
- if (adapter->ifp != NULL)
- if_free(adapter->ifp);
+ if (adapter->ifp != (void *)NULL)
+ if_free_drv(adapter->ifp);
lem_free_pci_resources(adapter);
free(adapter->mta, M_DEVBUF);
EM_TX_LOCK_DESTROY(adapter);
@@ -700,19 +701,19 @@ static int
lem_detach(device_t dev)
{
struct adapter *adapter = device_get_softc(dev);
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
INIT_DEBUGOUT("em_detach: begin");
/* Make sure VLANS are not using driver */
- if (adapter->ifp->if_vlantrunk != NULL) {
+ if (if_vlantrunkinuse(ifp)) {
device_printf(dev,"Vlan in use, detach first\n");
return (EBUSY);
}
#ifdef DEVICE_POLLING
- if (ifp->if_capenable & IFCAP_POLLING)
- ether_poll_deregister(ifp);
+ if (if_getcapenable(ifp) & IFCAP_POLLING)
+ ether_poll_deregister_drv(ifp);
#endif
if (adapter->led_dev != NULL)
@@ -735,7 +736,7 @@ lem_detach(device_t dev)
if (adapter->vlan_detach != NULL)
EVENTHANDLER_DEREGISTER(vlan_unconfig, adapter->vlan_detach);
- ether_ifdetach(adapter->ifp);
+ ether_ifdetach_drv(adapter->ifp);
callout_drain(&adapter->timer);
callout_drain(&adapter->tx_fifo_timer);
@@ -744,7 +745,7 @@ lem_detach(device_t dev)
#endif /* DEV_NETMAP */
lem_free_pci_resources(adapter);
bus_generic_detach(dev);
- if_free(ifp);
+ if_free_drv(ifp);
lem_free_transmit_structures(adapter);
lem_free_receive_structures(adapter);
@@ -805,7 +806,7 @@ static int
lem_resume(device_t dev)
{
struct adapter *adapter = device_get_softc(dev);
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
EM_CORE_LOCK(adapter);
lem_init_locked(adapter);
@@ -818,14 +819,14 @@ lem_resume(device_t dev)
static void
-lem_start_locked(struct ifnet *ifp)
+lem_start_locked(if_t ifp)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
struct mbuf *m_head;
EM_TX_LOCK_ASSERT(adapter);
- 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;
if (!adapter->link_active)
@@ -844,9 +845,9 @@ lem_start_locked(struct ifnet *ifp)
}
}
- while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) {
+ while (!if_sendq_empty(ifp)) {
+ m_head = if_dequeue(ifp);
- IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head);
if (m_head == NULL)
break;
/*
@@ -856,31 +857,31 @@ lem_start_locked(struct ifnet *ifp)
if (lem_xmit(adapter, &m_head)) {
if (m_head == NULL)
break;
- ifp->if_drv_flags |= IFF_DRV_OACTIVE;
- IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
+ if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
+ if_sendq_prepend(ifp, m_head);
break;
}
/* Send a copy of the frame to the BPF listener */
- ETHER_BPF_MTAP(ifp, m_head);
+ if_etherbpfmtap(ifp, m_head);
/* Set timeout in case hardware has problems transmitting. */
adapter->watchdog_check = TRUE;
adapter->watchdog_time = ticks;
}
if (adapter->num_tx_desc_avail <= EM_TX_OP_THRESHOLD)
- ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0);
return;
}
static void
-lem_start(struct ifnet *ifp)
+lem_start(if_t ifp)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
EM_TX_LOCK(adapter);
- if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
lem_start_locked(ifp);
EM_TX_UNLOCK(adapter);
}
@@ -895,9 +896,9 @@ lem_start(struct ifnet *ifp)
**********************************************************************/
static int
-lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
+lem_ioctl(if_t ifp, u_long command, caddr_t data)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
struct ifreq *ifr = (struct ifreq *)data;
#if defined(INET) || defined(INET6)
struct ifaddr *ifa = (struct ifaddr *)data;
@@ -923,15 +924,15 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
** so we avoid doing it when possible.
*/
if (avoid_reset) {
- ifp->if_flags |= IFF_UP;
- if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
+ if_setflagbits(ifp, IFF_UP, 0);
+ if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING))
lem_init(adapter);
#ifdef INET
- if (!(ifp->if_flags & IFF_NOARP))
- arp_ifinit(ifp, ifa);
+ if (!(if_getflags(ifp) & IFF_NOARP))
+ arp_ifinit_drv(ifp, ifa);
#endif
} else
- error = ether_ioctl(ifp, command, data);
+ error = ether_ioctl_drv(ifp, command, data);
break;
case SIOCSIFMTU:
{
@@ -954,9 +955,9 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
break;
}
- ifp->if_mtu = ifr->ifr_mtu;
+ if_setmtu(ifp, ifr->ifr_mtu);
adapter->max_frame_size =
- ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+ if_getmtu(ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN;
lem_init_locked(adapter);
EM_CORE_UNLOCK(adapter);
break;
@@ -965,9 +966,9 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
IOCTL_DEBUGOUT("ioctl rcv'd:\
SIOCSIFFLAGS (Set Interface Flags)");
EM_CORE_LOCK(adapter);
- if (ifp->if_flags & IFF_UP) {
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) {
- if ((ifp->if_flags ^ adapter->if_flags) &
+ if (if_getflags(ifp) & IFF_UP) {
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING)) {
+ if ((if_getflags(ifp) ^ adapter->if_flags) &
(IFF_PROMISC | IFF_ALLMULTI)) {
lem_disable_promisc(adapter);
lem_set_promisc(adapter);
@@ -975,18 +976,18 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
} else
lem_init_locked(adapter);
} else
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
EM_TX_LOCK(adapter);
lem_stop(adapter);
EM_TX_UNLOCK(adapter);
}
- adapter->if_flags = ifp->if_flags;
+ adapter->if_flags = if_getflags(ifp);
EM_CORE_UNLOCK(adapter);
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
IOCTL_DEBUGOUT("ioctl rcv'd: SIOC(ADD|DEL)MULTI");
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
EM_CORE_LOCK(adapter);
lem_disable_intr(adapter);
lem_set_multi(adapter);
@@ -995,7 +996,7 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
lem_initialize_receive_unit(adapter);
}
#ifdef DEVICE_POLLING
- if (!(ifp->if_capenable & IFCAP_POLLING))
+ if (!(if_getcapenable(ifp) & IFCAP_POLLING))
#endif
lem_enable_intr(adapter);
EM_CORE_UNLOCK(adapter);
@@ -1014,7 +1015,7 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
case SIOCGIFMEDIA:
IOCTL_DEBUGOUT("ioctl rcv'd: \
SIOCxIFMEDIA (Get/Set Interface Media)");
- error = ifmedia_ioctl(ifp, ifr, &adapter->media, command);
+ error = ifmedia_ioctl_drv(ifp, ifr, &adapter->media, command);
break;
case SIOCSIFCAP:
{
@@ -1022,50 +1023,50 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFCAP (Set Capabilities)");
reinit = 0;
- mask = ifr->ifr_reqcap ^ ifp->if_capenable;
+ mask = ifr->ifr_reqcap ^ if_getcapenable(ifp);
#ifdef DEVICE_POLLING
if (mask & IFCAP_POLLING) {
if (ifr->ifr_reqcap & IFCAP_POLLING) {
- error = ether_poll_register(lem_poll, ifp);
+ error = ether_poll_register_drv(lem_poll, ifp);
if (error)
return (error);
EM_CORE_LOCK(adapter);
lem_disable_intr(adapter);
- ifp->if_capenable |= IFCAP_POLLING;
+ if_setcapenablebit(ifp, IFCAP_POLLING, 0);
EM_CORE_UNLOCK(adapter);
} else {
- error = ether_poll_deregister(ifp);
+ error = ether_poll_deregister_drv(ifp);
/* Enable interrupt even in error case */
EM_CORE_LOCK(adapter);
lem_enable_intr(adapter);
- ifp->if_capenable &= ~IFCAP_POLLING;
+ if_setcapenablebit(ifp, 0, IFCAP_POLLING);
EM_CORE_UNLOCK(adapter);
}
}
#endif
if (mask & IFCAP_HWCSUM) {
- ifp->if_capenable ^= IFCAP_HWCSUM;
+ if_togglecapenable(ifp, IFCAP_HWCSUM);
reinit = 1;
}
if (mask & IFCAP_VLAN_HWTAGGING) {
- ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
+ if_togglecapenable(ifp, IFCAP_VLAN_HWTAGGING);
reinit = 1;
}
if ((mask & IFCAP_WOL) &&
- (ifp->if_capabilities & IFCAP_WOL) != 0) {
+ (if_getcapabilities(ifp) & IFCAP_WOL) != 0) {
if (mask & IFCAP_WOL_MCAST)
- ifp->if_capenable ^= IFCAP_WOL_MCAST;
+ if_togglecapenable(ifp, IFCAP_WOL_MCAST);
if (mask & IFCAP_WOL_MAGIC)
- ifp->if_capenable ^= IFCAP_WOL_MAGIC;
+ if_togglecapenable(ifp, IFCAP_WOL_MAGIC);
}
- if (reinit && (ifp->if_drv_flags & IFF_DRV_RUNNING))
+ if (reinit && (if_getdrvflags(ifp) & IFF_DRV_RUNNING))
lem_init(adapter);
- VLAN_CAPABILITIES(ifp);
+ if_vlancap(ifp);
break;
}
default:
- error = ether_ioctl(ifp, command, data);
+ error = ether_ioctl_drv(ifp, command, data);
break;
}
@@ -1087,7 +1088,7 @@ lem_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
static void
lem_init_locked(struct adapter *adapter)
{
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
device_t dev = adapter->dev;
u32 pba;
@@ -1134,7 +1135,7 @@ lem_init_locked(struct adapter *adapter)
E1000_WRITE_REG(&adapter->hw, E1000_PBA, pba);
/* Get the latest mac address, User can use a LAA */
- bcopy(IF_LLADDR(adapter->ifp), adapter->hw.mac.addr,
+ bcopy(if_getlladdr(adapter->ifp), adapter->hw.mac.addr,
ETHER_ADDR_LEN);
/* Put the address into the Receive Address Array */
@@ -1151,10 +1152,10 @@ lem_init_locked(struct adapter *adapter)
E1000_WRITE_REG(&adapter->hw, E1000_VET, ETHERTYPE_VLAN);
/* Set hardware offload abilities */
- ifp->if_hwassist = 0;
+ if_clearhwassist(ifp);
if (adapter->hw.mac.type >= e1000_82543) {
- if (ifp->if_capenable & IFCAP_TXCSUM)
- ifp->if_hwassist |= (CSUM_TCP | CSUM_UDP);
+ if (if_getcapenable(ifp) & IFCAP_TXCSUM)
+ if_sethwassistbits(ifp, CSUM_TCP | CSUM_UDP, 0);
}
/* Configure for OS presence */
@@ -1178,8 +1179,8 @@ lem_init_locked(struct adapter *adapter)
lem_initialize_receive_unit(adapter);
/* Use real VLAN Filter support? */
- if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) {
- if (ifp->if_capenable & IFCAP_VLAN_HWFILTER)
+ if (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) {
+ if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER)
/* Use real VLAN Filter support */
lem_setup_vlan_hw_support(adapter);
else {
@@ -1193,8 +1194,7 @@ lem_init_locked(struct adapter *adapter)
/* Don't lose promiscuous settings */
lem_set_promisc(adapter);
- ifp->if_drv_flags |= IFF_DRV_RUNNING;
- ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE);
callout_reset(&adapter->timer, hz, lem_local_timer, adapter);
e1000_clear_hw_cntrs_base_generic(&adapter->hw);
@@ -1204,7 +1204,7 @@ lem_init_locked(struct adapter *adapter)
* Only enable interrupts if we are not polling, make sure
* they are off otherwise.
*/
- if (ifp->if_capenable & IFCAP_POLLING)
+ if (if_getcapenable(ifp) & IFCAP_POLLING)
lem_disable_intr(adapter);
else
#endif /* DEVICE_POLLING */
@@ -1233,13 +1233,13 @@ lem_init(void *arg)
*
*********************************************************************/
static int
-lem_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
+lem_poll(if_t ifp, enum poll_cmd cmd, int count)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
u32 reg_icr, rx_done = 0;
EM_CORE_LOCK(adapter);
- if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) {
EM_CORE_UNLOCK(adapter);
return (rx_done);
}
@@ -1260,7 +1260,7 @@ lem_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
EM_TX_LOCK(adapter);
lem_txeof(adapter);
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if(!if_sendq_empty(ifp))
lem_start_locked(ifp);
EM_TX_UNLOCK(adapter);
return (rx_done);
@@ -1276,12 +1276,12 @@ static void
lem_intr(void *arg)
{
struct adapter *adapter = arg;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
u32 reg_icr;
- if ((ifp->if_capenable & IFCAP_POLLING) ||
- ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0))
+ if ((if_getcapenable(ifp) & IFCAP_POLLING) ||
+ ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0))
return;
EM_CORE_LOCK(adapter);
@@ -1311,8 +1311,8 @@ lem_intr(void *arg)
EM_TX_LOCK(adapter);
lem_txeof(adapter);
- if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
- !IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) &&
+ (!if_sendq_empty(ifp)))
lem_start_locked(ifp);
EM_TX_UNLOCK(adapter);
return;
@@ -1323,9 +1323,9 @@ static void
lem_handle_link(void *context, int pending)
{
struct adapter *adapter = context;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
- if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
+ if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING))
return;
EM_CORE_LOCK(adapter);
@@ -1343,14 +1343,14 @@ static void
lem_handle_rxtx(void *context, int pending)
{
struct adapter *adapter = context;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
bool more = lem_rxeof(adapter, adapter->rx_process_limit, NULL);
EM_TX_LOCK(adapter);
lem_txeof(adapter);
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+ if(!if_sendq_empty(ifp))
lem_start_locked(ifp);
EM_TX_UNLOCK(adapter);
if (more) {
@@ -1359,7 +1359,7 @@ lem_handle_rxtx(void *context, int pending)
}
}
- if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+ if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
lem_enable_intr(adapter);
}
@@ -1372,7 +1372,7 @@ static int
lem_irq_fast(void *arg)
{
struct adapter *adapter = arg;
- struct ifnet *ifp;
+ if_t ifp;
u32 reg_icr;
ifp = adapter->ifp;
@@ -1416,9 +1416,9 @@ lem_irq_fast(void *arg)
*
**********************************************************************/
static void
-lem_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
+lem_media_status(if_t ifp, struct ifmediareq *ifmr)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
u_char fiber_type = IFM_1000_SX;
INIT_DEBUGOUT("lem_media_status: begin");
@@ -1470,9 +1470,9 @@ lem_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
*
**********************************************************************/
static int
-lem_media_change(struct ifnet *ifp)
+lem_media_change(if_t ifp)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
struct ifmedia *ifm = &adapter->media;
INIT_DEBUGOUT("lem_media_change: begin");
@@ -1849,18 +1849,18 @@ lem_82547_tx_fifo_reset(struct adapter *adapter)
static void
lem_set_promisc(struct adapter *adapter)
{
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
u32 reg_rctl;
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
- if (ifp->if_flags & IFF_PROMISC) {
+ if (if_getflags(ifp) & IFF_PROMISC) {
reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
/* Turn this on if you want to see bad packets */
if (lem_debug_sbp)
reg_rctl |= E1000_RCTL_SBP;
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
- } else if (ifp->if_flags & IFF_ALLMULTI) {
+ } else if (if_getflags(ifp) & IFF_ALLMULTI) {
reg_rctl |= E1000_RCTL_MPE;
reg_rctl &= ~E1000_RCTL_UPE;
E1000_WRITE_REG(&adapter->hw, E1000_RCTL, reg_rctl);
@@ -1870,34 +1870,17 @@ lem_set_promisc(struct adapter *adapter)
static void
lem_disable_promisc(struct adapter *adapter)
{
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
u32 reg_rctl;
int mcnt = 0;
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
reg_rctl &= (~E1000_RCTL_UPE);
- if (ifp->if_flags & IFF_ALLMULTI)
+ if (if_getflags(ifp) & IFF_ALLMULTI)
mcnt = MAX_NUM_MULTICAST_ADDRESSES;
- else {
- struct ifmultiaddr *ifma;
-#if __FreeBSD_version < 800000
- IF_ADDR_LOCK(ifp);
-#else
- if_maddr_rlock(ifp);
-#endif
- TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- if (mcnt == MAX_NUM_MULTICAST_ADDRESSES)
- break;
- mcnt++;
- }
-#if __FreeBSD_version < 800000
- IF_ADDR_UNLOCK(ifp);
-#else
- if_maddr_runlock(ifp);
-#endif
- }
+ else
+ mcnt = if_multiaddr_count(ifp, MAX_NUM_MULTICAST_ADDRESSES);
+
/* Don't disable if in MAX groups */
if (mcnt < MAX_NUM_MULTICAST_ADDRESSES)
reg_rctl &= (~E1000_RCTL_MPE);
@@ -1916,8 +1899,7 @@ lem_disable_promisc(struct adapter *adapter)
static void
lem_set_multi(struct adapter *adapter)
{
- struct ifnet *ifp = adapter->ifp;
- struct ifmultiaddr *ifma;
+ if_t ifp = adapter->ifp;
u32 reg_rctl = 0;
u8 *mta; /* Multicast array memory */
int mcnt = 0;
@@ -1937,27 +1919,8 @@ lem_set_multi(struct adapter *adapter)
msec_delay(5);
}
-#if __FreeBSD_version < 800000
- IF_ADDR_LOCK(ifp);
-#else
- if_maddr_rlock(ifp);
-#endif
- TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
-
- if (mcnt == MAX_NUM_MULTICAST_ADDRESSES)
- break;
+ if_multiaddr_array(ifp, mta, &mcnt, MAX_NUM_MULTICAST_ADDRESSES);
- bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
- &mta[mcnt * ETH_ADDR_LEN], ETH_ADDR_LEN);
- mcnt++;
- }
-#if __FreeBSD_version < 800000
- IF_ADDR_UNLOCK(ifp);
-#else
- if_maddr_runlock(ifp);
-#endif
if (mcnt >= MAX_NUM_MULTICAST_ADDRESSES) {
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
reg_rctl |= E1000_RCTL_MPE;
@@ -2009,7 +1972,7 @@ lem_local_timer(void *arg)
return;
hung:
device_printf(adapter->dev, "Watchdog timeout -- resetting\n");
- adapter->ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
+ if_setdrvflagbits(adapter->ifp, 0, IFF_DRV_RUNNING);
adapter->watchdog_events++;
lem_init_locked(adapter);
}
@@ -2018,7 +1981,7 @@ static void
lem_update_link_status(struct adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
device_t dev = adapter->dev;
u32 link_check = 0;
@@ -2059,17 +2022,18 @@ lem_update_link_status(struct adapter *adapter)
"Full Duplex" : "Half Duplex"));
adapter->link_active = 1;
adapter->smartspeed = 0;
- ifp->if_baudrate = adapter->link_speed * 1000000;
- if_link_state_change(ifp, LINK_STATE_UP);
+ if_setbaudrate(ifp, adapter->link_speed * 1000000);
+ if_linkstate_change_drv(ifp, LINK_STATE_UP);
} else if (!link_check && (adapter->link_active == 1)) {
- ifp->if_baudrate = adapter->link_speed = 0;
+ if_setbaudrate(ifp, 0);
+ adapter->link_speed = 0;
adapter->link_duplex = 0;
if (bootverbose)
device_printf(dev, "Link is Down\n");
adapter->link_active = 0;
/* Link down, disable watchdog */
adapter->watchdog_check = FALSE;
- if_link_state_change(ifp, LINK_STATE_DOWN);
+ if_linkstate_change_drv(ifp, LINK_STATE_DOWN);
}
}
@@ -2086,7 +2050,7 @@ static void
lem_stop(void *arg)
{
struct adapter *adapter = arg;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
EM_CORE_LOCK_ASSERT(adapter);
EM_TX_LOCK_ASSERT(adapter);
@@ -2098,7 +2062,7 @@ lem_stop(void *arg)
callout_stop(&adapter->tx_fifo_timer);
/* Tell the stack that the interface is no longer active */
- ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
+ if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
e1000_reset_hw(&adapter->hw);
if (adapter->hw.mac.type >= e1000_82544)
@@ -2349,40 +2313,39 @@ lem_hardware_init(struct adapter *adapter)
static int
lem_setup_interface(device_t dev, struct adapter *adapter)
{
- struct ifnet *ifp;
+ if_t ifp;
INIT_DEBUGOUT("lem_setup_interface: begin");
- ifp = adapter->ifp = if_alloc(IFT_ETHER);
- if (ifp == NULL) {
+ ifp = adapter->ifp = if_gethandle(IFT_ETHER);
+ if (ifp == (void *)NULL) {
device_printf(dev, "can not allocate ifnet structure\n");
return (-1);
}
- if_initname(ifp, device_get_name(dev), device_get_unit(dev));
- ifp->if_init = lem_init;
- ifp->if_softc = adapter;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = lem_ioctl;
- ifp->if_start = lem_start;
- IFQ_SET_MAXLEN(&ifp->if_snd, adapter->num_tx_desc - 1);
- ifp->if_snd.ifq_drv_maxlen = adapter->num_tx_desc - 1;
- IFQ_SET_READY(&ifp->if_snd);
+ if_initname_drv(ifp, device_get_name(dev), device_get_unit(dev));
+ if_setinitfn(ifp, lem_init);
+ if_setsoftc(ifp, adapter);
+ if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
+ if_setioctlfn(ifp, lem_ioctl);
+ if_setstartfn(ifp, lem_start);
+ if_setsendqlen(ifp, adapter->num_tx_desc - 1);
+ if_setsendqready(ifp);
- ether_ifattach(ifp, adapter->hw.mac.addr);
+ ether_ifattach_drv(ifp, adapter->hw.mac.addr);
- ifp->if_capabilities = ifp->if_capenable = 0;
+ if_setcapabilities(ifp, 0);
if (adapter->hw.mac.type >= e1000_82543) {
- ifp->if_capabilities |= IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM;
- ifp->if_capenable |= IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM;
+ if_setcapabilitiesbit(ifp, IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM, 0);
+ if_setcapenablebit(ifp, IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM, 0);
}
/*
* Tell the upper layer(s) we support long frames.
*/
- ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
- ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU;
- ifp->if_capenable |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU;
+ if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));
+ if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU, 0);
+ if_setcapenablebit(ifp, IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU, 0);
/*
** Dont turn this on by default, if vlans are
@@ -2392,23 +2355,23 @@ lem_setup_interface(device_t dev, struct adapter *adapter)
** using vlans directly on the em driver you can
** enable this and get full hardware tag filtering.
*/
- ifp->if_capabilities |= IFCAP_VLAN_HWFILTER;
+ if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWFILTER, 0);
#ifdef DEVICE_POLLING
- ifp->if_capabilities |= IFCAP_POLLING;
+ if_setcapabilitiesbit(ifp, IFCAP_POLLING, 0);
#endif
/* Enable only WOL MAGIC by default */
if (adapter->wol) {
- ifp->if_capabilities |= IFCAP_WOL;
- ifp->if_capenable |= IFCAP_WOL_MAGIC;
+ if_setcapabilitiesbit(ifp, IFCAP_WOL, 0);
+ if_setcapenablebit(ifp, IFCAP_WOL_MAGIC, 0);
}
/*
* Specify the media types supported by this adapter and register
* callbacks to update media and link information
*/
- ifmedia_init(&adapter->media, IFM_IMASK,
+ ifmedia_init_drv(&adapter->media, IFM_IMASK,
lem_media_change, lem_media_status);
if ((adapter->hw.phy.media_type == e1000_media_type_fiber) ||
(adapter->hw.phy.media_type == e1000_media_type_internal_serdes)) {
@@ -2655,7 +2618,7 @@ lem_setup_transmit_structures(struct adapter *adapter)
struct em_buffer *tx_buffer;
#ifdef DEV_NETMAP
/* we are already locked */
- struct netmap_adapter *na = NA(adapter->ifp);
+ struct netmap_adapter *na = netmap_getna(adapter->ifp);
struct netmap_slot *slot = netmap_reset(na, NR_TX, 0, 0);
#endif /* DEV_NETMAP */
@@ -2981,7 +2944,7 @@ lem_txeof(struct adapter *adapter)
int first, last, done, num_avail;
struct em_buffer *tx_buffer;
struct e1000_tx_desc *tx_desc, *eop_desc;
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
EM_TX_LOCK_ASSERT(adapter);
@@ -3021,7 +2984,7 @@ lem_txeof(struct adapter *adapter)
++num_avail;
if (tx_buffer->m_head) {
- ifp->if_opackets++;
+ if_incopackets(ifp, 1);
bus_dmamap_sync(adapter->txtag,
tx_buffer->map,
BUS_DMASYNC_POSTWRITE);
@@ -3062,7 +3025,7 @@ lem_txeof(struct adapter *adapter)
* If there are no pending descriptors, clear the watchdog.
*/
if (adapter->num_tx_desc_avail > EM_TX_CLEANUP_THRESHOLD) {
- ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
if (adapter->num_tx_desc_avail == adapter->num_tx_desc) {
adapter->watchdog_check = FALSE;
return;
@@ -3219,7 +3182,7 @@ lem_setup_receive_structures(struct adapter *adapter)
int i, error;
#ifdef DEV_NETMAP
/* we are already under lock */
- struct netmap_adapter *na = NA(adapter->ifp);
+ struct netmap_adapter *na = netmap_getna(adapter->ifp);
struct netmap_slot *slot = netmap_reset(na, NR_RX, 0, 0);
#endif
@@ -3277,7 +3240,7 @@ lem_setup_receive_structures(struct adapter *adapter)
static void
lem_initialize_receive_unit(struct adapter *adapter)
{
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
u64 bus_addr;
u32 rctl, rxcsum;
@@ -3342,14 +3305,14 @@ lem_initialize_receive_unit(struct adapter *adapter)
break;
}
- if (ifp->if_mtu > ETHERMTU)
+ if (if_getmtu(ifp) > ETHERMTU)
rctl |= E1000_RCTL_LPE;
else
rctl &= ~E1000_RCTL_LPE;
/* Enable 82543 Receive Checksum Offload for TCP and UDP */
if ((adapter->hw.mac.type >= e1000_82543) &&
- (ifp->if_capenable & IFCAP_RXCSUM)) {
+ (if_getcapenable(ifp) & IFCAP_RXCSUM)) {
rxcsum = E1000_READ_REG(&adapter->hw, E1000_RXCSUM);
rxcsum |= (E1000_RXCSUM_IPOFL | E1000_RXCSUM_TUOFL);
E1000_WRITE_REG(&adapter->hw, E1000_RXCSUM, rxcsum);
@@ -3366,8 +3329,10 @@ lem_initialize_receive_unit(struct adapter *adapter)
rctl = adapter->num_rx_desc - 1; /* default RDT value */
#ifdef DEV_NETMAP
/* preserve buffers already made available to clients */
- if (ifp->if_capenable & IFCAP_NETMAP)
- rctl -= nm_kr_rxspace(&NA(adapter->ifp)->rx_rings[0]);
+ if (if_getcapenable(ifp) & IFCAP_NETMAP) {
+ struct netmap_adapter *na = netmap_getna(adapter->ifp);
+ rctl -= nm_kr_rxspace(&na->rx_rings[0]);
+ }
#endif /* DEV_NETMAP */
E1000_WRITE_REG(&adapter->hw, E1000_RDT(0), rctl);
@@ -3439,7 +3404,7 @@ lem_free_receive_structures(struct adapter *adapter)
static bool
lem_rxeof(struct adapter *adapter, int count, int *done)
{
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
struct mbuf *mp;
u8 status = 0, accept_frame = 0, eop = 0;
u16 len, desc_len, prev_len_adj;
@@ -3466,7 +3431,7 @@ lem_rxeof(struct adapter *adapter, int count, int *done)
return (FALSE);
}
- while (count != 0 && ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ while (count != 0 && if_getdrvflags(ifp) & IFF_DRV_RUNNING) {
struct mbuf *m = NULL;
status = current_desc->status;
@@ -3520,7 +3485,7 @@ lem_rxeof(struct adapter *adapter, int count, int *done)
if (accept_frame) {
if (lem_get_buf(adapter, i) != 0) {
- ifp->if_iqdrops++;
+ if_inciqdrops(ifp, 1);
goto discard;
}
@@ -3550,8 +3515,8 @@ lem_rxeof(struct adapter *adapter, int count, int *done)
}
if (eop) {
- adapter->fmp->m_pkthdr.rcvif = ifp;
- ifp->if_ipackets++;
+ if_setrcvif(adapter->fmp, ifp);
+ if_incipackets(ifp, 1);
lem_receive_checksum(adapter, current_desc,
adapter->fmp);
#ifndef __NO_STRICT_ALIGNMENT
@@ -3603,7 +3568,7 @@ discard:
if (m != NULL) {
adapter->next_rx_desc_to_check = i;
EM_RX_UNLOCK(adapter);
- (*ifp->if_input)(ifp, m);
+ if_input(ifp, m);
EM_RX_LOCK(adapter);
rx_sent++;
i = adapter->next_rx_desc_to_check;
@@ -3716,12 +3681,12 @@ lem_receive_checksum(struct adapter *adapter,
* config EVENT
*/
static void
-lem_register_vlan(void *arg, struct ifnet *ifp, u16 vtag)
+lem_register_vlan(void *arg, if_t ifp, u16 vtag)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
u32 index, bit;
- if (ifp->if_softc != arg) /* Not our event */
+ if (if_getsoftc(ifp) != arg) /* Not our event */
return;
if ((vtag == 0) || (vtag > 4095)) /* Invalid ID */
@@ -3733,7 +3698,7 @@ lem_register_vlan(void *arg, struct ifnet *ifp, u16 vtag)
adapter->shadow_vfta[index] |= (1 << bit);
++adapter->num_vlans;
/* Re-init to load the changes */
- if (ifp->if_capenable & IFCAP_VLAN_HWFILTER)
+ if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER)
lem_init_locked(adapter);
EM_CORE_UNLOCK(adapter);
}
@@ -3743,12 +3708,12 @@ lem_register_vlan(void *arg, struct ifnet *ifp, u16 vtag)
* unconfig EVENT
*/
static void
-lem_unregister_vlan(void *arg, struct ifnet *ifp, u16 vtag)
+lem_unregister_vlan(void *arg, if_t ifp, u16 vtag)
{
- struct adapter *adapter = ifp->if_softc;
+ struct adapter *adapter = if_getsoftc(ifp);
u32 index, bit;
- if (ifp->if_softc != arg)
+ if (if_getsoftc(ifp) != arg)
return;
if ((vtag == 0) || (vtag > 4095)) /* Invalid */
@@ -3760,7 +3725,7 @@ lem_unregister_vlan(void *arg, struct ifnet *ifp, u16 vtag)
adapter->shadow_vfta[index] &= ~(1 << bit);
--adapter->num_vlans;
/* Re-init to load the changes */
- if (ifp->if_capenable & IFCAP_VLAN_HWFILTER)
+ if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER)
lem_init_locked(adapter);
EM_CORE_UNLOCK(adapter);
}
@@ -3977,7 +3942,7 @@ static void
lem_enable_wakeup(device_t dev)
{
struct adapter *adapter = device_get_softc(dev);
- struct ifnet *ifp = adapter->ifp;
+ if_t ifp = adapter->ifp;
u32 pmc, ctrl, ctrl_ext, rctl;
u16 status;
@@ -4002,10 +3967,10 @@ lem_enable_wakeup(device_t dev)
** Determine type of Wakeup: note that wol
** is set with all bits on by default.
*/
- if ((ifp->if_capenable & IFCAP_WOL_MAGIC) == 0)
+ if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) == 0)
adapter->wol &= ~E1000_WUFC_MAG;
- if ((ifp->if_capenable & IFCAP_WOL_MCAST) == 0)
+ if ((if_getcapenable(ifp) & IFCAP_WOL_MCAST) == 0)
adapter->wol &= ~E1000_WUFC_MC;
else {
rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
@@ -4025,7 +3990,7 @@ lem_enable_wakeup(device_t dev)
/* Request PME */
status = pci_read_config(dev, pmc + PCIR_POWER_STATUS, 2);
status &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
- if (ifp->if_capenable & IFCAP_WOL)
+ if (if_getcapenable(ifp) & IFCAP_WOL)
status |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
pci_write_config(dev, pmc + PCIR_POWER_STATUS, status, 2);
@@ -4194,7 +4159,7 @@ lem_fill_descriptors (bus_addr_t address, u32 length,
static void
lem_update_stats_counters(struct adapter *adapter)
{
- struct ifnet *ifp;
+ if_t ifp;
if(adapter->hw.phy.media_type == e1000_media_type_copper ||
(E1000_READ_REG(&adapter->hw, E1000_STATUS) & E1000_STATUS_LU)) {
@@ -4271,17 +4236,17 @@ lem_update_stats_counters(struct adapter *adapter)
}
ifp = adapter->ifp;
- ifp->if_collisions = adapter->stats.colc;
+ if_setcollisions(ifp, adapter->stats.colc);
/* Rx Errors */
- ifp->if_ierrors = adapter->dropped_pkts + adapter->stats.rxerrc +
+ if_setierrors(ifp, adapter->dropped_pkts + adapter->stats.rxerrc +
adapter->stats.crcerrs + adapter->stats.algnerrc +
adapter->stats.ruc + adapter->stats.roc +
- adapter->stats.mpc + adapter->stats.cexterr;
+ adapter->stats.mpc + adapter->stats.cexterr);
/* Tx Errors */
- ifp->if_oerrors = adapter->stats.ecol +
- adapter->stats.latecol + adapter->watchdog_events;
+ if_setoerrors(ifp, adapter->stats.ecol + adapter->stats.latecol +
+ adapter->watchdog_events);
}
/* Export a single 32-bit register via a read-only sysctl. */
diff --git a/sys/dev/e1000/if_lem.h b/sys/dev/e1000/if_lem.h
index db6b5f0..41447d1 100644
--- a/sys/dev/e1000/if_lem.h
+++ b/sys/dev/e1000/if_lem.h
@@ -295,7 +295,7 @@ struct em_int_delay_info {
/* Our adapter structure */
struct adapter {
- struct ifnet *ifp;
+ if_t ifp;
#if __FreeBSD_version >= 800000
struct buf_ring *br;
#endif
OpenPOWER on IntegriCloud