summaryrefslogtreecommitdiffstats
path: root/sys/dev/en
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/dev/en
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/dev/en')
-rw-r--r--sys/dev/en/midway.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/sys/dev/en/midway.c b/sys/dev/en/midway.c
index 56558fb..0f24ed0 100644
--- a/sys/dev/en/midway.c
+++ b/sys/dev/en/midway.c
@@ -1366,13 +1366,13 @@ struct en_softc *sc;
continue;
slot = sc->rxvc2slot[lcv];
while (1) {
- IF_DEQUEUE(&sc->rxslot[slot].indma, m);
+ _IF_DEQUEUE(&sc->rxslot[slot].indma, m);
if (m == NULL)
break; /* >>> exit 'while(1)' here <<< */
m_freem(m);
}
while (1) {
- IF_DEQUEUE(&sc->rxslot[slot].q, m);
+ _IF_DEQUEUE(&sc->rxslot[slot].q, m);
if (m == NULL)
break; /* >>> exit 'while(1)' here <<< */
m_freem(m);
@@ -1393,13 +1393,13 @@ struct en_softc *sc;
for (lcv = 0 ; lcv < EN_NTX ; lcv++) {
while (1) {
- IF_DEQUEUE(&sc->txslot[lcv].indma, m);
+ _IF_DEQUEUE(&sc->txslot[lcv].indma, m);
if (m == NULL)
break; /* >>> exit 'while(1)' here <<< */
m_freem(m);
}
while (1) {
- IF_DEQUEUE(&sc->txslot[lcv].q, m);
+ _IF_DEQUEUE(&sc->txslot[lcv].q, m);
if (m == NULL)
break; /* >>> exit 'while(1)' here <<< */
m_freem(m);
@@ -1725,7 +1725,7 @@ struct ifnet *ifp;
sc->txslot[txchan].mbsize);
#endif
- IF_ENQUEUE(&sc->txslot[txchan].q, m);
+ _IF_ENQUEUE(&sc->txslot[txchan].q, m);
en_txdma(sc, txchan);
@@ -2093,7 +2093,7 @@ again:
* it is a go, commit! dequeue mbuf start working on the xfer.
*/
- IF_DEQUEUE(&sc->txslot[chan].q, tmp);
+ _IF_DEQUEUE(&sc->txslot[chan].q, tmp);
#ifdef EN_DIAG
if (launch.t != tmp)
panic("en dequeue");
@@ -2145,7 +2145,7 @@ again:
*/
sc->txslot[chan].bfree -= launch.need;
- IF_ENQUEUE(&sc->txslot[chan].indma, launch.t);
+ _IF_ENQUEUE(&sc->txslot[chan].indma, launch.t);
goto again;
/*
@@ -2157,7 +2157,7 @@ again:
*/
dequeue_drop:
- IF_DEQUEUE(&sc->txslot[chan].q, tmp);
+ _IF_DEQUEUE(&sc->txslot[chan].q, tmp);
if (launch.t != tmp)
panic("en dequeue drop");
m_freem(launch.t);
@@ -2624,7 +2624,7 @@ void *arg;
if ((dtq = sc->dtq[idx]) != 0) {
sc->dtq[idx] = 0; /* don't forget to zero it out when done */
slot = EN_DQ_SLOT(dtq);
- IF_DEQUEUE(&sc->txslot[slot].indma, m);
+ _IF_DEQUEUE(&sc->txslot[slot].indma, m);
if (!m) panic("enintr: dtqsync");
sc->txslot[slot].mbsize -= EN_DQ_LEN(dtq);
#ifdef EN_DEBUG
@@ -2675,7 +2675,7 @@ void *arg;
if (EN_DQ_LEN(drq) == 0) { /* "JK" trash DMA? */
m = NULL;
} else {
- IF_DEQUEUE(&sc->rxslot[slot].indma, m);
+ _IF_DEQUEUE(&sc->rxslot[slot].indma, m);
if (!m)
panic("enintr: drqsync: %s: lost mbuf in slot %d!",
sc->sc_dev.dv_xname, slot);
@@ -2978,7 +2978,7 @@ defer: /* defer processing */
EN_COUNT(sc->rxqnotus);
} else {
EN_COUNT(sc->rxqus);
- IF_DEQUEUE(&sc->rxslot[slot].q, m);
+ _IF_DEQUEUE(&sc->rxslot[slot].q, m);
drqneed = sav[1];
#ifdef EN_DEBUG
printf("%s: rx%d: recovered q'ed mbuf %p (drqneed=%d)\n",
@@ -3026,7 +3026,7 @@ defer: /* defer processing */
sav = mtod(m, u_int32_t *);
sav[0] = cur;
sav[1] = drqneed;
- IF_ENQUEUE(&sc->rxslot[slot].q, m);
+ _IF_ENQUEUE(&sc->rxslot[slot].q, m);
EN_COUNT(sc->rxdrqout);
#ifdef EN_DEBUG
printf("%s: rx%d: out of DRQs\n", sc->sc_dev.dv_xname, slot);
@@ -3218,7 +3218,7 @@ done:
m->m_pkthdr.len -= cnt;
m->m_data += cnt;
}
- IF_ENQUEUE(&sc->rxslot[slot].indma, m);
+ _IF_ENQUEUE(&sc->rxslot[slot].indma, m);
}
sc->rxslot[slot].cur = cur; /* update master copy of 'cur' */
OpenPOWER on IntegriCloud