From c49a85fd0bd31314be2c002ec0d6369ae62b77dc Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Sun, 20 Feb 2005 05:45:38 +0000 Subject: [PATCH] ALTQ support. --- sys/dev/netif/sf/if_sf.c | 21 ++++++++++--------- sys/dev/netif/sn/if_sn.c | 45 ++++++++++++++++++++-------------------- sys/dev/netif/ti/if_ti.c | 13 ++++++------ 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/sys/dev/netif/sf/if_sf.c b/sys/dev/netif/sf/if_sf.c index b52cc952b4..5b687112be 100644 --- a/sys/dev/netif/sf/if_sf.c +++ b/sys/dev/netif/sf/if_sf.c @@ -30,7 +30,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/pci/if_sf.c,v 1.18.2.8 2001/12/16 15:46:07 luigi Exp $ - * $DragonFly: src/sys/dev/netif/sf/if_sf.c,v 1.14 2005/01/23 20:21:31 joerg Exp $ + * $DragonFly: src/sys/dev/netif/sf/if_sf.c,v 1.15 2005/02/20 05:44:34 joerg Exp $ * * $FreeBSD: src/sys/pci/if_sf.c,v 1.18.2.8 2001/12/16 15:46:07 luigi Exp $ */ @@ -91,6 +91,7 @@ #include #include +#include #include #include #include @@ -818,7 +819,8 @@ static int sf_attach(dev) ifp->if_watchdog = sf_watchdog; ifp->if_init = sf_init; 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); /* * Call MI attach routine. @@ -1135,7 +1137,7 @@ static void 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)) sf_start(ifp); return; @@ -1329,7 +1331,7 @@ static void sf_start(ifp) sc = ifp->if_softc; - if (!sc->sf_link && ifp->if_snd.ifq_len < 10) + if (!sc->sf_link) return; if (ifp->if_flags & IFF_OACTIVE) @@ -1351,19 +1353,18 @@ static void sf_start(ifp) cur_tx = NULL; break; } - IF_DEQUEUE(&ifp->if_snd, m_head); + m_head = ifq_poll(&ifp->if_snd); if (m_head == NULL) break; cur_tx = &sc->sf_ldata->sf_tx_dlist[i]; if (sf_encap(sc, cur_tx, m_head)) { - IF_PREPEND(&ifp->if_snd, m_head); ifp->if_flags |= IFF_OACTIVE; cur_tx = NULL; break; } - - BPF_MTAP(ifp, m_head); + ifq_dequeue(&ifp->if_snd); + BPF_MTAP(ifp, cur_tx->sf_mbuf); SF_INC(i, SF_TX_DLIST_CNT); sc->sf_tx_cnt++; @@ -1470,7 +1471,7 @@ static 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)) sf_start(ifp); } @@ -1495,7 +1496,7 @@ static void sf_watchdog(ifp) sf_reset(sc); sf_init(sc); - if (ifp->if_snd.ifq_head != NULL) + if (!ifq_is_empty(&ifp->if_snd)) sf_start(ifp); return; diff --git a/sys/dev/netif/sn/if_sn.c b/sys/dev/netif/sn/if_sn.c index 8cf621f6a3..53c2117a65 100644 --- a/sys/dev/netif/sn/if_sn.c +++ b/sys/dev/netif/sn/if_sn.c @@ -29,7 +29,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sn/if_sn.c,v 1.7.2.3 2001/02/04 04:38:38 toshi Exp $ - * $DragonFly: src/sys/dev/netif/sn/if_sn.c,v 1.12 2005/01/23 20:21:31 joerg Exp $ + * $DragonFly: src/sys/dev/netif/sn/if_sn.c,v 1.13 2005/02/20 05:45:11 joerg Exp $ */ /* @@ -101,6 +101,7 @@ #include #include +#include #include #include #include @@ -222,7 +223,8 @@ sn_attach(device_t dev) ifp->if_ioctl = snioctl; ifp->if_watchdog = snwatchdog; ifp->if_init = sninit; - ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; + ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN); + ifq_set_ready(&ifp->if_snd); ifp->if_timer = 0; ether_ifattach(ifp, sc->arpcom.ac_enaddr); @@ -367,7 +369,7 @@ snstart(struct ifnet *ifp) s = splimp(); - if (sc->arpcom.ac_if.if_flags & IFF_OACTIVE) { + if (ifp->if_flags & IFF_OACTIVE) { splx(s); return; } @@ -382,7 +384,7 @@ startagain: /* * Sneak a peek at the next packet */ - m = sc->arpcom.ac_if.if_snd.ifq_head; + m = ifq_poll(&ifp->if_snd); if (m == 0) { splx(s); return; @@ -403,7 +405,7 @@ startagain: if (len + pad > ETHER_MAX_LEN - ETHER_CRC_LEN) { printf("%s: large packet discarded (A)\n", ifp->if_xname); ++sc->arpcom.ac_if.if_oerrors; - IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m); + m = ifq_dequeue(&ifp->if_snd); m_freem(m); goto readcheck; } @@ -460,8 +462,8 @@ startagain: outb(BASE + INTR_MASK_REG_B, mask); sc->intr_mask = mask; - sc->arpcom.ac_if.if_timer = 1; - sc->arpcom.ac_if.if_flags |= IFF_OACTIVE; + ifp->if_timer = 1; + ifp->if_flags |= IFF_OACTIVE; sc->pages_wanted = numPages; splx(s); @@ -497,7 +499,7 @@ startagain: * Get the packet from the kernel. This will include the Ethernet * frame header, MAC Addresses etc. */ - IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m); + m = ifq_dequeue(&ifp->if_snd); /* * Push out the data to the card. @@ -543,15 +545,14 @@ startagain: outw(BASE + MMU_CMD_REG_W, MMUCR_ENQUEUE); - sc->arpcom.ac_if.if_flags |= IFF_OACTIVE; - sc->arpcom.ac_if.if_timer = 1; + ifp->if_flags |= IFF_OACTIVE; + ifp->if_timer = 1; BPF_MTAP(ifp, top); - sc->arpcom.ac_if.if_opackets++; + ifp->if_opackets++; m_freem(top); - readcheck: /* @@ -599,7 +600,7 @@ snresume(struct ifnet *ifp) /* * Sneak a peek at the next packet */ - m = sc->arpcom.ac_if.if_snd.ifq_head; + m = ifq_poll(&ifp->if_snd); if (m == 0) { printf("%s: snresume() with nothing to send\n", ifp->if_xname); return; @@ -619,8 +620,8 @@ snresume(struct ifnet *ifp) */ if (len + pad > ETHER_MAX_LEN - ETHER_CRC_LEN) { printf("%s: large packet discarded (B)\n", ifp->if_xname); - ++sc->arpcom.ac_if.if_oerrors; - IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m); + ++ifp->if_oerrors; + ifq_dequeue(&ifp->if_snd); m_freem(m); return; } @@ -655,7 +656,7 @@ snresume(struct ifnet *ifp) packet_no = inb(BASE + ALLOC_RESULT_REG_B); if (packet_no & ARR_FAILED) { printf("%s: Memory allocation failed. Weird.\n", ifp->if_xname); - sc->arpcom.ac_if.if_timer = 1; + ifp->if_timer = 1; goto try_start; } /* @@ -696,7 +697,7 @@ snresume(struct ifnet *ifp) * Get the packet from the kernel. This will include the Ethernet * frame header, MAC Addresses etc. */ - IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m); + m = ifq_dequeue(&ifp->if_snd); /* * Push out the data to the card. @@ -743,7 +744,7 @@ snresume(struct ifnet *ifp) BPF_MTAP(ifp, top); - sc->arpcom.ac_if.if_opackets++; + ifp->if_opackets++; m_freem(top); try_start: @@ -751,17 +752,15 @@ try_start: /* * Now pass control to snstart() to queue any additional packets */ - sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; + ifp->if_flags &= ~IFF_OACTIVE; snstart(ifp); /* * We've sent something, so we're active. Set a watchdog in case the * TX_EMPTY interrupt is lost. */ - sc->arpcom.ac_if.if_flags |= IFF_OACTIVE; - sc->arpcom.ac_if.if_timer = 1; - - return; + ifp->if_flags |= IFF_OACTIVE; + ifp->if_timer = 1; } diff --git a/sys/dev/netif/ti/if_ti.c b/sys/dev/netif/ti/if_ti.c index da77b5d3c6..1fe2a4d2e9 100644 --- a/sys/dev/netif/ti/if_ti.c +++ b/sys/dev/netif/ti/if_ti.c @@ -30,7 +30,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/pci/if_ti.c,v 1.25.2.14 2002/02/15 04:20:20 silby Exp $ - * $DragonFly: src/sys/dev/netif/ti/if_ti.c,v 1.16 2005/02/14 16:21:34 joerg Exp $ + * $DragonFly: src/sys/dev/netif/ti/if_ti.c,v 1.17 2005/02/20 05:45:38 joerg Exp $ * * $FreeBSD: src/sys/pci/if_ti.c,v 1.25.2.14 2002/02/15 04:20:20 silby Exp $ */ @@ -91,6 +91,7 @@ #include #include +#include #include #include #include @@ -1714,7 +1715,8 @@ static int ti_attach(dev) ifp->if_watchdog = ti_watchdog; ifp->if_init = ti_init; 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); /* Set up ifmedia support. */ ifmedia_init(&sc->ifmedia, IFM_IMASK, ti_ifmedia_upd, ti_ifmedia_sts); @@ -1981,7 +1983,7 @@ static void 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; @@ -2120,7 +2122,7 @@ static void ti_start(ifp) 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); + m_head = ifq_poll(&ifp->if_snd); if (m_head == NULL) break; @@ -2136,7 +2138,6 @@ static void ti_start(ifp) m_head->m_pkthdr.csum_flags & (CSUM_DELAY_DATA)) { if ((TI_TX_RING_CNT - sc->ti_txcnt) < m_head->m_pkthdr.csum_data + 16) { - IF_PREPEND(&ifp->if_snd, m_head); ifp->if_flags |= IFF_OACTIVE; break; } @@ -2148,11 +2149,11 @@ static 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; } + m_head = ifq_dequeue(&ifp->if_snd); BPF_MTAP(ifp, m_head); } -- 2.41.0