Source-Changes-HG archive

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

[src/thorpej_scsipi]: src/sys/dev/ic Convert to thorpej_scsipi interface. Sti...



details:   https://anonhg.NetBSD.org/src/rev/feed81a9a012
branches:  thorpej_scsipi
changeset: 477347:feed81a9a012
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Thu Dec 14 13:09:30 2000 +0000

description:
Convert to thorpej_scsipi interface. Still some work to do to get all benefits
of the new middle layer, but it works.

diffstat:

 sys/dev/ic/siop.c           |  393 +++++++++++++++++++++++++------------------
 sys/dev/ic/siop_common.c    |   84 ++------
 sys/dev/ic/siopvar.h        |    5 +-
 sys/dev/ic/siopvar_common.h |    7 +-
 4 files changed, 258 insertions(+), 231 deletions(-)

diffs (truncated from 887 to 300 lines):

diff -r e0e25ac1a792 -r feed81a9a012 sys/dev/ic/siop.c
--- a/sys/dev/ic/siop.c Wed Dec 13 18:29:06 2000 +0000
+++ b/sys/dev/ic/siop.c Thu Dec 14 13:09:30 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: siop.c,v 1.37.2.3 2000/11/22 16:03:30 bouyer Exp $     */
+/*     $NetBSD: siop.c,v 1.37.2.4 2000/12/14 13:09:30 bouyer Exp $     */
 
 /*
  * Copyright (c) 2000 Manuel Bouyer.
@@ -84,28 +84,14 @@
 void   siop_start __P((struct siop_softc *));
 void   siop_timeout __P((void *));
 int    siop_scsicmd __P((struct scsipi_xfer *));
+void   siop_scsipi_request __P(( struct scsipi_channel *,
+                       scsipi_adapter_req_t, void *));
 void   siop_dump_script __P((struct siop_softc *));
 int    siop_morecbd __P((struct siop_softc *));
 struct siop_lunsw *siop_get_lunsw __P((struct siop_softc *));
 void   siop_add_reselsw __P((struct siop_softc *, int));
 void   siop_update_scntl3 __P((struct siop_softc *, struct siop_target *));
 
-struct scsipi_adapter siop_adapter = {
-       0,
-       siop_scsicmd,
-       siop_minphys,
-       siop_ioctl,
-       NULL,
-       NULL,
-};
-
-struct scsipi_device siop_dev = {
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-};
-
 #ifdef SIOP_STATS
 static int siop_stat_intr = 0;
 static int siop_stat_intr_shortxfer = 0;
@@ -214,22 +200,24 @@
            (u_int32_t)sc->sc_scriptaddr, sc->sc_script);
 #endif
 
-       sc->sc_link.adapter_softc = sc;
-       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;
-       sc->sc_link.scsipi_scsi.max_lun = 7;
-       sc->sc_link.scsipi_scsi.adapter_target = bus_space_read_1(sc->sc_rt,
-           sc->sc_rh, SIOP_SCID);
-       if (sc->sc_link.scsipi_scsi.adapter_target == 0 ||
-           sc->sc_link.scsipi_scsi.adapter_target >
-           sc->sc_link.scsipi_scsi.max_target)
-               sc->sc_link.scsipi_scsi.adapter_target = SIOP_DEFAULT_TARGET;
-       sc->sc_link.type = BUS_SCSI;
-       sc->sc_link.adapter = &siop_adapter;
-       sc->sc_link.device = &siop_dev;
-       sc->sc_link.flags  = 0;
+       sc->sc_adapt.adapt_dev = &sc->sc_dev;
+       sc->sc_adapt.adapt_nchannels = 1;
+       sc->sc_adapt.adapt_openings = 225;
+       sc->sc_adapt.adapt_max_periph = 15;
+       sc->sc_adapt.adapt_ioctl = siop_ioctl;
+       sc->sc_adapt.adapt_minphys = minphys;
+       sc->sc_adapt.adapt_request = siop_scsipi_request;
+
+       memset(&sc->sc_chan, 0, sizeof(sc->sc_chan));
+       sc->sc_chan.chan_adapter = &sc->sc_adapt;
+       sc->sc_chan.chan_bustype = &scsi_bustype;
+       sc->sc_chan.chan_channel = 0;
+       sc->sc_chan.chan_ntargets = (sc->features & SF_BUS_WIDE) ? 16 : 8;
+       sc->sc_chan.chan_nluns = 8;
+       sc->sc_chan.chan_id = bus_space_read_1(sc->sc_rt, sc->sc_rh, SIOP_SCID);
+       if (sc->sc_chan.chan_id == 0 ||
+           sc->sc_chan.chan_id >= sc->sc_chan.chan_ntargets)
+               sc->sc_chan.chan_id = SIOP_DEFAULT_TARGET;
 
        for (i = 0; i < 16; i++)
                sc->targets[i] = NULL;
@@ -257,7 +245,7 @@
        siop_dump_script(sc);
 #endif
 
-       config_found((struct device*)sc, &sc->sc_link, scsiprint);
+       config_found((struct device*)sc, &sc->sc_chan, scsiprint);
 }
 
 void
@@ -306,7 +294,7 @@
        }
        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_chan.chan_ntargets; i++) {
                if (sc->targets[i] == NULL)
                        continue;
 #ifdef SIOP_DEBUG
@@ -389,8 +377,8 @@
        if (siop_cmd) {
                xs = siop_cmd->xs;
                siop_target = siop_cmd->siop_target;
-               target = siop_cmd->xs->sc_link->scsipi_scsi.target;
-               lun = siop_cmd->xs->sc_link->scsipi_scsi.lun;
+               target = siop_cmd->xs->xs_periph->periph_target;
+               lun = siop_cmd->xs->xs_periph->periph_lun;
                tag = siop_cmd->tag;
                siop_lun = siop_target->siop_lun[lun];
 #ifdef DIAGNOSTIC
@@ -485,7 +473,7 @@
                }
                if (sist & SIST0_SGE) {
                        if (siop_cmd)
-                               scsi_print_addr(xs->sc_link);
+                               scsipi_printaddr(xs->xs_periph);
                        else
                                printf("%s:", sc->sc_dev.dv_xname);
                        printf("scsi gross error\n");
@@ -549,7 +537,7 @@
                if (sist & SIST0_PAR) {
                        /* parity error, reset */
                        if (siop_cmd)
