summaryrefslogtreecommitdiffstats
path: root/sys/i4b/layer1
diff options
context:
space:
mode:
authorjlemon <jlemon@FreeBSD.org>2000-11-25 07:35:38 +0000
committerjlemon <jlemon@FreeBSD.org>2000-11-25 07:35:38 +0000
commit954e1d2ccdb661d5c8b7f69340d118fa7ba7fb85 (patch)
tree0a4e9f6dcd5fa64a78f5991ac425f3ca97aba154 /sys/i4b/layer1
parent2daca11cae375091daf49a7cd704e5e4e1be27db (diff)
downloadFreeBSD-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')
-rw-r--r--sys/i4b/layer1/ifpi/i4b_ifpi_pci.c19
-rw-r--r--sys/i4b/layer1/ifpnp/i4b_ifpnp_avm.c19
-rw-r--r--sys/i4b/layer1/ihfc/i4b_ihfc_drv.c9
-rw-r--r--sys/i4b/layer1/ihfc/i4b_ihfc_l1if.c4
-rw-r--r--sys/i4b/layer1/isic/i4b_bchan.c10
-rw-r--r--sys/i4b/layer1/isic/i4b_hscx.c9
-rw-r--r--sys/i4b/layer1/iwic/i4b_iwic_bchan.c19
7 files changed, 36 insertions, 53 deletions
diff --git a/sys/i4b/layer1/ifpi/i4b_ifpi_pci.c b/sys/i4b/layer1/ifpi/i4b_ifpi_pci.c
index a59e07d..6fb3c11 100644
--- a/sys/i4b/layer1/ifpi/i4b_ifpi_pci.c
+++ b/sys/i4b/layer1/ifpi/i4b_ifpi_pci.c
@@ -863,14 +863,7 @@ avma1pp_hscx_intr(int h_chan, u_int stat, struct l1_softc *sc)
/* move rx'd data to rx queue */
- 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 layer that data are available */
(*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
@@ -1124,9 +1117,10 @@ avma1pp_bchannel_setup(int unit, int h_chan, 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_avma1pp_rx", MTX_DEF);
+
+ i4b_Bcleanifq(&chan->rx_queue); /* clean rx queue */
chan->rxcount = 0; /* reset rx counter */
@@ -1138,10 +1132,11 @@ avma1pp_bchannel_setup(int unit, int h_chan, 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_avma1pp_tx", MTX_DEF);
+ i4b_Bcleanifq(&chan->tx_queue); /* clean tx queue */
+
chan->txcount = 0; /* reset tx counter */
i4b_Bfreembuf(chan->out_mbuf_head); /* clean tx mbuf */
diff --git a/sys/i4b/layer1/ifpnp/i4b_ifpnp_avm.c b/sys/i4b/layer1/ifpnp/i4b_ifpnp_avm.c
index 401a19d..bc69399 100644
--- a/sys/i4b/layer1/ifpnp/i4b_ifpnp_avm.c
+++ b/sys/i4b/layer1/ifpnp/i4b_ifpnp_avm.c
@@ -799,14 +799,7 @@ avm_pnp_hscx_intr(int h_chan, u_int stat, u_int cnt, struct l1_softc *sc)
/* move rx'd data to rx queue */
- 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 layer that data are available */
(*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
@@ -1044,9 +1037,10 @@ avm_pnp_bchannel_setup(int unit, int h_chan, 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_avm_pnp_rx", MTX_DEF);
+
+ i4b_Bcleanifq(&chan->rx_queue); /* clean rx queue */
chan->rxcount = 0; /* reset rx counter */
@@ -1058,10 +1052,11 @@ avm_pnp_bchannel_setup(int unit, int h_chan, int bprot, int activate)
/* transmitter part */
+ chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
+ mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avm_pnp_tx", MTX_DEF);
+
i4b_Bcleanifq(&chan->tx_queue); /* clean tx queue */
- chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
-
chan->txcount = 0; /* reset tx counter */
i4b_Bfreembuf(chan->out_mbuf_head); /* clean tx mbuf */
diff --git a/sys/i4b/layer1/ihfc/i4b_ihfc_drv.c b/sys/i4b/layer1/ihfc/i4b_ihfc_drv.c
index 814a40a..7a01014 100644
--- a/sys/i4b/layer1/ihfc/i4b_ihfc_drv.c
+++ b/sys/i4b/layer1/ihfc/i4b_ihfc_drv.c
@@ -351,13 +351,14 @@ ihfc_init (ihfc_sc_t *sc, u_char chan, int prot, int activate)
do
{ if (chan < 2) /* D-Channel */
{
+ S_IFQUEUE.ifq_maxlen = IFQ_MAXLEN;
+ mtx_init(&S_IFQUEUE.ifq_mtx, "i4b_ihfc", MTX_DEF);
+
i4b_Dfreembuf(S_MBUF);
i4b_Dcleanifq(&S_IFQUEUE);
RESET_SOFT_CHAN(sc, chan);
- S_IFQUEUE.ifq_maxlen = IFQ_MAXLEN;
-
if (!activate) continue;
if (S_HFC & HFC_1)
@@ -373,13 +374,15 @@ ihfc_init (ihfc_sc_t *sc, u_char chan, int prot, int activate)
}
else /* B-Channel */
{
+ S_IFQUEUE.ifq_maxlen = IFQ_MAXLEN;
+ mtx_init(&S_IFQUEUE.ifq_mtx, "i4b_ihfc", MTX_DEF);
+
i4b_Bfreembuf(S_MBUF);
i4b_Bcleanifq(&S_IFQUEUE);
RESET_SOFT_CHAN(sc, chan);
S_PROT = prot;
- S_IFQUEUE.ifq_maxlen = IFQ_MAXLEN;
if (!activate) continue;
diff --git a/sys/i4b/layer1/ihfc/i4b_ihfc_l1if.c b/sys/i4b/layer1/ihfc/i4b_ihfc_l1if.c
index 5b9e6cf..4bb59f0 100644
--- a/sys/i4b/layer1/ihfc/i4b_ihfc_l1if.c
+++ b/sys/i4b/layer1/ihfc/i4b_ihfc_l1if.c
@@ -127,7 +127,7 @@ ihfc_ph_data_req(int unit, struct mbuf *m, int freeflag)
if (freeflag == MBUF_DONTFREE) m = m_copypacket(m, M_DONTWAIT);
- if (!IF_QFULL(&S_IFQUEUE) && m)
+ if (!_IF_QFULL(&S_IFQUEUE) && m)
{
IF_ENQUEUE(&S_IFQUEUE, m);
@@ -300,7 +300,7 @@ ihfc_putmbuf (ihfc_sc_t *sc, u_char chan, struct mbuf *m)
S_BDRVLINK->bch_activity(S_BDRVLINK->unit, ACT_RX);
}
- if (!IF_QFULL(&S_IFQUEUE))
+ if (!_IF_QFULL(&S_IFQUEUE))
{
S_BYTES += m->m_len;
IF_ENQUEUE(&S_IFQUEUE, m);
diff --git a/sys/i4b/layer1/isic/i4b_bchan.c b/sys/i4b/layer1/isic/i4b_bchan.c
index f1db0ea..c937790 100644
--- a/sys/i4b/layer1/isic/i4b_bchan.c
+++ b/sys/i4b/layer1/isic/i4b_bchan.c
@@ -91,9 +91,10 @@ isic_bchannel_setup(int unit, int h_chan, 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_isic_rx", MTX_DEF);
+
+ i4b_Bcleanifq(&chan->rx_queue); /* clean rx queue */
chan->rxcount = 0; /* reset rx counter */
@@ -105,10 +106,11 @@ isic_bchannel_setup(int unit, int h_chan, 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_isic_tx", MTX_DEF);
+ i4b_Bcleanifq(&chan->tx_queue); /* clean tx queue */
+
chan->txcount = 0; /* reset tx counter */
i4b_Bfreembuf(chan->out_mbuf_head); /* clean tx mbuf */
diff --git a/sys/i4b/layer1/isic/i4b_hscx.c b/sys/i4b/layer1/isic/i4b_hscx.c
index 121b8c5..79e74b8 100644
--- a/sys/i4b/layer1/isic/i4b_hscx.c
+++ b/sys/i4b/layer1/isic/i4b_hscx.c
@@ -270,14 +270,7 @@ isic_hscx_irq(register struct l1_softc *sc, u_char ista, int h_chan, u_char ex_i
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 */
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 */
OpenPOWER on IntegriCloud