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/rt2661.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/rt2661.c')
-rw-r--r-- | sys/dev/ic/rt2661.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c index e58b6eb31c3..15656768762 100644 --- a/sys/dev/ic/rt2661.c +++ b/sys/dev/ic/rt2661.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rt2661.c,v 1.87 2015/11/24 13:33:17 mpi Exp $ */ +/* $OpenBSD: rt2661.c,v 1.88 2015/11/25 03:09:58 dlg Exp $ */ /*- * Copyright (c) 2006 @@ -1150,7 +1150,7 @@ rt2661_tx_dma_intr(struct rt2661_softc *sc, struct rt2661_tx_ring *txq) if (sc->txq[0].queued < RT2661_TX_RING_COUNT - 1) sc->sc_flags &= ~RT2661_DATA_OACTIVE; if (!(sc->sc_flags & (RT2661_MGT_OACTIVE|RT2661_DATA_OACTIVE))) - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); rt2661_start(ifp); } } @@ -1928,13 +1928,13 @@ rt2661_start(struct ifnet *ifp) * net80211 may still try to send management frames even if the * IFF_RUNNING flag is not set... */ - if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) + if (!(ifp->if_flags & IFF_RUNNING) || ifq_is_oactive(&ifp->if_snd)) return; for (;;) { if (mq_len(&ic->ic_mgtq) > 0) { if (sc->mgtq.queued >= RT2661_MGT_RING_COUNT) { - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); break; } @@ -1951,7 +1951,7 @@ rt2661_start(struct ifnet *ifp) } else { if (sc->txq[0].queued >= RT2661_TX_RING_COUNT - 1) { - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); break; } @@ -2707,8 +2707,8 @@ rt2661_init(struct ifnet *ifp) /* kick Rx */ RAL_WRITE(sc, RT2661_RX_CNTL_CSR, 1); - ifp->if_flags &= ~IFF_OACTIVE; ifp->if_flags |= IFF_RUNNING; + ifq_clr_oactive(&ifp->if_snd); if (ic->ic_opmode != IEEE80211_M_MONITOR) ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); @@ -2728,7 +2728,8 @@ rt2661_stop(struct ifnet *ifp, int disable) sc->sc_tx_timer = 0; ifp->if_timer = 0; - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + ifp->if_flags &= ~IFF_RUNNING; + ifq_clr_oactive(&ifp->if_snd); ieee80211_new_state(ic, IEEE80211_S_INIT, -1); /* free all nodes */ rt2661_amrr_node_free_all(sc); |