summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-11-20 12:41:30 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-11-20 12:41:30 +0000
commit91b27ed57884836ad277500fb3eff12c35d8faf7 (patch)
tree97158f4f55ddb7c5707d01d7433a9647e5f27f29 /sys/dev
parente313fe8c34e2271b9c57faee82709bbf4ee4d3ae (diff)
Check for space on the ring before dequeuing packets.
Allows us to get rid of mq_requeue(9) and IFQ_POLL(9) because wireless drivers use a special queue for management frames. Tested by stsp@, ok dlg@, stsp@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/rt2560.c22
-rw-r--r--sys/dev/ic/rt2661.c24
2 files changed, 24 insertions, 22 deletions
diff --git a/sys/dev/ic/rt2560.c b/sys/dev/ic/rt2560.c
index 75b69c79cb2..85e0ef34bda 100644
--- a/sys/dev/ic/rt2560.c
+++ b/sys/dev/ic/rt2560.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2560.c,v 1.75 2015/11/20 03:35:22 dlg Exp $ */
+/* $OpenBSD: rt2560.c,v 1.76 2015/11/20 12:41:29 mpi Exp $ */
/*-
* Copyright (c) 2005, 2006
@@ -1928,15 +1928,16 @@ rt2560_start(struct ifnet *ifp)
return;
for (;;) {
- m0 = mq_dequeue(&ic->ic_mgtq);
- if (m0 != NULL) {
+ if (mq_len(&ic->ic_mgtq) > 0) {
if (sc->prioq.queued >= RT2560_PRIO_RING_COUNT) {
ifp->if_flags |= IFF_OACTIVE;
sc->sc_flags |= RT2560_PRIO_OACTIVE;
- mq_requeue(&ic->ic_mgtq, m0);
break;
}
+ m0 = mq_dequeue(&ic->ic_mgtq);
+ if (m0 == NULL)
+ continue;
ni = m0->m_pkthdr.ph_cookie;
#if NBPFILTER > 0
if (ic->ic_rawbpf != NULL)
@@ -1946,18 +1947,19 @@ rt2560_start(struct ifnet *ifp)
break;
} else {
- if (ic->ic_state != IEEE80211_S_RUN)
- break;
- m0 = ifq_deq_begin(&ifp->if_snd);
- if (m0 == NULL)
- break;
if (sc->txq.queued >= RT2560_TX_RING_COUNT - 1) {
ifq_deq_rollback(&ifp->if_snd, m0);
ifp->if_flags |= IFF_OACTIVE;
sc->sc_flags |= RT2560_DATA_OACTIVE;
break;
}
- ifq_deq_commit(&ifp->if_snd, m0);
+
+ if (ic->ic_state != IEEE80211_S_RUN)
+ break;
+
+ IFQ_DEQUEUE(&ifp->if_snd, m0);
+ if (m0 == NULL)
+ break;
#if NBPFILTER > 0
if (ifp->if_bpf != NULL)
bpf_mtap(ifp->if_bpf, m0, BPF_DIRECTION_OUT);
diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c
index 1fefe88c366..87deca78ac3 100644
--- a/sys/dev/ic/rt2661.c
+++ b/sys/dev/ic/rt2661.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2661.c,v 1.85 2015/11/20 03:35:22 dlg Exp $ */
+/* $OpenBSD: rt2661.c,v 1.86 2015/11/20 12:41:29 mpi Exp $ */
/*-
* Copyright (c) 2006
@@ -1933,14 +1933,15 @@ rt2661_start(struct ifnet *ifp)
return;
for (;;) {
- m0 = mq_dequeue(&ic->ic_mgtq);
- if (m0 != NULL) {
+ if (mq_len(&ic->ic_mgtq) > 0) {
if (sc->mgtq.queued >= RT2661_MGT_RING_COUNT) {
ifp->if_flags |= IFF_OACTIVE;
- mq_requeue(&ic->ic_mgtq, m0);
break;
}
+ m0 = mq_dequeue(&ic->ic_mgtq);
+ if (m0 == NULL)
+ continue;
ni = m0->m_pkthdr.ph_cookie;
#if NBPFILTER > 0
if (ic->ic_rawbpf != NULL)
@@ -1950,18 +1951,17 @@ rt2661_start(struct ifnet *ifp)
break;
} else {
- if (ic->ic_state != IEEE80211_S_RUN)
- break;
- m0 = ifq_deq_begin(&ifp->if_snd);
- if (m0 == NULL)
- break;
if (sc->txq[0].queued >= RT2661_TX_RING_COUNT - 1) {
- ifq_deq_rollback(&ifp->if_snd, m0);
- /* there is no place left in this ring */
ifp->if_flags |= IFF_OACTIVE;
break;
}
- ifq_deq_commit(&ifp->if_snd, m0);
+
+ if (ic->ic_state != IEEE80211_S_RUN)
+ break;
+
+ IFQ_DEQUEUE(&ifp->if_snd, m0);
+ if (m0 == NULL)
+ break;
#if NBPFILTER > 0
if (ifp->if_bpf != NULL)
bpf_mtap(ifp->if_bpf, m0, BPF_DIRECTION_OUT);