Index: sys/dev/bxe/bxe.c =================================================================== --- sys/dev/bxe/bxe.c (revision 278519) +++ sys/dev/bxe/bxe.c (working copy) @@ -2723,11 +2723,11 @@ static void bxe_tx_disable(struct bxe_softc* sc) { - struct ifnet *ifp = sc->ifnet; + if_t ifp = sc->ifp; /* tell the stack the driver is stopped and TX queue is full */ - if (ifp != NULL) { - ifp->if_drv_flags = 0; + if (ifp != NULL) { + if_setdrvflags(ifp, 0); } } @@ -3180,7 +3180,7 @@ struct eth_end_agg_rx_cqe *cqe, uint16_t cqe_idx) { - struct ifnet *ifp = sc->ifnet; + if_t ifp = sc->ifp; struct mbuf *m; int rc = 0; @@ -3225,7 +3225,7 @@ } /* assign packet to this interface interface */ - m->m_pkthdr.rcvif = ifp; + if_setrcvif(m, ifp); #if __FreeBSD_version >= 800000 /* specify what RSS queue was used for this flow */ @@ -3233,11 +3233,11 @@ m->m_flags |= M_FLOWID; #endif - ifp->if_ipackets++; + if_incipackets(ifp, 1); fp->eth_q_stats.rx_tpa_pkts++; /* pass the frame to the stack */ - (*ifp->if_input)(ifp, m); + if_input(ifp, m); } /* we passed an mbuf up the stack or dropped the frame */ @@ -3253,7 +3253,7 @@ bxe_rxeof(struct bxe_softc *sc, struct bxe_fastpath *fp) { - struct ifnet *ifp = sc->ifnet; + if_t ifp = sc->ifp; uint16_t bd_cons, bd_prod, bd_prod_fw, comp_ring_cons; uint16_t hw_cq_cons, sw_cq_cons, sw_cq_prod; int rx_pkts = 0; @@ -3421,13 +3421,13 @@ m->m_pkthdr.len = m->m_len = len; /* assign packet to this interface interface */ - m->m_pkthdr.rcvif = ifp; + if_setrcvif(m, ifp); /* assume no hardware checksum has complated */ m->m_pkthdr.csum_flags = 0; /* validate checksum if offload enabled */ - if (ifp->if_capenable & IFCAP_RXCSUM) { + if (if_getcapenable(ifp) & IFCAP_RXCSUM) { /* check for a valid IP frame */ if (!(cqe->fast_path_cqe.status_flags & ETH_FAST_PATH_RX_CQE_IP_XSUM_NO_VALIDATION_FLG)) { @@ -3476,9 +3476,9 @@ /* pass the frame to the stack */ if (__predict_true(m != NULL)) { - ifp->if_ipackets++; + if_incipackets(ifp, 1); rx_pkts++; - (*ifp->if_input)(ifp, m); + if_input(ifp, m); } next_cqe: @@ -3605,7 +3605,7 @@ bxe_txeof(struct bxe_softc *sc, struct bxe_fastpath *fp) { - struct ifnet *ifp = sc->ifnet; + if_t ifp = sc->ifp; uint16_t bd_cons, hw_cons, sw_cons, pkt_cons; uint16_t tx_bd_avail; @@ -3639,9 +3639,9 @@ tx_bd_avail = bxe_tx_avail(sc, fp); if (tx_bd_avail < BXE_TX_CLEANUP_THRESHOLD) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); } else { - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); } if (fp->tx_pkt_prod != fp->tx_pkt_cons) { @@ -4528,9 +4528,9 @@ * the user runs "ifconfig bxe media ..." or "ifconfig bxe mediaopt ...". */ static int -bxe_ifmedia_update(struct ifnet *ifp) +bxe_ifmedia_update(struct ifnet *ifp) { - struct bxe_softc *sc = (struct bxe_softc *)ifp->if_softc; + struct bxe_softc *sc = (struct bxe_softc *)if_getsoftc(ifp); struct ifmedia *ifm; ifm = &sc->ifmedia; @@ -4563,10 +4563,10 @@ static void bxe_ifmedia_status(struct ifnet *ifp, struct ifmediareq *ifmr) { - struct bxe_softc *sc = ifp->if_softc; + struct bxe_softc *sc = if_getsoftc(ifp); /* Report link down if the driver isn't running. */ - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) { ifmr->ifm_active |= IFM_NONE; return; } @@ -4709,8 +4709,8 @@ switch (work) { case CHIP_TQ_START: - if ((sc->ifnet->if_flags & IFF_UP) && - !(sc->ifnet->if_drv_flags & IFF_DRV_RUNNING)) { + if ((if_getflags(sc->ifp) & IFF_UP) && + !(if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING)) { /* start the interface */ BLOGD(sc, DBG_LOAD, "Starting the interface...\n"); BXE_CORE_LOCK(sc); @@ -4720,8 +4720,8 @@ break; case CHIP_TQ_STOP: - if (!(sc->ifnet->if_flags & IFF_UP) && - (sc->ifnet->if_drv_flags & IFF_DRV_RUNNING)) { + if (!(if_getflags(sc->ifp) & IFF_UP) && + (if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING)) { /* bring down the interface */ BLOGD(sc, DBG_LOAD, "Stopping the interface...\n"); bxe_periodic_stop(sc); @@ -4732,7 +4732,7 @@ break; case CHIP_TQ_REINIT: - if (sc->ifnet->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING) { /* restart the interface */ BLOGD(sc, DBG_LOAD, "Restarting the interface...\n"); bxe_periodic_stop(sc); @@ -4755,11 +4755,11 @@ * 0 = Success, >0 Failure */ static int -bxe_ioctl(struct ifnet *ifp, +bxe_ioctl(if_t ifp, u_long command, caddr_t data) { - struct bxe_softc *sc = ifp->if_softc; + struct bxe_softc *sc = if_getsoftc(ifp); struct ifreq *ifr = (struct ifreq *)data; struct bxe_nvram_data *nvdata; uint32_t priv_op; @@ -4790,9 +4790,12 @@ atomic_store_rel_int((volatile unsigned int *)&sc->mtu, (unsigned long)ifr->ifr_mtu); - atomic_store_rel_long((volatile unsigned long *)&ifp->if_mtu, + /* + atomic_store_rel_long((volatile unsigned long *)&if_getmtu(ifp), (unsigned long)ifr->ifr_mtu); - + XXX - Not sure why it needs to be atomic + */ + if_setmtu(ifp, ifr->ifr_mtu); reinit = 1; break; @@ -4801,8 +4804,8 @@ BLOGD(sc, DBG_IOCTL, "Received SIOCSIFFLAGS ioctl\n"); /* check if the interface is up */ - if (ifp->if_flags & IFF_UP) { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getflags(ifp) & IFF_UP) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { /* set the receive mode flags */ bxe_set_rx_mode(sc); } else { @@ -4810,7 +4813,7 @@ taskqueue_enqueue(sc->chip_tq, &sc->chip_tq_task); } } else { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { atomic_store_rel_long(&sc->chip_tq_flags, CHIP_TQ_STOP); taskqueue_enqueue(sc->chip_tq, &sc->chip_tq_task); } @@ -4824,7 +4827,7 @@ BLOGD(sc, DBG_IOCTL, "Received SIOCADDMULTI/SIOCDELMULTI ioctl\n"); /* check if the interface is up */ - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { /* set the receive mode flags */ bxe_set_rx_mode(sc); } @@ -4833,7 +4836,7 @@ case SIOCSIFCAP: /* find out which capabilities have changed */ - mask = (ifr->ifr_reqcap ^ ifp->if_capenable); + mask = (ifr->ifr_reqcap ^ if_getcapenable(ifp)); BLOGD(sc, DBG_IOCTL, "Received SIOCSIFCAP ioctl (mask=0x%08x)\n", mask); @@ -4840,65 +4843,66 @@ /* toggle the LRO capabilites enable flag */ if (mask & IFCAP_LRO) { - ifp->if_capenable ^= IFCAP_LRO; + if_togglecapenable(ifp, IFCAP_LRO); BLOGD(sc, DBG_IOCTL, "Turning LRO %s\n", - (ifp->if_capenable & IFCAP_LRO) ? "ON" : "OFF"); + (if_getcapenable(ifp) & IFCAP_LRO) ? "ON" : "OFF"); reinit = 1; } /* toggle the TXCSUM checksum capabilites enable flag */ if (mask & IFCAP_TXCSUM) { - ifp->if_capenable ^= IFCAP_TXCSUM; + if_togglecapenable(ifp, IFCAP_TXCSUM); BLOGD(sc, DBG_IOCTL, "Turning TXCSUM %s\n", - (ifp->if_capenable & IFCAP_TXCSUM) ? "ON" : "OFF"); - if (ifp->if_capenable & IFCAP_TXCSUM) { - ifp->if_hwassist = (CSUM_IP | + (if_getcapenable(ifp) & IFCAP_TXCSUM) ? "ON" : "OFF"); + if (if_getcapenable(ifp) & IFCAP_TXCSUM) { + if_sethwassistbits(ifp, (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_TSO | CSUM_TCP_IPV6 | - CSUM_UDP_IPV6); + CSUM_UDP_IPV6), 0); } else { - ifp->if_hwassist = 0; + if_clearhwassist(ifp); /* XXX */ } } /* toggle the RXCSUM checksum capabilities enable flag */ if (mask & IFCAP_RXCSUM) { - ifp->if_capenable ^= IFCAP_RXCSUM; + if_togglecapenable(ifp, IFCAP_RXCSUM); BLOGD(sc, DBG_IOCTL, "Turning RXCSUM %s\n", - (ifp->if_capenable & IFCAP_RXCSUM) ? "ON" : "OFF"); - if (ifp->if_capenable & IFCAP_RXCSUM) { - ifp->if_hwassist = (CSUM_IP | + (if_getcapenable(ifp) & IFCAP_RXCSUM) ? "ON" : "OFF"); + if (if_getcapenable(ifp) & IFCAP_RXCSUM) { + if_sethwassistbits(ifp, (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_TSO | CSUM_TCP_IPV6 | - CSUM_UDP_IPV6); + CSUM_UDP_IPV6), 0); } else { - ifp->if_hwassist = 0; + if_clearhwassist(ifp); /* XXX */ } } /* toggle TSO4 capabilities enabled flag */ if (mask & IFCAP_TSO4) { - ifp->if_capenable ^= IFCAP_TSO4; + if_togglecapenable(ifp, IFCAP_TSO4); BLOGD(sc, DBG_IOCTL, "Turning TSO4 %s\n", - (ifp->if_capenable & IFCAP_TSO4) ? "ON" : "OFF"); + (if_getcapenable(ifp) & IFCAP_TSO4) ? "ON" : "OFF"); } /* toggle TSO6 capabilities enabled flag */ if (mask & IFCAP_TSO6) { - ifp->if_capenable ^= IFCAP_TSO6; + if_togglecapenable(ifp, IFCAP_TSO6); BLOGD(sc, DBG_IOCTL, "Turning TSO6 %s\n", - (ifp->if_capenable & IFCAP_TSO6) ? "ON" : "OFF"); + (if_getcapenable(ifp) & IFCAP_TSO6) ? "ON" : "OFF"); } /* toggle VLAN_HWTSO capabilities enabled flag */ if (mask & IFCAP_VLAN_HWTSO) { - ifp->if_capenable ^= IFCAP_VLAN_HWTSO; + + if_togglecapenable(ifp, IFCAP_VLAN_HWTSO); BLOGD(sc, DBG_IOCTL, "Turning VLAN_HWTSO %s\n", - (ifp->if_capenable & IFCAP_VLAN_HWTSO) ? "ON" : "OFF"); + (if_getcapenable(ifp) & IFCAP_VLAN_HWTSO) ? "ON" : "OFF"); } /* toggle VLAN_HWCSUM capabilities enabled flag */ @@ -4941,7 +4945,7 @@ BLOGD(sc, DBG_IOCTL, "Received SIOCSIFMEDIA/SIOCGIFMEDIA ioctl (cmd=%lu)\n", (command & 0xff)); - error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, command); + error = ifmedia_ioctl_drv(ifp, ifr, &sc->ifmedia, command); break; case SIOCGPRIVATE_0: @@ -4977,11 +4981,11 @@ default: BLOGD(sc, DBG_IOCTL, "Received Unknown Ioctl (cmd=%lu)\n", (command & 0xff)); - error = ether_ioctl(ifp, command, data); + error = ether_ioctl_drv(ifp, command, data); break; } - if (reinit && (sc->ifnet->if_drv_flags & IFF_DRV_RUNNING)) { + if (reinit && (if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING)) { BLOGD(sc, DBG_LOAD | DBG_IOCTL, "Re-initializing hardware from IOCTL change\n"); atomic_store_rel_long(&sc->chip_tq_flags, CHIP_TQ_REINIT); @@ -5831,8 +5835,8 @@ } static void -bxe_tx_start_locked(struct bxe_softc *sc, - struct ifnet *ifp, +bxe_tx_start_locked(struct bxe_softc *sc, + if_t ifp, struct bxe_fastpath *fp) { struct mbuf *m = NULL; @@ -5842,13 +5846,13 @@ BXE_FP_TX_LOCK_ASSERT(fp); /* keep adding entries while there are frames to send */ - while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { + while (!if_sendq_empty(ifp)) { /* * check for any frames to send * dequeue can still be NULL even if queue is not empty */ - IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + m = if_dequeue(ifp); if (__predict_false(m == NULL)) { break; } @@ -5865,8 +5869,8 @@ fp->eth_q_stats.tx_encap_failures++; if (m != NULL) { /* mark the TX queue as full and return the frame */ - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - IFQ_DRV_PREPEND(&ifp->if_snd, m); + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); + if_sendq_prepend(ifp, m); fp->eth_q_stats.mbuf_alloc_tx--; fp->eth_q_stats.tx_queue_xoff++; } @@ -5879,7 +5883,7 @@ tx_count++; /* send a copy of the frame to any BPF listeners. */ - BPF_MTAP(ifp, m); + if_etherbpfmtap(ifp, m); tx_bd_avail = bxe_tx_avail(sc, fp); @@ -5887,7 +5891,7 @@ if (tx_bd_avail < BXE_TX_CLEANUP_THRESHOLD) { /* bxe_txeof will set IFF_DRV_OACTIVE appropriately */ bxe_txeof(sc, fp); - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) { + if (if_getdrvflags(ifp) & IFF_DRV_OACTIVE) { break; } } @@ -5902,19 +5906,19 @@ /* Legacy (non-RSS) dispatch routine */ static void -bxe_tx_start(struct ifnet *ifp) +bxe_tx_start(if_t ifp) { struct bxe_softc *sc; struct bxe_fastpath *fp; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { + if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) { BLOGW(sc, "Interface not running, ignoring transmit request\n"); return; } - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) { + if (if_getdrvflags(ifp) & IFF_DRV_OACTIVE) { BLOGW(sc, "Interface TX queue is full, ignoring transmit request\n"); return; } @@ -5935,7 +5939,7 @@ static int bxe_tx_mq_start_locked(struct bxe_softc *sc, - struct ifnet *ifp, + if_t ifp, struct bxe_fastpath *fp, struct mbuf *m) { @@ -5952,7 +5956,7 @@ } /* fetch the depth of the driver queue */ - depth = drbr_inuse(ifp, tx_br); + depth = drbr_inuse_drv(ifp, tx_br); if (depth > fp->eth_q_stats.tx_max_drbr_queue_depth) { fp->eth_q_stats.tx_max_drbr_queue_depth = depth; } @@ -5961,15 +5965,15 @@ if (m == NULL) { /* no new work, check for pending frames */ - next = drbr_dequeue(ifp, tx_br); - } else if (drbr_needs_enqueue(ifp, tx_br)) { + next = drbr_dequeue_drv(ifp, tx_br); + } else if (drbr_needs_enqueue_drv(ifp, tx_br)) { /* have both new and pending work, maintain packet order */ - rc = drbr_enqueue(ifp, tx_br, m); + rc = drbr_enqueue_drv(ifp, tx_br, m); if (rc != 0) { fp->eth_q_stats.tx_soft_errors++; goto bxe_tx_mq_start_locked_exit; } - next = drbr_dequeue(ifp, tx_br); + next = drbr_dequeue_drv(ifp, tx_br); } else { /* new work only and nothing pending */ next = m; @@ -5991,9 +5995,9 @@ fp->eth_q_stats.tx_encap_failures++; if (next != NULL) { /* mark the TX queue as full and save the frame */ - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); /* XXX this may reorder the frame */ - rc = drbr_enqueue(ifp, tx_br, next); + rc = drbr_enqueue_drv(ifp, tx_br, next); fp->eth_q_stats.mbuf_alloc_tx--; fp->eth_q_stats.tx_frames_deferred++; } @@ -6006,7 +6010,7 @@ tx_count++; /* send a copy of the frame to any BPF listeners */ - BPF_MTAP(ifp, next); + if_etherbpfmtap(ifp, next); tx_bd_avail = bxe_tx_avail(sc, fp); @@ -6014,12 +6018,12 @@ if (tx_bd_avail < BXE_TX_CLEANUP_THRESHOLD) { /* bxe_txeof will set IFF_DRV_OACTIVE appropriately */ bxe_txeof(sc, fp); - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) { + if (if_getdrvflags(ifp) & IFF_DRV_OACTIVE) { break; } } - next = drbr_dequeue(ifp, tx_br); + next = drbr_dequeue_drv(ifp, tx_br); } /* all TX packets were dequeued and/or the tx ring is full */ @@ -6038,7 +6042,7 @@ bxe_tx_mq_start(struct ifnet *ifp, struct mbuf *m) { - struct bxe_softc *sc = ifp->if_softc; + struct bxe_softc *sc = if_getsoftc(ifp); struct bxe_fastpath *fp; int fp_index, rc; @@ -6051,12 +6055,12 @@ fp = &sc->fp[fp_index]; - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { + if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) { BLOGW(sc, "Interface not running, ignoring transmit request\n"); return (ENETDOWN); } - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) { + if (if_getdrvflags(ifp) & IFF_DRV_OACTIVE) { BLOGW(sc, "Interface TX queue is full, ignoring transmit request\n"); return (EBUSY); } @@ -6078,7 +6082,7 @@ static void bxe_mq_flush(struct ifnet *ifp) { - struct bxe_softc *sc = ifp->if_softc; + struct bxe_softc *sc = if_getsoftc(ifp); struct bxe_fastpath *fp; struct mbuf *m; int i; @@ -6102,7 +6106,7 @@ } } - if_qflush(ifp); + if_qflush_drv(ifp); } #endif /* FreeBSD_version >= 800000 */ @@ -6793,7 +6797,7 @@ fp->rx_cq_prod = cqe_ring_prod; fp->eth_q_stats.rx_calls = fp->eth_q_stats.rx_pkts = 0; - if (sc->ifnet->if_capenable & IFCAP_LRO) { + if (if_getcapenable(sc->ifp) & IFCAP_LRO) { max_agg_queues = MAX_AGG_QS(sc); fp->tpa_enable = TRUE; @@ -8009,7 +8013,7 @@ ether_stat->mtu_size = sc->mtu; ether_stat->feature_flags |= FEATURE_ETH_CHKSUM_OFFLOAD_MASK; - if (sc->ifnet->if_capenable & (IFCAP_TSO4 | IFCAP_TSO6)) { + if (if_getcapenable(sc->ifp) & (IFCAP_TSO4 | IFCAP_TSO6)) { ether_stat->feature_flags |= FEATURE_ETH_LSO_MASK; } @@ -9040,7 +9044,7 @@ * can use to tell the task here not to do anything. */ #if 0 - if (!(sc->ifnet->if_drv_flags & IFF_DRV_RUNNING)) { + if (!(if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING)) { return; } #endif @@ -10602,7 +10606,7 @@ * This flag is relevant for E1x only. * E2 doesn't have a TPA configuration in a function level. */ - flags |= (sc->ifnet->if_capenable & IFCAP_LRO) ? FUNC_FLG_TPA : 0; + flags |= (if_getcapenable(sc->ifp) & IFCAP_LRO) ? FUNC_FLG_TPA : 0; func_init.func_flgs = flags; func_init.pf_id = SC_FUNC(sc); @@ -11659,7 +11663,7 @@ bxe_set_bit(ECORE_Q_FLG_OV, &flags); } - if (sc->ifnet->if_capenable & IFCAP_LRO) { + if (if_getcapenable(sc->ifp) & IFCAP_LRO) { bxe_set_bit(ECORE_Q_FLG_TPA, &flags); bxe_set_bit(ECORE_Q_FLG_TPA_IPV6, &flags); #if 0 @@ -11708,7 +11712,7 @@ uint16_t sge_sz = 0; uint16_t tpa_agg_size = 0; - if (sc->ifnet->if_capenable & IFCAP_LRO) { + if (if_getcapenable(sc->ifp) & IFCAP_LRO) { pause->sge_th_lo = SGE_TH_LO(sc); pause->sge_th_hi = SGE_TH_HI(sc); @@ -12257,7 +12261,7 @@ if (bxe_test_bit(BXE_LINK_REPORT_LINK_DOWN, &cur_data.link_report_flags)) { - if_link_state_change(sc->ifnet, LINK_STATE_DOWN); + if_linkstate_change_drv(sc->ifp, LINK_STATE_DOWN); BLOGI(sc, "NIC Link is Down\n"); } else { const char *duplex; @@ -12298,7 +12302,7 @@ flow = "none"; } - if_link_state_change(sc->ifnet, LINK_STATE_UP); + if_linkstate_change_drv(sc->ifp, LINK_STATE_UP); BLOGI(sc, "NIC Link is Up, %d Mbps %s duplex, Flow control: %s\n", cur_data.line_speed, duplex, flow); } @@ -12468,19 +12472,14 @@ bxe_init_mcast_macs_list(struct bxe_softc *sc, struct ecore_mcast_ramrod_params *p) { - struct ifnet *ifp = sc->ifnet; + if_t ifp = sc->ifp; int mc_count = 0; - struct ifmultiaddr *ifma; + int mcnt, i; struct ecore_mcast_list_elem *mc_mac; + unsigned char *mta; - TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) { - continue; - } - - mc_count++; - } - + mc_count = if_multiaddr_count(ifp, -1);/* XXX they don't have a limit */ + /* should we enforce one? */ ECORE_LIST_INIT(&p->mcast_list); p->mcast_list_len = 0; @@ -12488,19 +12487,27 @@ return (0); } + mta = malloc(sizeof(unsigned char) * ETHER_ADDR_LEN * + mc_count, M_DEVBUF, M_NOWAIT); + + if(mta == NULL) { + BLOGE(sc, "Failed to allocate temp mcast list\n"); + return (-1); + } + mc_mac = malloc(sizeof(*mc_mac) * mc_count, M_DEVBUF, (M_NOWAIT | M_ZERO)); if (!mc_mac) { + free(mta, M_DEVBUF); BLOGE(sc, "Failed to allocate temp mcast list\n"); return (-1); } - TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) { - continue; - } + if_multiaddr_array(ifp, mta, &mcnt, mc_count); /* mta and mcnt not expected + to be different */ + for(i=0; i< mcnt; i++) { - mc_mac->mac = (uint8_t *)LLADDR((struct sockaddr_dl *)ifma->ifma_addr); + bcopy((mta + (i * ETHER_ADDR_LEN)), mc_mac->mac, ETHER_ADDR_LEN); ECORE_LIST_PUSH_TAIL(&mc_mac->link, &p->mcast_list); BLOGD(sc, DBG_LOAD, @@ -12512,6 +12519,7 @@ } p->mcast_list_len = mc_count; + free(mta, M_DEVBUF); return (0); } @@ -12571,7 +12579,7 @@ static int bxe_set_uc_list(struct bxe_softc *sc) { - struct ifnet *ifp = sc->ifnet; + if_t ifp = sc->ifp; struct ecore_vlan_mac_obj *mac_obj = &sc->sp_objs->mac_obj; struct ifaddr *ifa; unsigned long ramrod_flags = 0; @@ -12580,7 +12588,7 @@ #if __FreeBSD_version < 800000 IF_ADDR_LOCK(ifp); #else - if_addr_rlock(ifp); + if_addr_rlock_drv(ifp); #endif /* first schedule a cleanup up of old configuration */ @@ -12590,12 +12598,12 @@ #if __FreeBSD_version < 800000 IF_ADDR_UNLOCK(ifp); #else - if_addr_runlock(ifp); + if_addr_runlock_drv(ifp); #endif return (rc); } - ifa = ifp->if_addr; + ifa = if_getifaddr(ifp); /* XXX Is this structure */ while (ifa) { if (ifa->ifa_addr->sa_family != AF_LINK) { ifa = TAILQ_NEXT(ifa, ifa_link); @@ -12613,7 +12621,7 @@ #if __FreeBSD_version < 800000 IF_ADDR_UNLOCK(ifp); #else - if_addr_runlock(ifp); + if_addr_runlock_drv(ifp); #endif return (rc); } @@ -12624,7 +12632,7 @@ #if __FreeBSD_version < 800000 IF_ADDR_UNLOCK(ifp); #else - if_addr_runlock(ifp); + if_addr_runlock_drv(ifp); #endif /* Execute the pending commands */ @@ -12638,7 +12646,7 @@ int pending) { struct bxe_softc *sc = (struct bxe_softc *)context; - struct ifnet *ifp = sc->ifnet; + if_t ifp = sc->ifp; uint32_t rx_mode = BXE_RX_MODE_NORMAL; BXE_CORE_LOCK(sc); @@ -12649,12 +12657,12 @@ return; } - BLOGD(sc, DBG_SP, "ifp->if_flags=0x%x\n", ifp->if_flags); + BLOGD(sc, DBG_SP, "if_flags(ifp)=0x%x\n", if_getflags(sc->ifp)); - if (ifp->if_flags & IFF_PROMISC) { + if (if_getflags(ifp) & IFF_PROMISC) { rx_mode = BXE_RX_MODE_PROMISC; - } else if ((ifp->if_flags & IFF_ALLMULTI) || - ((ifp->if_amcount > BXE_MAX_MULTICAST) && + } else if ((if_getflags(ifp) & IFF_ALLMULTI) || + ((if_getamcount(ifp) > BXE_MAX_MULTICAST) && CHIP_IS_E1(sc))) { rx_mode = BXE_RX_MODE_ALLMULTI; } else { @@ -13101,7 +13109,7 @@ #endif /* Tell the stack the driver is running! */ - sc->ifnet->if_drv_flags = IFF_DRV_RUNNING; + if_setdrvflags(sc->ifp, IFF_DRV_RUNNING); BLOGD(sc, DBG_LOAD, "NIC successfully loaded\n"); @@ -13154,7 +13162,7 @@ BXE_CORE_LOCK_ASSERT(sc); /* check if the driver is already running */ - if (sc->ifnet->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(sc->ifp) & IFF_DRV_RUNNING) { BLOGD(sc, DBG_LOAD, "Init called while driver is running!\n"); return (0); } @@ -13219,7 +13227,7 @@ /* Tell the stack the driver is NOT running! */ BLOGE(sc, "Initialization failed, " "stack notified driver is NOT running!\n"); - sc->ifnet->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(sc->ifp, 0, IFF_DRV_RUNNING); } return (rc); @@ -13252,7 +13260,8 @@ static int bxe_init_ifnet(struct bxe_softc *sc) { - struct ifnet *ifp; + if_t ifp; + int capabilities; /* ifconfig entrypoint for media type/status reporting */ ifmedia_init(&sc->ifmedia, IFM_IMASK, @@ -13267,32 +13276,33 @@ sc->ifmedia.ifm_media = sc->ifmedia.ifm_cur->ifm_media; /* XXX ? */ /* allocate the ifnet structure */ - if ((ifp = if_alloc(IFT_ETHER)) == NULL) { + if ((ifp = if_gethandle(IFT_ETHER)) == NULL) { BLOGE(sc, "Interface allocation failed!\n"); return (ENXIO); } - ifp->if_softc = sc; - if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev)); - ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); - ifp->if_ioctl = bxe_ioctl; - ifp->if_start = bxe_tx_start; + if_setsoftc(ifp, sc); + if_initname_drv(ifp, device_get_name(sc->dev), device_get_unit(sc->dev)); + if_setflags(ifp, (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST)); + if_setioctlfn(ifp, bxe_ioctl); + if_setstartfn(ifp, bxe_tx_start); #if __FreeBSD_version >= 800000 - ifp->if_transmit = bxe_tx_mq_start; - ifp->if_qflush = bxe_mq_flush; + if_settransmitfn(ifp, bxe_tx_mq_start); + if_setqflushfn(ifp, bxe_mq_flush); #endif #ifdef FreeBSD8_0 - ifp->if_timer = 0; + if_settimer(ifp, 0); #endif - ifp->if_init = bxe_init; - ifp->if_mtu = sc->mtu; - ifp->if_hwassist = (CSUM_IP | + if_setinitfn(ifp, bxe_init); + if_setmtu(ifp, sc->mtu); + if_sethwassist(ifp, (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_TSO | CSUM_TCP_IPV6 | - CSUM_UDP_IPV6); - ifp->if_capabilities = + CSUM_UDP_IPV6)); + + capabilities = #if __FreeBSD_version < 700000 (IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING | @@ -13312,18 +13322,17 @@ IFCAP_TSO6 | IFCAP_WOL_MAGIC); #endif - ifp->if_capenable = ifp->if_capabilities; - ifp->if_capenable &= ~IFCAP_WOL_MAGIC; /* XXX not yet... */ - ifp->if_baudrate = IF_Gbps(10); - ifp->if_snd.ifq_drv_maxlen = sc->tx_ring_size; + if_setcapabilitiesbit(ifp, capabilities, 0); /* XXX */ + if_setbaudrate(ifp, IF_Gbps(10)); +/* XXX */ + if_setsendqlen(ifp, sc->tx_ring_size); + if_setsendqready(ifp); +/* XXX */ - IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); - IFQ_SET_READY(&ifp->if_snd); + sc->ifp = ifp; - sc->ifnet = ifp; - /* attach to the Ethernet interface list */ - ether_ifattach(ifp, sc->link_params.mac_addr); + ether_ifattach_drv(ifp, sc->link_params.mac_addr); return (0); } @@ -15182,7 +15191,7 @@ /***********************/ /* set required sizes before mapping to conserve resources */ - if (sc->ifnet->if_capenable & (IFCAP_TSO4 | IFCAP_TSO6)) { + if (if_getcapenable(sc->ifp) & (IFCAP_TSO4 | IFCAP_TSO6)) { max_size = BXE_TSO_MAX_SIZE; max_segments = BXE_TSO_MAX_SEGMENTS; max_seg_size = BXE_TSO_MAX_SEG_SIZE; @@ -16388,8 +16397,8 @@ /* allocate device interrupts */ if (bxe_interrupt_alloc(sc) != 0) { - if (sc->ifnet != NULL) { - ether_ifdetach(sc->ifnet); + if (sc->ifp != NULL) { + ether_ifdetach_drv(sc->ifp); } ifmedia_removeall(&sc->ifmedia); bxe_release_mutexes(sc); @@ -16401,8 +16410,8 @@ /* allocate ilt */ if (bxe_alloc_ilt_mem(sc) != 0) { bxe_interrupt_free(sc); - if (sc->ifnet != NULL) { - ether_ifdetach(sc->ifnet); + if (sc->ifp != NULL) { + ether_ifdetach_drv(sc->ifp); } ifmedia_removeall(&sc->ifmedia); bxe_release_mutexes(sc); @@ -16415,8 +16424,8 @@ if (bxe_alloc_hsi_mem(sc) != 0) { bxe_free_ilt_mem(sc); bxe_interrupt_free(sc); - if (sc->ifnet != NULL) { - ether_ifdetach(sc->ifnet); + if (sc->ifp != NULL) { + ether_ifdetach_drv(sc->ifp); } ifmedia_removeall(&sc->ifmedia); bxe_release_mutexes(sc); @@ -16474,14 +16483,14 @@ bxe_detach(device_t dev) { struct bxe_softc *sc; - struct ifnet *ifp; + if_t ifp; sc = device_get_softc(dev); BLOGD(sc, DBG_LOAD, "Starting detach...\n"); - ifp = sc->ifnet; - if (ifp != NULL && ifp->if_vlantrunk != NULL) { + ifp = sc->ifp; + if (ifp != NULL && if_vlantrunkinuse(ifp)) { BLOGE(sc, "Cannot detach while VLANs are in use.\n"); return(EBUSY); } @@ -16506,7 +16515,7 @@ /* release the network interface */ if (ifp != NULL) { - ether_ifdetach(ifp); + ether_ifdetach_drv(ifp); } ifmedia_removeall(&sc->ifmedia); @@ -16528,8 +16537,8 @@ bxe_deallocate_bars(sc); /* Release the FreeBSD interface. */ - if (sc->ifnet != NULL) { - if_free(sc->ifnet); + if (sc->ifp != NULL) { + if_free_drv(sc->ifp); } pci_disable_busmaster(dev); Index: sys/dev/bxe/bxe.h =================================================================== --- sys/dev/bxe/bxe.h (revision 278519) +++ sys/dev/bxe/bxe.h (working copy) @@ -57,8 +57,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -1367,9 +1367,9 @@ struct bxe_softc { /* * First entry must be a pointer to the BSD ifnet struct which - * has a first element of 'void *if_softc' (which is us). + * has a first element of 'void *if_softc' (which is us). XXX */ - struct ifnet *ifnet; + if_t ifp; struct ifmedia ifmedia; /* network interface media structure */ int media; @@ -1528,11 +1528,11 @@ #define BXE_MCAST_LOCK(sc) \ do { \ mtx_lock(&sc->mcast_mtx); \ - IF_ADDR_LOCK(sc->ifnet); \ + IF_ADDR_LOCK(sc->ifp); \ } while (0) #define BXE_MCAST_UNLOCK(sc) \ do { \ - IF_ADDR_UNLOCK(sc->ifnet); \ + IF_ADDR_UNLOCK(sc->ifp); \ mtx_unlock(&sc->mcast_mtx); \ } while (0) #else @@ -1539,11 +1539,11 @@ #define BXE_MCAST_LOCK(sc) \ do { \ mtx_lock(&sc->mcast_mtx); \ - if_maddr_rlock(sc->ifnet); \ + if_maddr_rlock(sc->ifp); \ } while (0) #define BXE_MCAST_UNLOCK(sc) \ do { \ - if_maddr_runlock(sc->ifnet); \ + if_maddr_runlock(sc->ifp); \ mtx_unlock(&sc->mcast_mtx); \ } while (0) #endif Index: sys/dev/bxe/bxe_debug.c =================================================================== --- sys/dev/bxe/bxe_debug.c (revision 278519) +++ sys/dev/bxe/bxe_debug.c (working copy) @@ -299,7 +299,7 @@ char *blah4) { char if_xname[IFNAMSIZ]; - struct ifnet *ifp = NULL; + if_t ifp = NULL; struct bxe_softc *sc; db_expr_t next_arg; int index; @@ -335,13 +335,13 @@ } snprintf(if_xname, sizeof(if_xname), "bxe%d", index); - if ((ifp = ifunit_ref(if_xname)) == NULL) + if ((ifp = ifunit_ref(if_xname)) == NULL) /* XXX */ { db_printf("ERROR: Invalid interface %s\n", if_xname); goto bxe_ddb_done; } - sc = (struct bxe_softc *)ifp->if_softc; + sc = (struct bxe_softc *)if_getsoftc(ifp); db_printf("ifnet=%p (%s)\n", ifp, if_xname); db_printf("softc=%p\n", sc); db_printf(" dev=%p\n", sc->dev); Index: sys/dev/bxe/bxe_stats.c =================================================================== --- sys/dev/bxe/bxe_stats.c (revision 278519) +++ sys/dev/bxe/bxe_stats.c (working copy) @@ -1165,34 +1165,30 @@ bxe_net_stats_update(struct bxe_softc *sc) { struct bxe_eth_stats *estats = &sc->eth_stats; - struct ifnet *ifnet = sc->ifnet; - unsigned long tmp; + if_t ifnet = sc->ifp; int i; - ifnet->if_data.ifi_ipackets = + if_setipackets(ifnet, bxe_hilo(&estats->total_unicast_packets_received_hi) + bxe_hilo(&estats->total_multicast_packets_received_hi) + - bxe_hilo(&estats->total_broadcast_packets_received_hi); + bxe_hilo(&estats->total_broadcast_packets_received_hi)); - ifnet->if_data.ifi_opackets = + if_setopackets(ifnet, bxe_hilo(&estats->total_unicast_packets_transmitted_hi) + bxe_hilo(&estats->total_multicast_packets_transmitted_hi) + - bxe_hilo(&estats->total_broadcast_packets_transmitted_hi); + bxe_hilo(&estats->total_broadcast_packets_transmitted_hi)); - ifnet->if_data.ifi_ibytes = bxe_hilo(&estats->total_bytes_received_hi); + if_setibytes(ifnet, bxe_hilo(&estats->total_bytes_received_hi)); - ifnet->if_data.ifi_obytes = bxe_hilo(&estats->total_bytes_transmitted_hi); + if_setobytes(ifnet, bxe_hilo(&estats->total_bytes_transmitted_hi)); - tmp = 0; for (i = 0; i < sc->num_queues; i++) { struct tstorm_per_queue_stats *old_tclient = &sc->fp[i].old_tclient; - tmp += le32toh(old_tclient->checksum_discard); + if_inciqdrops(ifnet, le32toh(old_tclient->checksum_discard)); } - ifnet->if_data.ifi_iqdrops = tmp; - - ifnet->if_data.ifi_ierrors = + if_setierrors(ifnet, bxe_hilo(&estats->rx_stat_etherstatsundersizepkts_hi) + bxe_hilo(&estats->etherstatsoverrsizepkts_hi) + bxe_hilo(&estats->brb_drop_hi) + @@ -1199,19 +1195,19 @@ bxe_hilo(&estats->brb_truncate_hi) + bxe_hilo(&estats->rx_stat_dot3statsfcserrors_hi) + bxe_hilo(&estats->rx_stat_dot3statsalignmenterrors_hi) + - bxe_hilo(&estats->no_buff_discard_hi); + bxe_hilo(&estats->no_buff_discard_hi)); - ifnet->if_data.ifi_oerrors = + if_setoerrors(ifnet, bxe_hilo(&estats->rx_stat_dot3statscarriersenseerrors_hi) + - bxe_hilo(&estats->tx_stat_dot3statsinternalmactransmiterrors_hi); + bxe_hilo(&estats->tx_stat_dot3statsinternalmactransmiterrors_hi)); - ifnet->if_data.ifi_imcasts = - bxe_hilo(&estats->total_multicast_packets_received_hi); + if_setimcasts(ifnet, + bxe_hilo(&estats->total_multicast_packets_received_hi)); - ifnet->if_data.ifi_collisions = + if_setcollisions(ifnet, bxe_hilo(&estats->tx_stat_etherstatscollisions_hi) + bxe_hilo(&estats->tx_stat_dot3statslatecollisions_hi) + - bxe_hilo(&estats->tx_stat_dot3statsexcessivecollisions_hi); + bxe_hilo(&estats->tx_stat_dot3statsexcessivecollisions_hi)); } static void @@ -1670,14 +1666,14 @@ /* prepare statistics ramrod data */ bxe_prep_fw_stats_req(sc); - sc->ifnet->if_data.ifi_ipackets = 0; - sc->ifnet->if_data.ifi_opackets = 0; - sc->ifnet->if_data.ifi_ibytes = 0; - sc->ifnet->if_data.ifi_obytes = 0; - sc->ifnet->if_data.ifi_ierrors = 0; - sc->ifnet->if_data.ifi_oerrors = 0; - sc->ifnet->if_data.ifi_imcasts = 0; - sc->ifnet->if_data.ifi_collisions = 0; + if_setipackets(sc->ifp, 0); + if_setopackets(sc->ifp, 0); + if_setibytes(sc->ifp, 0); + if_setobytes(sc->ifp, 0); + if_setierrors(sc->ifp, 0); + if_setoerrors(sc->ifp, 0); + if_setimcasts(sc->ifp, 0); + if_setcollisions(sc->ifp, 0); if (sc->stats_init) { memset(&sc->net_stats_old, 0, sizeof(sc->net_stats_old)); @@ -1733,7 +1729,7 @@ } /* save net_device_stats statistics */ - sc->net_stats_old.rx_dropped = sc->ifnet->if_data.ifi_iqdrops; + sc->net_stats_old.rx_dropped = if_getiqdrops(sc->ifp); /* store port firmware statistics */ if (sc->port.pmf) { Index: sys/dev/dc/dcphy.c =================================================================== --- sys/dev/dc/dcphy.c (revision 278519) +++ sys/dev/dc/dcphy.c (working copy) @@ -153,7 +153,7 @@ &dcphy_funcs, 0); /*PHY_RESET(sc);*/ - dc_sc = sc->mii_pdata->mii_ifp->if_softc; + dc_sc = if_getsoftc(sc->mii_pdata->mii_ifp); CSR_WRITE_4(dc_sc, DC_10BTSTAT, 0); CSR_WRITE_4(dc_sc, DC_10BTCTRL, 0); @@ -191,7 +191,7 @@ int reg; u_int32_t mode; - dc_sc = mii->mii_ifp->if_softc; + dc_sc = if_getsoftc(mii->mii_ifp); switch (cmd) { case MII_POLLSTAT: @@ -201,7 +201,7 @@ /* * 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->mii_media_active = IFM_NONE; @@ -251,7 +251,7 @@ /* * Is the interface even up? */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + if ((if_getflags(mii->mii_ifp) & IFF_UP) == 0) return (0); /* @@ -298,12 +298,12 @@ int anlpar, tstat; struct dc_softc *dc_sc; - dc_sc = mii->mii_ifp->if_softc; + dc_sc = if_getsoftc(mii->mii_ifp); mii->mii_media_status = IFM_AVALID; mii->mii_media_active = IFM_ETHER; - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + if ((if_getflags(mii->mii_ifp) & IFF_UP) == 0) return; tstat = CSR_READ_4(dc_sc, DC_10BTSTAT); @@ -378,7 +378,7 @@ { struct dc_softc *sc; - sc = mii->mii_pdata->mii_ifp->if_softc; + sc = if_getsoftc(mii->mii_pdata->mii_ifp); DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_FULLDUPLEX); @@ -399,7 +399,7 @@ { struct dc_softc *sc; - sc = mii->mii_pdata->mii_ifp->if_softc; + sc = if_getsoftc(mii->mii_pdata->mii_ifp); DC_CLRBIT(sc, DC_SIARESET, DC_SIA_RESET); DELAY(1000); Index: sys/dev/dc/pnphy.c =================================================================== --- sys/dev/dc/pnphy.c (revision 278519) +++ sys/dev/dc/pnphy.c (working copy) @@ -152,7 +152,7 @@ /* * 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; /* @@ -180,7 +180,7 @@ /* * Is the interface even up? */ - if ((mii->mii_ifp->if_flags & IFF_UP) == 0) + if ((if_getflags(mii->mii_ifp) & IFF_UP) == 0) return (0); break; @@ -201,7 +201,7 @@ int reg; struct dc_softc *dc_sc; - dc_sc = mii->mii_ifp->if_softc; + dc_sc = if_getsoftc(mii->mii_ifp); mii->mii_media_status = IFM_AVALID; mii->mii_media_active = IFM_ETHER; Index: sys/dev/e1000/if_em.c =================================================================== --- sys/dev/e1000/if_em.c (revision 278519) +++ sys/dev/e1000/if_em.c (working copy) @@ -202,20 +202,20 @@ 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_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 __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_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 @@ 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 @@ 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 @@ 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_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 @@ { 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,8 +877,8 @@ 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 @@ -886,7 +885,7 @@ 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 @@ * 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 @@ } 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 @@ 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 @@ ** 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 @@ ** 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,14 +999,14 @@ #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; @@ -1014,15 +1013,15 @@ 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 @@ 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 @@ } 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 @@ **********************************************************************/ 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 @@ ** 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_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_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 @@ * 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,9 +1422,9 @@ * *********************************************************************/ 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; @@ -1433,7 +1431,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ { 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 @@ 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 @@ * **********************************************************************/ 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 @@ * **********************************************************************/ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_multiaddr_array(ifp, mta, &mcnt, MAX_NUM_MULTICAST_ADDRESSES); - if (mcnt == MAX_NUM_MULTICAST_ADDRESSES) - break; - - 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 @@ 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 @@ 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 @@ 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 @@ "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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ /* 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,7 +2886,7 @@ 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); @@ -2934,7 +2893,7 @@ 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 @@ 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,16 +2979,16 @@ ** 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); } /* @@ -3036,7 +2995,7 @@ * 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ } 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ ** 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 @@ /* 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 @@ 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 @@ } 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 @@ 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"); Index: sys/dev/e1000/if_em.h =================================================================== --- sys/dev/e1000/if_em.h (revision 278519) +++ sys/dev/e1000/if_em.h (working copy) @@ -345,7 +345,7 @@ /* Our adapter structure */ struct adapter { - struct ifnet *ifp; + if_t ifp; struct e1000_hw hw; /* FreeBSD operating-system-specific structures. */ Index: sys/dev/e1000/if_lem.c =================================================================== --- sys/dev/e1000/if_lem.c (revision 278519) +++ sys/dev/e1000/if_lem.c (working copy) @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -167,14 +168,14 @@ 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_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 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ #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 @@ 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 @@ 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 @@ } } - 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,13 +857,13 @@ 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; @@ -869,18 +870,18 @@ 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 @@ **********************************************************************/ 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 @@ ** 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 @@ 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 @@ 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 @@ } 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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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_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 @@ /* 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 @@ * 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 @@ * *********************************************************************/ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } } - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) lem_enable_intr(adapter); } @@ -1372,7 +1372,7 @@ 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 @@ * **********************************************************************/ 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 @@ * **********************************************************************/ 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 @@ 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 @@ 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 @@ 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 @@ 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_multiaddr_array(ifp, mta, &mcnt, MAX_NUM_MULTICAST_ADDRESSES); - if (mcnt == MAX_NUM_MULTICAST_ADDRESSES) - break; - - 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 @@ 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 @@ 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,10 +2022,11 @@ "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"); @@ -2069,7 +2033,7 @@ 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 @@ 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 @@ 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 @@ 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,16 +2355,16 @@ ** 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); } /* @@ -2408,7 +2371,7 @@ * 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 @@ 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 @@ 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 @@ ++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 @@ * 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 @@ 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 @@ 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,7 +3305,7 @@ break; } - if (ifp->if_mtu > ETHERMTU) + if (if_getmtu(ifp) > ETHERMTU) rctl |= E1000_RCTL_LPE; else rctl &= ~E1000_RCTL_LPE; @@ -3349,7 +3312,7 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ if (accept_frame) { if (lem_get_buf(adapter, i) != 0) { - ifp->if_iqdrops++; + if_inciqdrops(ifp, 1); goto discard; } @@ -3550,8 +3515,8 @@ } 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 @@ 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 @@ * 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ ** 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 @@ /* 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 @@ 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 @@ } 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. */ Index: sys/dev/e1000/if_lem.h =================================================================== --- sys/dev/e1000/if_lem.h (revision 278519) +++ sys/dev/e1000/if_lem.h (working copy) @@ -295,7 +295,7 @@ /* Our adapter structure */ struct adapter { - struct ifnet *ifp; + if_t ifp; #if __FreeBSD_version >= 800000 struct buf_ring *br; #endif Index: sys/dev/fxp/if_fxp.c =================================================================== --- sys/dev/fxp/if_fxp.c (revision 278519) +++ sys/dev/fxp/if_fxp.c (working copy) @@ -220,20 +220,20 @@ 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, @@ -254,11 +254,11 @@ 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, @@ -427,7 +427,7 @@ 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]; @@ -439,11 +439,11 @@ mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, MTX_DEF); callout_init_mtx(&sc->stat_ch, &sc->sc_mtx, 0); - ifmedia_init(&sc->sc_media, 0, fxp_serial_ifmedia_upd, + ifmedia_init_drv(&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; @@ -827,9 +827,10 @@ 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,41 +837,43 @@ } } - 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_initname_drv(ifp, device_get_name(dev), device_get_unit(dev)); + 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 /* * Attach the interface. */ - ether_ifattach(ifp, eaddr); + ether_ifattach_drv(ifp, eaddr); /* * Tell the upper layer(s) we support long frames. @@ -877,14 +880,14 @@ * 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); } /* @@ -891,9 +894,8 @@ * 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. @@ -902,7 +904,7 @@ NULL, fxp_intr, sc, &sc->ih); if (error) { device_printf(dev, "could not setup irq\n"); - ether_ifdetach(sc->ifp); + ether_ifdetach_drv(sc->ifp); goto fail; } @@ -991,7 +993,7 @@ if (sc->mcs_tag) bus_dma_tag_destroy(sc->mcs_tag); if (sc->ifp) - if_free(sc->ifp); + if_free_drv(sc->ifp); mtx_destroy(&sc->sc_mtx); } @@ -1005,8 +1007,8 @@ struct fxp_softc *sc = device_get_softc(dev); #ifdef DEVICE_POLLING - if (sc->ifp->if_capenable & IFCAP_POLLING) - ether_poll_deregister(sc->ifp); + if (if_getcapenable(sc->ifp) & IFCAP_POLLING) + ether_poll_deregister_drv(sc->ifp); #endif FXP_LOCK(sc); @@ -1021,7 +1023,7 @@ /* * Close down routes etc. */ - ether_ifdetach(sc->ifp); + ether_ifdetach_drv(sc->ifp); /* * Unhook interrupt before dropping lock. This is to prevent @@ -1061,7 +1063,7 @@ fxp_suspend(device_t dev) { struct fxp_softc *sc = device_get_softc(dev); - struct ifnet *ifp; + if_t ifp; int pmc; uint16_t pmstat; @@ -1071,12 +1073,12 @@ 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); @@ -1097,7 +1099,7 @@ 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; @@ -1118,7 +1120,7 @@ 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; @@ -1323,9 +1325,9 @@ * 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); @@ -1338,15 +1340,15 @@ * 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; @@ -1359,13 +1361,12 @@ * 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; @@ -1372,14 +1373,14 @@ 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); } /* @@ -1402,7 +1403,7 @@ 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; @@ -1669,17 +1670,17 @@ } #ifdef DEVICE_POLLING -static poll_handler_t fxp_poll; +static poll_handler_drv_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); } @@ -1713,7 +1714,7 @@ 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); @@ -1723,7 +1724,7 @@ } #ifdef DEVICE_POLLING - if (ifp->if_capenable & IFCAP_POLLING) { + if (if_getcapenable(ifp) & IFCAP_POLLING) { FXP_UNLOCK(sc); return; } @@ -1744,7 +1745,7 @@ * 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); @@ -1753,7 +1754,7 @@ static void fxp_txeof(struct fxp_softc *sc) { - struct ifnet *ifp; + if_t ifp; struct fxp_tx *txp; ifp = sc->ifp; @@ -1772,7 +1773,7 @@ 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, @@ -1782,7 +1783,7 @@ } 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; @@ -1860,7 +1861,7 @@ } 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; @@ -1902,7 +1903,7 @@ /* * Try to start more packets transmitting. */ - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + if (!if_sendq_empty(ifp)) fxp_start_body(ifp); /* @@ -1969,7 +1970,7 @@ */ 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; } @@ -1984,12 +1985,12 @@ } 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); @@ -2004,14 +2005,14 @@ * 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_inciqdrops(ifp, 1); fxp_discard_rfabuf(sc, rxp); } fxp_add_rfabuf(sc, rxp); @@ -2028,7 +2029,7 @@ 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; @@ -2069,10 +2070,10 @@ 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_incopackets(ifp, le32toh(sp->tx_good)); + if_inccollisions(ifp, le32toh(sp->tx_total_collisions)); if (sp->rx_good) { - ifp->if_ipackets += le32toh(sp->rx_good); + if_incipackets(ifp, le32toh(sp->rx_good)); sc->rx_idle_secs = 0; } else if (sc->flags & FXP_FLAG_RXBUG) { /* @@ -2080,17 +2081,17 @@ */ sc->rx_idle_secs++; } - ifp->if_ierrors += + if_incierrors(ifp, 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 * threshold by another 512 bytes (64 * 8). */ if (sp->tx_underruns) { - ifp->if_oerrors += le32toh(sp->tx_underruns); + if_incoerrors(ifp, le32toh(sp->tx_underruns)); if (tx_threshold < 192) tx_threshold += 64; } @@ -2115,7 +2116,7 @@ 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); @@ -2143,8 +2144,8 @@ */ 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; @@ -2180,11 +2181,11 @@ 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; /* @@ -2235,6 +2236,7 @@ static void fxp_watchdog(struct fxp_softc *sc) { + if_t ifp = sc->ifp; FXP_LOCK_ASSERT(sc, MA_OWNED); @@ -2242,9 +2244,9 @@ return; device_printf(sc->dev, "device timeout\n"); - sc->ifp->if_oerrors++; + if_incoerrors(ifp, 1); - sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); fxp_init_body(sc, 1); } @@ -2270,7 +2272,7 @@ 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; @@ -2280,7 +2282,7 @@ FXP_LOCK_ASSERT(sc, MA_OWNED); - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) return; /* @@ -2295,7 +2297,7 @@ 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 @@ -2322,7 +2324,7 @@ * 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); } @@ -2378,7 +2380,7 @@ 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 */ @@ -2405,10 +2407,10 @@ 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) { /* @@ -2487,7 +2489,7 @@ 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. @@ -2549,8 +2551,7 @@ 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. @@ -2560,7 +2561,7 @@ * ... 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 */ @@ -2573,7 +2574,7 @@ } static int -fxp_serial_ifmedia_upd(struct ifnet *ifp) +fxp_serial_ifmedia_upd(if_t ifp) { return (0); @@ -2580,7 +2581,7 @@ } 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; @@ -2590,9 +2591,9 @@ * 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; @@ -2609,9 +2610,9 @@ * 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); @@ -2800,13 +2801,13 @@ { 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; @@ -2822,14 +2823,14 @@ */ 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; @@ -2843,19 +2844,19 @@ * 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; @@ -2862,8 +2863,8 @@ 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); @@ -2873,33 +2874,33 @@ case SIOCGIFMEDIA: if (sc->miibus != NULL) { mii = device_get_softc(sc->miibus); - error = ifmedia_ioctl(ifp, ifr, + error = ifmedia_ioctl_drv(ifp, ifr, &mii->mii_media, command); } else { - error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, command); + error = ifmedia_ioctl_drv(ifp, ifr, &sc->sc_media, command); } break; 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) { - error = ether_poll_register(fxp_poll, ifp); + error = ether_poll_register_drv(fxp_poll, ifp); if (error) return(error); 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); + error = ether_poll_deregister_drv(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); } } @@ -2906,65 +2907,66 @@ #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: - error = ether_ioctl(ifp, command, data); + error = ether_ioctl_drv(ifp, command, data); } return (error); } @@ -2976,24 +2978,15 @@ 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); } Index: sys/dev/fxp/if_fxpvar.h =================================================================== --- sys/dev/fxp/if_fxpvar.h (revision 278519) +++ sys/dev/fxp/if_fxpvar.h (working copy) @@ -178,7 +178,7 @@ * 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 */ Index: sys/dev/fxp/inphy.c =================================================================== --- sys/dev/fxp/inphy.c (revision 278519) +++ sys/dev/fxp/inphy.c (working copy) @@ -122,7 +122,7 @@ /* * 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); Index: sys/dev/hme/if_hme_pci.c =================================================================== --- sys/dev/hme/if_hme_pci.c (revision 278519) +++ sys/dev/hme/if_hme_pci.c (working copy) @@ -58,6 +58,7 @@ #include #include +#include #include #include #include Index: sys/dev/mii/acphy.c =================================================================== --- sys/dev/mii/acphy.c (revision 278519) +++ sys/dev/mii/acphy.c (working copy) @@ -68,6 +68,7 @@ #include #include +#include #include #include Index: sys/dev/mii/amphy.c =================================================================== --- sys/dev/mii/amphy.c (revision 278519) +++ sys/dev/mii/amphy.c (working copy) @@ -47,6 +47,7 @@ #include #include +#include #include #include Index: sys/dev/mii/atphy.c =================================================================== --- sys/dev/mii/atphy.c (revision 278519) +++ sys/dev/mii/atphy.c (working copy) @@ -40,6 +40,7 @@ #include #include +#include #include #include Index: sys/dev/mii/axphy.c =================================================================== --- sys/dev/mii/axphy.c (revision 278519) +++ sys/dev/mii/axphy.c (working copy) @@ -39,6 +39,7 @@ #include #include +#include #include #include Index: sys/dev/mii/bmtphy.c =================================================================== --- sys/dev/mii/bmtphy.c (revision 278519) +++ sys/dev/mii/bmtphy.c (working copy) @@ -72,6 +72,7 @@ #include #include +#include #include #include Index: sys/dev/mii/brgphy.c =================================================================== --- sys/dev/mii/brgphy.c (revision 278519) +++ sys/dev/mii/brgphy.c (working copy) @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -197,7 +198,7 @@ struct bge_softc *bge_sc = NULL; struct bce_softc *bce_sc = NULL; struct mii_softc *sc; - struct ifnet *ifp; + if_t ifp; bsc = device_get_softc(dev); sc = &bsc->mii_sc; @@ -209,10 +210,10 @@ ifp = sc->mii_pdata->mii_ifp; /* Find the MAC driver associated with this PHY. */ - if (strcmp(ifp->if_dname, "bge") == 0) - bge_sc = ifp->if_softc; - else if (strcmp(ifp->if_dname, "bce") == 0) - bce_sc = ifp->if_softc; + if (strcmp(if_getdname(ifp), "bge") == 0) + bge_sc = if_getsoftc(ifp); + else if (strcmp(if_getdname(ifp), "bce") == 0) + bce_sc = if_getsoftc(ifp); /* Handle any special cases based on the PHY ID */ switch (sc->mii_mpd_oui) { @@ -879,7 +880,7 @@ { struct bge_softc *bge_sc = NULL; struct bce_softc *bce_sc = NULL; - struct ifnet *ifp; + if_t ifp; int i, val; /* @@ -932,10 +933,10 @@ ifp = sc->mii_pdata->mii_ifp; /* Find the driver associated with this PHY. */ - if (strcmp(ifp->if_dname, "bge") == 0) { - bge_sc = ifp->if_softc; - } else if (strcmp(ifp->if_dname, "bce") == 0) { - bce_sc = ifp->if_softc; + if (strcmp(if_getdname(ifp), "bge") == 0) { + bge_sc = if_getsoftc(ifp); + } else if (strcmp(if_getdname(ifp), "bce") == 0) { + bce_sc = if_getsoftc(ifp); } if (bge_sc) { @@ -954,7 +955,7 @@ brgphy_fixup_jitter_bug(sc); if (bge_sc->bge_flags & BGE_FLAG_JUMBO) - brgphy_jumbo_settings(sc, ifp->if_mtu); + brgphy_jumbo_settings(sc, if_getmtu(ifp)); if ((bge_sc->bge_phy_flags & BGE_PHY_NO_WIRESPEED) == 0) brgphy_ethernet_wirespeed(sc); @@ -1065,11 +1066,11 @@ (BCE_CHIP_REV(bce_sc) == BCE_CHIP_REV_Bx)) brgphy_fixup_disable_early_dac(sc); - brgphy_jumbo_settings(sc, ifp->if_mtu); + brgphy_jumbo_settings(sc, if_getmtu(ifp)); brgphy_ethernet_wirespeed(sc); } else { brgphy_fixup_ber_bug(sc); - brgphy_jumbo_settings(sc, ifp->if_mtu); + brgphy_jumbo_settings(sc, if_getmtu(ifp)); brgphy_ethernet_wirespeed(sc); } } Index: sys/dev/mii/ciphy.c =================================================================== --- sys/dev/mii/ciphy.c (revision 278519) +++ sys/dev/mii/ciphy.c (working copy) @@ -45,6 +45,7 @@ #include #include +#include #include #include Index: sys/dev/mii/e1000phy.c =================================================================== --- sys/dev/mii/e1000phy.c (revision 278519) +++ sys/dev/mii/e1000phy.c (working copy) @@ -132,7 +132,7 @@ e1000phy_attach(device_t dev) { struct mii_softc *sc; - struct ifnet *ifp; + if_t ifp; sc = device_get_softc(dev); @@ -139,7 +139,7 @@ mii_phy_dev_attach(dev, MIIF_NOMANPAUSE, &e1000phy_funcs, 0); ifp = sc->mii_pdata->mii_ifp; - if (strcmp(ifp->if_dname, "msk") == 0 && + if (strcmp(if_getdname(ifp), "msk") == 0 && (sc->mii_flags & MIIF_MACPRIV0) != 0) sc->mii_flags |= MIIF_PHYPRIV0; Index: sys/dev/mii/gentbi.c =================================================================== --- sys/dev/mii/gentbi.c (revision 278519) +++ sys/dev/mii/gentbi.c (working copy) @@ -78,6 +78,7 @@ #include #include +#include #include #include Index: sys/dev/mii/icsphy.c =================================================================== --- sys/dev/mii/icsphy.c (revision 278519) +++ sys/dev/mii/icsphy.c (working copy) @@ -70,6 +70,7 @@ #include #include +#include #include #include Index: sys/dev/mii/ip1000phy.c =================================================================== --- sys/dev/mii/ip1000phy.c (revision 278519) +++ sys/dev/mii/ip1000phy.c (working copy) @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -109,7 +110,7 @@ ma = device_get_ivars(dev); flags = MIIF_NOISOLATE | MIIF_NOMANPAUSE; if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxICPLUS_IP1000A && - strcmp(ma->mii_data->mii_ifp->if_dname, "stge") == 0 && + strcmp(if_getdname(ma->mii_data->mii_ifp), "stge") == 0 && (miibus_get_flags(dev) & MIIF_MACPRIV0) != 0) flags |= MIIF_PHYPRIV0; mii_phy_dev_attach(dev, flags, &ip1000phy_funcs, 1); Index: sys/dev/mii/jmphy.c =================================================================== --- sys/dev/mii/jmphy.c (revision 278519) +++ sys/dev/mii/jmphy.c (working copy) @@ -105,7 +105,7 @@ ma = device_get_ivars(dev); flags = 0; - if (strcmp(ma->mii_data->mii_ifp->if_dname, "jme") == 0 && + if (strcmp(if_getdname(ma->mii_data->mii_ifp), "jme") == 0 && (miibus_get_flags(dev) & MIIF_MACPRIV0) != 0) flags |= MIIF_PHYPRIV0; mii_phy_dev_attach(dev, flags, &jmphy_funcs, 1); Index: sys/dev/mii/lxtphy.c =================================================================== --- sys/dev/mii/lxtphy.c (revision 278519) +++ sys/dev/mii/lxtphy.c (working copy) @@ -72,6 +72,7 @@ #include #include +#include #include #include Index: sys/dev/mii/mii.c =================================================================== --- sys/dev/mii/mii.c (revision 278519) +++ sys/dev/mii/mii.c (working copy) @@ -106,7 +106,7 @@ }; struct miibus_ivars { - struct ifnet *ifp; + if_t ifp; ifm_change_cb_t ifmedia_upd; ifm_stat_cb_t ifmedia_sts; u_int mii_flags; @@ -147,8 +147,8 @@ ifmedia_init(&mii->mii_media, IFM_IMASK, ivars->ifmedia_upd, ivars->ifmedia_sts); mii->mii_ifp = ivars->ifp; - mii->mii_ifp->if_capabilities |= IFCAP_LINKSTATE; - mii->mii_ifp->if_capenable |= IFCAP_LINKSTATE; + if_setcapabilitiesbit(mii->mii_ifp, IFCAP_LINKSTATE, 0); + if_setcapenablebit(mii->mii_ifp, IFCAP_LINKSTATE, 0); LIST_INIT(&mii->mii_phys); return (bus_generic_attach(dev)); @@ -308,7 +308,7 @@ MIIBUS_STATCHG(parent); mii = device_get_softc(dev); - mii->mii_ifp->if_baudrate = ifmedia_baudrate(mii->mii_media_active); + if_setbaudrate(mii->mii_ifp, ifmedia_baudrate(mii->mii_media_active)); } static void @@ -330,7 +330,7 @@ link_state = LINK_STATE_DOWN; } else link_state = LINK_STATE_UNKNOWN; - if_link_state_change(mii->mii_ifp, link_state); + if_linkstate_change_drv(mii->mii_ifp, link_state); } static void @@ -358,7 +358,7 @@ * the PHYs to the network interface driver parent. */ int -mii_attach(device_t dev, device_t *miibus, struct ifnet *ifp, +mii_attach(device_t dev, device_t *miibus, void *ifp, ifm_change_cb_t ifmedia_upd, ifm_stat_cb_t ifmedia_sts, int capmask, int phyloc, int offloc, int flags) { Index: sys/dev/mii/mii_physubr.c =================================================================== --- sys/dev/mii/mii_physubr.c (revision 278519) +++ sys/dev/mii/mii_physubr.c (working copy) @@ -46,6 +46,7 @@ #include #include +#include #include #include Index: sys/dev/mii/miivar.h =================================================================== --- sys/dev/mii/miivar.h (revision 278519) +++ sys/dev/mii/miivar.h (working copy) @@ -36,6 +36,7 @@ #define _DEV_MII_MIIVAR_H_ #include +#include /* XXX driver API temporary */ /* * Media Independent Interface data structure defintions @@ -57,7 +58,7 @@ */ struct mii_data { struct ifmedia mii_media; /* media information */ - struct ifnet *mii_ifp; /* pointer back to network interface */ + if_t mii_ifp; /* pointer back to network interface */ /* * For network interfaces with multiple PHYs, a list of all @@ -246,7 +247,7 @@ extern devclass_t miibus_devclass; extern driver_t miibus_driver; -int mii_attach(device_t, device_t *, struct ifnet *, ifm_change_cb_t, +int mii_attach(device_t, device_t *, if_t, ifm_change_cb_t, ifm_stat_cb_t, int, int, int, int); void mii_down(struct mii_data *); int mii_mediachg(struct mii_data *); Index: sys/dev/mii/mlphy.c =================================================================== --- sys/dev/mii/mlphy.c (revision 278519) +++ sys/dev/mii/mlphy.c (working copy) @@ -58,6 +58,7 @@ #include #include +#include #include #include Index: sys/dev/mii/nsgphy.c =================================================================== --- sys/dev/mii/nsgphy.c (revision 278519) +++ sys/dev/mii/nsgphy.c (working copy) @@ -64,6 +64,7 @@ #include #include +#include #include #include Index: sys/dev/mii/nsphy.c =================================================================== --- sys/dev/mii/nsphy.c (revision 278519) +++ sys/dev/mii/nsphy.c (working copy) @@ -186,7 +186,7 @@ */ reg |= 0x0100 | 0x0400; - if (strcmp(mii->mii_ifp->if_dname, "fxp") == 0) + if (strcmp(if_getdname(mii->mii_ifp), "fxp") == 0) PHY_WRITE(sc, MII_NSPHY_PCR, reg); mii_phy_setmedia(sc); Index: sys/dev/mii/nsphyter.c =================================================================== --- sys/dev/mii/nsphyter.c (revision 278519) +++ sys/dev/mii/nsphyter.c (working copy) @@ -75,6 +75,7 @@ #include #include +#include #include #include Index: sys/dev/mii/pnaphy.c =================================================================== --- sys/dev/mii/pnaphy.c (revision 278519) +++ sys/dev/mii/pnaphy.c (working copy) @@ -52,6 +52,7 @@ #include #include +#include #include #include Index: sys/dev/mii/qsphy.c =================================================================== --- sys/dev/mii/qsphy.c (revision 278519) +++ sys/dev/mii/qsphy.c (working copy) @@ -72,6 +72,7 @@ #include #include +#include #include #include Index: sys/dev/mii/rdcphy.c =================================================================== --- sys/dev/mii/rdcphy.c (revision 278519) +++ sys/dev/mii/rdcphy.c (working copy) @@ -40,6 +40,7 @@ #include #include +#include #include #include Index: sys/dev/mii/rgephy.c =================================================================== --- sys/dev/mii/rgephy.c (revision 278519) +++ sys/dev/mii/rgephy.c (working copy) @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -118,7 +119,7 @@ sc = device_get_softc(dev); ma = device_get_ivars(dev); flags = 0; - if (strcmp(ma->mii_data->mii_ifp->if_dname, "re") == 0) + if (strcmp(if_getdname(ma->mii_data->mii_ifp), "re") == 0) flags |= MIIF_PHYPRIV0; mii_phy_dev_attach(dev, flags, &rgephy_funcs, 0); Index: sys/dev/mii/rlphy.c =================================================================== --- sys/dev/mii/rlphy.c (revision 278519) +++ sys/dev/mii/rlphy.c (working copy) @@ -46,6 +46,7 @@ #include /* XXXGL: if_rlreg.h contamination */ #include +#include #include #include Index: sys/dev/mii/rlswitch.c =================================================================== --- sys/dev/mii/rlswitch.c (revision 278519) +++ sys/dev/mii/rlswitch.c (working copy) @@ -47,6 +47,7 @@ #include /* XXXGL: if_rlreg.h contamination */ #include +#include #include #include Index: sys/dev/mii/smcphy.c =================================================================== --- sys/dev/mii/smcphy.c (revision 278519) +++ sys/dev/mii/smcphy.c (working copy) @@ -42,6 +42,7 @@ #include #include +#include #include #include Index: sys/dev/mii/smscphy.c =================================================================== --- sys/dev/mii/smscphy.c (revision 278519) +++ sys/dev/mii/smscphy.c (working copy) @@ -41,6 +41,7 @@ #include #include +#include #include #include Index: sys/dev/mii/tdkphy.c =================================================================== --- sys/dev/mii/tdkphy.c (revision 278519) +++ sys/dev/mii/tdkphy.c (working copy) @@ -52,6 +52,7 @@ #include #include +#include #include #include Index: sys/dev/mii/tlphy.c =================================================================== --- sys/dev/mii/tlphy.c (revision 278519) +++ sys/dev/mii/tlphy.c (working copy) @@ -73,6 +73,7 @@ #include #include +#include #include #include Index: sys/dev/mii/truephy.c =================================================================== --- sys/dev/mii/truephy.c (revision 278519) +++ sys/dev/mii/truephy.c (working copy) @@ -265,7 +265,7 @@ mii_phy_reset(sc); - if (TRUEPHY_FRAMELEN(sc->mii_pdata->mii_ifp->if_mtu) > 2048) { + if (TRUEPHY_FRAMELEN((if_getmtu(sc->mii_pdata->mii_ifp)) > 2048)) { int conf; conf = PHY_READ(sc, TRUEPHY_CONF); Index: sys/dev/mii/ukphy.c =================================================================== --- sys/dev/mii/ukphy.c (revision 278519) +++ sys/dev/mii/ukphy.c (working copy) @@ -70,6 +70,7 @@ #include #include +#include #include #include Index: sys/dev/mii/ukphy_subr.c =================================================================== --- sys/dev/mii/ukphy_subr.c (revision 278519) +++ sys/dev/mii/ukphy_subr.c (working copy) @@ -44,6 +44,7 @@ #include #include +#include #include #include Index: sys/dev/mii/xmphy.c =================================================================== --- sys/dev/mii/xmphy.c (revision 278519) +++ sys/dev/mii/xmphy.c (working copy) @@ -47,6 +47,7 @@ #include #include +#include #include #include Index: sys/dev/netmap/netmap_generic.c =================================================================== --- sys/dev/netmap/netmap_generic.c (revision 278519) +++ sys/dev/netmap/netmap_generic.c (working copy) @@ -804,3 +804,9 @@ return retval; } + +struct netmap_adapter * +netmap_getna(if_t ifp) +{ + return (NA((struct ifnet *)ifp)); +} Index: sys/dev/netmap/netmap_kern.h =================================================================== --- sys/dev/netmap/netmap_kern.h (revision 278519) +++ sys/dev/netmap/netmap_kern.h (working copy) @@ -1262,6 +1262,7 @@ int generic_xmit_frame(struct ifnet *ifp, struct mbuf *m, void *addr, u_int len, u_int ring_nr); int generic_find_num_desc(struct ifnet *ifp, u_int *tx, u_int *rx); void generic_find_num_queues(struct ifnet *ifp, u_int *txq, u_int *rxq); +struct netmap_adapter *netmap_getna(if_t ifp); /* * netmap_mitigation API. This is used by the generic adapter @@ -1376,5 +1377,4 @@ struct netmap_vp_adapter *dst_na, struct nm_bdg_fwd *ft_p, struct netmap_ring *ring, u_int *j, u_int lim, u_int *howmany); - #endif /* _NET_NETMAP_KERN_H_ */ Index: sys/dev/usb/net/ruephy.c =================================================================== --- sys/dev/usb/net/ruephy.c (revision 278519) +++ sys/dev/usb/net/ruephy.c (working copy) @@ -41,6 +41,7 @@ #include #include +#include #include #include Index: sys/dev/xl/xlphy.c =================================================================== --- sys/dev/xl/xlphy.c (revision 278519) +++ sys/dev/xl/xlphy.c (working copy) @@ -69,6 +69,7 @@ #include #include +#include #include #include Index: sys/kern/kern_poll.c =================================================================== --- sys/kern/kern_poll.c (revision 278519) +++ sys/kern/kern_poll.c (working copy) @@ -451,6 +451,19 @@ mtx_unlock(&poll_mtx); } +/* The following should be temporary, till all drivers use the driver API */ +int +ether_poll_register_drv(poll_handler_drv_t *h, if_t ifh) +{ + return (ether_poll_register((poll_handler_t *)h, (struct ifnet *)ifh)); +} + +int +ether_poll_deregister_drv(if_t ifh) +{ + return (ether_poll_deregister((struct ifnet *)ifh)); +} + /* * Try to register routine for polling. Returns 0 if successful * (and polling should be enabled), error code otherwise. Index: sys/net/if.c =================================================================== --- sys/net/if.c (revision 278519) +++ sys/net/if.c (working copy) @@ -63,6 +63,8 @@ #include #include +#include +#include #include #include #include @@ -69,6 +71,8 @@ #include #include #include +#include +#include #include #include #include @@ -1400,17 +1404,17 @@ } void -if_maddr_rlock(struct ifnet *ifp) +if_maddr_rlock(if_t ifp) { - IF_ADDR_RLOCK(ifp); + IF_ADDR_RLOCK((struct ifnet *)ifp); } void -if_maddr_runlock(struct ifnet *ifp) +if_maddr_runlock(if_t ifp) { - IF_ADDR_RUNLOCK(ifp); + IF_ADDR_RUNLOCK((struct ifnet *)ifp); } /* @@ -3447,3 +3451,644 @@ if_com_alloc[type] = NULL; if_com_free[type] = NULL; } + +/* API for driver access to network stack owned ifnet.*/ +uint64_t +if_setbaudrate(void *arg, uint64_t baudrate) +{ + struct ifnet *ifp = arg; + uint64_t oldbrate; + + oldbrate = ifp->if_baudrate; + ifp->if_baudrate = baudrate; + return (oldbrate); +} + +uint64_t +if_getbaudrate(if_t ifp) +{ + + return (((struct ifnet *)ifp)->if_baudrate); +} + +int +if_setcapabilities(if_t ifp, int capabilities) +{ + ((struct ifnet *)ifp)->if_capabilities = capabilities; + return (0); +} + +int +if_setcapabilitiesbit(if_t ifp, int setbit, int clearbit) +{ + ((struct ifnet *)ifp)->if_capabilities |= setbit; + ((struct ifnet *)ifp)->if_capabilities &= ~clearbit; + + return (0); +} + +int +if_getcapabilities(if_t ifp) +{ + return ((struct ifnet *)ifp)->if_capabilities; +} + +int +if_setcapenable(if_t ifp, int capabilities) +{ + ((struct ifnet *)ifp)->if_capenable = capabilities; + return (0); +} + +int +if_setcapenablebit(if_t ifp, int setcap, int clearcap) +{ + if(setcap) + ((struct ifnet *)ifp)->if_capenable |= setcap; + if(clearcap) + ((struct ifnet *)ifp)->if_capenable &= ~clearcap; + + return (0); +} + +const char * +if_getdname(if_t ifp) +{ + return ((struct ifnet *)ifp)->if_dname; +} + +int +if_togglecapenable(if_t ifp, int togglecap) +{ + ((struct ifnet *)ifp)->if_capenable ^= togglecap; + return (0); +} + +int +if_getcapenable(if_t ifp) +{ + return ((struct ifnet *)ifp)->if_capenable; +} + +/* + * This is largely undesirable because it ties ifnet to a device, but does + * provide flexiblity for an embedded product vendor. Should be used with + * the understanding that it violates the interface boundaries, and should be + * a last resort only. + */ +int +if_setdev(if_t ifp, void *dev) +{ + return (0); +} + +int +if_setdrvflagbits(if_t ifp, int set_flags, int clear_flags) +{ + ((struct ifnet *)ifp)->if_drv_flags |= set_flags; + ((struct ifnet *)ifp)->if_drv_flags &= ~clear_flags; + + return (0); +} + +int +if_getdrvflags(if_t ifp) +{ + return ((struct ifnet *)ifp)->if_drv_flags; +} + +int +if_setdrvflags(if_t ifp, int flags) +{ + ((struct ifnet *)ifp)->if_drv_flags = flags; + return (0); +} + + +int +if_setflags(if_t ifp, int flags) +{ + ((struct ifnet *)ifp)->if_flags = flags; + return (0); +} + +int +if_setflagbits(if_t ifp, int set, int clear) +{ + ((struct ifnet *)ifp)->if_flags |= set; + ((struct ifnet *)ifp)->if_flags &= ~clear; + + return (0); +} + +int +if_getflags(if_t ifp) +{ + return ((struct ifnet *)ifp)->if_flags; +} + +int +if_clearhwassist(if_t ifp) +{ + ((struct ifnet *)ifp)->if_hwassist = 0; + return (0); +} + +int +if_sethwassistbits(if_t ifp, int toset, int toclear) +{ + ((struct ifnet *)ifp)->if_hwassist |= toset; + ((struct ifnet *)ifp)->if_hwassist &= ~toclear; + + return (0); +} + +int +if_sethwassist(if_t ifp, int hwassist_bit) +{ + ((struct ifnet *)ifp)->if_hwassist = hwassist_bit; + return (0); +} + +int +if_gethwassist(if_t ifp) +{ + return ((struct ifnet *)ifp)->if_hwassist; +} + +int +if_setmtu(if_t ifp, int mtu) +{ + ((struct ifnet *)ifp)->if_mtu = mtu; + return (0); +} + +int +if_getmtu(if_t ifp) +{ + return ((struct ifnet *)ifp)->if_mtu; +} + +int +if_setsoftc(if_t ifp, void *softc) +{ + ((struct ifnet *)ifp)->if_softc = softc; + return (0); +} + +void * +if_getsoftc(if_t ifp) +{ + return ((struct ifnet *)ifp)->if_softc; +} + +void +if_setrcvif(struct mbuf *m, if_t ifp) +{ + m->m_pkthdr.rcvif = (struct ifnet *)ifp; +} + +void +if_setvtag(struct mbuf *m, uint16_t tag) +{ + m->m_pkthdr.ether_vtag = tag; +} + +uint16_t +if_getvtag(struct mbuf *m) +{ + + return (m->m_pkthdr.ether_vtag); +} + +/* Statistics */ +int +if_incipackets(if_t ifp, int pkts) +{ + ((struct ifnet *)ifp)->if_ipackets += pkts; + return (0); +} + +int +if_incopackets(if_t ifp, int pkts) +{ + ((struct ifnet *)ifp)->if_opackets += pkts; + return (0); +} + +int +if_incierrors(if_t ifp, int ierrors) +{ + ((struct ifnet *)ifp)->if_ierrors += ierrors; + return (0); +} + + +int +if_setierrors(if_t ifp, int ierrors) +{ + ((struct ifnet *)ifp)->if_ierrors = ierrors; + return (0); +} + +int +if_setoerrors(if_t ifp, int oerrors) +{ + ((struct ifnet *)ifp)->if_oerrors = oerrors; + return (0); +} + +int if_incoerrors(if_t ifp, int oerrors) +{ + ((struct ifnet *)ifp)->if_oerrors += oerrors; + return (0); +} + +int if_inciqdrops(if_t ifp, int val) +{ + ((struct ifnet *)ifp)->if_iqdrops += val; + return (0); +} + +int +if_setcollisions(if_t ifp, int collisions) +{ + ((struct ifnet *)ifp)->if_collisions = collisions; + return (0); +} + +int +if_inccollisions(if_t ifp, int collisions) +{ + ((struct ifnet *)ifp)->if_collisions += collisions; + return (0); +} + +int +if_setipackets(if_t ifp, int pkts) +{ + ((struct ifnet *)ifp)->if_ipackets = pkts; + return (0); +} + +int +if_setopackets(if_t ifp, int pkts) +{ + ((struct ifnet *)ifp)->if_opackets = pkts; + return (0); +} + +int +if_incobytes(if_t ifp, int bytes) +{ + ((struct ifnet *)ifp)->if_obytes += bytes; + return (0); +} + +int +if_setibytes(if_t ifp, int bytes) +{ + ((struct ifnet *)ifp)->if_ibytes = bytes; + return (0); +} + +int +if_setobytes(if_t ifp, int bytes) +{ + ((struct ifnet *)ifp)->if_obytes = bytes; + return (0); +} + + +int +if_sendq_empty(if_t ifp) +{ + return IFQ_DRV_IS_EMPTY(&((struct ifnet *)ifp)->if_snd); +} + +int if_getiqdrops(if_t ifp) +{ + return ((struct ifnet *)ifp)->if_iqdrops; +} + +int +if_incimcasts(if_t ifp, int mcast) +{ + ((struct ifnet *)ifp)->if_imcasts += mcast; + return (0); +} + + +int +if_incomcasts(if_t ifp, int mcast) +{ + ((struct ifnet *)ifp)->if_omcasts += mcast; + return (0); +} + +int +if_setimcasts(if_t ifp, int mcast) +{ + ((struct ifnet *)ifp)->if_imcasts = mcast; + return (0); +} + + +struct ifaddr * +if_getifaddr(if_t ifp) +{ + return ((struct ifnet *)ifp)->if_addr; +} + +int +if_getamcount(if_t ifp) +{ + return ((struct ifnet *)ifp)->if_amcount; +} + + +int +if_setsendqready(if_t ifp) +{ + IFQ_SET_READY(&((struct ifnet *)ifp)->if_snd); + return (0); +} + +int +if_setsendqlen(if_t ifp, int tx_desc_count) +{ + IFQ_SET_MAXLEN(&((struct ifnet *)ifp)->if_snd, tx_desc_count); + ((struct ifnet *)ifp)->if_snd.ifq_drv_maxlen = tx_desc_count; + + return (0); +} + +int +if_vlantrunkinuse(if_t ifp) +{ + return ((struct ifnet *)ifp)->if_vlantrunk != NULL?1:0; +} + +int +if_input(if_t ifp, struct mbuf* sendmp) +{ + (*((struct ifnet *)ifp)->if_input)((struct ifnet *)ifp, sendmp); + return (0); + +} + +/* XXX */ +#ifndef ETH_ADDR_LEN +#define ETH_ADDR_LEN 6 +#endif + +int +if_setupmultiaddr(if_t ifp, void *mta, int *cnt, int max) +{ + struct ifmultiaddr *ifma; + uint8_t *lmta = (uint8_t *)mta; + int mcnt = 0; + + TAILQ_FOREACH(ifma, &((struct ifnet *)ifp)->if_multiaddrs, ifma_link) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + + if (mcnt == max) + break; + + bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr), + &lmta[mcnt * ETH_ADDR_LEN], ETH_ADDR_LEN); + mcnt++; + } + *cnt = mcnt; + + return (0); +} + +int +if_multiaddr_array(if_t ifp, void *mta, int *cnt, int max) +{ + int error; + + if_maddr_rlock(ifp); + error = if_setupmultiaddr(ifp, mta, cnt, max); + if_maddr_runlock(ifp); + return (error); +} + +int +if_multiaddr_count(if_t ifp, int max) +{ + struct ifmultiaddr *ifma; + int count; + + count = 0; + if_maddr_rlock(ifp); + TAILQ_FOREACH(ifma, &((struct ifnet *)ifp)->if_multiaddrs, ifma_link) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + count++; + if (count == max) + break; + } + if_maddr_runlock(ifp); + return (count); +} + +struct mbuf * +if_dequeue(if_t ifp) +{ + struct mbuf *m; + IFQ_DRV_DEQUEUE(&((struct ifnet *)ifp)->if_snd, m); + + return (m); +} + +int +if_sendq_prepend(if_t ifp, struct mbuf *m) +{ + IFQ_DRV_PREPEND(&((struct ifnet *)ifp)->if_snd, m); + return (0); +} + +int +if_setifheaderlen(if_t ifp, int len) +{ + ((struct ifnet *)ifp)->if_data.ifi_hdrlen = len; + return (0); +} + +caddr_t +if_getlladdr(if_t ifp) +{ + return (IF_LLADDR((struct ifnet *)ifp)); +} + +void * +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) +{ + struct ifnet *ifp = (struct ifnet *)ifh; + + ETHER_BPF_MTAP(ifp, m); +} + +void +if_vlancap(if_t ifh) +{ + struct ifnet *ifp = (struct ifnet *)ifh; + VLAN_CAPABILITIES(ifp); +} + +void +if_setinitfn(if_t ifp, void (*init_fn)(void *)) +{ + ((struct ifnet *)ifp)->if_init = init_fn; +} + +void +if_setioctlfn(if_t ifp, int (*ioctl_fn)(void *, u_long, caddr_t)) +{ + ((struct ifnet *)ifp)->if_ioctl = (void *)ioctl_fn; +} + +void +if_setstartfn(if_t ifp, void (*start_fn)(void *)) +{ + ((struct ifnet *)ifp)->if_start = (void *)start_fn; +} + +void +if_settransmitfn(if_t ifp, if_transmit_fn_t start_fn) +{ + ((struct ifnet *)ifp)->if_transmit = start_fn; +} + +void if_setqflushfn(if_t ifp, if_qflush_fn_t flush_fn) +{ + ((struct ifnet *)ifp)->if_qflush = flush_fn; + +} + +/* These wrappers are hopefully temporary, till all drivers use drvapi */ +#ifdef INET +void +arp_ifinit_drv(if_t ifh, struct ifaddr *ifa) +{ + arp_ifinit((struct ifnet *)ifh, ifa); +} +#endif + +void +ether_ifattach_drv(if_t ifh, const u_int8_t *lla) +{ + ether_ifattach((struct ifnet *)ifh, lla); +} + +void +ether_ifdetach_drv(if_t ifh) +{ + ether_ifdetach((struct ifnet *)ifh); +} + +int +ether_ioctl_drv(if_t ifh, u_long cmd, caddr_t data) +{ + struct ifnet *ifp = (struct ifnet *)ifh; + + return (ether_ioctl(ifp, cmd, data)); +} + +int +ifmedia_ioctl_drv(if_t ifh, struct ifreq *ifr, struct ifmedia *ifm, + u_long cmd) +{ + struct ifnet *ifp = (struct ifnet *)ifh; + + return (ifmedia_ioctl(ifp, ifr, ifm, cmd)); +} + +void +if_free_drv(if_t ifh) +{ + if_free((struct ifnet *)ifh); +} + +void +if_initname_drv(if_t ifh, const char *name, int unit) +{ + if_initname((struct ifnet *)ifh, name, unit); +} + +void +if_linkstate_change_drv(if_t ifh, int link_state) +{ + if_link_state_change((struct ifnet *)ifh, link_state); +} + +void +ifmedia_init_drv(struct ifmedia *ifm, int ncmask, int (*chg_cb)(void *), + void (*sts_cb)(void *, struct ifmediareq *)) +{ + ifmedia_init(ifm, ncmask, (ifm_change_cb_t)chg_cb, + (ifm_stat_cb_t)sts_cb); +} + +void +if_addr_rlock_drv(if_t ifh) +{ + + if_addr_runlock((struct ifnet *)ifh); +} + +void +if_addr_runlock_drv(if_t ifh) +{ + if_addr_runlock((struct ifnet *)ifh); +} + +void +if_qflush_drv(if_t ifh) +{ + if_qflush((struct ifnet *)ifh); + +} + +/* Revisit these - These are inline functions originally. */ +int +drbr_inuse_drv(if_t ifh, struct buf_ring *br) +{ + return drbr_inuse_drv(ifh, br); +} + +struct mbuf* +drbr_dequeue_drv(if_t ifh, struct buf_ring *br) +{ + return drbr_dequeue(ifh, br); +} + +int +drbr_needs_enqueue_drv(if_t ifh, struct buf_ring *br) +{ + return drbr_needs_enqueue(ifh, br); +} + +int +drbr_enqueue_drv(if_t ifh, struct buf_ring *br, struct mbuf *m) +{ + return drbr_enqueue(ifh, br, m); + +} Index: sys/net/if_media.h =================================================================== --- sys/net/if_media.h (revision 278519) +++ sys/net/if_media.h (working copy) @@ -59,8 +59,8 @@ /* * Driver callbacks for media status and change requests. */ -typedef int (*ifm_change_cb_t)(struct ifnet *ifp); -typedef void (*ifm_stat_cb_t)(struct ifnet *ifp, struct ifmediareq *req); +typedef int (*ifm_change_cb_t)(struct ifnet *); +typedef void (*ifm_stat_cb_t)(struct ifnet *, struct ifmediareq *req); /* * In-kernel representation of a single supported media type. @@ -106,6 +106,7 @@ int ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, u_long cmd); + /* Compute baudrate for a given media. */ uint64_t ifmedia_baudrate(int); Index: sys/net/if_var.h =================================================================== --- sys/net/if_var.h (revision 278519) +++ sys/net/if_var.h (working copy) @@ -66,6 +66,7 @@ struct ifvlantrunk; struct route; /* if_output */ struct vnet; +struct ifmedia; #ifdef _KERNEL #include /* ifqueue only? */ @@ -93,6 +94,15 @@ #define V_link_pfil_hook VNET(link_pfil_hook) #endif /* _KERNEL */ +typedef void (*if_start_fn_t)(struct ifnet *); +typedef int (*if_ioctl_fn_t)(struct ifnet *, u_long, caddr_t); +typedef void (*if_init_fn_t)(void *); +typedef void (*if_qflush_fn_t)(struct ifnet *); +typedef int (*if_transmit_fn_t)(struct ifnet *, struct mbuf *); + +/* Opaque object pointing to interface structure (ifnet) */ +typedef void *if_t; + /* * Structure defining a network interface. * @@ -170,18 +180,14 @@ struct route *); void (*if_input) /* input routine (from h/w driver) */ (struct ifnet *, struct mbuf *); - void (*if_start) /* initiate output routine */ - (struct ifnet *); - int (*if_ioctl) /* ioctl routine */ - (struct ifnet *, u_long, caddr_t); - void (*if_init) /* Init routine */ - (void *); + if_start_fn_t if_start; /* initiate output routine */ + if_ioctl_fn_t if_ioctl; /* ioctl routine */ + if_init_fn_t if_init; /* Init routine */ int (*if_resolvemulti) /* validate/resolve multicast */ (struct ifnet *, struct sockaddr **, struct sockaddr *); - void (*if_qflush) /* flush any queues */ - (struct ifnet *); - int (*if_transmit) /* initiate output routine */ - (struct ifnet *, struct mbuf *); + if_qflush_fn_t if_qflush; /* flush any queue */ + if_transmit_fn_t if_transmit; /* initiate output routine */ + void (*if_reassign) /* reassign to vnet routine */ (struct ifnet *, struct vnet *, char *); @@ -254,8 +260,8 @@ */ void if_addr_rlock(struct ifnet *ifp); /* if_addrhead */ void if_addr_runlock(struct ifnet *ifp); /* if_addrhead */ -void if_maddr_rlock(struct ifnet *ifp); /* if_multiaddrs */ -void if_maddr_runlock(struct ifnet *ifp); /* if_multiaddrs */ +void if_maddr_rlock(if_t ifp); /* if_multiaddrs */ +void if_maddr_runlock(if_t ifp); /* if_multiaddrs */ #ifdef _KERNEL #ifdef _SYS_EVENTHANDLER_H_ @@ -512,5 +518,109 @@ #define IF_LLADDR(ifp) \ LLADDR((struct sockaddr_dl *)((ifp)->if_addr->ifa_addr)) +uint64_t if_setbaudrate(if_t ifp, uint64_t baudrate); +uint64_t if_getbaudrate(if_t ifp); +int if_setcapabilities(if_t ifp, int capabilities); +int if_setcapabilitiesbit(if_t ifp, int setbit, int clearbit); +int if_getcapabilities(if_t ifp); +int if_togglecapenable(if_t ifp, int togglecap); +int if_setcapenable(if_t ifp, int capenable); +int if_setcapenablebit(if_t ifp, int setcap, int clearcap); +int if_getcapenable(if_t ifp); +const char *if_getdname(if_t ifp); +int if_setdev(if_t ifp, void *dev); +int if_setdrvflagbits(if_t ifp, int if_setflags, int clear_flags); +int if_getdrvflags(if_t ifp); +int if_setdrvflags(if_t ifp, int flags); +int if_clearhwassist(if_t ifp); +int if_sethwassistbits(if_t ifp, int toset, int toclear); +int if_sethwassist(if_t ifp, int hwassist_bit); +int if_gethwassist(if_t ifp); +int if_setsoftc(if_t ifp, void *softc); +void *if_getsoftc(if_t ifp); +int if_setflags(if_t ifp, int flags); +int if_setmtu(if_t ifp, int mtu); +int if_getmtu(if_t ifp); +int if_setflagbits(if_t ifp, int set, int clear); +int if_getflags(if_t ifp); +int if_sendq_empty(if_t ifp); +int if_setsendqready(if_t ifp); +int if_setsendqlen(if_t ifp, int tx_desc_count); +int if_input(if_t ifp, struct mbuf* sendmp); +int if_sendq_prepend(if_t ifp, struct mbuf *m); +struct mbuf *if_dequeue(if_t ifp); +int if_setifheaderlen(if_t ifp, int len); +void if_setrcvif(struct mbuf *m, if_t ifp); +void if_setvtag(struct mbuf *m, u_int16_t tag); +u_int16_t if_getvtag(struct mbuf *m); +int if_vlantrunkinuse(if_t ifp); +caddr_t if_getlladdr(if_t ifp); +void *if_gethandle(u_char); +void if_bpfmtap(if_t ifp, struct mbuf *m); +void if_etherbpfmtap(if_t ifp, struct mbuf *m); +void if_vlancap(if_t ifp); + +int if_setupmultiaddr(if_t ifp, void *mta, int *cnt, int max); +int if_multiaddr_array(if_t ifp, void *mta, int *cnt, int max); +int if_multiaddr_count(if_t ifp, int max); + +int if_getamcount(if_t ifp); +struct ifaddr * if_getifaddr(if_t ifp); +/* Shim for drivers using drvapi */ +int ifmedia_ioctl_drv(if_t ifp, struct ifreq *ifr, struct ifmedia *ifm, + u_long cmd); + +/* Statistics */ + +int if_incipackets(if_t ifp, int pkt); +int if_incopackets(if_t ifp, int pkts); +int if_incierrors(if_t ifp, int ierrors); +int if_incoerrors(if_t ifp, int oerrors); +int if_inciqdrops(if_t ifp, int val); +int if_setierrors(if_t ifp, int ierrors); +int if_setoerrors(if_t ifp, int oerrors); +int if_setcollisions(if_t ifp, int collisions); +int if_inccollisions(if_t ifp, int collisions); +int if_incobytes(if_t ifp, int bytes); +int if_getiqdrops(if_t ifp); +int if_incimcasts(if_t ifp, int imcasts); +int if_incomcasts(if_t ifp, int imcasts); +int if_setipackets(if_t ifp, int pkts); +int if_setopackets(if_t ifp, int pkts); +int if_setibytes(if_t ifp, int bytes); +int if_setobytes(if_t ifp, int bytes); +int if_setimcasts(if_t ifp, int pkts); + +/* Functions */ +void if_setinitfn(if_t ifp, void (*)(void *)); +void if_setioctlfn(if_t ifp, int (*)(void *, u_long, caddr_t)); +void if_setstartfn(if_t ifp, void (*)(void *)); +void if_settransmitfn(if_t ifp, if_transmit_fn_t); +void if_setqflushfn(if_t ifp, if_qflush_fn_t); + + +/* Shim functions till all drivers use drvapi */ +void arp_ifinit_drv(if_t ifp, struct ifaddr *ifa); +void ether_ifattach_drv(if_t ifp, const u_int8_t *lla); +void ether_ifdetach_drv(if_t ifp); +int ether_ioctl_drv(if_t ifp, u_long cmd, caddr_t data); +void if_free_drv(if_t ifp); +void if_initname_drv(if_t ifp, const char *name, int unit); +void if_linkstate_change_drv(if_t ifp, int link_state); + +struct ifmedia; +void ifmedia_init_drv(struct ifmedia *, int, int (*)(void *), + void (*)(void *, struct ifmediareq *)); + +void if_addr_rlock_drv(if_t ifp); +void if_addr_runlock_drv(if_t ifp); +void if_qflush_drv(if_t ifp); + +/* Revisit the below. These are inline functions originally */ +int drbr_inuse_drv(if_t ifp, struct buf_ring *br); +struct mbuf* drbr_dequeue_drv(if_t ifp, struct buf_ring *br); +int drbr_needs_enqueue_drv(if_t ifp, struct buf_ring *br); +int drbr_enqueue_drv(if_t ifp, struct buf_ring *br, struct mbuf *m); + #endif /* _KERNEL */ #endif /* !_NET_IF_VAR_H_ */ Index: sys/net/ifq.h =================================================================== --- sys/net/ifq.h (revision 278519) +++ sys/net/ifq.h (working copy) @@ -484,6 +484,10 @@ typedef int poll_handler_t(struct ifnet *ifp, enum poll_cmd cmd, int count); int ether_poll_register(poll_handler_t *h, struct ifnet *ifp); int ether_poll_deregister(struct ifnet *ifp); +/* The following should be temporary, till all drivers use the driver API */ +typedef int poll_handler_drv_t(if_t ifh, enum poll_cmd cmd, int count); +int ether_poll_register_drv(poll_handler_drv_t *h, if_t ifh); +int ether_poll_deregister_drv(if_t ifh); #endif /* DEVICE_POLLING */ #endif /* _KERNEL */