From c0673e7470e78851e90fed12a36fc994cd4a9596 Mon Sep 17 00:00:00 2001 From: Kenjiro Cho Date: Tue, 12 Mar 2002 09:51:21 +0000 Subject: sync with KAME ALTQify more drivers. ok millert@ --- sys/dev/pci/if_bge.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'sys/dev/pci/if_bge.c') 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); -- cgit v1.2.3