diff options
42 files changed, 372 insertions, 210 deletions
diff --git a/sys/dev/ic/am7990.c b/sys/dev/ic/am7990.c index 9bd2a7ba1e4..85a4a579819 100644 --- a/sys/dev/ic/am7990.c +++ b/sys/dev/ic/am7990.c @@ -1,4 +1,4 @@ -/* $OpenBSD: am7990.c,v 1.25 2001/06/24 22:36:57 miod Exp $ */ +/* $OpenBSD: am7990.c,v 1.26 2001/06/27 06:34:39 kjc Exp $ */ /* $NetBSD: am7990.c,v 1.22 1996/10/13 01:37:19 christos Exp $ */ /*- @@ -148,6 +148,7 @@ am7990_config(sc) #ifdef LANCE_REVC_BUG ifp->if_flags &= ~IFF_MULTICAST; #endif + IFQ_SET_READY(&ifp->if_snd); /* Attach the interface. */ if_attach(ifp); @@ -779,7 +780,7 @@ am7990_start(ifp) sc->sc_no_td, sc->sc_last_td); } - IF_DEQUEUE(&ifp->if_snd, m); + IFQ_DEQUEUE(&ifp->if_snd, m); if (m == 0) break; diff --git a/sys/dev/ic/awi.c b/sys/dev/ic/awi.c index 1ae8d5d923f..5b5a121c805 100644 --- a/sys/dev/ic/awi.c +++ b/sys/dev/ic/awi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: awi.c,v 1.8 2001/06/27 04:09:14 angelos Exp $ */ +/* $OpenBSD: awi.c,v 1.9 2001/06/27 06:34:40 kjc Exp $ */ /* $NetBSD: awi.c,v 1.26 2000/07/21 04:48:55 onoe Exp $ */ /*- @@ -318,10 +318,11 @@ awi_attach(sc) #endif #ifdef __FreeBSD__ ifp->if_output = ether_output; - ifp->if_snd.ifq_maxlen = ifqmaxlen; + IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); memcpy(sc->sc_ec.ac_enaddr, sc->sc_mib_addr.aMAC_Address, ETHER_ADDR_LEN); #endif + IFQ_SET_READY(&ifp->if_snd); printf("%s: IEEE802.11 %s %dMbps (firmware %s)\n", sc->sc_dev.dv_xname, @@ -899,12 +900,7 @@ awi_stop(sc) break; m_freem(m); } - for (;;) { - IF_DEQUEUE(&ifp->if_snd, m); - if (m == NULL) - break; - m_freem(m); - } + IFQ_PURGE(&ifp->if_snd); while ((bp = TAILQ_FIRST(&sc->sc_scan)) != NULL) { TAILQ_REMOVE(&sc->sc_scan, bp, list); free(bp, M_DEVBUF); @@ -983,7 +979,7 @@ awi_start(ifp) } else { if (!(ifp->if_flags & IFF_RUNNING)) break; - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_POLL(&ifp->if_snd, m0); if (m0 == NULL) break; len = m0->m_pkthdr.len + sizeof(struct ieee80211_frame); @@ -994,10 +990,10 @@ awi_start(ifp) len += IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN; if (awi_next_txd(sc, len, &frame, &ntxd)) { - IF_PREPEND(&ifp->if_snd, m0); ifp->if_flags |= IFF_OACTIVE; break; } + IFQ_DEQUEUE(&ifp->if_snd, m0); AWI_BPF_MTAP(sc, m0, AWI_BPF_NORM); m0 = awi_fix_txhdr(sc, m0); if (sc->sc_wep_algo != NULL && m0 != NULL) diff --git a/sys/dev/ic/dc.c b/sys/dev/ic/dc.c index 56df1a1f368..c54bb50100b 100644 --- a/sys/dev/ic/dc.c +++ b/sys/dev/ic/dc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dc.c,v 1.28 2001/06/23 23:17:35 fgsch Exp $ */ +/* $OpenBSD: dc.c,v 1.29 2001/06/27 06:34:40 kjc Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -1650,7 +1650,8 @@ void dc_attach(sc) ifp->if_start = dc_start; ifp->if_watchdog = dc_watchdog; ifp->if_baudrate = 10000000; - ifp->if_snd.ifq_maxlen = DC_TX_LIST_CNT - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, DC_TX_LIST_CNT - 1); + IFQ_SET_READY(&ifp->if_snd); bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); /* Do MII setup. If this is a 21143, check for a PHY on the @@ -2278,7 +2279,7 @@ void dc_tick(xsc) if (mii->mii_media_status & IFM_ACTIVE && IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { sc->dc_link++; - if (ifp->if_snd.ifq_head != NULL) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) dc_start(ifp); } } @@ -2388,7 +2389,7 @@ int dc_intr(arg) /* Re-enable interrupts. */ CSR_WRITE_4(sc, DC_IMR, DC_INTRS); - if (ifp->if_snd.ifq_head != NULL) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) dc_start(ifp); return (claimed); @@ -2452,6 +2453,11 @@ int dc_encap(sc, m_head, txidx) sc->dc_ldata->dc_tx_list[cur].dc_ctl |= DC_TXCTL_FINT; if (sc->dc_flags & DC_TX_USE_TX_INTR && sc->dc_cdata.dc_tx_cnt > 64) sc->dc_ldata->dc_tx_list[cur].dc_ctl |= DC_TXCTL_FINT; +#ifdef ALTQ + else if ((sc->dc_flags & DC_TX_USE_TX_INTR) && + TBR_IS_ENABLED(&sc->arpcom.ac_if.if_snd)) + sc->dc_ldata->dc_tx_list[cur].dc_ctl |= DC_TXCTL_FINT; +#endif sc->dc_ldata->dc_tx_list[*txidx].dc_status = DC_TXSTAT_OWN; *txidx = frag; @@ -2516,24 +2522,34 @@ void dc_start(ifp) idx = sc->dc_cdata.dc_tx_prod; while(sc->dc_cdata.dc_tx_chain[idx] == NULL) { - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_POLL(&ifp->if_snd, m_head); if (m_head == NULL) break; if (sc->dc_flags & DC_TX_COALESCE) { +#ifdef ALTQ + /* note: dc_coal breaks the poll-and-dequeue rule. + * if dc_coal fails, we lose the packet. + */ +#endif + IFQ_DEQUEUE(&ifp->if_snd, m_head); if (dc_coal(sc, &m_head)) { - IF_PREPEND(&ifp->if_snd, m_head); ifp->if_flags |= IFF_OACTIVE; break; } } if (dc_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 */ + if (sc->dc_flags & DC_TX_COALESCE) { + /* if mbuf is coalesced, it is already dequeued */ + } else + IFQ_DEQUEUE(&ifp->if_snd, m_head); + /* * If there's a BPF listener, bounce a copy of this frame * to him. @@ -2547,6 +2563,8 @@ void dc_start(ifp) break; } } + if (idx == sc->dc_cdata.dc_tx_prod) + return; /* Transmit */ sc->dc_cdata.dc_tx_prod = idx; @@ -2888,7 +2906,7 @@ void dc_watchdog(ifp) dc_reset(sc); dc_init(sc); - if (ifp->if_snd.ifq_head != NULL) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) dc_start(ifp); return; diff --git a/sys/dev/ic/dp8390.c b/sys/dev/ic/dp8390.c index f8e79d7bb7e..24e3feaff70 100644 --- a/sys/dev/ic/dp8390.c +++ b/sys/dev/ic/dp8390.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dp8390.c,v 1.14 2001/06/23 22:57:13 fgsch Exp $ */ +/* $OpenBSD: dp8390.c,v 1.15 2001/06/27 06:34:41 kjc Exp $ */ /* $NetBSD: dp8390.c,v 1.13 1998/07/05 06:49:11 jonathan Exp $ */ /* @@ -130,7 +130,7 @@ dp8390_config(sc) ifp->if_watchdog = dp8390_watchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); /* Print additional info when attached. */ printf("%s: address %s\n", sc->sc_dev.dv_xname, @@ -178,6 +178,7 @@ dp8390_mediastatus(ifp, ifmr) ifmr->ifm_status = 0; return; } + IFQ_SET_READY(&ifp->if_snd); if (sc->sc_mediastatus) (*sc->sc_mediastatus)(sc, ifmr); @@ -445,7 +446,7 @@ outloop: ifp->if_flags |= IFF_OACTIVE; return; } - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 == 0) return; diff --git a/sys/dev/ic/elink3.c b/sys/dev/ic/elink3.c index 46983427ec6..367d4c2a560 100644 --- a/sys/dev/ic/elink3.c +++ b/sys/dev/ic/elink3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elink3.c,v 1.51 2001/06/24 20:30:24 fgsch Exp $ */ +/* $OpenBSD: elink3.c,v 1.52 2001/06/27 06:34:41 kjc Exp $ */ /* $NetBSD: elink3.c,v 1.32 1997/05/14 00:22:00 thorpej Exp $ */ /* @@ -353,7 +353,8 @@ epconfig(sc, chipset, enaddr) ifp->if_watchdog = epwatchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); + IFQ_SET_READY(&ifp->if_snd); if_attach(ifp); ether_ifattach(ifp); @@ -984,7 +985,7 @@ epstart(ifp) startagain: /* Sneak a peek at the next packet */ - m0 = ifp->if_snd.ifq_head; + IFQ_POLL(&ifp->if_snd, m0); if (m0 == 0) return; @@ -1003,7 +1004,7 @@ startagain: if (len + pad > ETHER_MAX_LEN) { /* packet is obviously too large: toss it */ ++ifp->if_oerrors; - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); m_freem(m0); goto readcheck; } @@ -1019,8 +1020,7 @@ startagain: bus_space_write_2(iot, ioh, EP_COMMAND, SET_TX_AVAIL_THRESH | EP_THRESH_DISABLE); } - - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 == 0) /* not really needed */ return; diff --git a/sys/dev/ic/fxp.c b/sys/dev/ic/fxp.c index 098228bc1bb..cbbf43adeeb 100644 --- a/sys/dev/ic/fxp.c +++ b/sys/dev/ic/fxp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fxp.c,v 1.19 2001/06/23 23:17:35 fgsch Exp $ */ +/* $OpenBSD: fxp.c,v 1.20 2001/06/27 06:34:41 kjc Exp $ */ /* $NetBSD: if_fxp.c,v 1.2 1997/06/05 02:01:55 thorpej Exp $ */ /* @@ -363,6 +363,7 @@ fxp_attach_common(sc, enaddr, intrstr) ifp->if_ioctl = fxp_ioctl; ifp->if_start = fxp_start; ifp->if_watchdog = fxp_watchdog; + IFQ_SET_READY(&ifp->if_snd); printf(": %s, address %s\n", intrstr, ether_sprintf(sc->arpcom.ac_enaddr)); @@ -401,7 +402,7 @@ fxp_attach_common(sc, enaddr, intrstr) * Let the system queue as many packets as we have available * TX descriptors. */ - ifp->if_snd.ifq_maxlen = FXP_NTXCB - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, FXP_NTXCB - 1); ether_ifattach(ifp); /* @@ -630,14 +631,16 @@ fxp_start(ifp) * NOTE: One TxCB is reserved to guarantee that fxp_mc_setup() can add * a NOP command when needed. */ - while (ifp->if_snd.ifq_head != NULL && sc->tx_queued < FXP_NTXCB - 1) { + while (IFQ_IS_EMPTY(&ifp->if_snd) == 0 && sc->tx_queued < FXP_NTXCB - 1) { struct mbuf *m, *mb_head; int segment; /* * Grab a packet to transmit. */ - IF_DEQUEUE(&ifp->if_snd, mb_head); + IFQ_DEQUEUE(&ifp->if_snd, mb_head); + if (mb_head == NULL) + break; /* * Get pointer to next available tx desc. @@ -736,6 +739,11 @@ tbdinit: * going again if suspended. */ if (txp != NULL) { +#ifdef ALTQ + /* if tb regulator is used, we need tx complete interrupt */ + if (TBR_IS_ENABLED(&ifp->if_snd)) + txp->cb_command |= FXP_CB_COMMAND_I; +#endif fxp_scb_wait(sc); CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_RESUME); } @@ -803,7 +811,7 @@ fxp_intr(arg) /* * Try to start more packets transmitting. */ - if (ifp->if_snd.ifq_head != NULL) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) fxp_start(ifp); } /* diff --git a/sys/dev/ic/i82596.c b/sys/dev/ic/i82596.c index 52f52982b5b..9bd7b984aa8 100644 --- a/sys/dev/ic/i82596.c +++ b/sys/dev/ic/i82596.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i82596.c,v 1.5 2001/03/23 00:16:49 mickey Exp $ */ +/* $OpenBSD: i82596.c,v 1.6 2001/06/27 06:34:42 kjc Exp $ */ /* $NetBSD: i82586.c,v 1.18 1998/08/15 04:42:42 mycroft Exp $ */ /*- @@ -329,6 +329,7 @@ i82596_attach(sc, name, etheraddr, media, nmedia, defmedia) IFF_DEBUG | #endif IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; + IFQ_SET_READY(&ifp->if_snd); /* Initialize media goo. */ ifmedia_init(&sc->sc_media, 0, i82596_mediachange, i82596_mediastatus); @@ -1260,7 +1261,7 @@ i82596_start(ifp) break; } - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 == 0) break; diff --git a/sys/dev/ic/if_wi.c b/sys/dev/ic/if_wi.c index cc441bd687a..cfdb0f48eb8 100644 --- a/sys/dev/ic/if_wi.c +++ b/sys/dev/ic/if_wi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi.c,v 1.14 2001/06/25 19:36:13 drahn Exp $ */ +/* $OpenBSD: if_wi.c,v 1.15 2001/06/27 06:34:42 kjc Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -120,7 +120,7 @@ u_int32_t widebug = WIDEBUG; #if !defined(lint) && !defined(__OpenBSD__) static const char rcsid[] = - "$OpenBSD: if_wi.c,v 1.14 2001/06/25 19:36:13 drahn Exp $"; + "$OpenBSD: if_wi.c,v 1.15 2001/06/27 06:34:42 kjc Exp $"; #endif /* lint */ #ifdef foo @@ -197,7 +197,8 @@ wi_attach(sc, print_cis) ifp->if_start = wi_start; ifp->if_watchdog = wi_watchdog; ifp->if_baudrate = 10000000; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); + IFQ_SET_READY(&ifp->if_snd); bzero(sc->wi_node_name, sizeof(sc->wi_node_name)); bcopy(WI_DEFAULT_NODENAME, sc->wi_node_name, @@ -326,7 +327,7 @@ wi_intr(vsc) /* Re-enable interrupts. */ CSR_WRITE_2(sc, WI_INT_EN, WI_INTRS); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) wi_start(ifp); return (1); @@ -1340,7 +1341,7 @@ wi_start(ifp) if (ifp->if_flags & IFF_OACTIVE) return; - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 == NULL) return; diff --git a/sys/dev/ic/midway.c b/sys/dev/ic/midway.c index 4da7aa37156..107350bc320 100644 --- a/sys/dev/ic/midway.c +++ b/sys/dev/ic/midway.c @@ -1,4 +1,4 @@ -/* $OpenBSD: midway.c,v 1.27 2000/10/09 22:39:24 itojun Exp $ */ +/* $OpenBSD: midway.c,v 1.28 2001/06/27 06:34:42 kjc Exp $ */ /* (sync'd to midway.c 1.68) */ /* @@ -742,6 +742,7 @@ done_probe: ifp->if_ioctl = en_ioctl; ifp->if_output = atm_output; ifp->if_start = en_start; + IFQ_SET_READY(&ifp->if_snd); /* * init softc @@ -1481,7 +1482,6 @@ struct ifnet *ifp; #else struct en_softc *sc = (struct en_softc *) ifp->if_softc; #endif - struct ifqueue *ifq = &ifp->if_snd; /* if INPUT QUEUE */ struct mbuf *m, *lastm, *prev; struct atm_pseudohdr *ap, *new_ap; int txchan, mlen, got, need, toadd, cellcnt, first; @@ -1498,7 +1498,7 @@ struct ifnet *ifp; while (1) { - IF_DEQUEUE(ifq, m); + IFQ_DEQUEUE(&ifp->if_snd, m); if (m == NULL) return; /* EMPTY: >>> exit here <<< */ diff --git a/sys/dev/ic/pdq_ifsubr.c b/sys/dev/ic/pdq_ifsubr.c index 60b7b6b99dd..b2dabf6aa1e 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.6 1996/10/31 01:01:37 niklas Exp $ */ +/* $OpenBSD: pdq_ifsubr.c,v 1.7 2001/06/27 06:34:42 kjc Exp $ */ /* $NetBSD: pdq_ifsubr.c,v 1.5 1996/05/20 00:26:21 thorpej Exp $ */ /*- @@ -148,7 +148,7 @@ pdq_ifwatchdog( ifp->if_timer = 0; for (;;) { struct mbuf *m; - IF_DEQUEUE(&ifp->if_snd, m); + IFQ_DEQUEUE(&ifp->if_snd, m); if (m == NULL) return; m_freem(m); @@ -160,7 +160,6 @@ pdq_ifstart( struct ifnet *ifp) { pdq_softc_t *sc = (pdq_softc_t *) ((caddr_t) ifp - offsetof(pdq_softc_t, sc_ac.ac_if)); - struct ifqueue *ifq = &ifp->if_snd; struct mbuf *m; int tx = 0; @@ -175,15 +174,16 @@ pdq_ifstart( return; } for (;; tx = 1) { - IF_DEQUEUE(ifq, m); + IFQ_POLL(&ifp->if_snd, m); if (m == NULL) break; if (pdq_queue_transmit_data(sc->sc_pdq, m) == PDQ_FALSE) { ifp->if_flags |= IFF_OACTIVE; - IF_PREPEND(ifq, m); break; } + + IFQ_DEQUEUE(&ifp->if_snd, m); } if (tx) PDQ_DO_TYPE2_PRODUCER(sc->sc_pdq); @@ -221,7 +221,7 @@ pdq_os_restart_transmitter( { pdq_softc_t *sc = (pdq_softc_t *) pdq->pdq_os_ctx; sc->sc_if.if_flags &= ~IFF_OACTIVE; - if (sc->sc_if.if_snd.ifq_head != NULL) { + if (!IFQ_IS_EMPTY(&sc->sc_if.if_snd)) { sc->sc_if.if_timer = PDQ_OS_TX_TIMEOUT; pdq_ifstart(&sc->sc_if); } else { @@ -374,6 +374,9 @@ 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/rln.c b/sys/dev/ic/rln.c index db433db7b76..0a541599fc1 100644 --- a/sys/dev/ic/rln.c +++ b/sys/dev/ic/rln.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rln.c,v 1.11 2001/06/24 20:59:40 fgsch Exp $ */ +/* $OpenBSD: rln.c,v 1.12 2001/06/27 06:34:43 kjc Exp $ */ /* * David Leonard <d@openbsd.org>, 1999. Public Domain. * @@ -142,7 +142,8 @@ rlnconfig(sc) ifp->if_ioctl = rlnioctl; ifp->if_watchdog = rlnwatchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); + IFQ_SET_READY(&ifp->if_snd); if_attach(ifp); ether_ifattach(ifp); } @@ -239,7 +240,7 @@ rlnstart(ifp) startagain: s = splimp(); - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); splx(s); if (m0 == NULL) { diff --git a/sys/dev/ic/rtl81x9.c b/sys/dev/ic/rtl81x9.c index 6fad174afd8..817985b8be6 100644 --- a/sys/dev/ic/rtl81x9.c +++ b/sys/dev/ic/rtl81x9.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtl81x9.c,v 1.4 2001/06/23 23:17:35 fgsch Exp $ */ +/* $OpenBSD: rtl81x9.c,v 1.5 2001/06/27 06:34:43 kjc Exp $ */ /* * Copyright (c) 1997, 1998 @@ -844,7 +844,7 @@ int rl_intr(arg) /* Re-enable interrupts. */ CSR_WRITE_2(sc, RL_IMR, RL_INTRS); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) rl_start(ifp); return (claimed); @@ -911,16 +911,18 @@ void rl_start(ifp) { struct rl_softc *sc; struct mbuf *m_head = NULL; + int pkts = 0; sc = ifp->if_softc; while(RL_CUR_TXMBUF(sc) == NULL) { - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; /* Pack the data into the descriptor. */ rl_encap(sc, m_head); + pkts++; #if NBPFILTER > 0 /* @@ -941,6 +943,8 @@ void rl_start(ifp) RL_INC(sc->rl_cdata.cur_tx); } + if (pkts == 0) + return; /* * We broke out of the loop because all our TX slots are @@ -1271,7 +1275,8 @@ rl_attach(sc) ifp->if_start = rl_start; ifp->if_watchdog = rl_watchdog; ifp->if_baudrate = 10000000; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); + IFQ_SET_READY(&ifp->if_snd); bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); diff --git a/sys/dev/ic/smc91cxx.c b/sys/dev/ic/smc91cxx.c index e8221cc8e3f..d3eddb40d56 100644 --- a/sys/dev/ic/smc91cxx.c +++ b/sys/dev/ic/smc91cxx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smc91cxx.c,v 1.11 2001/06/24 04:57:07 fgsch Exp $ */ +/* $OpenBSD: smc91cxx.c,v 1.12 2001/06/27 06:34:43 kjc Exp $ */ /* $NetBSD: smc91cxx.c,v 1.11 1998/08/08 23:51:41 mycroft Exp $ */ /*- @@ -248,7 +248,8 @@ smc91cxx_attach(sc, myea) ifp->if_watchdog = smc91cxx_watchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); + IFQ_SET_READY(&ifp->if_snd); /* Attach the interface. */ if_attach(ifp); @@ -480,7 +481,8 @@ smc91cxx_start(ifp) /* * Peek at the next packet. */ - if ((m = ifp->if_snd.ifq_head) == NULL) + IFQ_POLL(&ifp->if_snd, m); + if (m == NULL) return; /* @@ -499,7 +501,7 @@ smc91cxx_start(ifp) if ((len + pad) > (ETHER_MAX_LEN - ETHER_CRC_LEN)) { printf("%s: large packet discarded\n", sc->sc_dev.dv_xname); ifp->if_oerrors++; - IF_DEQUEUE(&ifp->if_snd, m); + IFQ_DEQUEUE(&ifp->if_snd, m); m_freem(m); goto readcheck; } @@ -576,7 +578,7 @@ smc91cxx_start(ifp) * Get the packet from the kernel. This will include the Ethernet * frame header, MAC address, etc. */ - IF_DEQUEUE(&ifp->if_snd, m); + IFQ_DEQUEUE(&ifp->if_snd, m); /* * Push the packet out to the card. diff --git a/sys/dev/ic/tropic.c b/sys/dev/ic/tropic.c index 32c7e72e0ab..2bd28140f2b 100644 --- a/sys/dev/ic/tropic.c +++ b/sys/dev/ic/tropic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tropic.c,v 1.1 1999/12/27 21:51:35 fgsch Exp $ */ +/* $OpenBSD: tropic.c,v 1.2 2001/06/27 06:34:43 kjc Exp $ */ /* $NetBSD: tropic.c,v 1.6 1999/12/17 08:26:31 fvdl Exp $ */ /* @@ -352,6 +352,9 @@ 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: @@ -736,7 +739,7 @@ next: return; /* if data in queue, copy mbuf chain to fast path buffers */ - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 == 0) return; @@ -802,9 +805,6 @@ next: #endif } - -#define IF_EMPTYQUEUE(queue) ((queue).ifq_head == 0) - /* * tr_intr - interrupt handler. Find the cause of the interrupt and * service it. @@ -1043,7 +1043,7 @@ tr_intr(arg) sc->sc_dev.dv_xname); ifp->if_flags &= ~IFF_RUNNING; ifp->if_flags &= ~IFF_UP; - if_qflush(&ifp->if_snd); + IFQ_PURGE(&ifp->if_snd); timeout(tr_reinit, sc ,hz*30); } else { @@ -1117,7 +1117,7 @@ tr_intr(arg) * XXX should this be done here ? */ /* if data on send queue */ - if (!IF_EMPTYQUEUE(ifp->if_snd)) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) tr_oldstart(ifp); break; @@ -1351,7 +1351,7 @@ struct tr_softc *sc; * XXX what's command here ? command = 0x0d (always ?) */ /* if data in queue, copy mbuf chain to DHB */ - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 != 0) { #if NBPFILTER > 0 if (ifp->if_bpf) diff --git a/sys/dev/ic/xl.c b/sys/dev/ic/xl.c index 6c9726b702b..84fea27e41b 100644 --- a/sys/dev/ic/xl.c +++ b/sys/dev/ic/xl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xl.c,v 1.24 2001/06/23 23:17:35 fgsch Exp $ */ +/* $OpenBSD: xl.c,v 1.25 2001/06/27 06:34:43 kjc Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -708,6 +708,7 @@ void xl_testpacket(sc) { struct mbuf *m; struct ifnet *ifp; + int error; ifp = &sc->arpcom.ac_if; @@ -725,7 +726,7 @@ void xl_testpacket(sc) mtod(m, unsigned char *)[15] = 0; mtod(m, unsigned char *)[16] = 0xE3; m->m_len = m->m_pkthdr.len = sizeof(struct ether_header) + 3; - IF_ENQUEUE(&ifp->if_snd, m); + IFQ_ENQUEUE(&ifp->if_snd, m, NULL, error); xl_start(ifp); return; @@ -1498,7 +1499,7 @@ int xl_intr(arg) } } - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) (*ifp->if_start)(ifp); return (claimed); @@ -1660,7 +1661,7 @@ void xl_start(ifp) start_tx = sc->xl_cdata.xl_tx_free; while(sc->xl_cdata.xl_tx_free != NULL) { - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -1816,7 +1817,7 @@ xl_start_90xB(ifp) break; } - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -1984,7 +1985,11 @@ void xl_init(xsc) /* * Program the multicast filter, if necessary. */ +#if 0 if (sc->xl_type == XL_TYPE_905B) +#else + if (0) /* xl_setmulti_hash() does not work right */ +#endif xl_setmulti_hash(sc); else xl_setmulti(sc); @@ -2269,7 +2274,11 @@ xl_ioctl(ifp, command, data) * Multicast list has changed; set the hardware * filter accordingly. */ +#if 0 if (sc->xl_type == XL_TYPE_905B) +#else + if (0) /* xl_setmulti_hash() does not work right */ +#endif xl_setmulti_hash(sc); else xl_setmulti(sc); @@ -2319,7 +2328,7 @@ void xl_watchdog(ifp) xl_reset(sc, 0); xl_init(sc); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) (*ifp->if_start)(ifp); return; @@ -2489,7 +2498,8 @@ xl_attach(sc) ifp->if_start = xl_start; ifp->if_watchdog = xl_watchdog; ifp->if_baudrate = 10000000; - ifp->if_snd.ifq_maxlen = XL_TX_LIST_CNT - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, XL_TX_LIST_CNT - 1); + IFQ_SET_READY(&ifp->if_snd); bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); XL_SEL_WIN(3); diff --git a/sys/dev/isa/if_ed.c b/sys/dev/isa/if_ed.c index 9a56c092f28..5b4d8d9b2f9 100644 --- a/sys/dev/isa/if_ed.c +++ b/sys/dev/isa/if_ed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ed.c,v 1.44 2001/06/25 04:44:27 fgsch Exp $ */ +/* $OpenBSD: if_ed.c,v 1.45 2001/06/27 06:34:44 kjc Exp $ */ /* $NetBSD: if_ed.c,v 1.105 1996/10/21 22:40:45 thorpej Exp $ */ /* @@ -230,7 +230,7 @@ ed_pcmcia_isa_attach(parent, match, aux, pc_link) /* clear ED_NOTPRESENT, set ED_REATTACH if needed */ sc->spec_flags=pc_link->flags&PCMCIA_REATTACH?ED_REATTACH:0; sc->type_str = dev->model; - sc->sc_arpcom.ac_if.if_snd.ifq_maxlen=ifqmaxlen; + IFQ_SET_MAXLEN(&sc->sc_arpcom.ac_if.if_snd, ifqmaxlen); sc->sc_ic = ia->ia_ic; return 1; } else @@ -499,6 +499,7 @@ ed_pci_attach(parent, self, aux) ifp->if_watchdog = edwatchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; + IFQ_SET_READY(&ifp->if_snd); /* Attach the interface. */ if ((sc->spec_flags & ED_REATTACH) == 0) @@ -1655,6 +1656,7 @@ edattach(parent, self, aux) ifp->if_watchdog = edwatchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; + IFQ_SET_READY(&ifp->if_snd); /* * Set default state for LINK0 flag (used to disable the tranceiver @@ -1992,7 +1994,7 @@ outloop: return; } - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 == 0) return; diff --git a/sys/dev/isa/if_ef_isapnp.c b/sys/dev/isa/if_ef_isapnp.c index cf9e28652c8..b0d3e74a82d 100644 --- a/sys/dev/isa/if_ef_isapnp.c +++ b/sys/dev/isa/if_ef_isapnp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ef_isapnp.c,v 1.12 2001/06/25 04:44:28 fgsch Exp $ */ +/* $OpenBSD: if_ef_isapnp.c,v 1.13 2001/06/27 06:34:45 kjc Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -214,6 +214,7 @@ ef_isapnp_attach(parent, self, aux) ifp->if_watchdog = efwatchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; + IFQ_SET_READY(&ifp->if_snd); sc->sc_mii.mii_ifp = ifp; sc->sc_mii.mii_readreg = ef_miibus_readreg; @@ -253,7 +254,7 @@ efstart(ifp) return; startagain: - m0 = ifp->if_snd.ifq_head; + IFQ_POLL(&ifp->if_snd, m0); if (m0 == NULL) return; @@ -264,7 +265,7 @@ startagain: if (len + pad > ETHER_MAX_LEN) { ifp->if_oerrors++; - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); m_freem(m0); goto startagain; } @@ -287,7 +288,7 @@ startagain: bpf_mtap(ifp->if_bpf, m0); #endif - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 == NULL) /* XXX not needed */ return; diff --git a/sys/dev/isa/if_eg.c b/sys/dev/isa/if_eg.c index e6784ec5e64..800575e9023 100644 --- a/sys/dev/isa/if_eg.c +++ b/sys/dev/isa/if_eg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_eg.c,v 1.20 2001/06/25 04:44:28 fgsch Exp $ */ +/* $OpenBSD: if_eg.c,v 1.21 2001/06/27 06:34:45 kjc Exp $ */ /* $NetBSD: if_eg.c,v 1.26 1996/05/12 23:52:27 mycroft Exp $ */ /* @@ -444,6 +444,7 @@ egattach(parent, self, aux) ifp->if_ioctl = egioctl; ifp->if_watchdog = egwatchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; + IFQ_SET_READY(&ifp->if_snd); /* Now we can attach the interface. */ if_attach(ifp); @@ -543,7 +544,7 @@ egstart(ifp) loop: /* Dequeue the next datagram. */ - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 == 0) return; diff --git a/sys/dev/isa/if_el.c b/sys/dev/isa/if_el.c index f49bd8bef2e..cc79f9c35c1 100644 --- a/sys/dev/isa/if_el.c +++ b/sys/dev/isa/if_el.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_el.c,v 1.15 2001/06/25 04:44:28 fgsch Exp $ */ +/* $OpenBSD: if_el.c,v 1.16 2001/06/27 06:34:45 kjc Exp $ */ /* $NetBSD: if_el.c,v 1.39 1996/05/12 23:52:32 mycroft Exp $ */ /* @@ -187,6 +187,7 @@ elattach(parent, self, aux) ifp->if_ioctl = elioctl; ifp->if_watchdog = elwatchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; + IFQ_SET_READY(&ifp->if_snd); /* Now we can attach the interface. */ dprintf(("Attaching interface...\n")); @@ -316,7 +317,7 @@ elstart(ifp) */ for (;;) { /* Dequeue the next datagram. */ - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); /* If there's nothing to send, return. */ if (m0 == 0) diff --git a/sys/dev/isa/if_ex.c b/sys/dev/isa/if_ex.c index 7b12438e32b..b8541856ae1 100644 --- a/sys/dev/isa/if_ex.c +++ b/sys/dev/isa/if_ex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ex.c,v 1.6 2001/02/20 19:39:40 mickey Exp $ */ +/* $OpenBSD: if_ex.c,v 1.7 2001/06/27 06:34:46 kjc Exp $ */ /* * Copyright (c) 1997, Donald A. Schmidt * Copyright (c) 1996, Javier Martín Rueda (jmrueda@diatel.upm.es) @@ -294,6 +294,7 @@ ex_attach(parent, self, aux) ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST; /* XXX not done yet. | IFF_MULTICAST */ + IFQ_SET_READY(&ifp->if_snd); /* * Attach the interface. @@ -425,8 +426,10 @@ ex_start(ifp) * Main loop: send outgoing packets to network card until there are no * more packets left, or the card cannot accept any more yet. */ - while (((opkt = ifp->if_snd.ifq_head) != NULL) && - !(ifp->if_flags & IFF_OACTIVE)) { + while (!(ifp->if_flags & IFF_OACTIVE)) { + IFQ_POLL(&ifp->if_snd, opkt); + if (opkt == NULL) + break; /* * Ensure there is enough free transmit buffer space for this @@ -449,7 +452,7 @@ ex_start(ifp) avail = -i; DODEBUG(Sent_Pkts, printf("i=%d, avail=%d\n", i, avail);); if (avail >= len + XMT_HEADER_LEN) { - IF_DEQUEUE(&ifp->if_snd, opkt); + IFQ_DEQUEUE(&ifp->if_snd, opkt); #ifdef EX_PSA_INTR /* @@ -631,7 +634,7 @@ exintr(arg) * be sent, attempt to send more packets to the network card. */ - if (send_pkts && (ifp->if_snd.ifq_head != NULL)) + if (send_pkts && IFQ_IS_EMPTY(&ifp->if_snd) == 0) ex_start(ifp); #ifdef EXDEBUG exintr_count--; diff --git a/sys/dev/isa/if_fe.c b/sys/dev/isa/if_fe.c index 95cf28caa77..688345e7d9e 100644 --- a/sys/dev/isa/if_fe.c +++ b/sys/dev/isa/if_fe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_fe.c,v 1.15 2001/06/25 04:44:28 fgsch Exp $ */ +/* $OpenBSD: if_fe.c,v 1.16 2001/06/27 06:34:46 kjc Exp $ */ /* * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 @@ -999,6 +999,7 @@ feattach(parent, self, aux) ifp->if_watchdog = fe_watchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; + IFQ_SET_READY(&ifp->if_snd); /* * Set maximum size of output queue, if it has not been set. @@ -1508,7 +1509,7 @@ fe_start(ifp) /* * Get the next mbuf chain for a packet to send. */ - IF_DEQUEUE(&ifp->if_snd, m); + IFQ_DEQUEUE(&ifp->if_snd, m); if (m == 0) { /* No more packets to send. */ goto indicate_inactive; diff --git a/sys/dev/isa/if_hp.c b/sys/dev/isa/if_hp.c index b4a01b473d7..b7374534d64 100644 --- a/sys/dev/isa/if_hp.c +++ b/sys/dev/isa/if_hp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_hp.c,v 1.7 2001/06/23 22:03:09 fgsch Exp $ */ +/* $OpenBSD: if_hp.c,v 1.8 2001/06/27 06:34:46 kjc Exp $ */ /* $NetBSD: if_hp.c,v 1.21 1995/12/24 02:31:31 mycroft Exp $ */ /* XXX THIS DRIVER IS BROKEN. IT WILL NOT EVEN COMPILE. */ @@ -410,6 +410,7 @@ hpattach(dvp) ifp->if_ioctl = hpioctl; ifp->if_reset = hpreset; ifp->if_watchdog = 0; + IFQ_SET_READY(&ifp->if_snd); if_attach(ifp); } /* @@ -519,7 +520,7 @@ hpstart(ifp) if ((ns->ns_if.if_flags & IFF_RUNNING) == 0) return; - IF_DEQUEUE(&ns->ns_if.if_snd, m); + IFQ_DEQUEUE(&ns->ns_if.if_snd, m); if (m == 0) return; diff --git a/sys/dev/isa/if_ie.c b/sys/dev/isa/if_ie.c index 53e8b77c80f..d96e8592f4f 100644 --- a/sys/dev/isa/if_ie.c +++ b/sys/dev/isa/if_ie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ie.c,v 1.21 2001/06/23 21:54:52 fgsch Exp $ */ +/* $OpenBSD: if_ie.c,v 1.22 2001/06/27 06:34:46 kjc Exp $ */ /* $NetBSD: if_ie.c,v 1.51 1996/05/12 23:52:48 mycroft Exp $ */ /*- @@ -790,6 +790,7 @@ ieattach(parent, self, aux) ifp->if_watchdog = iewatchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; + IFQ_SET_READY(&ifp->if_snd); /* Attach the interface. */ if_attach(ifp); @@ -1484,7 +1485,7 @@ iestart(ifp) break; } - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 == 0) break; diff --git a/sys/dev/isa/if_iy.c b/sys/dev/isa/if_iy.c index 8315a07113d..56aa82081f7 100644 --- a/sys/dev/isa/if_iy.c +++ b/sys/dev/isa/if_iy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iy.c,v 1.13 2001/06/25 04:44:28 fgsch Exp $ */ +/* $OpenBSD: if_iy.c,v 1.14 2001/06/27 06:34:47 kjc Exp $ */ /* $NetBSD: if_iy.c,v 1.4 1996/05/12 23:52:53 mycroft Exp $ */ /* #define IYDEBUG */ /* #define IYMEMDEBUG */ @@ -295,6 +295,7 @@ iyattach(parent, self, aux) ifp->if_ioctl = iyioctl; ifp->if_watchdog = iywatchdog; + IFQ_SET_READY(&ifp->if_snd); /* Attach the interface. */ if_attach(ifp); @@ -495,7 +496,10 @@ struct ifnet *ifp; sc = ifp->if_softc; iobase = sc->sc_iobase; - while ((m0 = ifp->if_snd.ifq_head) != NULL) { + while (1) { + IFQ_POLL(&ifp->if_snd, m0); + if (m0 == NULL) + break; #ifdef IYDEBUG printf("%s: trying to write another packet to the hardware\n", sc->sc_dev.dv_xname); @@ -518,7 +522,7 @@ struct ifnet *ifp; if (len + pad > ETHER_MAX_LEN) { /* packet is obviously too large: toss it */ ++ifp->if_oerrors; - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); m_freem(m0); continue; } @@ -550,7 +554,7 @@ struct ifnet *ifp; } /* we know it fits in the hardware now, so dequeue it */ - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); last = sc->tx_end; end = last + pad + len + I595_XMT_HDRLEN; diff --git a/sys/dev/pci/if_de.c b/sys/dev/pci/if_de.c index 272b2d13f3e..dc4cb29873e 100644 --- a/sys/dev/pci/if_de.c +++ b/sys/dev/pci/if_de.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_de.c,v 1.46 2001/06/12 15:40:31 niklas Exp $ */ +/* $OpenBSD: if_de.c,v 1.47 2001/06/27 06:34:47 kjc Exp $ */ /* $NetBSD: if_de.c,v 1.45 1997/06/09 00:34:18 thorpej Exp $ */ /*- @@ -4116,6 +4116,11 @@ tulip_txput( int segcnt, free; u_int32_t d_status; struct mbuf *m0; +#if 1 /* ALTQ */ + struct ifnet *ifp = &sc->tulip_if; + struct mbuf *ombuf = m; + int compressed = 0; +#endif #if defined(TULIP_DEBUG) if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) { @@ -4169,6 +4174,26 @@ tulip_txput( * entries that we can use for one packet, so we have * recopy it into one mbuf and then try again. */ +#if 1 /* ALTQ */ + struct mbuf *tmp; + /* + * tulip_mbuf_compress() frees the original mbuf. + * thus, we have to remove the mbuf from the queue + * before calling it. + * we don't have to worry about space shortage + * after compressing the mbuf since the compressed + * mbuf will take only two segs. + */ + if (compressed) { + /* should not happen */ + printf("tulip_txput: compress called twice!\n"); + goto finish; + } + IFQ_DEQUEUE(&ifp->if_snd, tmp); + if (tmp != ombuf) + panic("tulip_txput: different mbuf dequeued!"); + compressed = 1; +#endif m = tulip_mbuf_compress(m); if (m == NULL) goto finish; @@ -4235,6 +4260,16 @@ tulip_txput( * The descriptors have been filled in. Now get ready * to transmit. */ +#if 1 /* ALTQ */ + if (!compressed && (sc->tulip_flags & TULIP_TXPROBE_ACTIVE) == 0) { + /* remove the mbuf from the queue */ + struct mbuf *tmp; + IFQ_DEQUEUE(&ifp->if_snd, tmp); + if (tmp != ombuf) + panic("tulip_txput: different mbuf dequeued!"); + } +#endif + IF_ENQUEUE(&sc->tulip_txq, m); m = NULL; @@ -4593,11 +4628,19 @@ tulip_ifioctl( return error; } +#if 1 /* ALTQ */ +/* + * the original dequeueing policy is dequeue-and-prepend if something + * goes wrong. when altq is used, it is changed to peek-and-dequeue. + * the modification becomes a bit complicated since tulip_txput() might + * copy and modify the mbuf passed. + */ +#endif /* * These routines gets called at device spl (from ether_output). This might * pose a problem for TULIP_USE_SOFTINTR if ether_output is called at * device spl from another driver. - */ + */ static ifnet_ret_t tulip_ifstart( @@ -4611,15 +4654,23 @@ tulip_ifstart( if ((sc->tulip_flags & (TULIP_WANTSETUP|TULIP_TXPROBE_ACTIVE)) == TULIP_WANTSETUP) tulip_txput_setup(sc); - while (sc->tulip_if.if_snd.ifq_head != NULL) { - struct mbuf *m; - IF_DEQUEUE(&sc->tulip_if.if_snd, m); - if ((m = tulip_txput(sc, m)) != NULL) { - IF_PREPEND(&sc->tulip_if.if_snd, m); + while (!IFQ_IS_EMPTY(&sc->tulip_if.if_snd)) { + struct mbuf *m, *m0; + IFQ_POLL(&sc->tulip_if.if_snd, m); + if (m == NULL) + break; + if ((m0 = tulip_txput(sc, m)) != NULL) { + if (m0 != m) + /* should not happen */ + printf("tulip_if_start: txput failed!\n"); break; } } - if (sc->tulip_if.if_snd.ifq_head == NULL) +#ifdef ALTQ + if (0) /* don't switch to the one packet mode */ +#else + if (IFQ_IS_EMPTY(&sc->tulip_if.if_snd)) +#endif sc->tulip_if.if_start = tulip_ifstart_one; } @@ -4634,11 +4685,13 @@ tulip_ifstart_one( tulip_softc_t * const sc = TULIP_IFP_TO_SOFTC(ifp); if ((sc->tulip_if.if_flags & IFF_RUNNING) - && sc->tulip_if.if_snd.ifq_head != NULL) { - struct mbuf *m; - IF_DEQUEUE(&sc->tulip_if.if_snd, m); - if ((m = tulip_txput(sc, m)) != NULL) - IF_PREPEND(&sc->tulip_if.if_snd, m); + && !IFQ_IS_EMPTY(&sc->tulip_if.if_snd)) { + struct mbuf *m, *m0; + IFQ_POLL(&sc->tulip_if.if_snd, m); + if (m != NULL && (m0 = tulip_txput(sc, m)) != NULL) + if (m0 != m) + /* should not happen */ + printf("tulip_if_start_one: txput failed!\n"); } TULIP_PERFEND(ifstart_one); } @@ -4837,6 +4890,7 @@ tulip_attach( tulip_reset(sc); + IFQ_SET_READY(&ifp->if_snd); #if defined(__bsdi__) && _BSDI_VERSION >= 199510 sc->tulip_pf = printf; TULIP_ETHER_IFATTACH(sc); diff --git a/sys/dev/pci/if_lmc.c b/sys/dev/pci/if_lmc.c index 165e70fdb48..ea5e2875cf7 100644 --- a/sys/dev/pci/if_lmc.c +++ b/sys/dev/pci/if_lmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_lmc.c,v 1.8 2001/06/27 05:44:55 nate Exp $ */ +/* $OpenBSD: if_lmc.c,v 1.9 2001/06/27 06:34:48 kjc Exp $ */ /* $NetBSD: if_lmc.c,v 1.1 1999/03/25 03:32:43 explorer Exp $ */ /*- @@ -1286,15 +1286,20 @@ static ifnet_ret_t lmc_ifstart(struct ifnet * const ifp) { lmc_softc_t * const sc = LMC_IFP_TO_SOFTC(ifp); - struct mbuf *m; + struct mbuf *m, *m0; if (sc->lmc_flags & LMC_IFUP) { while (sppp_isempty(ifp) == 0) { - m = sppp_dequeue(ifp); - if ((m = lmc_txput(sc, m)) != NULL) { - IF_PREPEND(&((struct sppp *)ifp)->pp_fastq, m); + m = sppp_pick(ifp); + if (m == NULL) break; - } + if ((m = lmc_txput(sc, m)) != NULL) + break; + m0 = sppp_dequeue(ifp); +#if defined(LMC_DEBUG) + if (m0 != m) + printf("lmc_ifstart: mbuf mismatch!\n"); +#endif } LMC_CSR_WRITE(sc, csr_txpoll, 1); } @@ -1304,13 +1309,17 @@ static ifnet_ret_t lmc_ifstart_one(struct ifnet * const ifp) { lmc_softc_t * const sc = LMC_IFP_TO_SOFTC(ifp); - struct mbuf *m; + struct mbuf *m, *m0; if ((sc->lmc_flags & LMC_IFUP) && (sppp_isempty(ifp) == 0)) { - m = sppp_dequeue(ifp); - if ((m = lmc_txput(sc, m)) != NULL) { - IF_PREPEND(&((struct sppp *)ifp)->pp_fastq, m); - } + m = sppp_pick(ifp); + if ((m = lmc_txput(sc, m)) != NULL) + return; + m0 = sppp_dequeue(ifp); +#if defined(LMC_DEBUG) + if (m0 != m) + printf("lmc_ifstart: mbuf mismatch!\n"); +#endif LMC_CSR_WRITE(sc, csr_txpoll, 1); } } @@ -1428,6 +1437,7 @@ lmc_attach(lmc_softc_t * const sc) ifp->if_watchdog = lmc_watchdog; ifp->if_timer = 1; ifp->if_mtu = LMC_MTU; + IFQ_SET_READY(&ifp->if_snd); #if defined(__bsdi__) ifp->if_type = IFT_NONE; diff --git a/sys/dev/pci/if_sf.c b/sys/dev/pci/if_sf.c index 19f8b4bf333..84f586a58a5 100644 --- a/sys/dev/pci/if_sf.c +++ b/sys/dev/pci/if_sf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sf.c,v 1.11 2001/06/24 20:26:59 fgsch Exp $ */ +/* $OpenBSD: if_sf.c,v 1.12 2001/06/27 06:34:48 kjc Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -739,7 +739,8 @@ void sf_attach(parent, self, aux) ifp->if_start = sf_start; ifp->if_watchdog = sf_watchdog; ifp->if_baudrate = 10000000; - ifp->if_snd.ifq_maxlen = SF_TX_DLIST_CNT - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, SF_TX_DLIST_CNT - 1); + IFQ_SET_READY(&ifp->if_snd); bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); /* @@ -1029,7 +1030,7 @@ int sf_intr(arg) /* Re-enable interrupts. */ csr_write_4(sc, SF_IMR, SF_INTRS); - if (ifp->if_snd.ifq_head != NULL) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) sf_start(ifp); return claimed; @@ -1231,7 +1232,7 @@ void sf_start(ifp) i = SF_IDX_HI(txprod) >> 4; while(sc->sf_ldata->sf_tx_dlist[i].sf_mbuf == NULL) { - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -1352,7 +1353,7 @@ void sf_stats_update(xsc) if (mii->mii_media_status & IFM_ACTIVE && IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) sc->sf_link++; - if (ifp->if_snd.ifq_head != NULL) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) sf_start(ifp); } @@ -1377,7 +1378,7 @@ void sf_watchdog(ifp) sf_reset(sc); sf_init(sc); - if (ifp->if_snd.ifq_head != NULL) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) sf_start(ifp); return; diff --git a/sys/dev/pci/if_sis.c b/sys/dev/pci/if_sis.c index eb88dac17ae..e012dd17ea3 100644 --- a/sys/dev/pci/if_sis.c +++ b/sys/dev/pci/if_sis.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sis.c,v 1.14 2001/06/24 20:27:00 fgsch Exp $ */ +/* $OpenBSD: if_sis.c,v 1.15 2001/06/27 06:34:48 kjc Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -826,7 +826,8 @@ void sis_attach(parent, self, aux) ifp->if_start = sis_start; ifp->if_watchdog = sis_watchdog; ifp->if_baudrate = 10000000; - ifp->if_snd.ifq_maxlen = SIS_TX_LIST_CNT - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, SIS_TX_LIST_CNT - 1); + IFQ_SET_READY(&ifp->if_snd); bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); sc->sc_mii.mii_ifp = ifp; @@ -1127,7 +1128,7 @@ void sis_tick(xsc) if (mii->mii_media_status & IFM_ACTIVE && IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) sc->sis_link++; - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) sis_start(ifp); } timeout_add(&sc->sis_timeout, hz); @@ -1190,7 +1191,7 @@ int sis_intr(arg) /* Re-enable interrupts. */ CSR_WRITE_4(sc, SIS_IER, 1); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) sis_start(ifp); return claimed; @@ -1258,7 +1259,6 @@ void sis_start(ifp) struct sis_softc *sc; struct mbuf *m_head = NULL; u_int32_t idx; - int s; sc = ifp->if_softc; @@ -1271,20 +1271,18 @@ void sis_start(ifp) return; while(sc->sis_ldata->sis_tx_list[idx].sis_mbuf == NULL) { - s = splimp(); - IF_DEQUEUE(&ifp->if_snd, m_head); - splx(s); + IFQ_POLL(&ifp->if_snd, m_head); if (m_head == NULL) break; if (sis_encap(sc, m_head, &idx)) { - s = splimp(); - IF_PREPEND(&ifp->if_snd, m_head); - splx(s); ifp->if_flags |= IFF_OACTIVE; break; } + /* now we are committed to transmit the packet */ + IFQ_DEQUEUE(&ifp->if_snd, m_head); + /* * If there's a BPF listener, bounce a copy of this frame * to him. @@ -1294,6 +1292,8 @@ void sis_start(ifp) bpf_mtap(ifp->if_bpf, m_head); #endif } + if (idx == sc->sis_cdata.sis_tx_prod) + return; /* Transmit */ sc->sis_cdata.sis_tx_prod = idx; @@ -1599,7 +1599,7 @@ void sis_watchdog(ifp) sis_reset(sc); sis_init(sc); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) sis_start(ifp); splx(s); diff --git a/sys/dev/pci/if_ste.c b/sys/dev/pci/if_ste.c index a72d091fa53..8dd665c8936 100644 --- a/sys/dev/pci/if_ste.c +++ b/sys/dev/pci/if_ste.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ste.c,v 1.11 2001/06/25 02:18:47 fgsch Exp $ */ +/* $OpenBSD: if_ste.c,v 1.12 2001/06/27 06:34:49 kjc Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -604,7 +604,7 @@ int ste_intr(xsc) /* Re-enable interrupts */ CSR_WRITE_2(sc, STE_IMR, STE_INTRS); - if (ifp->if_snd.ifq_head != NULL) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) ste_start(ifp); return claimed; @@ -818,7 +818,7 @@ void ste_stats_update(xsc) if (mii->mii_media_status & IFM_ACTIVE && IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) sc->ste_link++; - if (ifp->if_snd.ifq_head != NULL) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) ste_start(ifp); } @@ -986,7 +986,8 @@ void ste_attach(parent, self, aux) ifp->if_start = ste_start; ifp->if_watchdog = ste_watchdog; ifp->if_baudrate = 10000000; - ifp->if_snd.ifq_maxlen = STE_TX_LIST_CNT - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, STE_TX_LIST_CNT - 1); + IFQ_SET_READY(&ifp->if_snd); bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); sc->sc_mii.mii_ifp = ifp; @@ -1433,7 +1434,7 @@ void ste_start(ifp) break; } - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -1488,7 +1489,7 @@ void ste_watchdog(ifp) ste_reset(sc); ste_init(sc); - if (ifp->if_snd.ifq_head != NULL) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) ste_start(ifp); return; diff --git a/sys/dev/pci/if_ti.c b/sys/dev/pci/if_ti.c index a8170794bff..79b4ff8aaa8 100644 --- a/sys/dev/pci/if_ti.c +++ b/sys/dev/pci/if_ti.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ti.c,v 1.24 2001/06/27 05:44:55 nate Exp $ */ +/* $OpenBSD: if_ti.c,v 1.25 2001/06/27 06:34:49 kjc Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -1643,7 +1643,8 @@ ti_attach(parent, self, aux) ifp->if_start = ti_start; ifp->if_watchdog = ti_watchdog; ifp->if_mtu = ETHERMTU; - ifp->if_snd.ifq_maxlen = TI_TX_RING_CNT - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, TI_TX_RING_CNT - 1); + IFQ_SET_READY(&ifp->if_snd); bcopy(sc->sc_dv.dv_xname, ifp->if_xname, IFNAMSIZ); /* Set up ifmedia support. */ @@ -1901,7 +1902,7 @@ int ti_intr(xsc) /* Re-enable interrupts. */ CSR_WRITE_4(sc, TI_MB_HOSTINTR, 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)) ti_start(ifp); return (1); @@ -2024,13 +2025,14 @@ void ti_start(ifp) struct ti_softc *sc; struct mbuf *m_head = NULL; u_int32_t prodidx = 0; + int pkts = 0; sc = ifp->if_softc; prodidx = CSR_READ_4(sc, TI_MB_SENDPROD_IDX); while(sc->ti_cdata.ti_tx_chain[prodidx] == NULL) { - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_POLL(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -2040,11 +2042,14 @@ void ti_start(ifp) * for the NIC to drain the ring. */ if (ti_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. @@ -2054,6 +2059,8 @@ void ti_start(ifp) bpf_mtap(ifp->if_bpf, m_head); #endif } + if (pkts == 0) + return; /* Transmit */ CSR_WRITE_4(sc, TI_MB_SENDPROD_IDX, prodidx); diff --git a/sys/dev/pci/if_tl.c b/sys/dev/pci/if_tl.c index b5ad89c0198..60d970d3bc0 100644 --- a/sys/dev/pci/if_tl.c +++ b/sys/dev/pci/if_tl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tl.c,v 1.20 2001/06/24 20:27:01 fgsch Exp $ */ +/* $OpenBSD: if_tl.c,v 1.21 2001/06/27 06:34:49 kjc Exp $ */ /* * Copyright (c) 1997, 1998 @@ -1392,7 +1392,7 @@ int tl_intr(xsc) CMD_PUT(sc, TL_CMD_ACK | r | type); } - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) tl_start(ifp); return r; @@ -1568,7 +1568,7 @@ void tl_start(ifp) start_tx = sc->tl_cdata.tl_tx_free; while(sc->tl_cdata.tl_tx_free != NULL) { - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -2151,7 +2151,8 @@ tl_attach(parent, self, aux) ifp->if_start = tl_start; ifp->if_watchdog = tl_watchdog; ifp->if_baudrate = 10000000; - ifp->if_snd.ifq_maxlen = TL_TX_LIST_CNT - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, TL_TX_LIST_CNT - 1); + IFQ_SET_READY(&ifp->if_snd); bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); /* diff --git a/sys/dev/pci/if_tx.c b/sys/dev/pci/if_tx.c index 9f8c070e74c..9c4abd38f72 100644 --- a/sys/dev/pci/if_tx.c +++ b/sys/dev/pci/if_tx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tx.c,v 1.16 2001/06/25 02:18:48 fgsch Exp $ */ +/* $OpenBSD: if_tx.c,v 1.17 2001/06/27 06:34:50 kjc Exp $ */ /* $FreeBSD: src/sys/pci/if_tx.c,v 1.45 2001/02/07 20:11:02 semenu Exp $ */ /*- @@ -447,7 +447,8 @@ epic_freebsd_attach(dev) ifp->if_init = (if_init_f_t*)epic_init; ifp->if_timer = 0; ifp->if_baudrate = 10000000; - ifp->if_snd.ifq_maxlen = TX_RING_SIZE - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, TX_RING_SIZE - 1); + IFQ_SET_READY(&ifp->if_snd); /* Enable ports, memory and busmastering */ command = pci_read_config(dev, PCIR_COMMAND, 4); @@ -819,7 +820,7 @@ epic_ifstart(ifp) flist = sc->tx_flist + sc->cur_tx; /* Get next packet to send */ - IF_DEQUEUE( &ifp->if_snd, m0 ); + IFQ_DEQUEUE( &ifp->if_snd, m0 ); /* If nothing to send, return */ if( NULL == m0 ) return; @@ -1032,7 +1033,7 @@ epic_intr(arg) if( status & (INTSTAT_TXC|INTSTAT_TCC|INTSTAT_TQE) ) { epic_tx_done( sc ); if(!(sc->sc_if.if_flags & IFF_OACTIVE) && - sc->sc_if.if_snd.ifq_head ) + !IFQ_IS_EMPTY( &sc->sc_if.if_snd )) epic_ifstart( &sc->sc_if ); } @@ -1122,7 +1123,7 @@ epic_ifwatchdog(ifp) printf("seems we can continue normaly\n"); /* Start output */ - if( ifp->if_snd.ifq_head ) epic_ifstart( ifp ); + if( !IFQ_IS_EMPTY( &ifp->if_snd ) ) epic_ifstart( ifp ); splx(x); } diff --git a/sys/dev/pci/if_txp.c b/sys/dev/pci/if_txp.c index 9a777506fd4..a0ad84c0b18 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.47 2001/06/24 22:58:01 fgsch Exp $ */ +/* $OpenBSD: if_txp.c,v 1.48 2001/06/27 06:34:50 kjc Exp $ */ /* * Copyright (c) 2001 @@ -270,7 +270,8 @@ txp_attach(parent, self, aux) ifp->if_start = txp_start; ifp->if_watchdog = txp_watchdog; ifp->if_baudrate = 10000000; - ifp->if_snd.ifq_maxlen = TX_ENTRIES; + IFQ_SET_MAXLEN(&ifp->if_snd, TX_ENTRIES); + IFQ_SET_READY(&ifp->if_snd); ifp->if_capabilities = 0; bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); @@ -1280,7 +1281,7 @@ txp_start(ifp) cnt = r->r_cnt; while (1) { - IF_DEQUEUE(&ifp->if_snd, m); + IFQ_DEQUEUE(&ifp->if_snd, m); if (m == NULL) break; diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c index f4d2ead0bd8..1c720aa7748 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.17 2001/06/24 22:38:47 aaron Exp $ */ +/* $OpenBSD: if_vr.c,v 1.18 2001/06/27 06:34:50 kjc Exp $ */ /* * Copyright (c) 1997, 1998 @@ -766,6 +766,7 @@ vr_attach(parent, self, aux) ifp->if_start = vr_start; ifp->if_watchdog = vr_watchdog; ifp->if_baudrate = 10000000; + IFQ_SET_READY(&ifp->if_snd); bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); /* @@ -1185,7 +1186,7 @@ vr_intr(arg) /* Re-enable interrupts. */ CSR_WRITE_2(sc, VR_IMR, VR_INTRS); - if (ifp->if_snd.ifq_head != NULL) { + if (!IFQ_IS_EMPTY(&ifp->if_snd)) { vr_start(ifp); } @@ -1291,7 +1292,7 @@ vr_start(ifp) start_tx = sc->vr_cdata.vr_tx_free; while(sc->vr_cdata.vr_tx_free->vr_mbuf == NULL) { - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -1548,7 +1549,7 @@ vr_watchdog(ifp) vr_reset(sc); vr_init(sc); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) vr_start(ifp); return; diff --git a/sys/dev/pci/if_wb.c b/sys/dev/pci/if_wb.c index 8655e3d5d32..e324c0abfc7 100644 --- a/sys/dev/pci/if_wb.c +++ b/sys/dev/pci/if_wb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wb.c,v 1.10 2001/06/24 20:27:02 fgsch Exp $ */ +/* $OpenBSD: if_wb.c,v 1.11 2001/06/27 06:34:50 kjc Exp $ */ /* * Copyright (c) 1997, 1998 @@ -903,7 +903,9 @@ wb_attach(parent, self, aux) ifp->if_start = wb_start; ifp->if_watchdog = wb_watchdog; ifp->if_baudrate = 10000000; - ifp->if_snd.ifq_maxlen = WB_TX_LIST_CNT - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, WB_TX_LIST_CNT - 1); + IFQ_SET_READY(&ifp->if_snd); + bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ); /* @@ -1310,7 +1312,7 @@ int wb_intr(arg) /* Re-enable interrupts. */ CSR_WRITE_4(sc, WB_IMR, WB_INTRS); - if (ifp->if_snd.ifq_head != NULL) { + if (!IFQ_IS_EMPTY(&ifp->if_snd)) { wb_start(ifp); } @@ -1449,7 +1451,7 @@ void wb_start(ifp) start_tx = sc->wb_cdata.wb_tx_free; while(sc->wb_cdata.wb_tx_free->wb_mbuf == NULL) { - IF_DEQUEUE(&ifp->if_snd, m_head); + IFQ_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -1752,7 +1754,7 @@ void wb_watchdog(ifp) wb_reset(sc); wb_init(sc); - if (ifp->if_snd.ifq_head != NULL) + if (!IFQ_IS_EMPTY(&ifp->if_snd)) wb_start(ifp); return; diff --git a/sys/dev/pci/if_wx.c b/sys/dev/pci/if_wx.c index cc43092c01c..2557548b476 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.13 2001/06/24 20:27:03 fgsch Exp $ */ +/* $OpenBSD: if_wx.c,v 1.14 2001/06/27 06:34:51 kjc Exp $ */ /* * Principal Author: Matthew Jacob * Copyright (c) 1999, 2001 by Traakan Software @@ -722,7 +722,8 @@ wx_attach(device_t dev) ifp->if_ioctl = wx_ioctl; ifp->if_start = wx_start; ifp->if_watchdog = wx_txwatchdog; - ifp->if_snd.ifq_maxlen = WX_MAX_TDESC - 1; + IFQ_SET_MAXLEN(&ifp->if_snd, WX_MAX_TDESC - 1); + IFQ_SET_READY(&ifp->if_snd); ether_ifattach(ifp, ETHER_BPF_SUPPORTED); out: WX_UNLOCK(sc); @@ -1125,7 +1126,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; } @@ -1264,6 +1265,17 @@ wx_start(struct ifnet *ifp) if (nactv == WX_MAX_TDESC && mb_head->m_next == NULL) { sc->wx_xmitputback++; ifp->if_flags |= IFF_OACTIVE; +#ifdef ALTQ + /* + * XXX when altq is enabled, we can't put the + * packet back to the queue. + * just give up this packet for now. + */ + if (ALTQ_IS_ENABLED(&ifp->if_snd)) { + m_freem(mb_head); + break; + } +#endif IF_PREPEND(&ifp->if_snd, mb_head); break; } @@ -1336,7 +1348,7 @@ wx_intr(void *arg) if (sc->tactive) { wx_gc(sc); } - if (sc->wx_if.if_snd.ifq_head != NULL) { + if (IFQ_IS_EMPTY(&sc->wx_if.if_snd) == 0) { wx_start(&sc->wx_if); } WX_ENABLE_INT(sc); diff --git a/sys/dev/pcmcia/if_cnw.c b/sys/dev/pcmcia/if_cnw.c index 005432fafe6..2f439b4f50a 100644 --- a/sys/dev/pcmcia/if_cnw.c +++ b/sys/dev/pcmcia/if_cnw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cnw.c,v 1.8 2001/06/25 04:05:50 fgsch Exp $ */ +/* $OpenBSD: if_cnw.c,v 1.9 2001/06/27 06:34:51 kjc Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. * All rights reserved. @@ -434,6 +434,7 @@ cnw_attach(parent, self, aux) ifp->if_ioctl = cnw_ioctl; ifp->if_watchdog = cnw_watchdog; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS; + IFQ_SET_READY(&ifp->if_snd); /* Attach the interface */ if_attach(ifp); @@ -471,7 +472,7 @@ cnw_start(ifp) return; } - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (m0 == 0) return; diff --git a/sys/dev/pcmcia/if_ray.c b/sys/dev/pcmcia/if_ray.c index e5d677dae07..a6bf096274c 100644 --- a/sys/dev/pcmcia/if_ray.c +++ b/sys/dev/pcmcia/if_ray.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ray.c,v 1.15 2001/06/25 04:05:51 fgsch Exp $ */ +/* $OpenBSD: if_ray.c,v 1.16 2001/06/27 06:34:52 kjc Exp $ */ /* $NetBSD: if_ray.c,v 1.21 2000/07/05 02:35:54 onoe Exp $ */ /* @@ -649,6 +649,7 @@ ray_attach(parent, self, aux) ifp->if_ioctl = ray_ioctl; ifp->if_mtu = ETHERMTU; ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST; + IFQ_SET_READY(&ifp->if_snd); if_attach(ifp); memcpy(&sc->sc_ec.ac_enaddr, ep->e_station_addr, ETHER_ADDR_LEN); ether_ifattach(ifp); @@ -1227,7 +1228,7 @@ ray_intr_start(sc) return; } - if (ifp->if_snd.ifq_len == 0) { + if (IFQ_IS_EMPTY(&ifp->if_snd)) { RAY_DPRINTF(("%s: nothing to send.\n",ifp->if_xname)); return; } @@ -1260,7 +1261,7 @@ ray_intr_start(sc) } } - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); if (!m0) { RAY_DPRINTF(("%s: dry queue.\n", ifp->if_xname)); break; diff --git a/sys/dev/pcmcia/if_xe.c b/sys/dev/pcmcia/if_xe.c index 5ab49083ea2..7c564bfab7b 100644 --- a/sys/dev/pcmcia/if_xe.c +++ b/sys/dev/pcmcia/if_xe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_xe.c,v 1.20 2001/06/25 04:05:51 fgsch Exp $ */ +/* $OpenBSD: if_xe.c,v 1.21 2001/06/27 06:34:52 kjc Exp $ */ /* * Copyright (c) 1999 Niklas Hallqvist, Brandon Creighton, Job de Haas @@ -382,7 +382,8 @@ xe_pcmcia_attach(parent, self, aux) ifp->if_ioctl = xe_ioctl; ifp->if_start = xe_start; ifp->if_watchdog = xe_watchdog; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); + IFQ_SET_READY(&ifp->if_snd); /* Establish the interrupt. */ sc->sc_ih = pcmcia_intr_establish(pa->pf, IPL_NET, xe_intr, sc); @@ -736,7 +737,7 @@ xe_intr(arg) } /* Try to start more packets transmitting. */ - if (ifp->if_snd.ifq_head) + if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) xe_start(ifp); /* Detected excessive collisions? */ @@ -1112,7 +1113,7 @@ xe_start(ifp) return; /* Peek at the next packet. */ - m0 = ifp->if_snd.ifq_head; + IFQ_POLL(&ifp->if_snd, m0); if (m0 == 0) return; @@ -1135,7 +1136,7 @@ xe_start(ifp) return; } - IF_DEQUEUE(&ifp->if_snd, m0); + IFQ_DEQUEUE(&ifp->if_snd, m0); #if NBPFILTER > 0 if (ifp->if_bpf) 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); } |