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/sbus | |
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/sbus')
-rw-r--r-- | sys/dev/sbus/be.c | 10 | ||||
-rw-r--r-- | sys/dev/sbus/qe.c | 14 |
2 files changed, 12 insertions, 12 deletions
diff --git a/sys/dev/sbus/be.c b/sys/dev/sbus/be.c index a6e58d7ffa4..dacb19acb80 100644 --- a/sys/dev/sbus/be.c +++ b/sys/dev/sbus/be.c @@ -1,4 +1,4 @@ -/* $OpenBSD: be.c,v 1.37 2015/11/24 17:11:40 mpi Exp $ */ +/* $OpenBSD: be.c,v 1.38 2015/11/25 03:09:59 dlg Exp $ */ /* $NetBSD: be.c,v 1.26 2001/03/20 15:39:20 pk Exp $ */ /*- @@ -570,7 +570,7 @@ bestart(struct ifnet *ifp) unsigned int bix, len; unsigned int ntbuf = sc->sc_rb.rb_ntbuf; - if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) + if (!(ifp->if_flags & IFF_RUNNING) || ifq_is_oactive(&ifp->if_snd)) return; bix = sc->sc_rb.rb_tdhead; @@ -606,7 +606,7 @@ bestart(struct ifnet *ifp) bix = 0; if (++sc->sc_rb.rb_td_nbusy == ntbuf) { - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); break; } } @@ -851,7 +851,7 @@ betint(struct be_softc *sc) if (txflags & QEC_XD_OWN) break; - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); ifp->if_opackets++; if (++bix == QEC_XD_RING_MAXSIZE) @@ -1060,7 +1060,7 @@ beinit(struct be_softc *sc) bus_space_write_4(t, br, BE_BRI_RXCFG, v); ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); be_ifmedia_upd(ifp); timeout_add_sec(&sc->sc_tick_ch, 1); diff --git a/sys/dev/sbus/qe.c b/sys/dev/sbus/qe.c index 12bfbc56a7d..108f64047de 100644 --- a/sys/dev/sbus/qe.c +++ b/sys/dev/sbus/qe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qe.c,v 1.35 2015/11/24 17:11:40 mpi Exp $ */ +/* $OpenBSD: qe.c,v 1.36 2015/11/25 03:09:59 dlg Exp $ */ /* $NetBSD: qe.c,v 1.16 2001/03/30 17:30:18 christos Exp $ */ /*- @@ -442,7 +442,7 @@ qestart(ifp) unsigned int bix, len; unsigned int ntbuf = sc->sc_rb.rb_ntbuf; - if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) + if (!(ifp->if_flags & IFF_RUNNING) || ifq_is_oactive(&ifp->if_snd)) return; bix = sc->sc_rb.rb_tdhead; @@ -479,7 +479,7 @@ qestart(ifp) bix = 0; if (++sc->sc_rb.rb_td_nbusy == ntbuf) { - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); break; } } @@ -628,7 +628,7 @@ qe_tint(sc) if (txflags & QEC_XD_OWN) break; - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); ifp->if_opackets++; if (++bix == QEC_XD_RING_MAXSIZE) @@ -642,8 +642,8 @@ qe_tint(sc) if (sc->sc_rb.rb_tdtail != bix) { sc->sc_rb.rb_tdtail = bix; - if (ifp->if_flags & IFF_OACTIVE) { - ifp->if_flags &= ~IFF_OACTIVE; + if (ifq_is_oactive(&ifp->if_snd)) { + ifq_clr_oactive(&ifp->if_snd); qestart(ifp); } } @@ -1039,7 +1039,7 @@ qeinit(sc) qe_mcreset(sc); ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); splx(s); } |