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/usb/if_cdce.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/usb/if_cdce.c')
-rw-r--r-- | sys/dev/usb/if_cdce.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/dev/usb/if_cdce.c b/sys/dev/usb/if_cdce.c index d8435a28d67..8bc98d8b629 100644 --- a/sys/dev/usb/if_cdce.c +++ b/sys/dev/usb/if_cdce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cdce.c,v 1.67 2015/11/20 03:35:23 dlg Exp $ */ +/* $OpenBSD: if_cdce.c,v 1.68 2015/11/25 03:10:00 dlg Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wpaul@windriver.com> @@ -386,7 +386,7 @@ cdce_start(struct ifnet *ifp) struct cdce_softc *sc = ifp->if_softc; struct mbuf *m_head = NULL; - if (usbd_is_dying(sc->cdce_udev) || (ifp->if_flags & IFF_OACTIVE)) + if (usbd_is_dying(sc->cdce_udev) || ifq_is_oactive(&ifp->if_snd)) return; m_head = ifq_deq_begin(&ifp->if_snd); @@ -395,7 +395,7 @@ cdce_start(struct ifnet *ifp) if (cdce_encap(sc, m_head, 0)) { ifq_deq_rollback(&ifp->if_snd, m_head); - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); return; } @@ -406,7 +406,7 @@ cdce_start(struct ifnet *ifp) bpf_mtap(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); #endif - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); ifp->if_timer = 6; } @@ -453,7 +453,8 @@ cdce_stop(struct cdce_softc *sc) int i; ifp->if_timer = 0; - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + ifp->if_flags &= ~IFF_RUNNING; + ifq_clr_oactive(&ifp->if_snd); if (sc->cdce_bulkin_pipe != NULL) { usbd_abort_pipe(sc->cdce_bulkin_pipe); @@ -626,7 +627,7 @@ cdce_init(void *xsc) } ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); splx(s); } @@ -800,7 +801,7 @@ cdce_txeof(struct usbd_xfer *xfer, void *priv, usbd_status status) s = splnet(); ifp->if_timer = 0; - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); if (status != USBD_NORMAL_COMPLETION) { if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) { |