Source-Changes-HG archive

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

[src/thorpej_scsipi]: src/sys/dev Adapt to scsipi API changes.



details:   https://anonhg.NetBSD.org/src/rev/b599d9d71f18
branches:  thorpej_scsipi
changeset: 477271:b599d9d71f18
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Oct 19 17:47:28 1999 +0000

description:
Adapt to scsipi API changes.

diffstat:

 sys/dev/ic/adv.c            |  437 ++++++++++-----------
 sys/dev/ic/advlib.c         |    3 +-
 sys/dev/ic/advlib.h         |    7 +-
 sys/dev/ic/adw.c            |  274 +++++--------
 sys/dev/ic/adwlib.h         |    7 +-
 sys/dev/ic/aha.c            |  391 ++++++++-----------
 sys/dev/ic/ahavar.h         |    7 +-
 sys/dev/ic/aic6360.c        |  299 +++++++++------
 sys/dev/ic/aic6360var.h     |    4 +-
 sys/dev/ic/aic7xxx.c        |  848 +++++++++++++++++--------------------------
 sys/dev/ic/aic7xxxvar.h     |   13 +-
 sys/dev/ic/dpt.c            |  408 ++++++++++-----------
 sys/dev/ic/dptvar.h         |    5 +-
 sys/dev/ic/isp_netbsd.c     |  507 ++++++++++++-------------
 sys/dev/ic/isp_netbsd.h     |   29 +-
 sys/dev/ic/ncr5380sbc.c     |  205 ++++++----
 sys/dev/ic/ncr5380var.h     |    7 +-
 sys/dev/ic/ncr53c9x.c       |  290 +++++++++-----
 sys/dev/ic/ncr53c9xvar.h    |   13 +-
 sys/dev/ic/uha.c            |  375 ++++++++----------
 sys/dev/ic/uhavar.h         |    7 +-
 sys/dev/ic/wdc.c            |   20 +-
 sys/dev/ic/wdcvar.h         |    7 +-
 sys/dev/isa/nca.c           |   29 +-
 sys/dev/isa/seagate.c       |  274 +++++++------
 sys/dev/isa/wds.c           |  452 ++++++++++------------
 sys/dev/pci/ncr.c           |  350 +++++-------------
 sys/dev/pci/pcscp.c         |   21 +-
 sys/dev/pcmcia/aic_pcmcia.c |   20 +-
 sys/dev/pcmcia/wdc_pcmcia.c |   12 +-
 30 files changed, 2452 insertions(+), 2869 deletions(-)

diffs (truncated from 7920 to 300 lines):

diff -r ebb050ef6d3e -r b599d9d71f18 sys/dev/ic/adv.c
--- a/sys/dev/ic/adv.c  Tue Oct 19 17:47:01 1999 +0000
+++ b/sys/dev/ic/adv.c  Tue Oct 19 17:47:28 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: adv.c,v 1.14 1999/09/30 23:04:40 thorpej Exp $ */
+/*     $NetBSD: adv.c,v 1.14.2.1 1999/10/19 17:47:28 thorpej Exp $     */
 
 /*
  * Generic driver for the Advanced Systems Inc. Narrow SCSI controllers
@@ -83,7 +83,8 @@
 static void adv_start_ccbs __P((ASC_SOFTC *));
 
 
-static int adv_scsi_cmd __P((struct scsipi_xfer *));
+static void adv_scsipi_request __P((struct scsipi_channel *,
+       scsipi_adapter_req_t, void *));
 static void advminphys __P((struct buf *));
 static void adv_narrow_isr_callback __P((ASC_SOFTC *, ASC_QDONE_INFO *));
 
@@ -94,21 +95,9 @@
 
 /******************************************************************************/
 
-
-/* the below structure is so we have a default dev struct for out link struct */
-struct scsipi_device adv_dev =
-{
-       NULL,                   /* Use default error handler */
-       NULL,                   /* have a queue, served by this */
-       NULL,                   /* have no async handler */
-       NULL,                   /* Use default 'done' routine */
-};
-
-
 #define ADV_ABORT_TIMEOUT       2000   /* time to wait for abort (mSec) */
 #define ADV_WATCH_TIMEOUT       1000   /* time to wait for watchdog (mSec) */
 
-
 /******************************************************************************/
 /*                             Control Blocks routines                        */
 /******************************************************************************/
