Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Rearrange for script changes (scheduler core in m...



details:   https://anonhg.NetBSD.org/src/rev/67456fbcfce1
branches:  trunk
changeset: 498427:67456fbcfce1
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Mon Oct 23 14:56:16 2000 +0000

description:
Rearrange for script changes (scheduler core in main script, command part
of the scheduler in command table).
Add tagged command queuing support.

diffstat:

 sys/dev/ic/siop.c           |  831 +++++++++++++++++++++++--------------------
 sys/dev/ic/siop_common.c    |  131 ++++-
 sys/dev/ic/siopvar.h        |   12 +-
 sys/dev/ic/siopvar_common.h |   68 ++-
 4 files changed, 588 insertions(+), 454 deletions(-)

diffs (truncated from 1858 to 300 lines):

diff -r ecd2dca02208 -r 67456fbcfce1 sys/dev/ic/siop.c
--- a/sys/dev/ic/siop.c Mon Oct 23 14:54:50 2000 +0000
+++ b/sys/dev/ic/siop.c Mon Oct 23 14:56:16 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: siop.c,v 1.34 2000/10/21 13:56:17 bouyer Exp $ */
+/*     $NetBSD: siop.c,v 1.35 2000/10/23 14:56:16 bouyer Exp $ */
 
 /*
  * Copyright (c) 2000 Manuel Bouyer.
@@ -54,10 +54,13 @@
 #include <dev/ic/siopvar.h>
 #include <dev/ic/siopvar_common.h>
 
+#ifndef DEBUG
 #undef DEBUG
-#undef DEBUG_DR
-#undef DEBUG_INTR
-#undef DEBUG_SCHED
+#endif
+#undef SIOP_DEBUG
+#undef SIOP_DEBUG_DR
+#undef SIOP_DEBUG_INTR
+#undef SIOP_DEBUG_SCHED
 #undef DUMP_SCRIPT
 
 #define SIOP_STATS
@@ -69,6 +72,9 @@
 /* number of cmd descriptors per block */
 #define SIOP_NCMDPB (NBPG / sizeof(struct siop_xfer))
 
+/* Number of scheduler slot (needs to match script) */
+#define SIOP_NSLOTS 40
+
 void   siop_reset __P((struct siop_softc *));
 void   siop_handle_reset __P((struct siop_softc *));
 int    siop_handle_qtag_reject __P((struct siop_cmd *));
@@ -104,36 +110,13 @@
 static int siop_stat_intr_sdp = 0;
 static int siop_stat_intr_done = 0;
 static int siop_stat_intr_xferdisc = 0;
+static int siop_stat_intr_lunresel = 0;
 void siop_printstats __P((void));
 #define INCSTAT(x) x++
 #else
 #define INCSTAT(x) 
 #endif
 
-static __inline__ void siop_table_sync __P((struct siop_cmd *, int));
-static __inline__ void
-siop_table_sync(siop_cmd, ops)
-       struct siop_cmd *siop_cmd;
-       int ops;
-{
-       struct siop_softc *sc  = siop_cmd->siop_sc;
-       bus_addr_t offset;
-       
-       offset = siop_cmd->dsa -
-           siop_cmd->siop_cbdp->xferdma->dm_segs[0].ds_addr;
-       bus_dmamap_sync(sc->sc_dmat, siop_cmd->siop_cbdp->xferdma, offset,
-           sizeof(struct siop_xfer), ops);
-}
-
-static __inline__ void siop_sched_sync __P((struct siop_softc *, int));
-static __inline__ void
-siop_sched_sync(sc, ops)
-       struct siop_softc *sc;
-       int ops;
-{
-       bus_dmamap_sync(sc->sc_dmat, sc->sc_scheddma, 0, NBPG, ops);
-}
-
 static __inline__ void siop_script_sync __P((struct siop_softc *, int));
 static __inline__ void
 siop_script_sync(sc, ops)
@@ -144,11 +127,11 @@
                bus_dmamap_sync(sc->sc_dmat, sc->sc_scriptdma, 0, NBPG, ops);
 }
 
-static __inline__ u_int32_t siop_script_read __P((struct siop_softc *, int));
+static __inline__ u_int32_t siop_script_read __P((struct siop_softc *, u_int));
 static __inline__ u_int32_t
 siop_script_read(sc, offset)
        struct siop_softc *sc;
-       int offset;
+       u_int offset;
 {
        if (sc->features & SF_CHIP_RAM) {
                return bus_space_read_4(sc->sc_ramt, sc->sc_ramh, offset * 4);
@@ -157,12 +140,12 @@
        }
 }
 
