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_myx.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_myx.c')
-rw-r--r-- | sys/dev/pci/if_myx.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/dev/pci/if_myx.c b/sys/dev/pci/if_myx.c index 0c1b7d11740..ecb47ce472e 100644 --- a/sys/dev/pci/if_myx.c +++ b/sys/dev/pci/if_myx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_myx.c,v 1.87 2015/11/24 10:04:34 dlg Exp $ */ +/* $OpenBSD: if_myx.c,v 1.88 2015/11/25 03:09:59 dlg Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@openbsd.org> @@ -1205,7 +1205,7 @@ myx_up(struct myx_softc *sc) goto empty_rx_ring_big; } - CLR(ifp->if_flags, IFF_OACTIVE); + ifq_clr_oactive(&ifp->if_snd); SET(ifp->if_flags, IFF_RUNNING); myx_iff(sc); myx_start(ifp); @@ -1361,7 +1361,8 @@ myx_down(struct myx_softc *sc) printf("%s: failed to reset the device\n", DEVNAME(sc)); } - CLR(ifp->if_flags, IFF_RUNNING | IFF_OACTIVE); + CLR(ifp->if_flags, IFF_RUNNING); + ifq_clr_oactive(&ifp->if_snd); for (ring = 0; ring < 2; ring++) { struct myx_rx_ring *mrr = &sc->sc_rx_ring[ring]; @@ -1437,7 +1438,7 @@ myx_start(struct ifnet *ifp) u_int8_t flags; if (!ISSET(ifp->if_flags, IFF_RUNNING) || - ISSET(ifp->if_flags, IFF_OACTIVE) || + ifq_is_oactive(&ifp->if_snd) || IFQ_IS_EMPTY(&ifp->if_snd)) return; @@ -1455,7 +1456,7 @@ myx_start(struct ifnet *ifp) for (;;) { if (used + sc->sc_tx_nsegs + 1 > free) { - SET(ifp->if_flags, IFF_OACTIVE); + ifq_set_oactive(&ifp->if_snd); break; } @@ -1638,7 +1639,7 @@ myx_intr(void *arg) bus_space_write_raw_region_4(sc->sc_memt, sc->sc_memh, sc->sc_irqclaimoff + sizeof(data), &data, sizeof(data)); - start = ISSET(ifp->if_flags, IFF_OACTIVE); + start = ifq_is_oactive(&ifp->if_snd); if (sts->ms_statusupdated) { if (state == MYX_S_DOWN && @@ -1662,7 +1663,7 @@ myx_intr(void *arg) if (start) { KERNEL_LOCK(); - CLR(ifp->if_flags, IFF_OACTIVE); + ifq_clr_oactive(&ifp->if_snd); myx_start(ifp); KERNEL_UNLOCK(); } |