From 954e1d2ccdb661d5c8b7f69340d118fa7ba7fb85 Mon Sep 17 00:00:00 2001 From: jlemon Date: Sat, 25 Nov 2000 07:35:38 +0000 Subject: 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. --- sys/dev/ppbus/if_plip.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'sys/dev/ppbus') diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c index 2410afe..ee379fe 100644 --- a/sys/dev/ppbus/if_plip.c +++ b/sys/dev/ppbus/if_plip.c @@ -513,11 +513,6 @@ lp_intr (void *arg) sc->sc_iferrs = 0; - if (IF_QFULL(&ipintrq)) { - lprintf("DROP"); - IF_DROP(&ipintrq); - goto done; - } len -= CLPIPHDRLEN; sc->sc_if.if_ipackets++; sc->sc_if.if_ibytes += len; @@ -525,8 +520,11 @@ lp_intr (void *arg) if (top) { if (sc->sc_if.if_bpf) lptap(&sc->sc_if, top); - IF_ENQUEUE(&ipintrq, top); - schednetisr(NETISR_IP); + if (! IF_HANDOFF(&ipintrq, top, NULL)) { + lprintf("DROP"); + } else { + schednetisr(NETISR_IP); + } } goto done; } @@ -564,11 +562,6 @@ lp_intr (void *arg) sc->sc_iferrs = 0; - if (IF_QFULL(&ipintrq)) { - lprintf("DROP"); - IF_DROP(&ipintrq); - goto done; - } len -= LPIPHDRLEN; sc->sc_if.if_ipackets++; sc->sc_if.if_ibytes += len; @@ -576,8 +569,11 @@ lp_intr (void *arg) if (top) { if (sc->sc_if.if_bpf) lptap(&sc->sc_if, top); - IF_ENQUEUE(&ipintrq, top); - schednetisr(NETISR_IP); + if (! IF_HANDOFF(&ipintrq, top, NULL)) { + lprintf("DROP"); + } else { + schednetisr(NETISR_IP); + } } } goto done; -- cgit v1.1