-static __inline__ void siop_script_write __P((struct siop_softc *, int,
+static __inline__ void siop_script_write __P((struct siop_softc *, u_int,
        u_int32_t));
 static __inline__ void
 siop_script_write(sc, offset, val)
        struct siop_softc *sc;
-       int offset;
+       u_int offset;
        u_int32_t val;
 {
        if (sc->features & SF_CHIP_RAM) {
@@ -172,7 +155,6 @@
        }
 }
 
-
 void
 siop_attach(sc)
        struct siop_softc *sc;
@@ -182,8 +164,7 @@
        int rseg;
 
        /*
-        * Allocate DMA-safe memory for the script and script scheduler
-        * and map it.
+        * Allocate DMA-safe memory for the script and map it.
         */
        if ((sc->features & SF_CHIP_RAM) == 0) {
                error = bus_dmamem_alloc(sc->sc_dmat, NBPG, 
@@ -215,53 +196,21 @@
                        return;
                }
                sc->sc_scriptaddr = sc->sc_scriptdma->dm_segs[0].ds_addr;
-       }
-       error = bus_dmamem_alloc(sc->sc_dmat, NBPG, 
-           NBPG, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT);
-       if (error) {
-               printf("%s: unable to allocate scheduler DMA memory, "
-                   "error = %d\n", sc->sc_dev.dv_xname, error);
-               return;
-       }
-       error = bus_dmamem_map(sc->sc_dmat, &seg, rseg, NBPG,
-           (caddr_t *)&sc->sc_sched, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
-       if (error) {
-               printf("%s: unable to map scheduler DMA memory, error = %d\n",
-                   sc->sc_dev.dv_xname, error);
-               return;
-       }
-       error = bus_dmamap_create(sc->sc_dmat, NBPG, 1,
-           NBPG, 0, BUS_DMA_NOWAIT, &sc->sc_scheddma);
-       if (error) {
-               printf("%s: unable to create scheduler DMA map, error = %d\n",
-                   sc->sc_dev.dv_xname, error);
-               return;
-       }
-       error = bus_dmamap_load(sc->sc_dmat, sc->sc_scheddma, sc->sc_sched,
-           NBPG, NULL, BUS_DMA_NOWAIT);
-       if (error) {
-               printf("%s: unable to load scheduler DMA map, error = %d\n",
-                   sc->sc_dev.dv_xname, error);
-               return;
+               sc->ram_size = NBPG;
        }
        TAILQ_INIT(&sc->free_list);
        TAILQ_INIT(&sc->ready_list);
        TAILQ_INIT(&sc->cmds);
        TAILQ_INIT(&sc->lunsw_list);
-       /* compute number of scheduler slots */
-       sc->sc_nschedslots = (
-           NBPG /* memory size allocated for scheduler */
-           - sizeof(endslot_script) /* memory needed at end of scheduler */
-           ) / (sizeof(slot_script) - 8);
        sc->sc_currschedslot = 0;
-#ifdef DEBUG
-       printf("%s: script size = %d, PHY addr=0x%x, VIRT=%p nslots %d\n",
+#ifdef SIOP_DEBUG
+       printf("%s: script size = %d, PHY addr=0x%x, VIRT=%p\n",
            sc->sc_dev.dv_xname, (int)sizeof(siop_script),
-           (u_int32_t)sc->sc_scriptaddr, sc->sc_script, sc->sc_nschedslots);
+           (u_int32_t)sc->sc_scriptaddr, sc->sc_script);
 #endif
 
        sc->sc_link.adapter_softc = sc;
-       sc->sc_link.openings = 1;
+       sc->sc_link.openings = 2;
        sc->sc_link.scsipi_scsi.channel = SCSI_CHANNEL_ONLY_ONE;
        sc->sc_link.scsipi_scsi.max_target  =
            (sc->features & SF_BUS_WIDE) ? 15 : 7;
@@ -311,8 +260,6 @@
        struct siop_softc *sc;
 {
        int i, j;
-       u_int32_t *scr;
-       bus_addr_t physaddr;
        struct siop_lunsw *lunsw;
 
        siop_common_reset(sc);
@@ -322,14 +269,6 @@
                bus_space_write_region_4(sc->sc_ramt, sc->sc_ramh, 0,
                    siop_script, sizeof(siop_script) / sizeof(siop_script[0]));
                for (j = 0; j <
-                   (sizeof(E_script_abs_sched_Used) /
-                   sizeof(E_script_abs_sched_Used[0]));
-                   j++) {
-                       bus_space_write_4(sc->sc_ramt, sc->sc_ramh,
-                           E_script_abs_sched_Used[j] * 4,
-                           sc->sc_scheddma->dm_segs[0].ds_addr);
-               }
-               for (j = 0; j <
                    (sizeof(E_abs_msgin_Used) / sizeof(E_abs_msgin_Used[0]));
                    j++) {
                        bus_space_write_4(sc->sc_ramt, sc->sc_ramh,
@@ -342,55 +281,18 @@
                        sc->sc_script[j] = htole32(siop_script[j]);
                }
                for (j = 0; j <
-                   (sizeof(E_script_abs_sched_Used) /
-                   sizeof(E_script_abs_sched_Used[0]));
-                   j++) {
-                       sc->sc_script[E_script_abs_sched_Used[j]] =
-                           htole32(sc->sc_scheddma->dm_segs[0].ds_addr);
-               }
-               for (j = 0; j <
                    (sizeof(E_abs_msgin_Used) / sizeof(E_abs_msgin_Used[0]));
                    j++) {
                        sc->sc_script[E_abs_msgin_Used[j]] =
                            htole32(sc->sc_scriptaddr + Ent_msgin_space);
                }
        }
-       sc->ram_free = sizeof(siop_script) / sizeof(siop_script[0]);
-       /* copy and init the scheduler slots script */
-       for (i = 0; i < sc->sc_nschedslots; i++) {
-               scr = &sc->sc_sched[(Ent_nextslot / 4) * i];
-               physaddr = sc->sc_scheddma->dm_segs[0].ds_addr +
-                   Ent_nextslot * i;
-               for (j = 0; j < (Ent_nextslot / 4); j++) {
-                       scr[j] = htole32(slot_script[j]);
-               }
-               /*
-                * save current jump offset and patch MOVE MEMORY operands
-                * to restore it.
-                */
-               scr[(Ent_slotdata/4) + 1] = scr[(Ent_slot/4) + 1];
-               scr[E_slot_nextp_Used[0]] = htole32(physaddr + Ent_slot + 4);
-               scr[E_slot_sched_addrsrc_Used[0]] = htole32(physaddr +
-                   Ent_slotdata + 4);
-               /* JUMP selected, in main script */
-               scr[E_slot_abs_selected_Used[0]] =
-                  htole32(sc->sc_scriptaddr + Ent_selected);
-               /* JUMP addr if SELECT fail */
-               scr[E_slot_abs_reselect_Used[0]] = 
-                  htole32(sc->sc_scriptaddr + Ent_reselect);
-       }
-       /* Now the final JUMP */
-       scr = &sc->sc_sched[(Ent_nextslot / 4) * sc->sc_nschedslots];
-       for (j = 0; j < (sizeof(endslot_script) / sizeof(endslot_script[0]));
-           j++) {
-               scr[j] = htole32(endslot_script[j]);
-       }
-       scr[E_endslot_abs_reselect_Used[0]] = 
-           htole32(sc->sc_scriptaddr + Ent_reselect);
+       sc->script_free_lo = sizeof(siop_script) / sizeof(siop_script[0]);
+       sc->script_free_hi = sc->ram_size / 4;
 
        /* free used and unused lun switches */
        while((lunsw = TAILQ_FIRST(&sc->lunsw_list)) != NULL) {
-#ifdef DEBUG
+#ifdef SIOP_DEBUG
                printf("%s: free lunsw at offset %d\n",
                                sc->sc_dev.dv_xname, lunsw->lunsw_off);
 #endif
@@ -399,10 +301,10 @@
        }
        TAILQ_INIT(&sc->lunsw_list);
        /* restore reselect switch */
-       for (i = 0; i < sc->sc_link.scsipi_scsi.max_target; i++) {
+       for (i = 0; i <= sc->sc_link.scsipi_scsi.max_target; i++) {
                if (sc->targets[i] == NULL)
                        continue;
-#ifdef DEBUG
+#ifdef SIOP_DEBUG
                printf("%s: restore sw for target %d\n",
                                sc->sc_dev.dv_xname, i);
 #endif
@@ -421,7 +323,6 @@
                bus_dmamap_sync(sc->sc_dmat, sc->sc_scriptdma, 0, NBPG,
                    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
        }
-       siop_sched_sync(sc, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
        bus_space_write_4(sc->sc_rt, sc->sc_rh, SIOP_DSP,
            sc->sc_scriptaddr + Ent_reselect);
 }
@@ -448,13 +349,13 @@
        struct siop_cmd *siop_cmd;
        struct siop_lun *siop_lun;
        struct scsipi_xfer *xs;
-       int istat, sist0, sist1, sstat1, dstat;
+       int istat, sist, sstat1, dstat;
        u_int32_t irqcode;
        int need_reset = 0;
-       int freetarget = 0;
-       int offset, lun;
+       int offset, target, lun, tag;
        bus_addr_t dsa;
        struct siop_cbd *cbdp;
+       int freetarget = 0;
 
        istat = bus_space_read_1(sc->sc_rt, sc->sc_rh, SIOP_ISTAT);



Home | Main Index | Thread Index | Old Index