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/pci/if_nep.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/pci/if_nep.c')
-rw-r--r-- | sys/dev/pci/if_nep.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/dev/pci/if_nep.c b/sys/dev/pci/if_nep.c index f20df06c633..ae3d817d588 100644 --- a/sys/dev/pci/if_nep.c +++ b/sys/dev/pci/if_nep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nep.c,v 1.23 2015/11/24 17:11:39 mpi Exp $ */ +/* $OpenBSD: if_nep.c,v 1.24 2015/11/25 03:09:59 dlg Exp $ */ /* * Copyright (c) 2014, 2015 Mark Kettenis * @@ -1091,7 +1091,7 @@ nep_tx_proc(struct nep_softc *sc) count--; } - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); sc->sc_tx_cnt--; sc->sc_tx_cons++; @@ -1648,7 +1648,7 @@ nep_up(struct nep_softc *sc) nep_write(sc, RXDMA_CFIG1(sc->sc_port), val); ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; + ifq_clr_oactive(&ifp->if_snd); ifp->if_timer = 0; /* Enable interrupts. */ @@ -1685,7 +1685,8 @@ nep_down(struct nep_softc *sc) nep_write(sc, LD_IM0(LDN_RXDMA(sc->sc_port)), 1); nep_write(sc, LD_IM0(LDN_TXDMA(sc->sc_port)), 1); - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + ifp->if_flags &= ~IFF_RUNNING; + ifq_clr_oactive(&ifp->if_snd); ifp->if_timer = 0; nep_disable_rx_mac(sc); @@ -1869,7 +1870,7 @@ nep_start(struct ifnet *ifp) if (!(ifp->if_flags & IFF_RUNNING)) return; - if (ifp->if_flags & IFF_OACTIVE) + if (ifq_is_oactive(&ifp->if_snd)) return; if (IFQ_IS_EMPTY(&ifp->if_snd)) return; @@ -1882,7 +1883,7 @@ nep_start(struct ifnet *ifp) if (sc->sc_tx_cnt >= (NEP_NTXDESC - NEP_NTXSEGS)) { ifq_deq_rollback(&ifp->if_snd, m); - ifp->if_flags |= IFF_OACTIVE; + ifq_set_oactive(&ifp->if_snd); break; } |