summaryrefslogtreecommitdiff
path: root/sys/dev/pci/if_vge.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2015-11-25 03:10:01 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2015-11-25 03:10:01 +0000
commit6215416f96d04fd1a1b0e14e2670c208f0acc34c (patch)
tree14249f751ae54985d3581b0632deb81620be2edf /sys/dev/pci/if_vge.c
parentbbe7ffca434bff081b83e600614f4ec4cded8f3b (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/pci/if_vge.c')
-rw-r--r--sys/dev/pci/if_vge.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/dev/pci/if_vge.c b/sys/dev/pci/if_vge.c
index 1cbbd425b28..ef328617276 100644
--- a/sys/dev/pci/if_vge.c
+++ b/sys/dev/pci/if_vge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vge.c,v 1.68 2015/11/24 17:11:39 mpi Exp $ */
+/* $OpenBSD: if_vge.c,v 1.69 2015/11/25 03:09:59 dlg Exp $ */
/* $FreeBSD: if_vge.c,v 1.3 2004/09/11 22:13:25 wpaul Exp $ */
/*
* Copyright (c) 2004
@@ -1193,7 +1193,7 @@ vge_txeof(struct vge_softc *sc)
if (idx != sc->vge_ldata.vge_tx_considx) {
sc->vge_ldata.vge_tx_considx = idx;
- ifp->if_flags &= ~IFF_OACTIVE;
+ ifq_clr_oactive(&ifp->if_snd);
ifp->if_timer = 0;
}
@@ -1412,7 +1412,7 @@ vge_start(struct ifnet *ifp)
sc = ifp->if_softc;
- if (!sc->vge_link || ifp->if_flags & IFF_OACTIVE)
+ if (!sc->vge_link || ifq_is_oactive(&ifp->if_snd))
return;
if (IFQ_IS_EMPTY(&ifp->if_snd))
@@ -1426,7 +1426,7 @@ vge_start(struct ifnet *ifp)
for (;;) {
if (sc->vge_ldata.vge_tx_mbuf[idx] != NULL) {
- ifp->if_flags |= IFF_OACTIVE;
+ ifq_set_oactive(&ifp->if_snd);
break;
}
@@ -1639,7 +1639,7 @@ vge_init(struct ifnet *ifp)
mii_mediachg(&sc->sc_mii);
ifp->if_flags |= IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
+ ifq_clr_oactive(&ifp->if_snd);
sc->vge_link = 0;
@@ -1809,7 +1809,8 @@ vge_stop(struct vge_softc *sc)
timeout_del(&sc->timer_handle);
- ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+ ifp->if_flags &= ~IFF_RUNNING;
+ ifq_clr_oactive(&ifp->if_snd);
CSR_WRITE_1(sc, VGE_CRC3, VGE_CR3_INT_GMSK);
CSR_WRITE_1(sc, VGE_CRS0, VGE_CR0_STOP);