From 6215416f96d04fd1a1b0e14e2670c208f0acc34c Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Wed, 25 Nov 2015 03:10:01 +0000 Subject: 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@ --- sys/dev/pci/if_wb.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sys/dev/pci/if_wb.c') diff --git a/sys/dev/pci/if_wb.c b/sys/dev/pci/if_wb.c index 8cf4c154d8f..ea52e9a4bf9 100644 --- a/sys/dev/pci/if_wb.c +++ b/sys/dev/pci/if_wb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wb.c,v 1.65 2015/11/24 17:11:39 mpi Exp $ */ +/* $OpenBSD: if_wb.c,v 1.66 2015/11/25 03:09:59 dlg Exp $ */ /* * Copyright (c) 1997, 1998 @@ -1065,7 +1065,7 @@ void wb_txeoc(sc) ifp->if_timer = 0; if (sc->wb_cdata.wb_tx_head == NULL) { - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); sc->wb_cdata.wb_tx_tail = NULL; } else { if (WB_TXOWN(sc->wb_cdata.wb_tx_head) == WB_UNSENT) { @@ -1285,7 +1285,7 @@ void wb_start(ifp) * punt. */ if (sc->wb_cdata.wb_tx_free->wb_mbuf != NULL) { - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); return; } @@ -1468,7 +1468,7 @@ void wb_init(xsc) WB_SETBIT(sc, WB_NETCFG, WB_NETCFG_TX_ON); ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); splx(s); @@ -1593,7 +1593,8 @@ void wb_stop(sc) timeout_del(&sc->wb_tick_tmo); - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + ifp->if_flags &= ~IFF_RUNNING; + ifq_clr_oactive(&ifp->if_snd); WB_CLRBIT(sc, WB_NETCFG, (WB_NETCFG_RX_ON|WB_NETCFG_TX_ON)); CSR_WRITE_4(sc, WB_IMR, 0x00000000); -- cgit v1.2.3