summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64
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/arch/sparc64
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/arch/sparc64')
-rw-r--r--sys/arch/sparc64/dev/vnet.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/sys/arch/sparc64/dev/vnet.c b/sys/arch/sparc64/dev/vnet.c
index 001f317301e..39a37c89800 100644
--- a/sys/arch/sparc64/dev/vnet.c
+++ b/sys/arch/sparc64/dev/vnet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnet.c,v 1.50 2015/11/24 17:11:38 mpi Exp $ */
+/* $OpenBSD: vnet.c,v 1.51 2015/11/25 03:09:58 dlg Exp $ */
/*
* Copyright (c) 2009, 2015 Mark Kettenis
*
@@ -660,7 +660,7 @@ vnet_rx_vio_rdx(struct vnet_softc *sc, struct vio_msg_tag *tag)
vnet_setmulti(sc, 1);
KERNEL_LOCK();
- ifp->if_flags &= ~IFF_OACTIVE;
+ ifq_clr_oactive(&ifp->if_snd);
vnet_start(ifp);
KERNEL_UNLOCK();
}
@@ -889,7 +889,7 @@ vnet_rx_vio_dring_data(struct vnet_softc *sc, struct vio_msg_tag *tag)
KERNEL_LOCK();
if (count < (sc->sc_vd->vd_nentries - 1))
- ifp->if_flags &= ~IFF_OACTIVE;
+ ifq_clr_oactive(&ifp->if_snd);
if (count == 0)
ifp->if_timer = 0;
@@ -1064,7 +1064,7 @@ vnet_start(struct ifnet *ifp)
u_int start, prod, count;
int err;
- if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
+ if (!(ifp->if_flags & IFF_RUNNING) || ifq_is_oactive(&ifp->if_snd))
return;
if (IFQ_IS_EMPTY(&ifp->if_snd))
@@ -1088,7 +1088,7 @@ vnet_start(struct ifnet *ifp)
tx_tail += sizeof(struct ldc_pkt);
tx_tail &= ((lc->lc_txq->lq_nentries * sizeof(struct ldc_pkt)) - 1);
if (tx_tail == tx_head) {
- ifp->if_flags |= IFF_OACTIVE;
+ ifq_set_oactive(&ifp->if_snd);
return;
}
@@ -1107,14 +1107,14 @@ vnet_start(struct ifnet *ifp)
if (count >= (sc->sc_vd->vd_nentries - 1) ||
map->lm_count >= map->lm_nentries) {
ifq_deq_rollback(&ifp->if_snd, m);
- ifp->if_flags |= IFF_OACTIVE;
+ ifq_set_oactive(&ifp->if_snd);
break;
}
buf = pool_get(&sc->sc_pool, PR_NOWAIT|PR_ZERO);
if (buf == NULL) {
ifq_deq_rollback(&ifp->if_snd, m);
- ifp->if_flags |= IFF_OACTIVE;
+ ifq_set_oactive(&ifp->if_snd);
break;
}
m_copydata(m, 0, m->m_pkthdr.len, buf + VNET_ETHER_ALIGN);
@@ -1184,14 +1184,14 @@ vnet_start_desc(struct ifnet *ifp)
if (count >= (sc->sc_vd->vd_nentries - 1) ||
map->lm_count >= map->lm_nentries) {
ifq_deq_rollback(&ifp->if_snd, m);
- ifp->if_flags |= IFF_OACTIVE;
+ ifq_set_oactive(&ifp->if_snd);
return;
}
buf = pool_get(&sc->sc_pool, PR_NOWAIT|PR_ZERO);
if (buf == NULL) {
ifq_deq_rollback(&ifp->if_snd, m);
- ifp->if_flags |= IFF_OACTIVE;
+ ifq_set_oactive(&ifp->if_snd);
return;
}
m_copydata(m, 0, m->m_pkthdr.len, buf);
@@ -1429,7 +1429,8 @@ vnet_stop(struct ifnet *ifp)
struct vnet_softc *sc = ifp->if_softc;
struct ldc_conn *lc = &sc->sc_lc;
- ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+ ifp->if_flags &= ~IFF_RUNNING;
+ ifq_clr_oactive(&ifp->if_snd);
ifp->if_timer = 0;
cbus_intr_setenabled(sc->sc_bustag, sc->sc_tx_ino, INTR_DISABLED);