From nobody Mon Feb 06 17:53:57 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P9Ym55R4xz3n0gX; Mon, 6 Feb 2023 17:53:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P9Ym557cCz4XKD; Mon, 6 Feb 2023 17:53:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675706037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wAlHbVkm9YAgaETVQTTxt35XEqY8PFbLdwq9pGPqYYQ=; b=CIjuV4l2N53M2uXRe9++wqsDEYwiYixf7fuA0gimWTa75V3sikjvFDvspzW3BEIkp6nv+E zl5vXlhte75yVh0Nh2JZB/veNbS6U5nIDSTyyZPdEKRWpF4rbCnaQr0W1O9lgRi6PhQdTk /34u4gBHI56ce4fFI8ONmPM/bZ4ZU2qle7uaFrBVCBmbgREX2RHbKVSeaMV/DhhBNKpWiW w9N+byGcLD2Pd4H4q/tZ2P5LOZGGeldWlT7jFuTf7GuUHP3OFDjQqVv/iXWkmcRVyvsQIk FIE8L79a8pt2Wt45dpa00R2fiqd7UBHcssGQsSv+DNF9veTSHKQw08YdPoarMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675706037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wAlHbVkm9YAgaETVQTTxt35XEqY8PFbLdwq9pGPqYYQ=; b=I4ci6ZkRYTTAZb/0YHV93qriJTspAoFGm29j68pTjE3FTRTeTefi22qtAWJuIbPKaTpUKw YKk1qXjB28TD15doQAekd1WazIuONihaXbLLUJeUQD+erxuabUlMxhOjK7ilhogU545OQx pgEKGJfVXYEbqaeDjdVWjyUfZC6Gk8CUwDdiPe3ZG5tSpdxQlyKtvLs36Y0Jk0vtB7dZ7S 05ka7YC8HMYHVi5yOVRIE1JUEMoVG22/I104rrHhkGpc1gwNb6fXnL8EvBltyknrIJ3SCi s8FLMO0zacwM8IiG59Ec/DBZZXNHvhoNSKSLlVJFzOPVUN3gf5FvHhPQDtdYsQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675706037; a=rsa-sha256; cv=none; b=k248LKIzRg87lRAH33LqgwnEaEYTZ3LatyhPgyojWavJJI16hWW6gxGJLx8aGl5VJxNP8f 4+S9DtjaAJ8m0lacooa2p4rA5pCtz5jpq18I2TVrMq80Eu5iZxQHJKRbenF+X5g/+htyXu JGcanWurfcsLmfxBx4d4y8RgTyvhGE9phJTS+z8snl7GtoyBoqFWdL4ML8zbvezwAtZ50+ UMOrmNxuosfwTUaVZNZ9n4vl093gHdkdjxLqQf2lODW3cauNw1yD990/UZw5DPXmSoPnSL x2U+1qHDm3Wi7fqPI95VqiE1TNb5yAsba71J+5znloC/X3PLwWGxXFvIo5eyHA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P9Ym54DY7zkTJ; Mon, 6 Feb 2023 17:53:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 316Hrvs0074241; Mon, 6 Feb 2023 17:53:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 316Hrv7W074240; Mon, 6 Feb 2023 17:53:57 GMT (envelope-from git) Date: Mon, 6 Feb 2023 17:53:57 GMT Message-Id: <202302061753.316Hrv7W074240@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: 3f14814f05b5 - main - Mechanically convert ae(4) to IfAPI List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3f14814f05b5085b408ea25ae0bca68f4603c0ea Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=3f14814f05b5085b408ea25ae0bca68f4603c0ea commit 3f14814f05b5085b408ea25ae0bca68f4603c0ea Author: Justin Hibbits AuthorDate: 2021-10-26 16:45:58 +0000 Commit: Justin Hibbits CommitDate: 2023-02-06 17:32:05 +0000 Mechanically convert ae(4) to IfAPI Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37786 --- sys/dev/ae/if_ae.c | 163 +++++++++++++++++++++++++------------------------- sys/dev/ae/if_aevar.h | 2 +- 2 files changed, 82 insertions(+), 83 deletions(-) diff --git a/sys/dev/ae/if_ae.c b/sys/dev/ae/if_ae.c index 1ffd8b06e522..72d4fdca6aa0 100644 --- a/sys/dev/ae/if_ae.c +++ b/sys/dev/ae/if_ae.c @@ -114,8 +114,8 @@ static int ae_detach(device_t dev); static int ae_miibus_readreg(device_t dev, int phy, int reg); static int ae_miibus_writereg(device_t dev, int phy, int reg, int val); static void ae_miibus_statchg(device_t dev); -static void ae_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr); -static int ae_mediachange(struct ifnet *ifp); +static void ae_mediastatus(if_t ifp, struct ifmediareq *ifmr); +static int ae_mediachange(if_t ifp); static void ae_retrieve_address(ae_softc_t *sc); static void ae_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error); @@ -128,8 +128,8 @@ static void ae_powersave_enable(ae_softc_t *sc); static int ae_resume(device_t dev); static unsigned int ae_tx_avail_size(ae_softc_t *sc); static int ae_encap(ae_softc_t *sc, struct mbuf **m_head); -static void ae_start(struct ifnet *ifp); -static void ae_start_locked(struct ifnet *ifp); +static void ae_start(if_t ifp); +static void ae_start_locked(if_t ifp); static void ae_link_task(void *arg, int pending); static void ae_stop_rxmac(ae_softc_t *sc); static void ae_stop_txmac(ae_softc_t *sc); @@ -143,7 +143,7 @@ static void ae_watchdog(ae_softc_t *sc); static void ae_tick(void *arg); static void ae_rxfilter(ae_softc_t *sc); static void ae_rxvlan(ae_softc_t *sc); -static int ae_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); +static int ae_ioctl(if_t ifp, u_long cmd, caddr_t data); static void ae_stop(ae_softc_t *sc); static int ae_check_eeprom_present(ae_softc_t *sc, int *vpdc); static int ae_vpd_read_word(ae_softc_t *sc, int reg, uint32_t *word); @@ -238,7 +238,7 @@ static int ae_attach(device_t dev) { ae_softc_t *sc; - struct ifnet *ifp; + if_t ifp; uint8_t chiprev; uint32_t pcirev; int nmsi, pmc; @@ -335,22 +335,21 @@ ae_attach(device_t dev) goto fail; } - ifp->if_softc = sc; + if_setsoftc(ifp, sc); if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_ioctl = ae_ioctl; - ifp->if_start = ae_start; - ifp->if_init = ae_init; - ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING; - ifp->if_hwassist = 0; - ifp->if_snd.ifq_drv_maxlen = ifqmaxlen; - IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); - IFQ_SET_READY(&ifp->if_snd); + if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); + if_setioctlfn(ifp, ae_ioctl); + if_setstartfn(ifp, ae_start); + if_setinitfn(ifp, ae_init); + if_setcapabilities(ifp, IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING); + if_sethwassist(ifp, 0); + if_setsendqlen(ifp, ifqmaxlen); + if_setsendqready(ifp); if (pci_find_cap(dev, PCIY_PMG, &pmc) == 0) { - ifp->if_capabilities |= IFCAP_WOL_MAGIC; + if_setcapabilitiesbit(ifp, IFCAP_WOL_MAGIC, 0); sc->flags |= AE_FLAG_PMG; } - ifp->if_capenable = ifp->if_capabilities; + if_setcapenable(ifp, if_getcapabilities(ifp)); /* * Configure and attach MII bus. @@ -365,7 +364,7 @@ ae_attach(device_t dev) ether_ifattach(ifp, sc->eaddr); /* Tell the upper layer(s) we support long frames. */ - ifp->if_hdrlen = sizeof(struct ether_vlan_header); + if_setifheaderlen(ifp, sizeof(struct ether_vlan_header)); /* * Create and run all helper tasks. @@ -557,7 +556,7 @@ ae_phy_init(ae_softc_t *sc) static int ae_init_locked(ae_softc_t *sc) { - struct ifnet *ifp; + if_t ifp; struct mii_data *mii; uint8_t eaddr[ETHER_ADDR_LEN]; uint32_t val; @@ -566,7 +565,7 @@ ae_init_locked(ae_softc_t *sc) AE_LOCK_ASSERT(sc); ifp = sc->ifp; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) return (0); mii = device_get_softc(sc->miibus); @@ -584,7 +583,7 @@ ae_init_locked(ae_softc_t *sc) /* * Set the MAC address. */ - bcopy(IF_LLADDR(ifp), eaddr, ETHER_ADDR_LEN); + bcopy(if_getlladdr(ifp), eaddr, ETHER_ADDR_LEN); val = eaddr[2] << 24 | eaddr[3] << 16 | eaddr[4] << 8 | eaddr[5]; AE_WRITE_4(sc, AE_EADDR0_REG, val); val = eaddr[0] << 8 | eaddr[1]; @@ -653,7 +652,7 @@ ae_init_locked(ae_softc_t *sc) /* * Configure MTU. */ - val = ifp->if_mtu + ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + + val = if_getmtu(ifp) + ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + ETHER_CRC_LEN; AE_WRITE_2(sc, AE_MTU_REG, val); @@ -743,8 +742,8 @@ ae_init_locked(ae_softc_t *sc) callout_reset(&sc->tick_ch, hz, ae_tick, sc); - 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); #ifdef AE_DEBUG device_printf(sc->dev, "Initialization complete.\n"); @@ -757,7 +756,7 @@ static int ae_detach(device_t dev) { struct ae_softc *sc; - struct ifnet *ifp; + if_t ifp; sc = device_get_softc(dev); KASSERT(sc != NULL, ("[ae: %d]: sc is NULL", __LINE__)); @@ -882,12 +881,12 @@ ae_miibus_statchg(device_t dev) } static void -ae_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr) +ae_mediastatus(if_t ifp, struct ifmediareq *ifmr) { ae_softc_t *sc; struct mii_data *mii; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); KASSERT(sc != NULL, ("[ae, %d]: sc is NULL", __LINE__)); AE_LOCK(sc); @@ -899,7 +898,7 @@ ae_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr) } static int -ae_mediachange(struct ifnet *ifp) +ae_mediachange(if_t ifp) { ae_softc_t *sc; struct mii_data *mii; @@ -907,7 +906,7 @@ ae_mediachange(struct ifnet *ifp) int error; /* XXX: check IFF_UP ?? */ - sc = ifp->if_softc; + sc = if_getsoftc(ifp); KASSERT(sc != NULL, ("[ae, %d]: sc is NULL", __LINE__)); AE_LOCK(sc); mii = device_get_softc(sc->miibus); @@ -1320,7 +1319,7 @@ ae_powersave_enable(ae_softc_t *sc) static void ae_pm_init(ae_softc_t *sc) { - struct ifnet *ifp; + if_t ifp; uint32_t val; uint16_t pmstat; struct mii_data *mii; @@ -1338,7 +1337,7 @@ ae_pm_init(ae_softc_t *sc) /* * Configure WOL if enabled. */ - if ((ifp->if_capenable & IFCAP_WOL) != 0) { + if ((if_getcapenable(ifp) & IFCAP_WOL) != 0) { mii = device_get_softc(sc->miibus); mii_pollstat(mii); if ((mii->mii_media_status & IFM_AVALID) != 0 && @@ -1386,7 +1385,7 @@ ae_pm_init(ae_softc_t *sc) 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) != 0) + if ((if_getcapenable(ifp) & IFCAP_WOL) != 0) pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE; pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2); } @@ -1417,7 +1416,7 @@ ae_resume(device_t dev) AE_LOCK(sc); AE_READ_4(sc, AE_WOL_REG); /* Clear WOL status. */ - if ((sc->ifp->if_flags & IFF_UP) != 0) + if ((if_getflags(sc->ifp) & IFF_UP) != 0) ae_init_locked(sc); AE_UNLOCK(sc); @@ -1512,25 +1511,25 @@ ae_encap(ae_softc_t *sc, struct mbuf **m_head) } static void -ae_start(struct ifnet *ifp) +ae_start(if_t ifp) { ae_softc_t *sc; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); AE_LOCK(sc); ae_start_locked(ifp); AE_UNLOCK(sc); } static void -ae_start_locked(struct ifnet *ifp) +ae_start_locked(if_t ifp) { ae_softc_t *sc; unsigned int count; struct mbuf *m0; int error; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); KASSERT(sc != NULL, ("[ae, %d]: sc is NULL", __LINE__)); AE_LOCK_ASSERT(sc); @@ -1538,21 +1537,21 @@ ae_start_locked(struct ifnet *ifp) if_printf(ifp, "Start called.\n"); #endif - if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING || (sc->flags & AE_FLAG_LINK) == 0) return; count = 0; - while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { - IFQ_DRV_DEQUEUE(&ifp->if_snd, m0); + while (!if_sendq_empty(ifp)) { + m0 = if_dequeue(ifp); if (m0 == NULL) break; /* Nothing to do. */ error = ae_encap(sc, &m0); if (error != 0) { if (m0 != NULL) { - IFQ_DRV_PREPEND(&ifp->if_snd, m0); - ifp->if_drv_flags |= IFF_DRV_OACTIVE; + if_sendq_prepend(ifp, m0); + if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); #ifdef AE_DEBUG if_printf(ifp, "Setting OACTIVE.\n"); #endif @@ -1583,7 +1582,7 @@ ae_link_task(void *arg, int pending) { ae_softc_t *sc; struct mii_data *mii; - struct ifnet *ifp; + if_t ifp; uint32_t val; sc = (ae_softc_t *)arg; @@ -1593,7 +1592,7 @@ ae_link_task(void *arg, int pending) ifp = sc->ifp; mii = device_get_softc(sc->miibus); if (mii == NULL || ifp == NULL || - (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { + (if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) { AE_UNLOCK(sc); /* XXX: could happen? */ return; } @@ -1753,7 +1752,7 @@ static void ae_int_task(void *arg, int pending) { ae_softc_t *sc; - struct ifnet *ifp; + if_t ifp; uint32_t val; sc = (ae_softc_t *)arg; @@ -1777,10 +1776,10 @@ ae_int_task(void *arg, int pending) if_printf(ifp, "Interrupt received: 0x%08x\n", val); #endif - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) { if ((val & (AE_ISR_DMAR_TIMEOUT | AE_ISR_DMAW_TIMEOUT | AE_ISR_PHY_LINKDOWN)) != 0) { - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); ae_init_locked(sc); AE_UNLOCK(sc); return; @@ -1795,7 +1794,7 @@ ae_int_task(void *arg, int pending) AE_WRITE_4(sc, AE_ISR_REG, 0); if ((sc->flags & AE_FLAG_TXAVAIL) != 0) { - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + if (!if_sendq_empty(ifp)) ae_start_locked(ifp); } } @@ -1806,7 +1805,7 @@ ae_int_task(void *arg, int pending) static void ae_tx_intr(ae_softc_t *sc) { - struct ifnet *ifp; + if_t ifp; ae_txd_t *txd; ae_txs_t *txs; uint16_t flags; @@ -1862,7 +1861,7 @@ ae_tx_intr(ae_softc_t *sc) } if ((sc->flags & AE_FLAG_TXAVAIL) != 0) - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE); if (sc->tx_inproc < 0) { if_printf(ifp, "Received stray Tx interrupt(s).\n"); sc->tx_inproc = 0; @@ -1883,7 +1882,7 @@ ae_tx_intr(ae_softc_t *sc) static void ae_rxeof(ae_softc_t *sc, ae_rxd_t *rxd) { - struct ifnet *ifp; + if_t ifp; struct mbuf *m; unsigned int size; uint16_t flags; @@ -1909,7 +1908,7 @@ ae_rxeof(ae_softc_t *sc, ae_rxd_t *rxd) return; } - if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0 && + if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) != 0 && (flags & AE_RXD_HAS_VLAN) != 0) { m->m_pkthdr.ether_vtag = AE_RXD_VLAN(le16toh(rxd->vlan)); m->m_flags |= M_VLANTAG; @@ -1920,7 +1919,7 @@ ae_rxeof(ae_softc_t *sc, ae_rxd_t *rxd) * Pass it through. */ AE_UNLOCK(sc); - (*ifp->if_input)(ifp, m); + if_input(ifp, m); AE_LOCK(sc); } @@ -1928,7 +1927,7 @@ static void ae_rx_intr(ae_softc_t *sc) { ae_rxd_t *rxd; - struct ifnet *ifp; + if_t ifp; uint16_t flags; int count; @@ -1977,7 +1976,7 @@ ae_rx_intr(ae_softc_t *sc) static void ae_watchdog(ae_softc_t *sc) { - struct ifnet *ifp; + if_t ifp; KASSERT(sc != NULL, ("[ae, %d]: sc is NULL!", __LINE__)); AE_LOCK_ASSERT(sc); @@ -1992,9 +1991,9 @@ ae_watchdog(ae_softc_t *sc) if_printf(ifp, "watchdog timeout - resetting.\n"); if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); ae_init_locked(sc); - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + if (!if_sendq_empty(ifp)) ae_start_locked(ifp); } @@ -2017,14 +2016,14 @@ ae_tick(void *arg) static void ae_rxvlan(ae_softc_t *sc) { - struct ifnet *ifp; + if_t ifp; uint32_t val; AE_LOCK_ASSERT(sc); ifp = sc->ifp; val = AE_READ_4(sc, AE_MAC_REG); val &= ~AE_MAC_RMVLAN_EN; - if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0) + if ((if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) != 0) val |= AE_MAC_RMVLAN_EN; AE_WRITE_4(sc, AE_MAC_REG, val); } @@ -2043,7 +2042,7 @@ ae_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) static void ae_rxfilter(ae_softc_t *sc) { - struct ifnet *ifp; + if_t ifp; uint32_t mchash[2]; uint32_t rxcfg; @@ -2056,11 +2055,11 @@ ae_rxfilter(ae_softc_t *sc) rxcfg = AE_READ_4(sc, AE_MAC_REG); rxcfg &= ~(AE_MAC_MCAST_EN | AE_MAC_BCAST_EN | AE_MAC_PROMISC_EN); - if ((ifp->if_flags & IFF_BROADCAST) != 0) + if ((if_getflags(ifp) & IFF_BROADCAST) != 0) rxcfg |= AE_MAC_BCAST_EN; - if ((ifp->if_flags & IFF_PROMISC) != 0) + if ((if_getflags(ifp) & IFF_PROMISC) != 0) rxcfg |= AE_MAC_PROMISC_EN; - if ((ifp->if_flags & IFF_ALLMULTI) != 0) + if ((if_getflags(ifp) & IFF_ALLMULTI) != 0) rxcfg |= AE_MAC_MCAST_EN; /* @@ -2068,7 +2067,7 @@ ae_rxfilter(ae_softc_t *sc) */ AE_WRITE_4(sc, AE_REG_MHT0, 0); AE_WRITE_4(sc, AE_REG_MHT1, 0); - if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) { + if ((if_getflags(ifp) & (IFF_PROMISC | IFF_ALLMULTI)) != 0) { AE_WRITE_4(sc, AE_REG_MHT0, 0xffffffff); AE_WRITE_4(sc, AE_REG_MHT1, 0xffffffff); AE_WRITE_4(sc, AE_MAC_REG, rxcfg); @@ -2086,14 +2085,14 @@ ae_rxfilter(ae_softc_t *sc) } static int -ae_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +ae_ioctl(if_t ifp, u_long cmd, caddr_t data) { struct ae_softc *sc; struct ifreq *ifr; struct mii_data *mii; int error, mask; - sc = ifp->if_softc; + sc = if_getsoftc(ifp); ifr = (struct ifreq *)data; error = 0; @@ -2101,11 +2100,11 @@ ae_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCSIFMTU: if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU) error = EINVAL; - else if (ifp->if_mtu != ifr->ifr_mtu) { + else if (if_getmtu(ifp) != ifr->ifr_mtu) { AE_LOCK(sc); - ifp->if_mtu = ifr->ifr_mtu; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + if_setmtu(ifp, ifr->ifr_mtu); + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) { + if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING); ae_init_locked(sc); } AE_UNLOCK(sc); @@ -2113,9 +2112,9 @@ ae_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; case SIOCSIFFLAGS: AE_LOCK(sc); - if ((ifp->if_flags & IFF_UP) != 0) { - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { - if (((ifp->if_flags ^ sc->if_flags) + if ((if_getflags(ifp) & IFF_UP) != 0) { + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) { + if (((if_getflags(ifp) ^ sc->if_flags) & (IFF_PROMISC | IFF_ALLMULTI)) != 0) ae_rxfilter(sc); } else { @@ -2123,16 +2122,16 @@ ae_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ae_init_locked(sc); } } else { - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) ae_stop(sc); } - sc->if_flags = ifp->if_flags; + sc->if_flags = if_getflags(ifp); AE_UNLOCK(sc); break; case SIOCADDMULTI: case SIOCDELMULTI: AE_LOCK(sc); - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) ae_rxfilter(sc); AE_UNLOCK(sc); break; @@ -2143,10 +2142,10 @@ ae_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; case SIOCSIFCAP: AE_LOCK(sc); - mask = ifr->ifr_reqcap ^ ifp->if_capenable; + mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); if ((mask & IFCAP_VLAN_HWTAGGING) != 0 && - (ifp->if_capabilities & IFCAP_VLAN_HWTAGGING) != 0) { - ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING; + (if_getcapabilities(ifp) & IFCAP_VLAN_HWTAGGING) != 0) { + if_togglecapenable(ifp, IFCAP_VLAN_HWTAGGING); ae_rxvlan(sc); } VLAN_CAPABILITIES(ifp); @@ -2162,13 +2161,13 @@ ae_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) static void ae_stop(ae_softc_t *sc) { - struct ifnet *ifp; + if_t ifp; int i; AE_LOCK_ASSERT(sc); ifp = sc->ifp; - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); sc->flags &= ~AE_FLAG_LINK; sc->wd_timer = 0; /* Cancel watchdog. */ callout_stop(&sc->tick_ch); diff --git a/sys/dev/ae/if_aevar.h b/sys/dev/ae/if_aevar.h index b6010e30ec84..ec076ab38958 100644 --- a/sys/dev/ae/if_aevar.h +++ b/sys/dev/ae/if_aevar.h @@ -102,7 +102,7 @@ typedef struct ae_stats { /* Software state structure. */ typedef struct ae_softc { - struct ifnet *ifp; + if_t ifp; device_t dev; device_t miibus; struct resource *mem[1];