git: 64c618ed7dbb - main - Mechanically convert qlxge(4) to IfAPI
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 07 Mar 2023 20:29:09 UTC
The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=64c618ed7dbbae169ff8284d987e9caf6027f7d2 commit 64c618ed7dbbae169ff8284d987e9caf6027f7d2 Author: Justin Hibbits <jhibbits@FreeBSD.org> AuthorDate: 2022-08-17 20:26:49 +0000 Commit: Justin Hibbits <jhibbits@FreeBSD.org> CommitDate: 2023-03-07 20:31:48 +0000 Mechanically convert qlxge(4) to IfAPI Reviewed by: zlei Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37819 --- sys/dev/qlxge/qls_def.h | 4 +- sys/dev/qlxge/qls_hw.c | 2 +- sys/dev/qlxge/qls_ioctl.c | 2 +- sys/dev/qlxge/qls_isr.c | 4 +- sys/dev/qlxge/qls_os.c | 149 +++++++++++++++++++++++----------------------- 5 files changed, 80 insertions(+), 81 deletions(-) diff --git a/sys/dev/qlxge/qls_def.h b/sys/dev/qlxge/qls_def.h index 47da2403d530..f83fbdbcc27a 100644 --- a/sys/dev/qlxge/qls_def.h +++ b/sys/dev/qlxge/qls_def.h @@ -283,7 +283,7 @@ struct qla_host { bus_dma_tag_t parent_tag; /* interface to o.s */ - struct ifnet *ifp; + if_t ifp; struct ifmedia media; uint16_t max_frame_size; @@ -364,7 +364,7 @@ typedef struct qla_host qla_host_t; #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) /* Return 0, if identical, else 1 */ diff --git a/sys/dev/qlxge/qls_hw.c b/sys/dev/qlxge/qls_hw.c index ab9449089f10..e16b81667863 100644 --- a/sys/dev/qlxge/qls_hw.c +++ b/sys/dev/qlxge/qls_hw.c @@ -1305,7 +1305,7 @@ qls_update_link_state(qla_host_t *ha) 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->link_up = 0; return; } diff --git a/sys/dev/qlxge/qls_ioctl.c b/sys/dev/qlxge/qls_ioctl.c index d32ee5e22eb7..e9f8dd387e17 100644 --- a/sys/dev/qlxge/qls_ioctl.c +++ b/sys/dev/qlxge/qls_ioctl.c @@ -55,7 +55,7 @@ int qls_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/qlxge/qls_isr.c b/sys/dev/qlxge/qls_isr.c index 38da2d2c3408..ed71939d831e 100644 --- a/sys/dev/qlxge/qls_isr.c +++ b/sys/dev/qlxge/qls_isr.c @@ -129,7 +129,7 @@ qls_rx_comp(qla_host_t *ha, uint32_t rxr_idx, uint32_t cq_idx, q81_rx_t *cq_e) qla_rx_ring_t *rxr; device_t dev = ha->pci_dev; struct mbuf *mp = NULL; - struct ifnet *ifp = ha->ifp; + if_t ifp = ha->ifp; #if defined(INET) || defined(INET6) struct lro_ctrl *lro; #endif @@ -210,7 +210,7 @@ qls_rx_comp(qla_host_t *ha, uint32_t rxr_idx, uint32_t cq_idx, q81_rx_t *cq_e) } else #endif { - (*ifp->if_input)(ifp, mp); + if_input(ifp, mp); } } } else { diff --git a/sys/dev/qlxge/qls_os.c b/sys/dev/qlxge/qls_os.c index d9404b92dbba..a7e262be015f 100644 --- a/sys/dev/qlxge/qls_os.c +++ b/sys/dev/qlxge/qls_os.c @@ -90,11 +90,11 @@ static int qls_pci_probe (device_t); static int qls_pci_attach (device_t); static int qls_pci_detach (device_t); -static void qls_start(struct ifnet *ifp); +static void qls_start(if_t ifp); static void qls_init(void *arg); -static int qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); -static int qls_media_change(struct ifnet *ifp); -static void qls_media_status(struct ifnet *ifp, struct ifmediareq *ifmr); +static int qls_ioctl(if_t ifp, u_long cmd, caddr_t data); +static int qls_media_change(if_t ifp); +static void qls_media_status(if_t ifp, struct ifmediareq *ifmr); static device_method_t qla_pci_methods[] = { /* Device interface */ @@ -286,7 +286,7 @@ static void qls_watchdog(void *arg) { qla_host_t *ha = arg; - struct ifnet *ifp; + if_t ifp; ifp = ha->ifp; @@ -303,7 +303,7 @@ qls_watchdog(void *arg) ha->err_inject = 0; taskqueue_enqueue(ha->err_tq, &ha->err_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); } @@ -716,7 +716,7 @@ qls_free_parent_dma_tag(qla_host_t *ha) static void qls_init_ifnet(device_t dev, qla_host_t *ha) { - struct ifnet *ifp; + if_t ifp; QL_DPRINT2((dev, "%s: enter\n", __func__)); @@ -726,18 +726,17 @@ qls_init_ifnet(device_t dev, qla_host_t *ha) panic("%s: cannot if_alloc()\n", device_get_nameunit(dev)); if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ifp->if_baudrate = IF_Gbps(10); - ifp->if_init = qls_init; - ifp->if_softc = ha; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_ioctl = qls_ioctl; - ifp->if_start = qls_start; - - IFQ_SET_MAXLEN(&ifp->if_snd, qls_get_ifq_snd_maxlen(ha)); - ifp->if_snd.ifq_drv_maxlen = qls_get_ifq_snd_maxlen(ha); - IFQ_SET_READY(&ifp->if_snd); - - ha->max_frame_size = ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; + if_setbaudrate(ifp, IF_Gbps(10)); + if_setinitfn(ifp, qls_init); + if_setsoftc(ifp, ha); + if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); + if_setioctlfn(ifp, qls_ioctl); + if_setstartfn(ifp, qls_start); + + if_setsendqlen(ifp, qls_get_ifq_snd_maxlen(ha)); + if_setsendqready(ifp); + + ha->max_frame_size = if_getmtu(ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN; if (ha->max_frame_size <= MCLBYTES) { ha->msize = MCLBYTES; } else if (ha->max_frame_size <= MJUMPAGESIZE) { @@ -747,19 +746,19 @@ qls_init_ifnet(device_t dev, qla_host_t *ha) ether_ifattach(ifp, qls_get_mac_addr(ha)); - ifp->if_capabilities = IFCAP_JUMBO_MTU; + if_setcapabilities(ifp, IFCAP_JUMBO_MTU); - ifp->if_capabilities |= IFCAP_HWCSUM; - ifp->if_capabilities |= IFCAP_VLAN_MTU; + if_setcapabilitiesbit(ifp, IFCAP_HWCSUM, 0); + if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0); - ifp->if_capabilities |= IFCAP_TSO4; - ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING; - ifp->if_capabilities |= IFCAP_VLAN_HWTSO; - ifp->if_capabilities |= IFCAP_LINKSTATE; + if_setcapabilitiesbit(ifp, IFCAP_TSO4, 0); + if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWTAGGING, 0); + if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWTSO, 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, qls_media_change, qls_media_status); @@ -777,7 +776,7 @@ qls_init_ifnet(device_t dev, qla_host_t *ha) static void qls_init_locked(qla_host_t *ha) { - struct ifnet *ifp = ha->ifp; + if_t ifp = ha->ifp; qls_stop(ha); @@ -789,17 +788,17 @@ qls_init_locked(qla_host_t *ha) if (qls_config_lro(ha)) return; - bcopy(IF_LLADDR(ha->ifp), ha->mac_addr, ETHER_ADDR_LEN); + bcopy(if_getlladdr(ha->ifp), ha->mac_addr, ETHER_ADDR_LEN); - ifp->if_hwassist = CSUM_IP; - ifp->if_hwassist |= CSUM_TCP; - ifp->if_hwassist |= CSUM_UDP; - ifp->if_hwassist |= CSUM_TSO; + if_sethwassist(ifp, CSUM_IP); + if_sethwassistbits(ifp, CSUM_TCP, 0); + if_sethwassistbits(ifp, CSUM_UDP, 0); + if_sethwassistbits(ifp, CSUM_TSO, 0); if (qls_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; } @@ -839,7 +838,7 @@ static void qls_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, qls_copy_maddr, mta); @@ -853,7 +852,7 @@ qls_set_multi(qla_host_t *ha, uint32_t add_multi) } static int -qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +qls_ioctl(if_t ifp, u_long cmd, caddr_t data) { int ret = 0; struct ifreq *ifr = (struct ifreq *)data; @@ -862,7 +861,7 @@ qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) #endif qla_host_t *ha; - ha = (qla_host_t *)ifp->if_softc; + ha = (qla_host_t *)if_getsoftc(ifp); switch (cmd) { case SIOCSIFADDR: @@ -871,8 +870,8 @@ qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) #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)) { (void)QLA_LOCK(ha, __func__, 0); qls_init_locked(ha); QLA_UNLOCK(ha, __func__); @@ -898,9 +897,9 @@ qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } else { (void) QLA_LOCK(ha, __func__, 0); - 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_getmtu(ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN; QLA_UNLOCK(ha, __func__); @@ -916,24 +915,24 @@ qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) (void)QLA_LOCK(ha, __func__, 0); - 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) { ret = qls_set_promisc(ha); - } else if ((ifp->if_flags ^ ha->if_flags) & + } else if ((if_getflags(ifp) ^ ha->if_flags) & IFF_ALLMULTI) { ret = qls_set_allmulti(ha); } } else { - ha->max_frame_size = ifp->if_mtu + + ha->max_frame_size = if_getmtu(ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN; qls_init_locked(ha); } } else { - if (ifp->if_drv_flags & IFF_DRV_RUNNING) + if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) qls_stop(ha); - ha->if_flags = ifp->if_flags; + ha->if_flags = if_getflags(ifp); } QLA_UNLOCK(ha, __func__); @@ -943,7 +942,7 @@ qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 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) { qls_set_multi(ha, 1); } break; @@ -952,7 +951,7 @@ qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 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) { qls_set_multi(ha, 0); } break; @@ -967,21 +966,21 @@ qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 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_VLAN_HWTAGGING) - ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING; + if_togglecapenable(ifp, IFCAP_VLAN_HWTAGGING); if (mask & IFCAP_VLAN_HWTSO) - ifp->if_capenable ^= IFCAP_VLAN_HWTSO; + if_togglecapenable(ifp, IFCAP_VLAN_HWTSO); - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) + if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) qls_init(ha); VLAN_CAPABILITIES(ifp); @@ -999,13 +998,13 @@ qls_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } static int -qls_media_change(struct ifnet *ifp) +qls_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__)); @@ -1020,11 +1019,11 @@ qls_media_change(struct ifnet *ifp) } static void -qls_media_status(struct ifnet *ifp, struct ifmediareq *ifmr) +qls_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__)); @@ -1044,11 +1043,11 @@ qls_media_status(struct ifnet *ifp, struct ifmediareq *ifmr) } static void -qls_start(struct ifnet *ifp) +qls_start(if_t ifp) { int i, ret = 0; 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__)); @@ -1058,17 +1057,17 @@ qls_start(struct ifnet *ifp) 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) { for (i = 0; i < ha->num_tx_rings; i++) { ret |= qls_hw_tx_done(ha, i); } if (ret == 0) - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); } - 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); @@ -1084,8 +1083,8 @@ qls_start(struct ifnet *ifp) } } - 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", @@ -1097,8 +1096,8 @@ qls_start(struct ifnet *ifp) 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 */ @@ -1205,9 +1204,9 @@ qls_send(qla_host_t *ha, struct mbuf **m_headp) static void qls_stop(qla_host_t *ha) { - struct ifnet *ifp = ha->ifp; + if_t ifp = ha->ifp; - ifp->if_drv_flags &= ~(IFF_DRV_OACTIVE | IFF_DRV_RUNNING); + if_setdrvflagbits(ifp, 0, (IFF_DRV_OACTIVE | IFF_DRV_RUNNING)); ha->flags.qla_watchdog_pause = 1; @@ -1433,14 +1432,14 @@ static void qls_tx_done(void *context, int pending) { qla_host_t *ha = context; - struct ifnet *ifp; + if_t ifp; ifp = ha->ifp; if (!ifp) return; - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { + if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) { QL_DPRINT8((ha->pci_dev, "%s: !IFF_DRV_RUNNING\n", __func__)); return; }