diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/an.c | 11 | ||||
-rw-r--r-- | sys/dev/ic/dp8390.c | 3 | ||||
-rw-r--r-- | sys/dev/ic/pdq_ifsubr.c | 12 | ||||
-rw-r--r-- | sys/dev/ic/smc90cx6.c | 5 | ||||
-rw-r--r-- | sys/dev/ic/tropic.c | 4 | ||||
-rw-r--r-- | sys/dev/ofw/ofnet.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/if_bge.c | 22 | ||||
-rw-r--r-- | sys/dev/pci/if_lge.c | 21 | ||||
-rw-r--r-- | sys/dev/pci/if_nge.c | 21 | ||||
-rw-r--r-- | sys/dev/pci/if_sk.c | 19 | ||||
-rw-r--r-- | sys/dev/pci/if_txp.c | 14 | ||||
-rw-r--r-- | sys/dev/pci/if_vr.c | 8 | ||||
-rw-r--r-- | sys/dev/pci/if_wx.c | 5 | ||||
-rw-r--r-- | sys/dev/usb/if_upl.c | 32 |
14 files changed, 114 insertions, 68 deletions
diff --git a/sys/dev/ic/an.c b/sys/dev/ic/an.c index 97595de2504..c62fc8e0824 100644 --- a/sys/dev/ic/an.c +++ b/sys/dev/ic/an.c @@ -1,4 +1,4 @@ -/* $OpenBSD: an.c,v 1.21 2002/01/02 18:34:11 mickey Exp $ */ +/* $OpenBSD: an.c,v 1.22 2002/03/12 09:51:20 kjc Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -239,6 +239,7 @@ an_attach(sc) ifp->if_start = an_start; ifp->if_watchdog = an_watchdog; ifp->if_baudrate = 10000000; + IFQ_SET_READY(&ifp->if_snd); bzero(sc->an_config.an_nodename, sizeof(sc->an_config.an_nodename)); bcopy(AN_DEFAULT_NODENAME, sc->an_config.an_nodename, @@ -518,7 +519,7 @@ an_intr(xsc) /* Re-enable interrupts. */ CSR_WRITE_2(sc, AN_INT_EN, AN_INTRS); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) an_start(ifp); return 1; @@ -1237,6 +1238,7 @@ an_start(ifp) int id; int idx; unsigned char txcontrol; + int pkts = 0; sc = ifp->if_softc; @@ -1253,10 +1255,11 @@ an_start(ifp) bzero((char *)&tx_frame_802_3, sizeof(tx_frame_802_3)); while(sc->an_rdata.an_tx_ring[idx] == 0) { - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 == NULL) break; + pkts++; id = sc->an_rdata.an_tx_fids[idx]; eh = mtod(m0, struct ether_header *); @@ -1301,6 +1304,8 @@ an_start(ifp) AN_INC(idx, AN_TX_RING_CNT); } + if (pkts == 0) + return; if (m0 != NULL) ifp->if_flags |= IFF_OACTIVE; diff --git a/sys/dev/ic/dp8390.c b/sys/dev/ic/dp8390.c index 4f369894d55..5cf5df6e4f7 100644 --- a/sys/dev/ic/dp8390.c +++ b/sys/dev/ic/dp8390.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dp8390.c,v 1.20 2002/01/08 05:38:53 fgsch Exp $ */ +/* $OpenBSD: dp8390.c,v 1.21 2002/03/12 09:51:20 kjc Exp $ */ /* $NetBSD: dp8390.c,v 1.13 1998/07/05 06:49:11 jonathan Exp $ */ /* @@ -138,6 +138,7 @@ dp8390_config(sc) /* Initialize media goo. */ (*sc->sc_media_init)(sc); + IFQ_SET_READY(&ifp->if_snd); /* Attach the interface. */ if_attach(ifp); diff --git a/sys/dev/ic/pdq_ifsubr.c b/sys/dev/ic/pdq_ifsubr.c index 198091004d7..8f55f8631b1 100644 --- a/sys/dev/ic/pdq_ifsubr.c +++ b/sys/dev/ic/pdq_ifsubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pdq_ifsubr.c,v 1.10 2001/11/06 19:53:18 miod Exp $ */ +/* $OpenBSD: pdq_ifsubr.c,v 1.11 2002/03/12 09:51:20 kjc Exp $ */ /* $NetBSD: pdq_ifsubr.c,v 1.5 1996/05/20 00:26:21 thorpej Exp $ */ /*- @@ -144,13 +144,7 @@ pdq_ifwatchdog( ifp->if_flags &= ~IFF_OACTIVE; ifp->if_timer = 0; - for (;;) { - struct mbuf *m; - IFQ_DEQUEUE(&ifp->if_snd, m); - if (m == NULL) - return; - m_freem(m); - } + IFQ_PURGE(&ifp->if_snd); } ifnet_ret_t @@ -372,9 +366,7 @@ pdq_ifattach( ifp->if_ioctl = pdq_ifioctl; ifp->if_output = fddi_output; ifp->if_start = pdq_ifstart; -#ifdef notyet /* if_fddisubr.c hasn't been converted yet */ IFQ_SET_READY(&ifp->if_snd); -#endif if_attach(ifp); fddi_ifattach(ifp); diff --git a/sys/dev/ic/smc90cx6.c b/sys/dev/ic/smc90cx6.c index 65a9d80ac92..86348f9dcce 100644 --- a/sys/dev/ic/smc90cx6.c +++ b/sys/dev/ic/smc90cx6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smc90cx6.c,v 1.3 1996/10/31 01:01:39 niklas Exp $ */ +/* $OpenBSD: smc90cx6.c,v 1.4 2002/03/12 09:51:20 kjc Exp $ */ /* $NetBSD: smc90cx6.c,v 1.17 1996/05/07 01:43:18 thorpej Exp $ */ /* @@ -285,6 +285,7 @@ bah_zbus_attach(parent, self, aux) IFF_NOTRAILERS | IFF_NOARP; ifp->if_mtu = ARCMTU; + IFQ_SET_READY(&ifp->if_snd); if_attach(ifp); arc_ifattach(ifp); @@ -557,7 +558,7 @@ bah_start(ifp) return; } - IF_DEQUEUE(&ifp->if_snd, m); + IFQ_DEQUEUE(&ifp->if_snd, m); buffer = sc->sc_tx_act ^ 1; splx(s); diff --git a/sys/dev/ic/tropic.c b/sys/dev/ic/tropic.c index a73ef15a060..7ea095b2cca 100644 --- a/sys/dev/ic/tropic.c +++ b/sys/dev/ic/tropic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tropic.c,v 1.4 2001/08/19 15:07:30 miod Exp $ */ +/* $OpenBSD: tropic.c,v 1.5 2002/03/12 09:51:20 kjc Exp $ */ /* $NetBSD: tropic.c,v 1.6 1999/12/17 08:26:31 fvdl Exp $ */ /* @@ -352,9 +352,7 @@ tr_attach(sc) ifp->if_start = tr_oldstart; ifp->if_flags = IFF_BROADCAST | IFF_NOTRAILERS; ifp->if_watchdog = tr_watchdog; -#ifdef notyet /* if_tokensubr.c hasn't been converted yet */ IFQ_SET_READY(&ifp->if_snd); -#endif switch (MM_INB(sc, TR_MEDIAS_OFFSET)) { case 0xF: diff --git a/sys/dev/ofw/ofnet.c b/sys/dev/ofw/ofnet.c index d252885e603..39031919342 100644 --- a/sys/dev/ofw/ofnet.c +++ b/sys/dev/ofw/ofnet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofnet.c,v 1.6 2001/08/08 21:49:16 miod Exp $ */ +/* $OpenBSD: ofnet.c,v 1.7 2002/03/12 09:51:20 kjc Exp $ */ /* $NetBSD: ofnet.c,v 1.4 1996/10/16 19:33:21 ws Exp $ */ /* @@ -162,6 +162,7 @@ printf("\nethernet dev: path %s\n", path); ifp->if_ioctl = ofnioctl; ifp->if_watchdog = ofnwatchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; + IFQ_SET_READY(&ifp->if_snd); timeout_set(&of->sc_tmo, ofntimer, of); @@ -295,7 +296,7 @@ ofnstart(ifp) ofnread(of); /* Now get the first packet on the queue */ - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (!m0) return; diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c index ab473540808..bcd08be204c 100644 --- a/sys/dev/pci/if_bge.c +++ b/sys/dev/pci/if_bge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bge.c,v 1.6 2002/02/15 20:45:31 nordin Exp $ */ +/* $OpenBSD: if_bge.c,v 1.7 2002/03/12 09:51:20 kjc Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2001 @@ -1613,7 +1613,8 @@ bge_attach(parent, self, aux) ifp->if_watchdog = bge_watchdog; ifp->if_baudrate = 1000000000; ifp->if_mtu = ETHERMTU; - ifp->if_snd.ifq_maxlen = BGE_TX_RING_CNT - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, BGE_TX_RING_CNT - 1); + IFQ_SET_READY(&ifp->if_snd); DPRINTFN(5, ("bcopy\n")); bcopy(sc->bge_dev.dv_xname, ifp->if_xname, IFNAMSIZ); @@ -1978,7 +1979,7 @@ bge_intr(xsc) /* Re-enable interrupts. */ CSR_WRITE_4(sc, BGE_MBX_IRQ0_LO, 0); - if (ifp->if_flags & IFF_RUNNING && ifp->if_snd.ifq_head != NULL) + if (ifp->if_flags & IFF_RUNNING && !IFQ_IS_EMPTY(&ifp->if_snd)) bge_start(ifp); return (1); @@ -2010,7 +2011,7 @@ bge_tick(xsc) sc->bge_link++; CSR_WRITE_4(sc, BGE_MAC_STS, 0xFFFFFFFF); printf("%s: gigabit link up\n", sc->bge_dev.dv_xname); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) bge_start(ifp); } splx(s); @@ -2025,7 +2026,7 @@ bge_tick(xsc) if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_TX || IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_SX) printf("%s: gigabit link up\n", sc->bge_dev.dv_xname); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) bge_start(ifp); } @@ -2169,6 +2170,7 @@ bge_start(ifp) struct bge_softc *sc; struct mbuf *m_head = NULL; u_int32_t prodidx = 0; + int pkts = 0; sc = ifp->if_softc; @@ -2178,7 +2180,7 @@ bge_start(ifp) prodidx = CSR_READ_4(sc, BGE_MBX_TX_HOST_PROD0_LO); while(sc->bge_cdata.bge_tx_chain[prodidx] == NULL) { - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_POLL(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -2195,7 +2197,6 @@ bge_start(ifp) m_head->m_pkthdr.csum_flags & (CSUM_DELAY_DATA)) { if ((BGE_TX_RING_CNT - sc->bge_txcnt) < m_head->m_pkthdr.csum_data + 16) { - IF_PREPEND(&ifp->if_snd, m_head); ifp->if_flags |= IFF_OACTIVE; break; } @@ -2208,11 +2209,14 @@ bge_start(ifp) * for the NIC to drain the ring. */ if (bge_encap(sc, m_head, &prodidx)) { - IF_PREPEND(&ifp->if_snd, m_head); ifp->if_flags |= IFF_OACTIVE; break; } + /* now we are committed to transmit the packet */ + IFQ_DEQUEUE(&ifp->if_snd, m_head); + pkts++; + /* * If there's a BPF listener, bounce a copy of this frame * to him. @@ -2220,6 +2224,8 @@ bge_start(ifp) if (ifp->if_bpf) bpf_mtap(ifp->if_bpf, m_head); } + if (pkts == 0) + return; /* Transmit */ CSR_WRITE_4(sc, BGE_MBX_TX_HOST_PROD0_LO, prodidx); diff --git a/sys/dev/pci/if_lge.c b/sys/dev/pci/if_lge.c index 1ab0c361833..44e02520d77 100644 --- a/sys/dev/pci/if_lge.c +++ b/sys/dev/pci/if_lge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_lge.c,v 1.7 2002/02/15 20:45:31 nordin Exp $ */ +/* $OpenBSD: if_lge.c,v 1.8 2002/03/12 09:51:20 kjc Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2000, 2001 @@ -648,7 +648,8 @@ void lge_attach(parent, self, aux) ifp->if_start = lge_start; ifp->if_watchdog = lge_watchdog; ifp->if_baudrate = 1000000000; - ifp->if_snd.ifq_maxlen = LGE_TX_LIST_CNT - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, LGE_TX_LIST_CNT - 1); + IFQ_SET_READY(&ifp->if_snd); DPRINTFN(5, ("bcopy\n")); bcopy(sc->sc_dv.dv_xname, ifp->if_xname, IFNAMSIZ); @@ -1149,7 +1150,7 @@ void lge_tick(xsc) IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_TX) printf("%s: gigabit link up\n", sc->sc_dv.dv_xname); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) lge_start(ifp); } } @@ -1210,7 +1211,7 @@ int lge_intr(arg) /* Re-enable interrupts. */ CSR_WRITE_4(sc, LGE_IMR, LGE_IMR_SETRST_CTL0|LGE_IMR_INTR_ENB); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) lge_start(ifp); return claimed; @@ -1276,6 +1277,7 @@ void lge_start(ifp) struct lge_softc *sc; struct mbuf *m_head = NULL; u_int32_t idx; + int pkts = 0; sc = ifp->if_softc; @@ -1291,16 +1293,19 @@ void lge_start(ifp) if (CSR_READ_1(sc, LGE_TXCMDFREE_8BIT) == 0) break; - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_POLL(&ifp->if_snd, m_head); if (m_head == NULL) break; if (lge_encap(sc, m_head, &idx)) { - IF_PREPEND(&ifp->if_snd, m_head); ifp->if_flags |= IFF_OACTIVE; break; } + /* now we are committed to transmit the packet */ + IFQ_DEQUEUE(&ifp->if_snd, m_head); + pkts++; + #if NBPFILTER > 0 /* * If there's a BPF listener, bounce a copy of this frame @@ -1310,6 +1315,8 @@ void lge_start(ifp) bpf_mtap(ifp->if_bpf, m_head); #endif } + if (pkts == 0) + return; sc->lge_cdata.lge_tx_prod = idx; @@ -1590,7 +1597,7 @@ void lge_watchdog(ifp) ifp->if_flags &= ~IFF_RUNNING; lge_init(sc); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) lge_start(ifp); return; diff --git a/sys/dev/pci/if_nge.c b/sys/dev/pci/if_nge.c index df73635c912..68ca63f24ff 100644 --- a/sys/dev/pci/if_nge.c +++ b/sys/dev/pci/if_nge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nge.c,v 1.16 2002/02/15 20:45:31 nordin Exp $ */ +/* $OpenBSD: if_nge.c,v 1.17 2002/03/12 09:51:20 kjc Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2000, 2001 @@ -927,7 +927,8 @@ void nge_attach(parent, self, aux) ifp->if_start = nge_start; ifp->if_watchdog = nge_watchdog; ifp->if_baudrate = 1000000000; - ifp->if_snd.ifq_maxlen = NGE_TX_LIST_CNT - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, NGE_TX_LIST_CNT - 1); + IFQ_SET_READY(&ifp->if_snd); ifp->if_capabilities = IFCAP_CSUM_IPv4 | IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4; #if NVLAN > 0 @@ -1439,7 +1440,7 @@ void nge_tick(xsc) if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_TX) DPRINTFN("%s: gigabit link up\n", sc->sc_dv.dv_xname); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) nge_start(ifp); } else timeout_add(&sc->nge_timeout, hz); @@ -1507,7 +1508,7 @@ int nge_intr(arg) /* Re-enable interrupts. */ CSR_WRITE_4(sc, NGE_IER, 1); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) nge_start(ifp); return claimed; @@ -1607,6 +1608,7 @@ void nge_start(ifp) struct nge_softc *sc; struct mbuf *m_head = NULL; u_int32_t idx; + int pkts = 0; sc = ifp->if_softc; @@ -1619,16 +1621,19 @@ void nge_start(ifp) return; while(sc->nge_ldata->nge_tx_list[idx].nge_mbuf == NULL) { - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_POLL(&ifp->if_snd, m_head); if (m_head == NULL) break; if (nge_encap(sc, m_head, &idx)) { - IF_PREPEND(&ifp->if_snd, m_head); ifp->if_flags |= IFF_OACTIVE; break; } + /* now we are committed to transmit the packet */ + IFQ_DEQUEUE(&ifp->if_snd, m_head); + pkts++; + #if NBPFILTER > 0 /* * If there's a BPF listener, bounce a copy of this frame @@ -1638,6 +1643,8 @@ void nge_start(ifp) bpf_mtap(ifp->if_bpf, m_head); #endif } + if (pkts == 0) + return; /* Transmit */ sc->nge_cdata.nge_tx_prod = idx; @@ -1974,7 +1981,7 @@ void nge_watchdog(ifp) ifp->if_flags &= ~IFF_RUNNING; nge_init(sc); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) nge_start(ifp); } diff --git a/sys/dev/pci/if_sk.c b/sys/dev/pci/if_sk.c index 8f8b3748296..f5fede691a0 100644 --- a/sys/dev/pci/if_sk.c +++ b/sys/dev/pci/if_sk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sk.c,v 1.21 2002/02/15 20:45:31 nordin Exp $ */ +/* $OpenBSD: if_sk.c,v 1.22 2002/03/12 09:51:20 kjc Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -957,7 +957,8 @@ sk_attach(parent, self, aux) ifp->if_start = sk_start; ifp->if_watchdog = sk_watchdog; ifp->if_baudrate = 1000000000; - ifp->if_snd.ifq_maxlen = SK_TX_RING_CNT - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, SK_TX_RING_CNT - 1); + IFQ_SET_READY(&ifp->if_snd); bcopy(sc_if->sk_dev.dv_xname, ifp->if_xname, IFNAMSIZ); /* @@ -1249,6 +1250,7 @@ void sk_start(ifp) struct sk_if_softc *sc_if; struct mbuf *m_head = NULL; u_int32_t idx; + int pkts = 0; sc_if = ifp->if_softc; sc = sc_if->sk_softc; @@ -1256,7 +1258,7 @@ void sk_start(ifp) idx = sc_if->sk_cdata.sk_tx_prod; while(sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf == NULL) { - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_POLL(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -1266,11 +1268,14 @@ void sk_start(ifp) * for the NIC to drain the ring. */ if (sk_encap(sc_if, m_head, &idx)) { - IF_PREPEND(&ifp->if_snd, m_head); ifp->if_flags |= IFF_OACTIVE; break; } + /* now we are committed to transmit the packet */ + IFQ_DEQUEUE(&ifp->if_snd, m_head); + pkts++; + /* * If there's a BPF listener, bounce a copy of this frame * to him. @@ -1280,6 +1285,8 @@ void sk_start(ifp) bpf_mtap(ifp->if_bpf, m_head); #endif } + if (pkts == 0) + return; /* Transmit */ sc_if->sk_cdata.sk_tx_prod = idx; @@ -1630,9 +1637,9 @@ int sk_intr(xsc) CSR_WRITE_4(sc, SK_IMR, sc->sk_intrmask); - if (ifp0 != NULL && ifp0->if_snd.ifq_head != NULL) + if (ifp0 != NULL && !IFQ_IS_EMPTY(&ifp0->if_snd)) sk_start(ifp0); - if (ifp1 != NULL && ifp1->if_snd.ifq_head != NULL) + if (ifp1 != NULL && !IFQ_IS_EMPTY(&ifp1->if_snd)) sk_start(ifp1); return (claimed); diff --git a/sys/dev/pci/if_txp.c b/sys/dev/pci/if_txp.c index fb46490d88f..64938b4300b 100644 --- a/sys/dev/pci/if_txp.c +++ b/sys/dev/pci/if_txp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_txp.c,v 1.61 2002/02/15 20:45:31 nordin Exp $ */ +/* $OpenBSD: if_txp.c,v 1.62 2002/03/12 09:51:20 kjc Exp $ */ /* * Copyright (c) 2001 @@ -1344,9 +1344,10 @@ txp_start(ifp) cnt = r->r_cnt; while (1) { - IFQ_DEQUEUE(&ifp->if_snd, m); + IFQ_POLL(&ifp->if_snd, m); if (m == NULL) break; + mnew = NULL; firstprod = prod; firstcnt = cnt; @@ -1368,6 +1369,7 @@ txp_start(ifp) } m_copydata(m, 0, m->m_pkthdr.len, mtod(mnew, caddr_t)); mnew->m_pkthdr.len = mnew->m_len = m->m_pkthdr.len; + IFQ_DEQUEUE(&ifp->if_snd, m); m_freem(m); m = mnew; if (bus_dmamap_load_mbuf(sc->sc_dmat, sd->sd_map, m, @@ -1451,6 +1453,13 @@ txp_start(ifp) } + /* + * if mnew isn't NULL, we already dequeued and copied + * the packet. + */ + if (mnew == NULL) + IFQ_DEQUEUE(&ifp->if_snd, m); + ifp->if_timer = 5; #if NBPFILTER > 0 @@ -1494,7 +1503,6 @@ oactive1: ifp->if_flags |= IFF_OACTIVE; r->r_prod = firstprod; r->r_cnt = firstcnt; - IF_PREPEND(&ifp->if_snd, m); } /* diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c index 8ddfcdd8c9c..e6781c06346 100644 --- a/sys/dev/pci/if_vr.c +++ b/sys/dev/pci/if_vr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vr.c,v 1.22 2002/02/15 20:45:31 nordin Exp $ */ +/* $OpenBSD: if_vr.c,v 1.23 2002/03/12 09:51:20 kjc Exp $ */ /* * Copyright (c) 1997, 1998 @@ -1290,7 +1290,7 @@ vr_start(ifp) start_tx = sc->vr_cdata.vr_tx_free; while(sc->vr_cdata.vr_tx_free->vr_mbuf == NULL) { - IFQ_DEQUEUE(&ifp->if_snd, m_head); + IFQ_POLL(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -1300,7 +1300,6 @@ vr_start(ifp) /* Pack the data into the descriptor. */ if (vr_encap(sc, cur_tx, m_head)) { - IF_PREPEND(&ifp->if_snd, m_head); ifp->if_flags |= IFF_OACTIVE; cur_tx = NULL; break; @@ -1309,6 +1308,9 @@ vr_start(ifp) if (cur_tx != start_tx) VR_TXOWN(cur_tx) = VR_TXSTAT_OWN; + /* now we are committed to transmit the packet */ + IFQ_DEQUEUE(&ifp->if_snd, m_head); + #if NBPFILTER > 0 /* * If there's a BPF listener, bounce a copy of this frame diff --git a/sys/dev/pci/if_wx.c b/sys/dev/pci/if_wx.c index 1126ca250e0..5697ede123b 100644 --- a/sys/dev/pci/if_wx.c +++ b/sys/dev/pci/if_wx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wx.c,v 1.18 2001/10/24 18:25:55 mjacob Exp $ */ +/* $OpenBSD: if_wx.c,v 1.19 2002/03/12 09:51:20 kjc Exp $ */ /* * Principal Author: Matthew Jacob <mjacob@feral.com> * Copyright (c) 1999, 2001 by Traakan Software @@ -276,6 +276,7 @@ wx_attach(struct device *parent, struct device *self, void *aux) ifp->if_ioctl = wx_ioctl; ifp->if_start = wx_start; ifp->if_watchdog = wx_txwatchdog; + IFQ_SET_READY(&ifp->if_snd); /* * Attach the interface. @@ -740,7 +741,7 @@ wx_start(struct ifnet *ifp) int gctried = 0; struct mbuf *m, *mb_head; - IF_DEQUEUE(&ifp->if_snd, mb_head); + IFQ_DEQUEUE(&ifp->if_snd, mb_head); if (mb_head == NULL) { break; } 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); |