diff options
Diffstat (limited to 'sys/dev/usb/if_upl.c')
-rw-r--r-- | sys/dev/usb/if_upl.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/sys/dev/usb/if_upl.c b/sys/dev/usb/if_upl.c index 0ae2682699c..2684f9efddf 100644 --- a/sys/dev/usb/if_upl.c +++ b/sys/dev/usb/if_upl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_upl.c,v 1.4 2001/10/31 04:24:44 nate Exp $ */ +/* $OpenBSD: if_upl.c,v 1.5 2002/03/12 09:51:20 kjc Exp $ */ /* $NetBSD: if_upl.c,v 1.15 2001/06/14 05:44:27 itojun Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -337,6 +337,7 @@ USB_ATTACH(upl) ifp->if_input = upl_input; #endif ifp->if_baudrate = 12000000; + IFQ_SET_READY(&ifp->if_snd); /* Attach the interface. */ if_attach(ifp); @@ -659,7 +660,7 @@ upl_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) m_freem(c->upl_mbuf); c->upl_mbuf = NULL; - if (ifp->if_snd.ifq_head != NULL) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) upl_start(ifp); splx(s); @@ -718,16 +719,17 @@ upl_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 (upl_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 @@ -965,7 +967,7 @@ upl_watchdog(struct ifnet *ifp) upl_stop(sc); upl_init(sc); - if (ifp->if_snd.ifq_head != NULL) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) upl_start(ifp); } @@ -1059,24 +1061,32 @@ Static int upl_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct rtentry *rt0) { - int s; + int s, len, error; + ALTQ_DECL(struct altq_pktattr pktattr;) DPRINTFN(10,("%s: %s: enter\n", USBDEVNAME(((struct upl_softc *)ifp->if_softc)->sc_dev), __FUNCTION__)); + /* + * if the queueing discipline needs packet classification, + * do it now. + */ + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + + len = m->m_pkthdr.len; s = splnet(); /* * Queue message on interface, and start output if interface * not yet active. */ - if (IF_QFULL(&ifp->if_snd)) { - IF_DROP(&ifp->if_snd); + IFQ_ENQUEUE(&ifp->if_snd, m, &pktattr, error); + if (error) { + /* mbuf is already freed */ splx(s); - return (ENOBUFS); + return (error); } - ifp->if_obytes += m->m_pkthdr.len; - IF_ENQUEUE(&ifp->if_snd, m); + ifp->if_obytes += len; if ((ifp->if_flags & IFF_OACTIVE) == 0) (*ifp->if_start)(ifp); splx(s); |