-                               scsi_print_addr(xs->sc_link);
+                               scsipi_printaddr(xs->xs_periph);
                        else
                                printf("%s:", sc->sc_dev.dv_xname);
                        printf("parity error\n");
@@ -725,7 +713,7 @@
                                if (msg == MSG_MESSAGE_REJECT) {
                                        /* MSG_REJECT  for a MSG_REJECT  !*/
                                        if (xs)
-                                               scsi_print_addr(xs->sc_link);
+                                               scsipi_printaddr(xs->xs_periph);
                                        else
                                                printf("%s: ",
                                                   sc->sc_dev.dv_xname);
@@ -736,12 +724,11 @@
                                if (msg == MSG_EXTENDED &&
                                    extmsg == MSG_EXT_WDTR) {
                                        /* WDTR rejected, initiate sync */
-                                       printf("%s: target %d using 8bit "
-                                           "transfers\n", sc->sc_dev.dv_xname,
-                                           target);
                                        if ((siop_target->flags & TARF_SYNC)
                                            == 0) {
                                                siop_target->status = TARST_OK;
+                                               siop_update_xfer_mode(sc,
+                                                   target);
                                                /* no table to flush here */
                                                CALL_SCRIPT(Ent_msgin_ack);
                                                return 1;
@@ -757,10 +744,10 @@
                                } else if (msg == MSG_EXTENDED &&
                                    extmsg == MSG_EXT_SDTR) {
                                        /* sync rejected */
-                                       printf("%s: target %d asynchronous\n",
-                                           sc->sc_dev.dv_xname,
-                                           target);
+                                       siop_target->offset = 0;
+                                       siop_target->period = 0;
                                        siop_target->status = TARST_OK;
+                                       siop_update_xfer_mode(sc, target);
                                        /* no table to flush here */
                                        CALL_SCRIPT(Ent_msgin_ack);
                                        return 1;
@@ -774,7 +761,7 @@
                                        return 1;
                                }
                                if (xs)
-                                       scsi_print_addr(xs->sc_link);
+                                       scsipi_printaddr(xs->xs_periph);
                                else
                                        printf("%s: ", sc->sc_dev.dv_xname);
                                if (msg == MSG_EXTENDED) {
@@ -789,7 +776,7 @@
                                return 1;
                        }
                        if (xs)
-                               scsi_print_addr(xs->sc_link);
+                               scsipi_printaddr(xs->xs_periph);
                        else
                                printf("%s: ", sc->sc_dev.dv_xname);
                        printf("unhandled message 0x%x\n",
@@ -987,7 +974,7 @@
        case SCSI_QUEUE_FULL:
                {
                struct siop_lun *siop_lun = siop_cmd->siop_target->siop_lun[
-                   xs->sc_link->scsipi_scsi.lun];
+                   xs->xs_periph->periph_lun];
                /*
                 * device didn't queue the command. We have to
                 * retry it.
@@ -1000,8 +987,8 @@
                INCSTAT(siop_stat_intr_qfull);
 #ifdef SIOP_DEBUG
                printf("%s:%d:%d: queue full (tag %d)\n", sc->sc_dev.dv_xname,
-                   xs->sc_link->scsipi_scsi.target,
-                   xs->sc_link->scsipi_scsi.lun, siop_cmd->tag);
+                   xs->xs_periph->periph_target,
+                   xs->xs_periph->periph_lun, siop_cmd->tag);
 #endif
                callout_stop(&xs->xs_callout);
                siop_lun->lun_flags |= SIOP_LUNF_FULL;
@@ -1038,7 +1025,7 @@
                /* issue a request sense for this target */
                int error;
                siop_cmd->rs_cmd.opcode = REQUEST_SENSE;
-               siop_cmd->rs_cmd.byte2 = xs->sc_link->scsipi_scsi.lun << 5;
+               siop_cmd->rs_cmd.byte2 = xs->xs_periph->periph_lun << 5;
                siop_cmd->rs_cmd.unused[0] = siop_cmd->rs_cmd.unused[1] = 0;
                siop_cmd->rs_cmd.length = sizeof(struct scsipi_sense_data);
                siop_cmd->rs_cmd.control = 0;
@@ -1094,8 +1081,8 @@
        struct siop_cmd *siop_cmd;
 {
        struct siop_softc *sc = siop_cmd->siop_sc;
-       int target = siop_cmd->xs->sc_link->scsipi_scsi.target;
-       int lun = siop_cmd->xs->sc_link->scsipi_scsi.lun;
+       int target = siop_cmd->xs->xs_periph->periph_target;
+       int lun = siop_cmd->xs->xs_periph->periph_lun;
        int tag = siop_cmd->siop_tables.msg_out[2];
        struct siop_lun *siop_lun = sc->targets[target]->siop_lun[lun];
 
@@ -1151,7 +1138,7 @@
        /*
         * Process all commands: first commmands being executed
         */
-       for (target = 0; target <= sc->sc_link.scsipi_scsi.max_target;
+       for (target = 0; target < sc->sc_chan.chan_ntargets;
            target++) {
                if (sc->targets[target] == NULL)
                        continue;
@@ -1175,6 +1162,7 @@
                }
                sc->targets[target]->status = TARST_ASYNC;
                sc->targets[target]->flags &= ~TARF_ISWIDE;
+               sc->targets[target]->period = sc->targets[target]->offset = 0;
        }
        /* Next commands from the urgent list */
        for (siop_cmd = TAILQ_FIRST(&sc->urgent_list); siop_cmd != NULL;
@@ -1182,8 +1170,8 @@
                next_siop_cmd = TAILQ_NEXT(siop_cmd, next);
                siop_cmd->flags &= ~CMDFL_TAG;
                printf("cmd %p (target %d:%d) in reset list (wait)\n",
-                   siop_cmd, siop_cmd->xs->sc_link->scsipi_scsi.target,
-                   siop_cmd->xs->sc_link->scsipi_scsi.lun);
+                   siop_cmd, siop_cmd->xs->xs_periph->periph_target,
+                   siop_cmd->xs->xs_periph->periph_lun);
                TAILQ_REMOVE(&sc->urgent_list, siop_cmd, next);
                TAILQ_INSERT_TAIL(&reset_list, siop_cmd, next);
        }
@@ -1193,8 +1181,8 @@
                next_siop_cmd = TAILQ_NEXT(siop_cmd, next);
                siop_cmd->flags &= ~CMDFL_TAG;
                printf("cmd %p (target %d:%d) in reset list (wait)\n",
-                   siop_cmd, siop_cmd->xs->sc_link->scsipi_scsi.target,
-                   siop_cmd->xs->sc_link->scsipi_scsi.lun);
+                   siop_cmd, siop_cmd->xs->xs_periph->periph_target,
+                   siop_cmd->xs->xs_periph->periph_lun);
                TAILQ_REMOVE(&sc->ready_list, siop_cmd, next);
                TAILQ_INSERT_TAIL(&reset_list, siop_cmd, next);
        }
@@ -1218,137 +1206,185 @@
        }
 }
 
-int
-siop_scsicmd(xs)
+void
+siop_scsipi_request(chan, req, arg)
+       struct scsipi_channel *chan;
+       scsipi_adapter_req_t req;
+       void *arg;
+{
        struct scsipi_xfer *xs;
-{
-       struct siop_softc *sc = (struct siop_softc *)xs->sc_link->adapter_softc;
+       struct scsipi_periph *periph;
+       struct siop_softc *sc = (void *)chan->chan_adapter->adapt_dev;
        struct siop_cmd *siop_cmd;
        int s, error, i;
-       const int target = xs->sc_link->scsipi_scsi.target;
-       const int lun = xs->sc_link->scsipi_scsi.lun;
+       int target;
+       int lun;
 
-       s = splbio();
+       switch (req) {
+       case ADAPTER_REQ_RUN_XFER:
+               xs = arg;
+               periph = xs->xs_periph;
+               target = periph->periph_target;
+               lun = periph->periph_lun;
+
+               s = splbio();
 #ifdef SIOP_DEBUG_SCHED
-       printf("starting cmd for %d:%d\n", target, lun);
+               printf("starting cmd for %d:%d\n", target, lun);
 #endif



Home | Main Index | Thread Index | Old Index