summaryrefslogtreecommitdiff
path: root/sys/dev/usb/if_url.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2015-11-20 03:35:24 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2015-11-20 03:35:24 +0000
commit93d7f55b038092ded0514b3f745fd014c1845492 (patch)
treeda8fbd80cf246b5a4ebcdf952d9bb7b92cbe5e19 /sys/dev/usb/if_url.c
parentd3a33e8102f3bbde40bab36e7fc5067836baf064 (diff)
shuffle struct ifqueue so in flight mbufs are protected by a mutex.
the code is refactored so the IFQ macros call newly implemented ifq functions. the ifq code is split so each discipline (priq and hfsc in our case) is an opaque set of operations that the common ifq code can call. the common code does the locking, accounting (ifq_len manipulation), and freeing of the mbuf if the disciplines enqueue function rejects it. theyre kind of like bufqs in the block layer with their fifo and nscan disciplines. the new api also supports atomic switching of disciplines at runtime. the hfsc setup in pf_ioctl.c has been tweaked to build a complete hfsc_if structure which it attaches to the send queue in a single operation, rather than attaching to the interface up front and building up a list of queues. the send queue is now mutexed, which raises the expectation that packets can be enqueued or purged on one cpu while another cpu is dequeueing them in a driver for transmission. a lot of drivers use IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before committing to it with a later IFQ_DEQUEUE operation. if the mbuf gets freed in between the POLL and DEQUEUE operations, fireworks will ensue. to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback, and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq mutex and get a reference to the mbuf they wish to try and tx. if there's space, they can ifq_deq_commit it to remove the mbuf and release the mutex. if there's no space, ifq_deq_rollback simply releases the mutex. this api was developed to make updating the drivers using IFQ_POLL easy, instead of having to do significant semantic changes to avoid POLL that we cannot test on all the hardware. the common code has been tested pretty hard, and all the driver modifications are straightforward except for de(4). if that breaks it can be dealt with later. ok mpi@ jmatthew@
Diffstat (limited to 'sys/dev/usb/if_url.c')
-rw-r--r--sys/dev/usb/if_url.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/dev/usb/if_url.c b/sys/dev/usb/if_url.c
index a9a4cbe113c..a60397df06b 100644
--- a/sys/dev/usb/if_url.c
+++ b/sys/dev/usb/if_url.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_url.c,v 1.76 2015/10/25 12:11:56 mpi Exp $ */
+/* $OpenBSD: if_url.c,v 1.77 2015/11/20 03:35:23 dlg Exp $ */
/* $NetBSD: if_url.c,v 1.6 2002/09/29 10:19:21 martin Exp $ */
/*
* Copyright (c) 2001, 2002
@@ -791,16 +791,17 @@ url_start(struct ifnet *ifp)
if (ifp->if_flags & IFF_OACTIVE)
return;
- IFQ_POLL(&ifp->if_snd, m_head);
+ m_head = ifq_deq_begin(&ifp->if_snd);
if (m_head == NULL)
return;
if (url_send(sc, m_head, 0)) {
+ ifq_deq_rollback(&ifp->if_snd, m_head);
ifp->if_flags |= IFF_OACTIVE;
return;
}
- IFQ_DEQUEUE(&ifp->if_snd, m_head);
+ ifq_deq_commit(&ifp->if_snd, m_head);
#if NBPFILTER > 0
if (ifp->if_bpf)