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/fxp.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/fxp.c')
-rw-r--r-- | sys/dev/ic/fxp.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/dev/ic/fxp.c b/sys/dev/ic/fxp.c index ddfe8bc65c7..cab62a62232 100644 --- a/sys/dev/ic/fxp.c +++ b/sys/dev/ic/fxp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fxp.c,v 1.126 2015/11/24 15:43:15 mpi Exp $ */ +/* $OpenBSD: fxp.c,v 1.127 2015/11/25 03:09:58 dlg Exp $ */ /* $NetBSD: if_fxp.c,v 1.2 1997/06/05 02:01:55 thorpej Exp $ */ /* @@ -676,12 +676,12 @@ fxp_start(struct ifnet *ifp) struct mbuf *m0, *m = NULL; int cnt = sc->sc_cbt_cnt, seg; - if ((ifp->if_flags & (IFF_OACTIVE | IFF_RUNNING)) != IFF_RUNNING) + if (!(ifp->if_flags & IFF_RUNNING) || ifq_is_oactive(&ifp->if_snd)) return; while (1) { if (cnt >= (FXP_NTXCB - 2)) { - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); break; } @@ -846,7 +846,7 @@ fxp_intr(void *arg) sc->sc_cbt_cnt = txcnt; /* Did we transmit any packets? */ if (sc->sc_cbt_cons != txs) - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); ifp->if_timer = sc->sc_cbt_cnt ? 5 : 0; sc->sc_cbt_cons = txs; @@ -1074,7 +1074,8 @@ fxp_stop(struct fxp_softc *sc, int drain, int softonly) * between panics, and the watchdog timer) */ ifp->if_timer = 0; - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + ifp->if_flags &= ~IFF_RUNNING; + ifq_clr_oactive(&ifp->if_snd); if (!softonly) mii_down(&sc->sc_mii); @@ -1426,7 +1427,7 @@ fxp_init(void *xsc) mii_mediachg(&sc->sc_mii); ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); /* * Request a software generated interrupt that will be used to |