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/i4b/layer1/iwic/i4b_iwic_bchan.c | |
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/i4b/layer1/iwic/i4b_iwic_bchan.c')
-rw-r--r-- | sys/i4b/layer1/iwic/i4b_iwic_bchan.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/sys/i4b/layer1/iwic/i4b_iwic_bchan.c b/sys/i4b/layer1/iwic/i4b_iwic_bchan.c index e836f78..0b8fa26 100644 --- a/sys/i4b/layer1/iwic/i4b_iwic_bchan.c +++ b/sys/i4b/layer1/iwic/i4b_iwic_bchan.c @@ -239,14 +239,7 @@ iwic_bchan_xirq(struct iwic_softc *sc, int chan_no) if(!(i4b_l1_bchan_tel_silence(chan->in_mbuf->m_data, chan->in_mbuf->m_len))) activity = ACT_RX; - if(!(IF_QFULL(&chan->rx_queue))) - { - IF_ENQUEUE(&chan->rx_queue, chan->in_mbuf); - } - else - { - i4b_Bfreembuf(chan->in_mbuf); - } + (void) IF_HANDOFF(&chan->rx_queue, chan->in_mbuf, NULL); /* signal upper driver that data is available */ @@ -416,9 +409,10 @@ iwic_bchannel_setup(int unit, int chan_no, int bprot, int activate) /* receiver part */ - i4b_Bcleanifq(&chan->rx_queue); /* clean rx queue */ - chan->rx_queue.ifq_maxlen = IFQ_MAXLEN; + mtx_init(&chan->rx_queue.ifq_mtx, "i4b_iwic_rx", MTX_DEF); + + i4b_Bcleanifq(&chan->rx_queue); /* clean rx queue */ chan->rxcount = 0; /* reset rx counter */ @@ -430,9 +424,10 @@ iwic_bchannel_setup(int unit, int chan_no, int bprot, int activate) /* transmitter part */ - i4b_Bcleanifq(&chan->tx_queue); /* clean tx queue */ - chan->tx_queue.ifq_maxlen = IFQ_MAXLEN; + mtx_init(&chan->tx_queue.ifq_mtx, "i4b_iwic_tx", MTX_DEF); + + i4b_Bcleanifq(&chan->tx_queue); /* clean tx queue */ chan->txcount = 0; /* reset tx counter */ |