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/arch/armv7/sunxi | |
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/arch/armv7/sunxi')
-rw-r--r-- | sys/arch/armv7/sunxi/sxie.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/arch/armv7/sunxi/sxie.c b/sys/arch/armv7/sunxi/sxie.c index c74bbaf7d19..062b0d06337 100644 --- a/sys/arch/armv7/sunxi/sxie.c +++ b/sys/arch/armv7/sunxi/sxie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sxie.c,v 1.12 2015/11/24 17:11:38 mpi Exp $ */ +/* $OpenBSD: sxie.c,v 1.13 2015/11/25 03:09:58 dlg Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> * Copyright (c) 2013 Artturi Alm @@ -396,7 +396,7 @@ sxie_init(struct sxie_softc *sc) /* Indicate we are up and running. */ ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); SXISET4(sc, SXIE_INTCR, SXIE_INTR_ENABLE); @@ -426,7 +426,7 @@ sxie_intr(void *arg) pending &= 3; if (pending) { - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); sc->txf_inuse--; ifp->if_opackets++; if (pending == 3) { /* 2 packets got sent */ @@ -461,9 +461,9 @@ sxie_start(struct ifnet *ifp) uint32_t txbuf[SXIE_MAX_PKT_SIZE / sizeof(uint32_t)]; /* XXX !!! */ if (sc->txf_inuse > 1) - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); - if ((ifp->if_flags & (IFF_OACTIVE | IFF_RUNNING)) != IFF_RUNNING) + if (!(ifp->if_flags & IFF_RUNNING) || ifq_is_oactive(&ifp->if_snd)) return; td = (uint8_t *)&txbuf[0]; @@ -484,7 +484,7 @@ trynext: if (sc->txf_inuse > 1) { ifq_deq_rollback(&ifp->if_snd, m); printf("sxie_start: tx fifos in use.\n"); - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); return; } @@ -524,8 +524,9 @@ sxie_stop(struct sxie_softc *sc) sxie_reset(sc); - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + ifp->if_flags &= ~IFF_RUNNING; ifp->if_timer = 0; + ifq_clr_oactive(&ifp->if_snd); } void |