summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorKenjiro Cho <kjc@cvs.openbsd.org>2001-06-27 06:34:54 +0000
committerKenjiro Cho <kjc@cvs.openbsd.org>2001-06-27 06:34:54 +0000
commit17cc5dbba19bbbbeb9361149e56ee11dbc22da68 (patch)
tree8a51ae8b2bde0887aa6650a31196833183a5b94f /sys/dev/usb
parent30721c7f5299136d216635afefc517f47511b9f3 (diff)
ALTQ'ify network drivers.
- use the new queue macros. - use IFQ_POLL() to peek at the next packet. - use IFQ_IS_EMPTY() for empty check. - drivers should always check if (m == NULL) after IFQ_DEQUEUE(), since it could return NULL even when IFQ_IS_EMPTY() is FALSE under rate-limiting. - drivers are supposed to call if_start from tx complete interrupts (in order to trigger the next dequeue under rate-limiting).
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/if_aue.c16
-rw-r--r--sys/dev/usb/if_cue.c14
-rw-r--r--sys/dev/usb/if_kue.c14
3 files changed, 25 insertions, 19 deletions
diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c
index 0ab8eca568c..9b7552df8d4 100644
--- a/sys/dev/usb/if_aue.c
+++ b/sys/dev/usb/if_aue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_aue.c,v 1.13 2001/05/03 02:20:32 aaron Exp $ */
+/* $OpenBSD: if_aue.c,v 1.14 2001/06/27 06:34:53 kjc Exp $ */
/* $NetBSD: if_aue.c,v 1.55 2001/03/25 22:59:43 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -751,8 +751,9 @@ USB_ATTACH(aue)
ifp->if_start = aue_start;
ifp->if_watchdog = aue_watchdog;
#if defined(__OpenBSD__)
- ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
+ IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
#endif
+ IFQ_SET_READY(&ifp->if_snd);
strncpy(ifp->if_xname, USBDEVNAME(sc->aue_dev), IFNAMSIZ);
/* Initialize MII/media info. */
@@ -1149,7 +1150,7 @@ aue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
m_freem(c->aue_mbuf);
c->aue_mbuf = NULL;
- if (ifp->if_snd.ifq_head != NULL)
+ if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
aue_start(ifp);
splx(s);
@@ -1200,7 +1201,7 @@ aue_tick_task(void *xsc)
DPRINTFN(2,("%s: %s: got link\n",
USBDEVNAME(sc->aue_dev),__FUNCTION__));
sc->aue_link++;
- if (ifp->if_snd.ifq_head != NULL)
+ if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
aue_start(ifp);
}
}
@@ -1277,16 +1278,17 @@ aue_start(struct ifnet *ifp)
if (ifp->if_flags & IFF_OACTIVE)
return;
- IF_DEQUEUE(&ifp->if_snd, m_head);
+ IFQ_POLL(&ifp->if_snd, m_head);
if (m_head == NULL)
return;
if (aue_send(sc, m_head, 0)) {
- IF_PREPEND(&ifp->if_snd, m_head);
ifp->if_flags |= IFF_OACTIVE;
return;
}
+ IFQ_DEQUEUE(&ifp->if_snd, m_head);
+
#if NBPFILTER > 0
/*
* If there's a BPF listener, bounce a copy of this frame
@@ -1592,7 +1594,7 @@ aue_watchdog(struct ifnet *ifp)
usbd_get_xfer_status(c->aue_xfer, NULL, NULL, NULL, &stat);
aue_txeof(c->aue_xfer, c, stat);
- if (ifp->if_snd.ifq_head != NULL)
+ if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
aue_start(ifp);
splx(s);
}
diff --git a/sys/dev/usb/if_cue.c b/sys/dev/usb/if_cue.c
index 6a82299a871..6917fdfa1d7 100644
--- a/sys/dev/usb/if_cue.c
+++ b/sys/dev/usb/if_cue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_cue.c,v 1.8 2001/05/03 02:20:32 aaron Exp $ */
+/* $OpenBSD: if_cue.c,v 1.9 2001/06/27 06:34:53 kjc Exp $ */
/* $NetBSD: if_cue.c,v 1.34 2001/04/12 23:54:56 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -578,8 +578,9 @@ USB_ATTACH(cue)
ifp->if_start = cue_start;
ifp->if_watchdog = cue_watchdog;
#if defined(__OpenBSD__)
- ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
+ IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
#endif
+ IFQ_SET_READY(&ifp->if_snd);
strncpy(ifp->if_xname, USBDEVNAME(sc->cue_dev), IFNAMSIZ);
/* Attach the interface. */
@@ -908,7 +909,7 @@ cue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
m_freem(c->cue_mbuf);
c->cue_mbuf = NULL;
- if (ifp->if_snd.ifq_head != NULL)
+ if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
cue_start(ifp);
splx(s);
@@ -1010,16 +1011,17 @@ cue_start(struct ifnet *ifp)
if (ifp->if_flags & IFF_OACTIVE)
return;
- IF_DEQUEUE(&ifp->if_snd, m_head);
+ IFQ_POLL(&ifp->if_snd, m_head);
if (m_head == NULL)
return;
if (cue_send(sc, m_head, 0)) {
- IF_PREPEND(&ifp->if_snd, m_head);
ifp->if_flags |= IFF_OACTIVE;
return;
}
+ IFQ_DEQUEUE(&ifp->if_snd, m_head);
+
#if NBPFILTER > 0
/*
* If there's a BPF listener, bounce a copy of this frame
@@ -1273,7 +1275,7 @@ cue_watchdog(struct ifnet *ifp)
usbd_get_xfer_status(c->cue_xfer, NULL, NULL, NULL, &stat);
cue_txeof(c->cue_xfer, c, stat);
- if (ifp->if_snd.ifq_head != NULL)
+ if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
cue_start(ifp);
splx(s);
}
diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c
index b2f15b13942..3ee0298c6c7 100644
--- a/sys/dev/usb/if_kue.c
+++ b/sys/dev/usb/if_kue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_kue.c,v 1.10 2001/05/03 02:20:32 aaron Exp $ */
+/* $OpenBSD: if_kue.c,v 1.11 2001/06/27 06:34:53 kjc Exp $ */
/* $NetBSD: if_kue.c,v 1.40 2001/04/08 02:10:57 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -519,8 +519,9 @@ USB_ATTACH(kue)
ifp->if_start = kue_start;
ifp->if_watchdog = kue_watchdog;
#if defined(__OpenBSD__)
- ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
+ IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
#endif
+ IFQ_SET_READY(&ifp->if_snd);
strncpy(ifp->if_xname, USBDEVNAME(sc->kue_dev), IFNAMSIZ);
/* Attach the interface. */
@@ -850,7 +851,7 @@ kue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
m_freem(c->kue_mbuf);
c->kue_mbuf = NULL;
- if (ifp->if_snd.ifq_head != NULL)
+ if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
kue_start(ifp);
splx(s);
@@ -914,16 +915,17 @@ kue_start(struct ifnet *ifp)
if (ifp->if_flags & IFF_OACTIVE)
return;
- IF_DEQUEUE(&ifp->if_snd, m_head);
+ IFQ_POLL(&ifp->if_snd, m_head);
if (m_head == NULL)
return;
if (kue_send(sc, m_head, 0)) {
- IF_PREPEND(&ifp->if_snd, m_head);
ifp->if_flags |= IFF_OACTIVE;
return;
}
+ IFQ_DEQUEUE(&ifp->if_snd, m_head);
+
#if NBPFILTER > 0
/*
* If there's a BPF listener, bounce a copy of this frame
@@ -1174,7 +1176,7 @@ kue_watchdog(struct ifnet *ifp)
usbd_get_xfer_status(c->kue_xfer, NULL, NULL, NULL, &stat);
kue_txeof(c->kue_xfer, c, stat);
- if (ifp->if_snd.ifq_head != NULL)
+ if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
kue_start(ifp);
splx(s);
}