Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Revert this to 1.205, undoing changes apparently ...



details:   https://anonhg.NetBSD.org/src/rev/6a3ff4f4b6d1
branches:  trunk
changeset: 368743:6a3ff4f4b6d1
user:      kre <kre%NetBSD.org@localhost>
date:      Mon Aug 01 10:30:28 2022 +0000

description:
Revert this to 1.205, undoing changes apparently mistakenly
committed in 1.206, and the total disaster that the attempt to
revert those in 1.207 created.

diffstat:

 sys/dev/ic/tulip.c |  1103 ++++++++++++++++++++++++++-------------------------
 1 files changed, 558 insertions(+), 545 deletions(-)

diffs (truncated from 3037 to 300 lines):

diff -r ab60c2cef77e -r 6a3ff4f4b6d1 sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c        Mon Aug 01 08:09:30 2022 +0000
+++ b/sys/dev/ic/tulip.c        Mon Aug 01 10:30:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulip.c,v 1.207 2022/08/01 07:37:18 mlelstv Exp $      */
+/*     $NetBSD: tulip.c,v 1.208 2022/08/01 10:30:28 kre Exp $  */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -36,9 +36,8 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.207 2022/08/01 07:37:18 mlelstv Exp $");
-
-#include "bpfilter.h"
+__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.208 2022/08/01 10:30:28 kre Exp $");
+
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -53,16 +52,12 @@
 
 #include <machine/endian.h>
 
-#include <uvm/uvm_extern.h>
-
 #include <net/if.h>
 #include <net/if_dl.h>
 #include <net/if_media.h>
 #include <net/if_ether.h>
 
-#if NBPFILTER > 0
 #include <net/bpf.h>
-#endif
 
 #include <sys/bus.h>
 #include <sys/intr.h>
@@ -74,7 +69,7 @@
 #include <dev/ic/tulipreg.h>
 #include <dev/ic/tulipvar.h>
 
-const char * const tlp_chip_names[] = TULIP_CHIP_NAMES;
+static const char * const tlp_chip_names[] = TULIP_CHIP_NAMES;
 
 static const struct tulip_txthresh_tab tlp_10_txthresh_tab[] =
     TLP_TXTHRESH_TAB_10;
@@ -82,9 +77,6 @@
 static const struct tulip_txthresh_tab tlp_10_100_txthresh_tab[] =
     TLP_TXTHRESH_TAB_10_100;
 
-static const struct tulip_txthresh_tab tlp_winb_txthresh_tab[] =
-    TLP_TXTHRESH_TAB_WINB;
-
 static const struct tulip_txthresh_tab tlp_dm9102_txthresh_tab[] =
     TLP_TXTHRESH_TAB_DM9102;
 
@@ -112,21 +104,21 @@
 static void    tlp_txintr(struct tulip_softc *);
 
 static void    tlp_mii_tick(void *);
-static void    tlp_mii_statchg(device_t);
-static void    tlp_winb_mii_statchg(device_t);
-static void    tlp_dm9102_mii_statchg(device_t);
+static void    tlp_mii_statchg(struct ifnet *);
+static void    tlp_winb_mii_statchg(struct ifnet *);
+static void    tlp_dm9102_mii_statchg(struct ifnet *);
 
 static void    tlp_mii_getmedia(struct tulip_softc *, struct ifmediareq *);
 static int     tlp_mii_setmedia(struct tulip_softc *);
 
-static int     tlp_bitbang_mii_readreg(device_t, int, int);
-static void    tlp_bitbang_mii_writereg(device_t, int, int, int);
-
-static int     tlp_pnic_mii_readreg(device_t, int, int);
-static void    tlp_pnic_mii_writereg(device_t, int, int, int);
-
-static int     tlp_al981_mii_readreg(device_t, int, int);
-static void    tlp_al981_mii_writereg(device_t, int, int, int);
+static int     tlp_bitbang_mii_readreg(device_t, int, int, uint16_t *);
+static int     tlp_bitbang_mii_writereg(device_t, int, int, uint16_t);
+
+static int     tlp_pnic_mii_readreg(device_t, int, int, uint16_t *);
+static int     tlp_pnic_mii_writereg(device_t, int, int, uint16_t);
+
+static int     tlp_al981_mii_readreg(device_t, int, int, uint16_t *);
+static int     tlp_al981_mii_writereg(device_t, int, int, uint16_t);
 
 static void    tlp_2114x_preinit(struct tulip_softc *);
 static void    tlp_2114x_mii_preinit(struct tulip_softc *);
