Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sgimips/hpc Remove the static sq_trace array and ma...



details:   https://anonhg.NetBSD.org/src/rev/e1fe6fa10144
branches:  trunk
changeset: 572295:e1fe6fa10144
user:      rumble <rumble%NetBSD.org@localhost>
date:      Wed Dec 29 02:11:31 2004 +0000

description:
Remove the static sq_trace array and make it per-device as
multiple seeq interfaces may exist. While here, add a few trace
actions, move the related macros into sqvar.h, and enhance the
sq_trace_dump output a bit.

diffstat:

 sys/arch/sgimips/hpc/if_sq.c |  96 ++++++++++++++++++-------------------------
 sys/arch/sgimips/hpc/sqvar.h |  37 ++++++++++++++++-
 2 files changed, 76 insertions(+), 57 deletions(-)

diffs (271 lines):

diff -r 35ffb04e58bd -r e1fe6fa10144 sys/arch/sgimips/hpc/if_sq.c
--- a/sys/arch/sgimips/hpc/if_sq.c      Wed Dec 29 01:55:25 2004 +0000
+++ b/sys/arch/sgimips/hpc/if_sq.c      Wed Dec 29 02:11:31 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sq.c,v 1.21 2004/10/30 18:08:35 thorpej Exp $       */
+/*     $NetBSD: if_sq.c,v 1.22 2004/12/29 02:11:31 rumble Exp $        */
 
 /*
  * Copyright (c) 2001 Rafal K. Boni
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sq.c,v 1.21 2004/10/30 18:08:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sq.c,v 1.22 2004/12/29 02:11:31 rumble Exp $");
 
 #include "bpfilter.h"
 
@@ -116,43 +116,10 @@
 static void    sq_reset(struct sq_softc *);
 static int     sq_add_rxbuf(struct sq_softc *, int);
 static void    sq_dump_buffer(u_int32_t addr, u_int32_t len);
+static void    sq_trace_dump(struct sq_softc *);
 
 static void    enaddr_aton(const char*, u_int8_t*);
 
-/* Actions */
-#define SQ_RESET               1
-#define SQ_ADD_TO_DMA          2
-#define SQ_START_DMA           3
-#define SQ_DONE_DMA            4
-#define SQ_RESTART_DMA         5
-#define SQ_TXINTR_ENTER                6
-#define SQ_TXINTR_EXIT         7
-#define SQ_TXINTR_BUSY         8
-
-struct sq_action_trace {
-       int action;
-       int bufno;
-       int status;
-       int freebuf;
-};
-
-#define SQ_TRACEBUF_SIZE       100
-int sq_trace_idx = 0;
-struct sq_action_trace sq_trace[SQ_TRACEBUF_SIZE];
-
-void sq_trace_dump(struct sq_softc* sc);
-
-#define SQ_TRACE(act, buf, stat, free) do {                            \
-       sq_trace[sq_trace_idx].action = (act);                          \
-       sq_trace[sq_trace_idx].bufno = (buf);                           \
-       sq_trace[sq_trace_idx].status = (stat);                         \
-       sq_trace[sq_trace_idx].freebuf = (free);                        \
-       if (++sq_trace_idx == SQ_TRACEBUF_SIZE) {                       \
-               memset(&sq_trace, 0, sizeof(sq_trace));                 \
-               sq_trace_idx = 0;                                       \
-       }                                                               \
-} while (0)
-
 CFATTACH_DECL(sq, sizeof(struct sq_softc),
     sq_match, sq_attach, NULL, NULL);
 
@@ -315,7 +282,7 @@
        if_attach(ifp);
        ether_ifattach(ifp, sc->sc_enaddr);
 
-       memset(&sq_trace, 0, sizeof(sq_trace));
+       memset(&sc->sq_trace, 0, sizeof(sc->sq_trace));
        /* Done! */
        return;
 
@@ -368,7 +335,7 @@
        sc->sc_nfreetx = SQ_NTXDESC;
        sc->sc_nexttx = sc->sc_prevtx = 0;
 
-       SQ_TRACE(SQ_RESET, 0, 0, sc->sc_nfreetx);
+       SQ_TRACE(SQ_RESET, sc, 0, 0);
 
        /* Set into 8003 mode, bank 0 to program ethernet address */
        bus_space_write_1(sc->sc_regt, sc->sc_regh, SEEQ_TXCMD, TXCMD_BANK0);
