diff options
| author | thorpej <thorpej@NetBSD.org> | 2022-09-18 17:54:46 +0000 |
|---|---|---|
| committer | thorpej <thorpej@NetBSD.org> | 2022-09-18 17:54:46 +0000 |
| commit | b6852db6696ff13ba3f5a1bb0d0ea375af79fa78 (patch) | |
| tree | 1a393de83617c506371ab5ac4d19f5029966d889 /sys/dev | |
| parent | 28feb90379c00cc191ee84e3ddbd2641f09e7733 (diff) | |
Eliminate use of IFF_OACTIVE.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ic/dm9000.c | 30 | ||||
| -rw-r--r-- | sys/dev/ic/dp8390.c | 18 | ||||
| -rw-r--r-- | sys/dev/ic/dwc_eqos.c | 17 | ||||
| -rw-r--r-- | sys/dev/ic/dwc_gmac.c | 19 | ||||
| -rw-r--r-- | sys/dev/ic/dwc_gmac_var.h | 3 |
5 files changed, 38 insertions, 49 deletions
diff --git a/sys/dev/ic/dm9000.c b/sys/dev/ic/dm9000.c index 0eb4eda1629..30da5237d38 100644 --- a/sys/dev/ic/dm9000.c +++ b/sys/dev/ic/dm9000.c @@ -1,4 +1,4 @@ -/* $NetBSD: dm9000.c,v 1.33 2021/12/31 14:25:22 riastradh Exp $ */ +/* $NetBSD: dm9000.c,v 1.34 2022/09/18 17:54:46 thorpej Exp $ */ /* * Copyright (c) 2009 Paul Fleischer @@ -401,7 +401,6 @@ dme_init(struct ifnet *ifp) sc->txbusy = sc->txready = 0; ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; callout_schedule(&sc->sc_link_callout, hz); return 0; @@ -591,7 +590,7 @@ dme_stop(struct ifnet *ifp, int disable) mii_down(&sc->sc_mii); callout_stop(&sc->sc_link_callout); - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + ifp->if_flags &= ~IFF_RUNNING; ifp->if_timer = 0; } @@ -600,24 +599,23 @@ dme_start(struct ifnet *ifp) { struct dme_softc *sc = ifp->if_softc; - if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) { - printf("No output\n"); + if ((ifp->if_flags & IFF_RUNNING) == 0) { return; } - if (sc->txbusy && sc->txready) - panic("DM9000: Internal error, trying to send without" - " any empty queue\n"); - - dme_prepare(ifp); + if (!sc->txready) { + dme_prepare(ifp); + } if (sc->txbusy) { - /* We need to wait until the current frame has + /* + * We need to wait until the current frame has * been transmitted. */ - ifp->if_flags |= IFF_OACTIVE; return; } - /* We are ready to transmit right away */ - dme_transmit(ifp); + if (sc->txready) { + /* We are ready to transmit right away */ + dme_transmit(ifp); + } dme_prepare(ifp); /* Prepare next one */ } @@ -629,13 +627,11 @@ dme_prepare(struct ifnet *ifp) uint16_t length; struct mbuf *m; - if (sc->txready) - panic("dme_prepare: Someone called us with txready set\n"); + KASSERT(!sc->txready); IFQ_DEQUEUE(&ifp->if_snd, m); if (m == NULL) { TX_DPRINTF(("dme_prepare: Nothing to transmit\n")); - ifp->if_flags &= ~IFF_OACTIVE; /* Clear OACTIVE bit */ return; /* Nothing to transmit */ } diff --git a/sys/dev/ic/dp8390.c b/sys/dev/ic/dp8390.c index 009e1ab29f0..5f113ec5abb 100644 --- a/sys/dev/ic/dp8390.c +++ b/sys/dev/ic/dp8390.c @@ -1,4 +1,4 @@ -/* $NetBSD: dp8390.c,v 1.99 2021/07/01 20:39:15 thorpej Exp $ */ +/* $NetBSD: dp8390.c,v 1.100 2022/09/18 18:03:51 thorpej Exp $ */ /* * Device driver for National Semiconductor DS8390/WD83C690 based ethernet @@ -14,7 +14,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.99 2021/07/01 20:39:15 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.100 2022/09/18 18:03:51 thorpej Exp $"); #include "opt_inet.h" @@ -385,7 +385,6 @@ dp8390_init(struct dp8390_softc *sc) /* Set 'running' flag, and clear output active flag. */ ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; /* ...and attempt to start output. */ dp8390_start(ifp); @@ -442,12 +441,10 @@ dp8390_xmit(struct dp8390_softc *sc) /* * Start output on interface. - * We make two assumptions here: + * We make one assumption here: * 1) that the current priority is set to splnet _before_ this code * is called *and* is returned to the appropriate priority after * return - * 2) that the IFF_OACTIVE flag is checked before this code is called - * (i.e. that the output part of the interface is idle) */ void dp8390_start(struct ifnet *ifp) @@ -457,14 +454,13 @@ dp8390_start(struct ifnet *ifp) int buffer; int len; - if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) + if ((ifp->if_flags & IFF_RUNNING) == 0) return; outloop: /* See if there is room to put another packet in the buffer. */ if (sc->txb_inuse == sc->txb_cnt) { - /* No room. Indicate this to the outside world and exit. */ - ifp->if_flags |= IFF_OACTIVE; + /* No room. */ return; } IFQ_DEQUEUE(&ifp->if_snd, m0); @@ -472,8 +468,7 @@ dp8390_start(struct ifnet *ifp) return; /* We need to use m->m_pkthdr.len, so require the header */ - if ((m0->m_flags & M_PKTHDR) == 0) - panic("dp8390_start: no header mbuf"); + KASSERT(m0->m_flags & M_PKTHDR); /* Tap off here if there is a BPF listener. */ bpf_mtap(ifp, m0, BPF_D_OUT); @@ -713,7 +708,6 @@ dp8390_intr(void *arg) /* Clear watchdog timer. */ ifp->if_timer = 0; - ifp->if_flags &= ~IFF_OACTIVE; /* * Add in total number of collisions on last diff --git a/sys/dev/ic/dwc_eqos.c b/sys/dev/ic/dwc_eqos.c index 0bbf36ec9bb..f7b83ac41c4 100644 --- a/sys/dev/ic/dwc_eqos.c +++ b/sys/dev/ic/dwc_eqos.c @@ -1,4 +1,4 @@ -/* $NetBSD: dwc_eqos.c,v 1.15 2022/08/28 08:40:56 skrll Exp $ */ +/* $NetBSD: dwc_eqos.c,v 1.16 2022/09/18 18:20:31 thorpej Exp $ */ /*- * Copyright (c) 2022 Jared McNeill <jmcneill@invisible.ca> @@ -33,7 +33,7 @@ #include "opt_net_mpsafe.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dwc_eqos.c,v 1.15 2022/08/28 08:40:56 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc_eqos.c,v 1.16 2022/09/18 18:20:31 thorpej Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -653,7 +653,6 @@ eqos_init_locked(struct eqos_softc *sc) eqos_enable_intr(sc); ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; mii_mediachg(mii); callout_schedule(&sc->sc_stat_ch, hz); @@ -731,7 +730,7 @@ eqos_stop_locked(struct eqos_softc *sc, int disable) /* Disable interrupts */ eqos_disable_intr(sc); - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + ifp->if_flags &= ~IFF_RUNNING; } static void @@ -924,8 +923,6 @@ eqos_txintr(struct eqos_softc *sc, int qid) i, i + 1, TX_DESC_COUNT, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); - ifp->if_flags &= ~IFF_OACTIVE; - /* Last descriptor in a packet contains DMA status */ if ((tdes3 & EQOS_TDES3_TX_LD) != 0) { if ((tdes3 & EQOS_TDES3_TX_DE) != 0) { @@ -961,12 +958,11 @@ eqos_start_locked(struct eqos_softc *sc) EQOS_ASSERT_TXLOCKED(sc); - if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) + if ((ifp->if_flags & IFF_RUNNING) == 0) return; for (cnt = 0, start = sc->sc_tx.cur; ; cnt++) { if (sc->sc_tx.queued >= TX_DESC_COUNT - TX_MAX_SEGS) { - ifp->if_flags |= IFF_OACTIVE; DPRINTF(EDEB_TXRING, "%u sc_tx.queued, ring full\n", sc->sc_tx.queued); break; @@ -980,11 +976,10 @@ eqos_start_locked(struct eqos_softc *sc) if (nsegs <= 0) { DPRINTF(EDEB_TXRING, "eqos_setup_txbuf failed " "with %d\n", nsegs); - if (nsegs == -1) { - ifp->if_flags |= IFF_OACTIVE; - } else if (nsegs == -2) { + if (nsegs == -2) { IFQ_DEQUEUE(&ifp->if_snd, m); m_freem(m); + continue; } break; } diff --git a/sys/dev/ic/dwc_gmac.c b/sys/dev/ic/dwc_gmac.c index b7b93dc786f..a8b07b71f07 100644 --- a/sys/dev/ic/dwc_gmac.c +++ b/sys/dev/ic/dwc_gmac.c @@ -1,4 +1,4 @@ -/* $NetBSD: dwc_gmac.c,v 1.77 2022/08/09 23:58:46 sekiya Exp $ */ +/* $NetBSD: dwc_gmac.c,v 1.78 2022/09/18 18:26:53 thorpej Exp $ */ /*- * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.77 2022/08/09 23:58:46 sekiya Exp $"); +__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.78 2022/09/18 18:26:53 thorpej Exp $"); /* #define DWC_GMAC_DEBUG 1 */ @@ -915,7 +915,7 @@ dwc_gmac_init_locked(struct ifnet *ifp) sc->sc_stopping = false; ifp->if_flags |= IFF_RUNNING; - ifp->if_flags &= ~IFF_OACTIVE; + sc->sc_txbusy = false; return 0; } @@ -945,7 +945,9 @@ dwc_gmac_start_locked(struct ifnet *ifp) int start = sc->sc_txq.t_cur; struct mbuf *m0; - if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) + if ((ifp->if_flags & IFF_RUNNING) == 0) + return; + if (sc->sc_txbusy) return; for (;;) { @@ -953,13 +955,13 @@ dwc_gmac_start_locked(struct ifnet *ifp) if (m0 == NULL) break; if (dwc_gmac_queue(sc, m0) != 0) { - ifp->if_flags |= IFF_OACTIVE; + sc->sc_txbusy = true; break; } IFQ_DEQUEUE(&ifp->if_snd, m0); bpf_mtap(ifp, m0, BPF_D_OUT); if (sc->sc_txq.t_queued == AWGE_TX_RING_COUNT) { - ifp->if_flags |= IFF_OACTIVE; + sc->sc_txbusy = true; break; } } @@ -1008,7 +1010,8 @@ dwc_gmac_stop_locked(struct ifnet *ifp, int disable) dwc_gmac_reset_tx_ring(sc, &sc->sc_txq); dwc_gmac_reset_rx_ring(sc, &sc->sc_rxq); - ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + ifp->if_flags &= ~IFF_RUNNING; + sc->sc_txbusy = false; } /* @@ -1213,7 +1216,7 @@ dwc_gmac_tx_intr(struct dwc_gmac_softc *sc) sc->sc_txq.t_next = i; if (sc->sc_txq.t_queued < AWGE_TX_RING_COUNT) { - ifp->if_flags &= ~IFF_OACTIVE; + sc->sc_txbusy = false; } mutex_exit(&sc->sc_txq.t_mtx); } diff --git a/sys/dev/ic/dwc_gmac_var.h b/sys/dev/ic/dwc_gmac_var.h index ee538cae565..2bfd5691412 100644 --- a/sys/dev/ic/dwc_gmac_var.h +++ b/sys/dev/ic/dwc_gmac_var.h @@ -1,4 +1,4 @@ -/* $NetBSD: dwc_gmac_var.h,v 1.16 2019/09/13 07:55:06 msaitoh Exp $ */ +/* $NetBSD: dwc_gmac_var.h,v 1.17 2022/09/18 18:26:53 thorpej Exp $ */ /*- * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc. @@ -122,6 +122,7 @@ struct dwc_gmac_softc { const struct dwc_gmac_desc_methods *sc_descm; u_short sc_if_flags; /* shadow of ether flags */ uint16_t sc_mii_clk; + bool sc_txbusy; bool sc_stopping; krndsource_t rnd_source; kmutex_t *sc_lock; /* lock for softc operations */ |
