diff options
author | Jonathan Lemon <jlemon@FreeBSD.org> | 2000-11-25 07:35:38 +0000 |
---|---|---|
committer | Jonathan Lemon <jlemon@FreeBSD.org> | 2000-11-25 07:35:38 +0000 |
commit | df5e1987230850fe5983a4479523708640160215 (patch) | |
tree | 05531b0125a3669b45ffc6aa7dc93115e4123969 /sys/dev/usb/usb_ethersubr.c | |
parent | f4e13f88b630686808a03dc19e3243ca37fa5645 (diff) |
Lock down the network interface queues. The queue mutex must be obtained
before adding/removing packets from the queue. Also, the if_obytes and
if_omcasts fields should only be manipulated under protection of the mutex.
IF_ENQUEUE, IF_PREPEND, and IF_DEQUEUE perform all necessary locking on
the queue. An IF_LOCK macro is provided, as well as the old (mutex-less)
versions of the macros in the form _IF_ENQUEUE, _IF_QFULL, for code which
needs them, but their use is discouraged.
Two new macros are introduced: IF_DRAIN() to drain a queue, and IF_HANDOFF,
which takes care of locking/enqueue, and also statistics updating/start
if necessary.
Notes
Notes:
svn path=/head/; revision=69152
Diffstat (limited to 'sys/dev/usb/usb_ethersubr.c')
-rw-r--r-- | sys/dev/usb/usb_ethersubr.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/sys/dev/usb/usb_ethersubr.c b/sys/dev/usb/usb_ethersubr.c index c02ed7dd0cb7..3065c47900b5 100644 --- a/sys/dev/usb/usb_ethersubr.c +++ b/sys/dev/usb/usb_ethersubr.c @@ -73,9 +73,7 @@ Static const char rcsid[] = #endif Static struct ifqueue usbq_rx; -Static struct mtx usbq_rx_mtx; Static struct ifqueue usbq_tx; -Static struct mtx usbq_tx_mtx; Static int mtx_inited = 0; Static void usbintr __P((void)); @@ -89,9 +87,7 @@ Static void usbintr() /* Check the RX queue */ while(1) { - mtx_enter(&usbq_rx_mtx, MTX_DEF); IF_DEQUEUE(&usbq_rx, m); - mtx_exit(&usbq_rx_mtx, MTX_DEF); if (m == NULL) break; eh = mtod(m, struct ether_header *); @@ -109,9 +105,7 @@ Static void usbintr() /* Check the TX queue */ while(1) { - mtx_enter(&usbq_tx_mtx, MTX_DEF); IF_DEQUEUE(&usbq_tx, m); - mtx_exit(&usbq_tx_mtx, MTX_DEF); if (m == NULL) break; ifp = m->m_pkthdr.rcvif; @@ -128,8 +122,8 @@ void usb_register_netisr() if (mtx_inited) return; register_netisr(NETISR_USB, usbintr); - mtx_init(&usbq_tx_mtx, "usbq_tx_mtx", MTX_DEF); - mtx_init(&usbq_rx_mtx, "usbq_rx_mtx", MTX_DEF); + mtx_init(&usbq_tx.ifq_mtx, "usbq_tx_mtx", MTX_DEF); + mtx_init(&usbq_rx.ifq_mtx, "usbq_rx_mtx", MTX_DEF); mtx_inited++; return; } @@ -141,9 +135,7 @@ void usb_register_netisr() void usb_ether_input(m) struct mbuf *m; { - mtx_enter(&usbq_rx_mtx, MTX_DEF); IF_ENQUEUE(&usbq_rx, m); - mtx_exit(&usbq_rx_mtx, MTX_DEF); schednetisr(NETISR_USB); return; @@ -152,9 +144,7 @@ void usb_ether_input(m) void usb_tx_done(m) struct mbuf *m; { - mtx_enter(&usbq_tx_mtx, MTX_DEF); IF_ENQUEUE(&usbq_tx, m); - mtx_exit(&usbq_tx_mtx, MTX_DEF); schednetisr(NETISR_USB); return; |