Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Eliminate use of IFF_OACTIVE.



details:   https://anonhg.NetBSD.org/src/rev/6ba0132a6a4f
branches:  trunk
changeset: 370150:6ba0132a6a4f
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Sep 18 17:54:46 2022 +0000

description:
Eliminate use of IFF_OACTIVE.

diffstat:

 sys/dev/ic/dm9000.c       |  30 +++++++++++++-----------------
 sys/dev/ic/dp8390.c       |  18 ++++++------------
 sys/dev/ic/dwc_eqos.c     |  17 ++++++-----------
 sys/dev/ic/dwc_gmac.c     |  19 +++++++++++--------
 sys/dev/ic/dwc_gmac_var.h |   3 ++-
 5 files changed, 38 insertions(+), 49 deletions(-)

diffs (truncated from 313 to 300 lines):

diff -r 7e5d29cfdf47 -r 6ba0132a6a4f sys/dev/ic/dm9000.c
--- a/sys/dev/ic/dm9000.c       Sun Sep 18 17:21:18 2022 +0000
+++ b/sys/dev/ic/dm9000.c       Sun Sep 18 17:54:46 2022 +0000
@@ -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 @@
        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 @@
        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 @@
 {
        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 @@
        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 -r 7e5d29cfdf47 -r 6ba0132a6a4f sys/dev/ic/dp8390.c
--- a/sys/dev/ic/dp8390.c       Sun Sep 18 17:21:18 2022 +0000
+++ b/sys/dev/ic/dp8390.c       Sun Sep 18 17:54:46 2022 +0000
@@ -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 @@
 
        /* 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 @@
 
 /*
  * 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 @@
        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 @@
                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 @@
 
                        /* Clear watchdog timer. */
                        ifp->if_timer = 0;
-                       ifp->if_flags &= ~IFF_OACTIVE;
 
                        /*
                         * Add in total number of collisions on last
diff -r 7e5d29cfdf47 -r 6ba0132a6a4f sys/dev/ic/dwc_eqos.c
--- a/sys/dev/ic/dwc_eqos.c     Sun Sep 18 17:21:18 2022 +0000
+++ b/sys/dev/ic/dwc_eqos.c     Sun Sep 18 17:54:46 2022 +0000
@@ -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@localhost>
@@ -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_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 @@
        /* Disable interrupts */
        eqos_disable_intr(sc);
 
-       ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
+       ifp->if_flags &= ~IFF_RUNNING;
 }
 
 static void
@@ -924,8 +923,6 @@
                    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_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 @@
                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 -r 7e5d29cfdf47 -r 6ba0132a6a4f sys/dev/ic/dwc_gmac.c
--- a/sys/dev/ic/dwc_gmac.c     Sun Sep 18 17:21:18 2022 +0000
+++ b/sys/dev/ic/dwc_gmac.c     Sun Sep 18 17:54:46 2022 +0000
@@ -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 @@
        sc->sc_stopping = false;
 
        ifp->if_flags |= IFF_RUNNING;
-       ifp->if_flags &= ~IFF_OACTIVE;
+       sc->sc_txbusy = false;
 
        return 0;
 }
@@ -945,7 +945,9 @@
        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 @@
                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_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 @@
        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 -r 7e5d29cfdf47 -r 6ba0132a6a4f sys/dev/ic/dwc_gmac_var.h
--- a/sys/dev/ic/dwc_gmac_var.h Sun Sep 18 17:21:18 2022 +0000
+++ b/sys/dev/ic/dwc_gmac_var.h Sun Sep 18 17:54:46 2022 +0000
@@ -1,4 +1,4 @@



Home | Main Index | Thread Index | Old Index