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 Port to thorpej_scsipi.



details:   https://anonhg.NetBSD.org/src/rev/f852b92c7425
branches:  thorpej_scsipi
changeset: 477485:f852b92c7425
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Mon Apr 23 13:41:43 2001 +0000

description:
Port to thorpej_scsipi.
XXX SUNSCPAL_OPENINGS can certainly be lowered to 8, as we won't queue more
than one command per device.

diffstat:

 sys/dev/ic/sunscpal.c    |  296 +++++++++++++++++-----------------------------
 sys/dev/ic/sunscpalvar.h |   12 +-
 2 files changed, 114 insertions(+), 194 deletions(-)

diffs (truncated from 507 to 300 lines):

diff -r ddc2d9c52f48 -r f852b92c7425 sys/dev/ic/sunscpal.c
--- a/sys/dev/ic/sunscpal.c     Mon Apr 23 12:33:34 2001 +0000
+++ b/sys/dev/ic/sunscpal.c     Mon Apr 23 13:41:43 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sunscpal.c,v 1.1.2.2 2001/04/23 09:42:20 bouyer Exp $  */
+/*     $NetBSD: sunscpal.c,v 1.1.2.3 2001/04/23 13:41:43 bouyer Exp $  */
 
 /*
  * Copyright (c) 2001 Matthew Fredette
@@ -148,7 +148,6 @@
 #define        SUNSCPAL_BREAK() \
        do { if (sunscpal_debug & SUNSCPAL_DBG_BREAK) Debugger(); } while (0)
 static void sunscpal_show_scsi_cmd __P((struct scsipi_xfer *));
-static void sunscpal_show_sense __P((struct scsipi_xfer *));
 #ifdef DDB
 void   sunscpal_clear_trace __P((void));
 void   sunscpal_show_trace __P((void));
@@ -159,7 +158,6 @@
 
 #define        SUNSCPAL_BREAK()                /* nada */
 #define sunscpal_show_scsi_cmd(xs) /* nada */
-#define sunscpal_show_sense(xs) /* nada */
 
 #endif /* SUNSCPAL_DEBUG */
 
@@ -661,7 +659,7 @@
 {
        struct sunscpal_req *sr = arg;
        struct scsipi_xfer *xs;
-       struct scsipi_link *sc_link;
+       struct scsipi_periph *periph;
        struct sunscpal_softc *sc;
        int s;
 
@@ -673,8 +671,8 @@
                printf("sunscpal_cmd_timeout: no scsipi_xfer\n");
                goto out;
        }
