diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2015-11-25 03:10:01 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2015-11-25 03:10:01 +0000 |
commit | 6215416f96d04fd1a1b0e14e2670c208f0acc34c (patch) | |
tree | 14249f751ae54985d3581b0632deb81620be2edf /sys/dev/ic/atw.c | |
parent | bbe7ffca434bff081b83e600614f4ec4cded8f3b (diff) |
replace IFF_OACTIVE manipulation with mpsafe operations.
there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.
IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.
instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.
this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.
ok kettenis@ mpi@ jmatthew@ deraadt@
Diffstat (limited to 'sys/dev/ic/atw.c')
-rw-r--r-- | sys/dev/ic/atw.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/sys/dev/ic/atw.c b/sys/dev/ic/atw.c index b43b4635017..c1003a4a327 100644 --- a/sys/dev/ic/atw.c +++ b/sys/dev/ic/atw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atw.c,v 1.90 2015/11/04 12:11:59 dlg Exp $ */ +/* $OpenBSD: atw.c,v 1.91 2015/11/25 03:09:58 dlg Exp $ */ /* $NetBSD: atw.c,v 1.69 2004/07/23 07:07:55 dyoung Exp $ */ /*- @@ -1433,7 +1433,7 @@ atw_init(struct ifnet *ifp) * Note that the interface is now running. */ ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); /* send no beacons, yet. */ atw_start_beacon(sc, 0); @@ -1444,7 +1444,8 @@ atw_init(struct ifnet *ifp) error = ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); out: if (error) { - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + ifp->if_flags &= ~IFF_RUNNING; + ifq_clr_oactive(&ifp->if_snd); ifp->if_timer = 0; printf("%s: interface not running\n", sc->sc_dev.dv_xname); } @@ -2644,7 +2645,8 @@ atw_stop(struct ifnet *ifp, int disable) /* * Mark the interface down and cancel the watchdog timer. */ - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + ifp->if_flags &= ~IFF_RUNNING; + ifq_clr_oactive(&ifp->if_snd); ifp->if_timer = 0; /* Disable interrupts. */ @@ -3215,7 +3217,7 @@ atw_txintr(struct atw_softc *sc) DPRINTF3(sc, ("%s: atw_txintr: sc_flags 0x%08x\n", sc->sc_dev.dv_xname, sc->sc_flags)); - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); /* * Go through our Tx list and free mbufs for those @@ -3571,7 +3573,7 @@ atw_start(struct ifnet *ifp) DPRINTF2(sc, ("%s: atw_start: sc_flags 0x%08x, if_flags 0x%08x\n", sc->sc_dev.dv_xname, sc->sc_flags, ifp->if_flags)); - if ((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING) + if (!(ifp->if_flags & IFF_RUNNING) || ifq_is_oactive(&ifp->if_snd)) return; /* @@ -3833,7 +3835,7 @@ atw_start(struct ifnet *ifp) * XXX We could allocate an mbuf and copy, but * XXX it is worth it? */ - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); bus_dmamap_unload(sc->sc_dmat, dmamap); m_freem(m0); break; @@ -3933,7 +3935,7 @@ atw_start(struct ifnet *ifp) if (txs == NULL || sc->sc_txfree == 0) { /* No more slots left; notify upper layer. */ - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); } if (sc->sc_txfree != ofree) { |