more smp cleanup for ure(4): - convert IFF_ALLMULTI to ETHER_F_ALLMULTI, using ETHER_LOCK(). - remove IFF_OACTIVE use, and simply check the ring count in start. - assert more locks Index: dev/usb/if_ure.c =================================================================== RCS file: /cvsroot/src/sys/dev/usb/if_ure.c,v retrieving revision 1.12 diff -p -u -r1.12 if_ure.c --- dev/usb/if_ure.c 24 Jun 2019 04:42:06 -0000 1.12 +++ dev/usb/if_ure.c 24 Jun 2019 09:25:37 -0000 @@ -436,7 +436,6 @@ ure_iff_locked(struct ure_softc *sc) rxmode = ure_read_4(sc, URE_PLA_RCR, URE_MCU_TYPE_PLA); rxmode &= ~URE_RCR_ACPT_ALL; - ifp->if_flags &= ~IFF_ALLMULTI; /* * Always accept frames destined to our station address. @@ -446,13 +445,18 @@ ure_iff_locked(struct ure_softc *sc) if (ifp->if_flags & IFF_PROMISC) { rxmode |= URE_RCR_AAP; -allmulti: ifp->if_flags |= IFF_ALLMULTI; +allmulti: + ETHER_LOCK(ec); + ec->ec_flags |= ETHER_F_ALLMULTI; + ETHER_UNLOCK(ec); rxmode |= URE_RCR_AM; hashes[0] = hashes[1] = 0xffffffff; } else { rxmode |= URE_RCR_AM; ETHER_LOCK(ec); + ec->ec_flags &= ~ETHER_F_ALLMULTI; + ETHER_FIRST_MULTI(step, ec, enm); while (enm != NULL) { if (memcmp(enm->enm_addrlo, enm->enm_addrhi, @@ -597,8 +601,8 @@ ure_init_locked(struct ifnet *ifp) mutex_exit(&sc->ure_rxlock); /* Indicate we are up and running. */ + KASSERT(IFNET_LOCKED(ifp)); ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; callout_reset(&sc->ure_stat_ch, hz, ure_tick, sc); @@ -625,9 +629,12 @@ ure_start_locked(struct ifnet *ifp) struct ure_cdata *cd = &sc->ure_cdata; int idx; + KASSERT(cd->tx_cnt <= URE_TX_LIST_CNT); + if (sc->ure_dying || sc->ure_stopping || (sc->ure_flags & URE_FLAG_LINK) == 0 || - (ifp->if_flags & (IFF_OACTIVE | IFF_RUNNING)) != IFF_RUNNING) { + (ifp->if_flags & IFF_RUNNING) == 0 || + cd->tx_cnt == URE_TX_LIST_CNT) { return; } @@ -650,9 +657,6 @@ ure_start_locked(struct ifnet *ifp) cd->tx_cnt++; } cd->tx_prod = idx; - - if (cd->tx_cnt >= URE_TX_LIST_CNT) - ifp->if_flags |= IFF_OACTIVE; } static void @@ -698,7 +702,8 @@ ure_stop_locked(struct ifnet *ifp, int d ure_reset(sc); - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + KASSERT(IFNET_LOCKED(ifp)); + ifp->if_flags &= ~IFF_RUNNING; callout_stop(&sc->ure_stat_ch); @@ -1350,8 +1355,11 @@ ure_detach(device_t self, int flags) /* partial-attach, below items weren't configured. */ if (sc->ure_phyno != -1) { - if (ifp->if_flags & IFF_RUNNING) + if (ifp->if_flags & IFF_RUNNING) { + IFNET_LOCK(ifp); ure_stop(ifp, 1); + IFNET_UNLOCK(ifp); + } rnd_detach_source(&sc->ure_rnd_source); mii_detach(&sc->ure_mii, MII_PHY_ANY, MII_OFFSET_ANY); @@ -1609,8 +1617,6 @@ ure_txeof(struct usbd_xfer *xfer, void * KASSERT(cd->tx_cnt > 0); cd->tx_cnt--; - ifp->if_flags &= ~IFF_OACTIVE; - switch (status) { case USBD_NOT_STARTED: case USBD_CANCELLED: @@ -1721,7 +1727,9 @@ ure_encap(struct ure_softc *sc, struct m err = usbd_transfer(c->uc_xfer); if (err != USBD_IN_PROGRESS) { + IFNET_LOCK(ifp); ure_stop(ifp, 0); + IFNET_UNLOCK(ifp); return EIO; }