-       sc_link = xs->sc_link;
-       sc = sc_link->adapter_softc;
+       periph = xs->xs_periph;
+       sc = (void *)periph->periph_channel->chan_adapter->adapt_dev;
 
        printf("%s: cmd timeout, targ=%d, lun=%d\n",
            sc->sc_dev.dv_xname,
@@ -730,93 +728,103 @@
  * WARNING:  This can be called recursively!
  * (see comment in sunscpal_done)
  */
-int
-sunscpal_scsi_cmd(xs)
-       struct scsipi_xfer *xs;
+void
+sunscpal_scsipi_reqyest(chan, req, arg)
+       struct scsipi_channel *chan;
+       scsipi_adapter_req_t req;
+       void *arg;
 {
-       struct  sunscpal_softc *sc;
+       struct scsipi_xfer *xs;
+       struct scsipi_periph *periph;
+       struct  sunscpal_softc *sc = (void *)chan->chan_adapter->adapt_dev;
        struct sunscpal_req     *sr;
-       int s, rv, i, flags;
+       int s, i, flags;
 
-       sc = xs->sc_link->adapter_softc;
-       flags = xs->xs_control;
+       switch (req) {
+       case ADAPTER_REQ_RUN_XFER:
+               xs = arg;
+               periph = xs->xs_periph;
+               flags = xs->xs_control;
 
-       if (sc->sc_flags & SUNSCPAL_FORCE_POLLING)
-               flags |= XS_CTL_POLL;
+               if (sc->sc_flags & SUNSCPAL_FORCE_POLLING)
+                       flags |= XS_CTL_POLL;
 
-       if (flags & XS_CTL_DATA_UIO)
-               panic("sunscpal: scsi data uio requested");
+               if (flags & XS_CTL_DATA_UIO)
+                       panic("sunscpal: scsi data uio requested");
 
-       s = splbio();
+               s = splbio();
 
-       if (flags & XS_CTL_POLL) {
-               /* Terminate any current command. */
-               sr = sc->sc_current;
-               if (sr) {
-                       printf("%s: polled request aborting %d/%d\n",
-                           sc->sc_dev.dv_xname,
-                           sr->sr_target, sr->sr_lun);
-                       sunscpal_abort(sc);
-               }
-               if (sc->sc_state != SUNSCPAL_IDLE) {
-                       panic("sunscpal_scsi_cmd: polled request, abort failed");
+               if (flags & XS_CTL_POLL) {
+                       /* Terminate any current command. */
+                       sr = sc->sc_current;
+                       if (sr) {
+                               printf("%s: polled request aborting %d/%d\n",
+                                   sc->sc_dev.dv_xname,
+                                   sr->sr_target, sr->sr_lun);
+                               sunscpal_abort(sc);
+                       }
+                       if (sc->sc_state != SUNSCPAL_IDLE) {
+                               panic("sunscpal_scsi_cmd: polled request, abort failed");
+                       }
                }
-       }
 
-       /*
-        * Find lowest empty slot in ring buffer.
-        * XXX: What about "fairness" and cmd order?
-        */
-       for (i = 0; i < SUNSCPAL_OPENINGS; i++)
-               if (sc->sc_ring[i].sr_xs == NULL)
-                       goto new;
+               /*
+                * Find lowest empty slot in ring buffer.
+                * XXX: What about "fairness" and cmd order?
+                */
+               for (i = 0; i < SUNSCPAL_OPENINGS; i++)
+                       if (sc->sc_ring[i].sr_xs == NULL)
+                               goto new;
 
-       rv = TRY_AGAIN_LATER;
-       SUNSCPAL_TRACE("scsipi_cmd: no openings, rv=%d\n", rv);
-       goto out;
+               xs->error = XS_RESOURCE_SHORTAGE;
+               SUNSCPAL_TRACE("scsipi_cmd: no openings, rv=%d\n", rv);
+               goto out;
 
 new:
-       /* Create queue entry */
-       sr = &sc->sc_ring[i];
-       sr->sr_xs = xs;
-       sr->sr_target = xs->sc_link->scsipi_scsi.target;
-       sr->sr_lun = xs->sc_link->scsipi_scsi.lun;
-       sr->sr_dma_hand = NULL;
-       sr->sr_dataptr = xs->data;
-       sr->sr_datalen = xs->datalen;
-       sr->sr_flags = (flags & XS_CTL_POLL) ? SR_IMMED : 0;
-       sr->sr_status = -1;     /* no value */
-       sc->sc_ncmds++;
-       rv = SUCCESSFULLY_QUEUED;
+               /* Create queue entry */
+               sr = &sc->sc_ring[i];
+               sr->sr_xs = xs;
+               sr->sr_target = xs->xs_periph->periph_target;
+               sr->sr_lun = xs->xs_periph->periph_lun;
+               sr->sr_dma_hand = NULL;
+               sr->sr_dataptr = xs->data;
+               sr->sr_datalen = xs->datalen;
+               sr->sr_flags = (flags & XS_CTL_POLL) ? SR_IMMED : 0;
+               sr->sr_status = -1;     /* no value */
+               sc->sc_ncmds++;
 
-       SUNSCPAL_TRACE("scsipi_cmd: new sr=0x%x\n", (long)sr);
+               SUNSCPAL_TRACE("scsipi_cmd: new sr=0x%x\n", (long)sr);
 
-       if (flags & XS_CTL_POLL) {
-               /* Force this new command to be next. */
-               sc->sc_rr = i;
-       }
+               if (flags & XS_CTL_POLL) {
+                       /* Force this new command to be next. */
+                       sc->sc_rr = i;
+               }
 
-       /*
-        * If we were idle, run some commands...
-        */
-       if (sc->sc_state == SUNSCPAL_IDLE) {
-               SUNSCPAL_TRACE("scsipi_cmd: call sched, cur=0x%x\n",
+               /*
+                * If we were idle, run some commands...
+                */
+               if (sc->sc_state == SUNSCPAL_IDLE) {
+                       SUNSCPAL_TRACE("scsipi_cmd: call sched, cur=0x%x\n",
                                  (long) sc->sc_current);
-               sunscpal_sched(sc);
-               SUNSCPAL_TRACE("scsipi_cmd: sched done, cur=0x%x\n",
+                       sunscpal_sched(sc);
+                       SUNSCPAL_TRACE("scsipi_cmd: sched done, cur=0x%x\n",
                                  (long) sc->sc_current);
-       }
+               }
 
-       if (flags & XS_CTL_POLL) {
-               /* Make sure sunscpal_sched() finished it. */
-               if ((xs->xs_status & XS_STS_DONE) == 0)
-                       panic("sunscpal_scsi_cmd: poll didn't finish");
-               rv = COMPLETE;
-       }
+               if (flags & XS_CTL_POLL) {
+                       /* Make sure sunscpal_sched() finished it. */
+                       if ((xs->xs_status & XS_STS_DONE) == 0)
+                               panic("sunscpal_scsi_cmd: poll didn't finish");
+               }
 
 out:
-       splx(s);
-       return (rv);
+               splx(s);
+               return;
+       case ADAPTER_REQ_GROW_RESOURCES:
+       case ADAPTER_REQ_SET_XFER_MODE:
+               /* not supported */
+               return;
+       }
 }
 
 
@@ -870,37 +878,12 @@
 
        SUNSCPAL_TRACE("done: check status=%d\n", sr->sr_status);
 
+       xs->status = sr->sr_status;
        switch (sr->sr_status) {
        case SCSI_OK:   /* 0 */
-               if (sr->sr_flags & SR_SENSE) {
-#ifdef SUNSCPAL_DEBUG
-                       if (sunscpal_debug & SUNSCPAL_DBG_CMDS) {
-                               sunscpal_show_sense(xs);
-                       }
-#endif
-                       xs->error = XS_SENSE;
-               }
                break;
 
        case SCSI_CHECK:
-               if (sr->sr_flags & SR_SENSE) {
-                       /* Sense command also asked for sense? */
-                       printf("sunscpal_done: sense asked for sense\n");
-                       SUNSCPAL_BREAK();
-                       xs->error = XS_DRIVER_STUFFUP;
-                       break;
-               }
-               sr->sr_flags |= SR_SENSE;
-               SUNSCPAL_TRACE("done: get sense, sr=0x%x\n", (long) sr);
-               /*
-                * Leave queued, but clear sc_current so we start over
-                * with selection.  Guaranteed to get the same request.
-                */
-               sc->sc_state = SUNSCPAL_IDLE;
-               sc->sc_current = NULL;
-               sc->sc_matrix[sr->sr_target][sr->sr_lun] = NULL;
-               return;         /* XXX */
-
        case SCSI_BUSY:
                xs->error = XS_BUSY;
                break;
@@ -941,7 +924,6 @@
        sc->sc_ncmds--;
 
        /* Tell common SCSI code it is done. */
-       xs->xs_status |= XS_STS_DONE;
        scsipi_done(xs);
 
        sc->sc_state = SUNSCPAL_IDLE;
@@ -983,10 +965,6 @@
 
        /*
         * Always start the search where we last looked.
-        * The REQUEST_SENSE logic depends on this to
-        * choose the same job as was last picked, so it
-        * can just clear sc_current and reschedule.
-        * (Avoids loss of "contingent allegiance".)
         */
        i = sc->sc_rr;
        sr = NULL;
@@ -1103,16 +1081,6 @@
        }
 
        /*
-        * This may be the continuation of some job that
-        * completed with a "check condition" code.
-        */
-       if (sr->sr_flags & SR_SENSE) {
-               SUNSCPAL_TRACE("sched: get sense, sr=0x%x\n", (long)sr);
-               /* Do not allocate DMA, nor set timeout. */
-               goto have_nexus;
-       }
-
-       /*
         * OK, we are starting a new command.
         * Initialize and allocate resources for the new command.
         * Device reset is special (only uses MSG_OUT phase).
@@ -1122,7 +1090,7 @@
 #ifdef SUNSCPAL_DEBUG
        if (sunscpal_debug & SUNSCPAL_DBG_CMDS) {
                printf("sunscpal_sched: begin, target=%d, LUN=%d\n",
-                   xs->sc_link->scsipi_scsi.target, xs->sc_link->scsipi_scsi.lun);
+                   xs->xs_periph->periph_target, xs->xs_periph->periph_lun);
                sunscpal_show_scsi_cmd(xs);
        }
 #endif



Home | Main Index | Thread Index | Old Index