diff --git a/sys/dev/qlxgb/qla_def.h b/sys/dev/qlxgb/qla_def.h --- a/sys/dev/qlxgb/qla_def.h +++ b/sys/dev/qlxgb/qla_def.h @@ -146,7 +146,7 @@ bus_dma_tag_t parent_tag; /* interface to o.s */ - struct ifnet *ifp; + if_t ifp; struct ifmedia media; uint16_t max_frame_size; @@ -206,7 +206,7 @@ #define QL_MIN(x, y) ((x < y) ? x : y) #define QL_RUNNING(ifp) \ - ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) == \ + ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) == \ IFF_DRV_RUNNING) #endif /* #ifndef _QLA_DEF_H_ */ diff --git a/sys/dev/qlxgb/qla_glbl.h b/sys/dev/qlxgb/qla_glbl.h --- a/sys/dev/qlxgb/qla_glbl.h +++ b/sys/dev/qlxgb/qla_glbl.h @@ -54,7 +54,7 @@ extern int qla_alloc_dmabuf(qla_host_t *ha, qla_dma_t *dma_buf); extern void qla_free_dmabuf(qla_host_t *ha, qla_dma_t *dma_buf); -extern void qla_start(struct ifnet *ifp); +extern void qla_start(if_t ifp); extern int qla_get_mbuf(qla_host_t *ha, qla_rx_buf_t *rxb, struct mbuf *nmp, uint32_t jumbo); diff --git a/sys/dev/qlxgb/qla_hw.c b/sys/dev/qlxgb/qla_hw.c --- a/sys/dev/qlxgb/qla_hw.c +++ b/sys/dev/qlxgb/qla_hw.c @@ -1733,7 +1733,7 @@ qla_hw_tx_done_locked(ha); if (ha->hw.txr_free > free_pkt_thres) - ha->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ha->ifp, 0, IFF_DRV_OACTIVE); mtx_unlock(&ha->tx_lock); return; @@ -1745,7 +1745,7 @@ uint32_t link_state; uint32_t prev_link_state; - if (!(ha->ifp->if_drv_flags & IFF_DRV_RUNNING)) { + if (!(if_getdrvflags(ha->ifp) & IFF_DRV_RUNNING)) { ha->hw.flags.link_up = 0; return; } diff --git a/sys/dev/qlxgb/qla_ioctl.c b/sys/dev/qlxgb/qla_ioctl.c --- a/sys/dev/qlxgb/qla_ioctl.c +++ b/sys/dev/qlxgb/qla_ioctl.c @@ -53,7 +53,7 @@ qla_make_cdev(qla_host_t *ha) { ha->ioctl_dev = make_dev(&qla_cdevsw, - ha->ifp->if_dunit, + if_getdunit(ha->ifp), UID_ROOT, GID_WHEEL, 0600, diff --git a/sys/dev/qlxgb/qla_isr.c b/sys/dev/qlxgb/qla_isr.c --- a/sys/dev/qlxgb/qla_isr.c +++ b/sys/dev/qlxgb/qla_isr.c @@ -58,7 +58,7 @@ uint32_t idx, length, status, ring; qla_rx_buf_t *rxb; struct mbuf *mp; - struct ifnet *ifp = ha->ifp; + if_t ifp = ha->ifp; qla_sds_t *sdsp; struct ether_vlan_header *eh; @@ -145,7 +145,7 @@ } else #endif { - (*ifp->if_input)(ifp, mp); + if_input(ifp, mp); } if (sdsp->rx_free > std_replenish) @@ -386,7 +386,7 @@ qla_hw_t *hw; uint32_t sds_idx; uint32_t ret; - struct ifnet *ifp; + if_t ifp; ha = ivec->ha; hw = &ha->hw; @@ -397,7 +397,7 @@ if (sds_idx == 0) { if (qla_le32_to_host(*(hw->tx_cons)) != hw->txr_comp) { taskqueue_enqueue(ha->tx_tq, &ha->tx_task); - } else if ((ifp->if_snd.ifq_head != NULL) && + } else if (!if_sendq_empty(ifp) && QL_RUNNING(ifp)) { taskqueue_enqueue(ha->tx_tq, &ha->tx_task); } diff --git a/sys/dev/qlxgb/qla_os.c b/sys/dev/qlxgb/qla_os.c --- a/sys/dev/qlxgb/qla_os.c +++ b/sys/dev/qlxgb/qla_os.c @@ -86,9 +86,9 @@ static int qla_pci_detach (device_t); static void qla_init(void *arg); -static int qla_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); -static int qla_media_change(struct ifnet *ifp); -static void qla_media_status(struct ifnet *ifp, struct ifmediareq *ifmr); +static int qla_ioctl(if_t ifp, u_long cmd, caddr_t data); +static int qla_media_change(if_t ifp); +static void qla_media_status(if_t ifp, struct ifmediareq *ifmr); static device_method_t qla_pci_methods[] = { /* Device interface */ @@ -208,7 +208,7 @@ { qla_host_t *ha = arg; qla_hw_t *hw; - struct ifnet *ifp; + if_t ifp; hw = &ha->hw; ifp = ha->ifp; @@ -219,7 +219,7 @@ if (!ha->flags.qla_watchdog_pause) { if (qla_le32_to_host(*(hw->tx_cons)) != hw->txr_comp) { taskqueue_enqueue(ha->tx_tq, &ha->tx_task); - } else if ((ifp->if_snd.ifq_head != NULL) && QL_RUNNING(ifp)) { + } else if (!if_sendq_empty(ifp) && QL_RUNNING(ifp)) { taskqueue_enqueue(ha->tx_tq, &ha->tx_task); } } @@ -654,7 +654,7 @@ static void qla_init_ifnet(device_t dev, qla_host_t *ha) { - struct ifnet *ifp; + if_t ifp; QL_DPRINT2((dev, "%s: enter\n", __func__)); @@ -665,32 +665,31 @@ if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ifp->if_mtu = ETHERMTU; - ifp->if_baudrate = IF_Gbps(10); - ifp->if_init = qla_init; - ifp->if_softc = ha; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_ioctl = qla_ioctl; - ifp->if_start = qla_start; + if_setmtu(ifp, ETHERMTU); + if_setbaudrate(ifp, IF_Gbps(10)); + if_setinitfn(ifp, qla_init); + if_setsoftc(ifp, ha); + if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); + if_setioctlfn(ifp, qla_ioctl); + if_setstartfn(ifp, qla_start); - IFQ_SET_MAXLEN(&ifp->if_snd, qla_get_ifq_snd_maxlen(ha)); - ifp->if_snd.ifq_drv_maxlen = qla_get_ifq_snd_maxlen(ha); - IFQ_SET_READY(&ifp->if_snd); + if_setsendqlen(ifp, qla_get_ifq_snd_maxlen(ha)); + if_setsendqready(ifp); - ha->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; + ha->max_frame_size = if_getmtu(ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN; ether_ifattach(ifp, qla_get_mac_addr(ha)); - ifp->if_capabilities = IFCAP_HWCSUM | + if_setcapabilities(ifp, IFCAP_HWCSUM | IFCAP_TSO4 | - IFCAP_JUMBO_MTU; + IFCAP_JUMBO_MTU); - ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU; - ifp->if_capabilities |= IFCAP_LINKSTATE; + if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU, 0); + if_setcapabilitiesbit(ifp, IFCAP_LINKSTATE, 0); - ifp->if_capenable = ifp->if_capabilities; + if_setcapenable(ifp, if_getcapabilities(ifp)); - ifp->if_hdrlen = sizeof(struct ether_vlan_header); + if_setifheaderlen(ifp, sizeof(struct ether_vlan_header)); ifmedia_init(&ha->media, IFM_IMASK, qla_media_change, qla_media_status); @@ -708,7 +707,7 @@ static void qla_init_locked(qla_host_t *ha) { - struct ifnet *ifp = ha->ifp; + if_t ifp = ha->ifp; qla_stop(ha); @@ -721,15 +720,15 @@ if (qla_config_lro(ha)) return; - bcopy(IF_LLADDR(ha->ifp), ha->hw.mac_addr, ETHER_ADDR_LEN); + bcopy(if_getlladdr(ha->ifp), ha->hw.mac_addr, ETHER_ADDR_LEN); - ifp->if_hwassist = CSUM_TCP | CSUM_UDP | CSUM_TSO; + if_sethwassist(ifp, CSUM_TCP | CSUM_UDP | CSUM_TSO); ha->flags.stop_rcv = 0; if (qla_init_hw_if(ha) == 0) { ifp = ha->ifp; - ifp->if_drv_flags |= IFF_DRV_RUNNING; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0); + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); ha->flags.qla_watchdog_pause = 0; } @@ -768,7 +767,7 @@ qla_set_multi(qla_host_t *ha, uint32_t add_multi) { uint8_t mta[Q8_MAX_NUM_MULTICAST_ADDRS * Q8_MAC_ADDR_LEN]; - struct ifnet *ifp = ha->ifp; + if_t ifp = ha->ifp; int mcnt; mcnt = if_foreach_llmaddr(ifp, qla_copy_maddr, mta); @@ -778,7 +777,7 @@ } static int -qla_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +qla_ioctl(if_t ifp, u_long cmd, caddr_t data) { int ret = 0; struct ifreq *ifr = (struct ifreq *)data; @@ -787,7 +786,7 @@ #endif qla_host_t *ha; - ha = (qla_host_t *)ifp->if_softc; + ha = (qla_host_t *)if_getsoftc(ifp); switch (cmd) { case SIOCSIFADDR: @@ -796,8 +795,8 @@ #ifdef INET if (ifa->ifa_addr->sa_family == AF_INET) { - 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)) { QLA_LOCK(ha, __func__); qla_init_locked(ha); QLA_UNLOCK(ha, __func__); @@ -825,10 +824,10 @@ ret = EINVAL; } else { QLA_LOCK(ha, __func__); - ifp->if_mtu = ifr->ifr_mtu; + if_setmtu(ifp, ifr->ifr_mtu); ha->max_frame_size = - ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) { + if_getmtu(ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN; + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING)) { ret = qla_set_max_mtu(ha, ha->max_frame_size, (ha->hw.rx_cntxt_rsp)->rx_rsp.cntxt_id); } @@ -844,19 +843,19 @@ QL_DPRINT4((ha->pci_dev, "%s: SIOCSIFFLAGS (0x%lx)\n", __func__, cmd)); - if (ifp->if_flags & IFF_UP) { - if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) { - if ((ifp->if_flags ^ ha->if_flags) & + if (if_getflags(ifp) & IFF_UP) { + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING)) { + if ((if_getflags(ifp) ^ ha->if_flags) & IFF_PROMISC) { qla_set_promisc(ha); - } else if ((ifp->if_flags ^ ha->if_flags) & + } else if ((if_getflags(ifp) ^ ha->if_flags) & IFF_ALLMULTI) { qla_set_allmulti(ha); } } else { QLA_LOCK(ha, __func__); qla_init_locked(ha); - ha->max_frame_size = ifp->if_mtu + + ha->max_frame_size = if_getmtu(ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN; ret = qla_set_max_mtu(ha, ha->max_frame_size, (ha->hw.rx_cntxt_rsp)->rx_rsp.cntxt_id); @@ -864,9 +863,9 @@ } } else { QLA_LOCK(ha, __func__); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) qla_stop(ha); - ha->if_flags = ifp->if_flags; + ha->if_flags = if_getflags(ifp); QLA_UNLOCK(ha, __func__); } break; @@ -875,7 +874,7 @@ QL_DPRINT4((ha->pci_dev, "%s: %s (0x%lx)\n", __func__, "SIOCADDMULTI", cmd)); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { qla_set_multi(ha, 1); } break; @@ -884,7 +883,7 @@ QL_DPRINT4((ha->pci_dev, "%s: %s (0x%lx)\n", __func__, "SIOCDELMULTI", cmd)); - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { qla_set_multi(ha, 0); } break; @@ -899,21 +898,21 @@ case SIOCSIFCAP: { - int mask = ifr->ifr_reqcap ^ ifp->if_capenable; + int mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); QL_DPRINT4((ha->pci_dev, "%s: SIOCSIFCAP (0x%lx)\n", __func__, cmd)); if (mask & IFCAP_HWCSUM) - ifp->if_capenable ^= IFCAP_HWCSUM; + if_togglecapenable(ifp, IFCAP_HWCSUM); if (mask & IFCAP_TSO4) - ifp->if_capenable ^= IFCAP_TSO4; + if_togglecapenable(ifp, IFCAP_TSO4); if (mask & IFCAP_TSO6) - ifp->if_capenable ^= IFCAP_TSO6; + if_togglecapenable(ifp, IFCAP_TSO6); if (mask & IFCAP_VLAN_HWTAGGING) - ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING; + if_togglecapenable(ifp, IFCAP_VLAN_HWTAGGING); - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) + if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) qla_init(ha); VLAN_CAPABILITIES(ifp); @@ -931,13 +930,13 @@ } static int -qla_media_change(struct ifnet *ifp) +qla_media_change(if_t ifp) { qla_host_t *ha; struct ifmedia *ifm; int ret = 0; - ha = (qla_host_t *)ifp->if_softc; + ha = (qla_host_t *)if_getsoftc(ifp); QL_DPRINT2((ha->pci_dev, "%s: enter\n", __func__)); @@ -952,11 +951,11 @@ } static void -qla_media_status(struct ifnet *ifp, struct ifmediareq *ifmr) +qla_media_status(if_t ifp, struct ifmediareq *ifmr) { qla_host_t *ha; - ha = (qla_host_t *)ifp->if_softc; + ha = (qla_host_t *)if_getsoftc(ifp); QL_DPRINT2((ha->pci_dev, "%s: enter\n", __func__)); @@ -976,10 +975,10 @@ } void -qla_start(struct ifnet *ifp) +qla_start(if_t ifp) { struct mbuf *m_head; - qla_host_t *ha = (qla_host_t *)ifp->if_softc; + qla_host_t *ha = (qla_host_t *)if_getsoftc(ifp); QL_DPRINT8((ha->pci_dev, "%s: enter\n", __func__)); @@ -989,7 +988,7 @@ return; } - if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) { QL_DPRINT8((ha->pci_dev, "%s: !IFF_DRV_RUNNING\n", __func__)); QLA_TX_UNLOCK(ha); @@ -1005,8 +1004,8 @@ return; } - while (ifp->if_snd.ifq_head != NULL) { - IF_DEQUEUE(&ifp->if_snd, m_head); + while (!if_sendq_empty(ifp)) { + m_head = if_dequeue(ifp); if (m_head == NULL) { QL_DPRINT8((ha->pci_dev, "%s: m_head == NULL\n", @@ -1018,8 +1017,8 @@ if (m_head == NULL) break; QL_DPRINT8((ha->pci_dev, "%s: PREPEND\n", __func__)); - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - IF_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 */ @@ -1123,7 +1122,7 @@ static void qla_stop(qla_host_t *ha) { - struct ifnet *ifp = ha->ifp; + if_t ifp = ha->ifp; ha->flags.qla_watchdog_pause = 1; qla_mdelay(__func__, 100); @@ -1138,7 +1137,7 @@ qla_free_xmt_bufs(ha); qla_free_rcv_bufs(ha); - ifp->if_drv_flags &= ~(IFF_DRV_OACTIVE | IFF_DRV_RUNNING); + if_setdrvflagbits(ifp, 0, (IFF_DRV_OACTIVE | IFF_DRV_RUNNING)); return; }