diff options
author | jlemon <jlemon@FreeBSD.org> | 2000-11-25 07:35:38 +0000 |
---|---|---|
committer | jlemon <jlemon@FreeBSD.org> | 2000-11-25 07:35:38 +0000 |
commit | 954e1d2ccdb661d5c8b7f69340d118fa7ba7fb85 (patch) | |
tree | 0a4e9f6dcd5fa64a78f5991ac425f3ca97aba154 /sys/dev/awi | |
parent | 2daca11cae375091daf49a7cd704e5e4e1be27db (diff) | |
download | FreeBSD-src-954e1d2ccdb661d5c8b7f69340d118fa7ba7fb85.zip FreeBSD-src-954e1d2ccdb661d5c8b7f69340d118fa7ba7fb85.tar.gz |
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.
Diffstat (limited to 'sys/dev/awi')
-rw-r--r-- | sys/dev/awi/awi.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/sys/dev/awi/awi.c b/sys/dev/awi/awi.c index 023796b..749e042 100644 --- a/sys/dev/awi/awi.c +++ b/sys/dev/awi/awi.c @@ -876,17 +876,12 @@ awi_stop(sc) ifp->if_timer = 0; sc->sc_tx_timer = sc->sc_rx_timer = sc->sc_mgt_timer = 0; for (;;) { - IF_DEQUEUE(&sc->sc_mgtq, m); - if (m == NULL) - break; - m_freem(m); - } - for (;;) { - IF_DEQUEUE(&ifp->if_snd, m); + _IF_DEQUEUE(&sc->sc_mgtq, m); if (m == NULL) break; m_freem(m); } + IF_DRAIN(&ifp->if_snd); while ((bp = TAILQ_FIRST(&sc->sc_scan)) != NULL) { TAILQ_REMOVE(&sc->sc_scan, bp, list); free(bp, M_DEVBUF); @@ -955,10 +950,10 @@ awi_start(ifp) for (;;) { txd = sc->sc_txnext; - IF_DEQUEUE(&sc->sc_mgtq, m0); + _IF_DEQUEUE(&sc->sc_mgtq, m0); if (m0 != NULL) { if (awi_next_txd(sc, m0->m_pkthdr.len, &frame, &ntxd)) { - IF_PREPEND(&sc->sc_mgtq, m0); + _IF_PREPEND(&sc->sc_mgtq, m0); ifp->if_flags |= IFF_OACTIVE; break; } @@ -2096,7 +2091,7 @@ awi_send_deauth(sc) deauth += 2; m->m_pkthdr.len = m->m_len = deauth - mtod(m, u_int8_t *); - IF_ENQUEUE(&sc->sc_mgtq, m); + _IF_ENQUEUE(&sc->sc_mgtq, m); awi_start(ifp); awi_drvstate(sc, AWI_DRV_INFTOSS); } @@ -2141,7 +2136,7 @@ awi_send_auth(sc, seq) auth += 2; m->m_pkthdr.len = m->m_len = auth - mtod(m, u_int8_t *); - IF_ENQUEUE(&sc->sc_mgtq, m); + _IF_ENQUEUE(&sc->sc_mgtq, m); awi_start(ifp); sc->sc_mgt_timer = AWI_TRANS_TIMEOUT / 1000; @@ -2261,7 +2256,7 @@ awi_send_asreq(sc, reassoc) asreq += 2 + asreq[1]; m->m_pkthdr.len = m->m_len = asreq - mtod(m, u_int8_t *); - IF_ENQUEUE(&sc->sc_mgtq, m); + _IF_ENQUEUE(&sc->sc_mgtq, m); awi_start(ifp); sc->sc_mgt_timer = AWI_TRANS_TIMEOUT / 1000; |