@@ -276,7 +268,7 @@
         */
        switch (sc->sc_chip) {
        case TULIP_CHIP_X3201_3:
-               sc->sc_setup_fsls = TDCTL_Tx_FS|TDCTL_Tx_LS;
+               sc->sc_setup_fsls = TDCTL_Tx_FS | TDCTL_Tx_LS;
                break;
 
        default:
@@ -399,16 +391,16 @@
        if ((error = bus_dmamem_alloc(sc->sc_dmat,
            sizeof(struct tulip_control_data), PAGE_SIZE, 0, &sc->sc_cdseg,
            1, &sc->sc_cdnseg, 0)) != 0) {
-               aprint_error_dev(self, "unable to allocate control data, error = %d\n",
-                   error);
+               aprint_error_dev(self,
+                   "unable to allocate control data, error = %d\n", error);
                goto fail_0;
        }
 
        if ((error = bus_dmamem_map(sc->sc_dmat, &sc->sc_cdseg, sc->sc_cdnseg,
            sizeof(struct tulip_control_data), (void **)&sc->sc_control_data,
            BUS_DMA_COHERENT)) != 0) {
-               aprint_error_dev(self, "unable to map control data, error = %d\n",
-                   error);
+               aprint_error_dev(self,
+                   "unable to map control data, error = %d\n", error);
                goto fail_1;
        }
 
@@ -416,15 +408,17 @@
            sizeof(struct tulip_control_data), 1,
            sizeof(struct tulip_control_data), 0, 0, &sc->sc_cddmamap)) != 0) {
                sc->sc_cddmamap = NULL;
-               aprint_error_dev(self, "unable to create control data DMA map, "
-                   "error = %d\n", error);
+               aprint_error_dev(self,
+                   "unable to create control data DMA map, error = %d\n",
+                   error);
                goto fail_2;
        }
 
        if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_cddmamap,
            sc->sc_control_data, sizeof(struct tulip_control_data), NULL,
            0)) != 0) {
-               aprint_error_dev(self, "unable to load control data DMA map, error = %d\n",
+               aprint_error_dev(self,
+                   "unable to load control data DMA map, error = %d\n",
                    error);
                goto fail_3;
        }
@@ -457,8 +451,9 @@
                    sc->sc_ntxsegs, MCLBYTES, 0, 0,
                    &sc->sc_txsoft[i].txs_dmamap)) != 0) {
                        sc->sc_txsoft[i].txs_dmamap = NULL;
-                       aprint_error_dev(self, "unable to create tx DMA map %d, "
-                           "error = %d\n", i, error);
+                       aprint_error_dev(self,
+                           "unable to create tx DMA map %d, error = %d\n", i,
+                           error);
                        goto fail_4;
                }
        }
@@ -469,9 +464,10 @@
        for (i = 0; i < TULIP_NRXDESC; i++) {
                if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1,
                    MCLBYTES, 0, 0, &sc->sc_rxsoft[i].rxs_dmamap)) != 0) {
-                       sc->sc_rxsoft[i].rxs_dmamap = NULL;
-                       aprint_error_dev(self, "unable to create rx DMA map %d, "
-                           "error = %d\n", i, error);
+                       sc->sc_rxsoft[i].rxs_dmamap = NULL;
+                       aprint_error_dev(self,
+                           "unable to create rx DMA map %d, error = %d\n", i,
+                           error);
                        goto fail_5;
                }
                sc->sc_rxsoft[i].rxs_mbuf = NULL;
@@ -528,12 +524,12 @@
         * Attach the interface.
         */
        if_attach(ifp);
+       if_deferred_start_init(ifp, NULL);
        ether_ifattach(ifp, enaddr);
        ether_set_ifflags_cb(&sc->sc_ethercom, tlp_ifflags_cb);
-#if NRND > 0
+
        rnd_attach_source(&sc->sc_rnd_source, device_xname(self),
-           RND_TYPE_NET, 0);
-#endif
+           RND_TYPE_NET, RND_FLAG_DEFAULT);
 
        if (pmf_device_register(self, NULL, NULL))
                pmf_class_network_register(self, ifp);