@@ -450,6 +439,8 @@
 adv_attach(sc)
        ASC_SOFTC      *sc;
 {
+       struct scsipi_adapter *adapt = &sc->sc_adapter;
+       struct scsipi_channel *chan = &sc->sc_channel;
        int             i, error;
 
        /*
@@ -480,29 +471,29 @@
        }
 
        /*
-        * Fill in the adapter.
+        * Fill in the scsipi_adapter.
         */
-       sc->sc_adapter.scsipi_cmd = adv_scsi_cmd;
-       sc->sc_adapter.scsipi_minphys = advminphys;
+       memset(adapt, 0, sizeof(*adapt));
+       adapt->adapt_dev = &sc->sc_dev;
+       adapt->adapt_nchannels = 1;
+       /* adapt_openings initialized below */
+       /* adapt_max_periph initialized below */
+       adapt->adapt_request = adv_scsipi_request;
+       adapt->adapt_minphys = advminphys;
 
        /*
-         * fill in the prototype scsipi_link.
-         */
-       sc->sc_link.scsipi_scsi.channel = SCSI_CHANNEL_ONLY_ONE;
-       sc->sc_link.adapter_softc = sc;
-       sc->sc_link.scsipi_scsi.adapter_target = sc->chip_scsi_id;
-       sc->sc_link.adapter = &sc->sc_adapter;
-       sc->sc_link.device = &adv_dev;
-       sc->sc_link.openings = 4;
-       sc->sc_link.scsipi_scsi.max_target = 7;
-       sc->sc_link.scsipi_scsi.max_lun = 7;
-       sc->sc_link.type = BUS_SCSI;
-
+        * Fill in the scsipi_channel.
+        */
+       memset(chan, 0, sizeof(*chan));
+       chan->chan_adapter = adapt;
+       chan->chan_bustype = &scsi_bustype;
+       chan->chan_channel = 0;
+       chan->chan_ntargets = 8;
+       chan->chan_nluns = 8;
+       chan->chan_id = sc->chip_scsi_id;
 
        TAILQ_INIT(&sc->sc_free_ccb);
        TAILQ_INIT(&sc->sc_waiting_ccb);
-       TAILQ_INIT(&sc->sc_queue);
-
 
        /*
          * Allocate the Control Blocks and the overrun buffer.
@@ -523,7 +514,11 @@
                printf("%s: WARNING: only %d of %d control blocks created\n",
                       sc->sc_dev.dv_xname, i, ADV_MAX_CCB);
        }
-       config_found(&sc->sc_dev, &sc->sc_link, scsiprint);
+
+       adapt->adapt_openings = i;
+       adapt->adapt_max_periph = adapt->adapt_openings;
+
+       config_found(&sc->sc_dev, chan, scsiprint);
 }
 
 
@@ -542,219 +537,212 @@
  * start a scsi operation given the command and the data address.  Also needs
  * the unit, target and lu.
  */
-static int
-adv_scsi_cmd(xs)
+static void
+adv_scsipi_request(chan, req, arg)
+       struct scsipi_channel *chan;
+       scsipi_adapter_req_t req; 
+       void *arg;
+{
        struct scsipi_xfer *xs;
-{
-       struct scsipi_link *sc_link = xs->sc_link;
-       ASC_SOFTC      *sc = sc_link->adapter_softc;
+       struct scsipi_periph *periph;
+       ASC_SOFTC      *sc = (void *)chan->chan_adapter->adapt_dev;
        bus_dma_tag_t   dmat = sc->sc_dmat;
        ADV_CCB        *ccb;
        int             s, flags, error, nsegs;
-       int             fromqueue = 1, dontqueue = 0;
 
-
-       s = splbio();           /* protect the queue */
-
-       /*
-         * If we're running the queue from adv_done(), we've been
-         * called with the first queue entry as our argument.
-         */
-       if (xs == TAILQ_FIRST(&sc->sc_queue)) {
-               TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q);
-               fromqueue = 1;
-       } else {
-
-               /* Polled requests can't be queued for later. */
-               dontqueue = xs->xs_control & XS_CTL_POLL;
+       switch (req) {
+       case ADAPTER_REQ_RUN_XFER:
+               xs = arg;
+               periph = xs->xs_periph;
+               flags = xs->xs_control;
 
                /*
-                 * If there are jobs in the queue, run them first.
-                 */
-               if (TAILQ_FIRST(&sc->sc_queue) != NULL) {
-                       /*
-                         * If we can't queue, we have to abort, since
-                         * we have to preserve order.
-                         */
-                       if (dontqueue) {
-                               splx(s);
-                               xs->error = XS_DRIVER_STUFFUP;
-                               return (TRY_AGAIN_LATER);
-                       }
-                       /*
-                         * Swap with the first queue entry.
-                         */
-                       TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q);
-                       xs = TAILQ_FIRST(&sc->sc_queue);
-                       TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q);
-                       fromqueue = 1;
+                * Get a CCB to use.
+                */
+               ccb = adv_get_ccb(sc, flags);
+#ifdef DIAGNOSTIC
+               /*
+                * This should never happen as we track the resources
+                * in the mid-layer.
+                */
+               if (ccb == NULL) {
+                       scsipi_printaddr(periph);
+                       printf("unable to allocate ccb\n");
+                       panic("adv_scsipi_request");
                }
-       }
-
-
-       /*
-         * get a ccb to use. If the transfer
-         * is from a buf (possibly from interrupt time)
-         * then we can't allow it to sleep
-         */
+#endif
 
-       flags = xs->xs_control;
-       if ((ccb = adv_get_ccb(sc, flags)) == NULL) {
-               /*
-                 * If we can't queue, we lose.
-                 */
-               if (dontqueue) {
-                       splx(s);
-                       xs->error = XS_DRIVER_STUFFUP;
-                       return (TRY_AGAIN_LATER);
-               }
+               ccb->xs = xs;
+               ccb->timeout = xs->timeout;
+
                /*
-                 * Stuff ourselves into the queue, in front
-                 * if we came off in the first place.
-                 */
-               if (fromqueue)
-                       TAILQ_INSERT_HEAD(&sc->sc_queue, xs, adapter_q);
-               else
-                       TAILQ_INSERT_TAIL(&sc->sc_queue, xs, adapter_q);
-               splx(s);
-               return (SUCCESSFULLY_QUEUED);
-       }
-       splx(s);                /* done playing with the queue */
+                * Build up the request
+                */
+               memset(&ccb->scsiq, 0, sizeof(ASC_SCSI_Q));
 
-       ccb->xs = xs;
-       ccb->timeout = xs->timeout;
-
-       /*
-         * Build up the request
-         */
-       memset(&ccb->scsiq, 0, sizeof(ASC_SCSI_Q));
-
-       ccb->scsiq.q2.ccb_ptr = sc->sc_dmamap_control->dm_segs[0].ds_addr +
+               ccb->scsiq.q2.ccb_ptr =
+                   sc->sc_dmamap_control->dm_segs[0].ds_addr +
                    ADV_CCB_OFF(ccb);
 
-       ccb->scsiq.cdbptr = &xs->cmd->opcode;
-       ccb->scsiq.q2.cdb_len = xs->cmdlen;
-       ccb->scsiq.q1.target_id = ASC_TID_TO_TARGET_ID(sc_link->scsipi_scsi.target);
-       ccb->scsiq.q1.target_lun = sc_link->scsipi_scsi.lun;
-       ccb->scsiq.q2.target_ix = ASC_TIDLUN_TO_IX(sc_link->scsipi_scsi.target,
-                                                  sc_link->scsipi_scsi.lun);
-       ccb->scsiq.q1.sense_addr = sc->sc_dmamap_control->dm_segs[0].ds_addr +
-               ADV_CCB_OFF(ccb) + offsetof(struct adv_ccb, scsi_sense);
-       ccb->scsiq.q1.sense_len = sizeof(struct scsipi_sense_data);
+               ccb->scsiq.cdbptr = &xs->cmd->opcode;
+               ccb->scsiq.q2.cdb_len = xs->cmdlen;
+               ccb->scsiq.q1.target_id =
+                   ASC_TID_TO_TARGET_ID(periph->periph_target);
+               ccb->scsiq.q1.target_lun = periph->periph_lun;
+               ccb->scsiq.q2.target_ix =
+                   ASC_TIDLUN_TO_IX(periph->periph_target,
+                   periph->periph_lun);
+               ccb->scsiq.q1.sense_addr =
+                   sc->sc_dmamap_control->dm_segs[0].ds_addr +
+                   ADV_CCB_OFF(ccb) + offsetof(struct adv_ccb, scsi_sense);
+               ccb->scsiq.q1.sense_len = sizeof(struct scsipi_sense_data);
 
-       /*
-         * If  there  are  any  outstanding  requests  for  the  current target,
-         * then  every  255th request  send an  ORDERED request.  This heuristic
-         * tries  to  retain  the  benefit  of request  sorting while preventing
-         * request starvation. 255 is the max number of tags or pending commands
-         * a device may have outstanding.
-         */
-       sc->reqcnt[sc_link->scsipi_scsi.target]++;
-       if ((sc->reqcnt[sc_link->scsipi_scsi.target] > 0) &&
-           (sc->reqcnt[sc_link->scsipi_scsi.target] % 255) == 0) {
-               ccb->scsiq.q2.tag_code = M2_QTAG_MSG_ORDERED;
-       } else {
-               ccb->scsiq.q2.tag_code = M2_QTAG_MSG_SIMPLE;
-       }
-
-
-       if (xs->datalen) {
                /*
-                 * Map the DMA transfer.
-                 */
-#ifdef TFS
-               if (flags & SCSI_DATA_UIO) {
-                       error = bus_dmamap_load_uio(dmat,
-                                 ccb->dmamap_xfer, (struct uio *) xs->data,
-                                                   (flags & XS_CTL_NOSLEEP) ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK);
-               } else
-#endif                         /* TFS */
-               {
-                       error = bus_dmamap_load(dmat,
-                             ccb->dmamap_xfer, xs->data, xs->datalen, NULL,
-                                               (flags & XS_CTL_NOSLEEP) ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK);
+                * If there are any outstanding requests for the current
+                * target, then every 255th request send an ORDERED request.
+                * This heuristic tries to retain the benefit of request
+                * sorting while preventing request starvation. 255 is the
+                * max number of tags or pending commands a device may have
+                * outstanding.
+                */
+               sc->reqcnt[periph->periph_target]++;
+               if ((sc->reqcnt[periph->periph_target] > 0) &&



Home | Main Index | Thread Index | Old Index