@@ -472,6 +439,8 @@
 {
        int s, error = 0;
 
+       SQ_TRACE(SQ_IOCTL, (struct sq_softc *)ifp->if_softc, 0, 0);
+
        s = splnet();
 
        error = ether_ioctl(ifp, cmd, data);
@@ -611,6 +580,8 @@
                 * WE ARE NOW COMMITTED TO TRANSMITTING THE PACKET.
                 */
 
+               SQ_TRACE(SQ_ENQUEUE, sc, sc->sc_nexttx, 0);
+
                /* Sync the DMA map. */
                bus_dmamap_sync(sc->sc_dmat, dmamap, 0, dmamap->dm_mapsize,
                    BUS_DMASYNC_PREWRITE);
@@ -729,8 +700,7 @@
                                sc->hpc_regs->enetx_ctl);
 
                if ((status & sc->hpc_regs->enetx_ctl_active) != 0) {
-                       SQ_TRACE(SQ_ADD_TO_DMA, firsttx, status,
-                           sc->sc_nfreetx);
+                       SQ_TRACE(SQ_ADD_TO_DMA, sc, firsttx, status);
 
                        /* NB: hpc3_hdd_ctl is also hpc1_hdd_bufptr */
                        sc->sc_txdesc[SQ_PREVTX(firsttx)].hpc3_hdd_ctl &=
@@ -739,7 +709,7 @@
                        SQ_CDTXSYNC(sc, SQ_PREVTX(firsttx),  1,
                            BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
                } else {
-                       SQ_TRACE(SQ_START_DMA, firsttx, status, sc->sc_nfreetx);
+                       SQ_TRACE(SQ_START_DMA, sc, firsttx, status);
 
                        bus_space_write_4(sc->sc_hpct, sc->sc_hpch,
                            sc->hpc_regs->enetx_ndbp, SQ_CDTXADDR(sc, firsttx));
@@ -801,23 +771,39 @@
 
        sq_trace_dump(sc);
 
-       memset(&sq_trace, 0, sizeof(sq_trace));
-       sq_trace_idx = 0;
+       memset(&sc->sq_trace, 0, sizeof(sc->sq_trace));
+       sc->sq_trace_idx = 0;
 
        ++ifp->if_oerrors;
 
        sq_init(ifp);
 }
 
-void sq_trace_dump(struct sq_softc* sc)
+static void
+sq_trace_dump(struct sq_softc *sc)
 {
        int i;
+       char *act;
 
-       for(i = 0; i < sq_trace_idx; i++) {
-               printf("%s: [%d] action %d, buf %d, free %d, status %08x\n",
-                       sc->sc_dev.dv_xname, i, sq_trace[i].action,
-                       sq_trace[i].bufno, sq_trace[i].freebuf,
-                       sq_trace[i].status);
+       for (i = 0; i < sc->sq_trace_idx; i++) {
+               switch (sc->sq_trace[i].action) {
+               case SQ_RESET:          act = "SQ_RESET";               break;
+               case SQ_ADD_TO_DMA:     act = "SQ_ADD_TO_DMA";          break;
+               case SQ_START_DMA:      act = "SQ_START_DMA";           break;
+               case SQ_DONE_DMA:       act = "SQ_DONE_DMA";            break; 
+               case SQ_RESTART_DMA:    act = "SQ_RESTART_DMA";         break;
+               case SQ_TXINTR_ENTER:   act = "SQ_TXINTR_ENTER";        break;
+               case SQ_TXINTR_EXIT:    act = "SQ_TXINTR_EXIT";         break;
+               case SQ_TXINTR_BUSY:    act = "SQ_TXINTR_BUSY";         break;
+               case SQ_IOCTL:          act = "SQ_IOCTL";               break;
+               case SQ_ENQUEUE:        act = "SQ_ENQUEUE";             break;
+               default:                act = "UNKNOWN";
+               }
+
+               printf("%s: [%03d] action %-16s buf %03d free %03d "
+                   "status %08x line %d\n", sc->sc_dev.dv_xname, i, act,
+                   sc->sq_trace[i].bufno, sc->sq_trace[i].freebuf,
+                   sc->sq_trace[i].status, sc->sq_trace[i].line);
        }
 }
 
@@ -1008,7 +994,7 @@
        status = bus_space_read_4(sc->sc_hpct, sc->sc_hpch,
                                  sc->hpc_regs->enetx_ctl) >> shift;
 
-       SQ_TRACE(SQ_TXINTR_ENTER, sc->sc_prevtx, status, sc->sc_nfreetx);
+       SQ_TRACE(SQ_TXINTR_ENTER, sc, sc->sc_prevtx, status);
 
        if ((status & ( (sc->hpc_regs->enetx_ctl_active >> shift) | TXSTAT_GOOD)) == 0) {
 /* XXX */ printf("txstat: %x\n", status);
@@ -1060,8 +1046,7 @@
                
                if (hpc3_not_ready == 0 || hpc1_ready == 2) {
                        if ((status & (sc->hpc_regs->enetx_ctl_active >> shift)) == 0) { // XXX
-                               SQ_TRACE(SQ_RESTART_DMA, i, status,
-                                   sc->sc_nfreetx);
+                               SQ_TRACE(SQ_RESTART_DMA, sc, i, status);
 
                                bus_space_write_4(sc->sc_hpct, sc->sc_hpch,
                                  sc->hpc_regs->enetx_ndbp, SQ_CDTXADDR(sc, i));
@@ -1084,8 +1069,7 @@
                                 */
                                ifp->if_timer = 5;
                        } else {
-                               SQ_TRACE(SQ_TXINTR_BUSY, i, status,
-                                   sc->sc_nfreetx);
+                               SQ_TRACE(SQ_TXINTR_BUSY, sc, i, status);
                        }
                        break;
                }
@@ -1101,7 +1085,7 @@
                ifp->if_opackets++;
                sc->sc_nfreetx++;
 
-               SQ_TRACE(SQ_DONE_DMA, i, status, sc->sc_nfreetx);
+               SQ_TRACE(SQ_DONE_DMA, sc, i, status);
                i = SQ_NEXTTX(i);
        }
 
@@ -1116,7 +1100,7 @@
        if (sc->sc_nfreetx == SQ_NTXDESC)
                ifp->if_timer = 0;
 
-       SQ_TRACE(SQ_TXINTR_EXIT, sc->sc_prevtx, status, sc->sc_nfreetx);
+       SQ_TRACE(SQ_TXINTR_EXIT, sc, sc->sc_prevtx, status);
        sq_start(ifp);
 
        return 1;
diff -r 35ffb04e58bd -r e1fe6fa10144 sys/arch/sgimips/hpc/sqvar.h
--- a/sys/arch/sgimips/hpc/sqvar.h      Wed Dec 29 01:55:25 2004 +0000
+++ b/sys/arch/sgimips/hpc/sqvar.h      Wed Dec 29 02:11:31 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sqvar.h,v 1.5 2003/12/30 23:48:07 sekiya Exp $ */
+/*     $NetBSD: sqvar.h,v 1.6 2004/12/29 02:11:31 rumble Exp $ */
 
 /*
  * Copyright (c) 2001 Rafal K. Boni
@@ -75,6 +75,38 @@
 #define        SQ_TYPE_8003            0
 #define        SQ_TYPE_80C03           1
 
+/* Trace Actions */
+#define SQ_RESET               1
+#define SQ_ADD_TO_DMA          2
+#define SQ_START_DMA           3
+#define SQ_DONE_DMA            4
+#define SQ_RESTART_DMA         5
+#define SQ_TXINTR_ENTER                6
+#define SQ_TXINTR_EXIT         7
+#define SQ_TXINTR_BUSY         8
+#define SQ_IOCTL               9
+#define SQ_ENQUEUE             10
+
+struct sq_action_trace {
+       int action;
+       int line;
+       int bufno;
+       int status;
+       int freebuf;
+};
+
+#define SQ_TRACEBUF_SIZE       100
+
+#define SQ_TRACE(act, sc, buf, stat) do {                              \
+       (sc)->sq_trace[(sc)->sq_trace_idx].action = (act);              \
+       (sc)->sq_trace[(sc)->sq_trace_idx].line = __LINE__;             \
+       (sc)->sq_trace[(sc)->sq_trace_idx].bufno = (buf);               \
+       (sc)->sq_trace[(sc)->sq_trace_idx].status = (stat);             \
+       (sc)->sq_trace[(sc)->sq_trace_idx].freebuf = (sc)->sc_nfreetx;  \
+       if (++(sc)->sq_trace_idx == SQ_TRACEBUF_SIZE)                   \
+               (sc)->sq_trace_idx = 0;                                 \
+} while (0)
+
 struct sq_softc {
        struct device           sc_dev;
 
@@ -128,6 +160,9 @@
        rndsource_element_t     rnd_source;     /* random source */
 #endif
        struct hpc_values       *hpc_regs;      /* HPC register definitions */
+
+       int                     sq_trace_idx;
+       struct sq_action_trace  sq_trace[SQ_TRACEBUF_SIZE];
 };
 
 #define        SQ_CDTXADDR(sc, x)      ((sc)->sc_cddma + SQ_CDTXOFF((x)))



Home | Main Index | Thread Index | Old Index