@@ -579,24 +575,14 @@
 tlp_activate(device_t self, enum devact act)
 {
        struct tulip_softc *sc = device_private(self);
-       int s, error = 0;
-
-       s = splnet();
+
        switch (act) {
-       case DVACT_ACTIVATE:
-               error = EOPNOTSUPP;
-               break;
-
        case DVACT_DEACTIVATE:
-               if (sc->sc_flags & TULIPF_HAS_MII)
-                       mii_activate(&sc->sc_mii, act, MII_PHY_ANY,
-                           MII_OFFSET_ANY);
                if_deactivate(&sc->sc_ethercom.ec_if);
-               break;
+               return 0;
+       default:
+               return EOPNOTSUPP;
        }
-       splx(s);
-
-       return (error);
 }
 
 /*
@@ -611,32 +597,36 @@
        struct tulip_rxsoft *rxs;
        struct tulip_txsoft *txs;
        device_t self = sc->sc_dev;
-       int i;
+       int i, s;
 
        /*
         * Succeed now if there isn't any work to do.
         */
        if ((sc->sc_flags & TULIPF_ATTACHED) == 0)
-               return (0);
-
-       /* Unhook our tick handler. */
-       if (sc->sc_tick)
-               callout_stop(&sc->sc_tick_callout);
+               return 0;
+
+       s = splnet();
+       /* Stop the interface. Callouts are stopped in it. */
+       tlp_stop(ifp, 1);
+       splx(s);
+
+       /* Destroy our callouts. */
+       callout_destroy(&sc->sc_nway_callout);
+       callout_destroy(&sc->sc_tick_callout);
 
        if (sc->sc_flags & TULIPF_HAS_MII) {
                /* Detach all PHYs */
                mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
        }
 
-       /* Delete all remaining media. */
-       ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
-
-#if NRND > 0
        rnd_detach_source(&sc->sc_rnd_source);
-#endif
+
        ether_ifdetach(ifp);
        if_detach(ifp);
 
+       /* Delete all remaining media. */
+       ifmedia_fini(&sc->sc_mii.mii_media);
+
        for (i = 0; i < TULIP_NRXDESC; i++) {
                rxs = &sc->sc_rxsoft[i];
                if (rxs->rxs_mbuf != NULL) {
@@ -666,7 +656,7 @@
        if (sc->sc_srom)
                free(sc->sc_srom, M_DEVBUF);
 
-       return (0);
+       return 0;
 }
 
 /*
@@ -682,6 +672,7 @@
        struct tulip_txsoft *txs, *last_txs = NULL;
        bus_dmamap_t dmamap;
        int error, firsttx, nexttx, lasttx = 1, ofree, seg;
+       struct tulip_desc *txd;
 
        DPRINTF(sc, ("%s: tlp_start: sc_flags 0x%08x, if_flags 0x%08x\n",
            device_xname(sc->sc_dev), sc->sc_flags, ifp->if_flags));
@@ -692,9 +683,9 @@
         * itself into the ring.
         */
        if (sc->sc_flags & TULIPF_WANT_SETUP)
-               ifp->if_flags |= IFF_OACTIVE;
-
-       if ((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING)
+               return;
+
+       if ((ifp->if_flags & IFF_RUNNING) != IFF_RUNNING)
                return;
 
        if (sc->sc_tick == tlp_2114x_nway_tick &&
@@ -742,7 +733,7 @@
                 */
                if ((sc->sc_ntxsegs == 1 && (mtod(m0, uintptr_t) & 3) != 0) ||
                    bus_dmamap_load_mbuf(sc->sc_dmat, dmamap, m0,
-                     BUS_DMA_WRITE|BUS_DMA_NOWAIT) != 0) {
+                     BUS_DMA_WRITE | BUS_DMA_NOWAIT) != 0) {
                        MGETHDR(m, M_DONTWAIT, MT_DATA);
                        if (m == NULL) {
                                aprint_error_dev(sc->sc_dev, "unable to allocate Tx mbuf\n");
@@ -761,7 +752,7 @@



Home | Main Index | Thread Index | Old Index