Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/thorpej_scsipi]: src/sys/dev make it compile
details: https://anonhg.NetBSD.org/src/rev/4c414cf35fb7
branches: thorpej_scsipi
changeset: 477377:4c414cf35fb7
user: bouyer <bouyer%NetBSD.org@localhost>
date: Mon Jan 22 18:00:43 2001 +0000
description:
make it compile
diffstat:
sys/dev/i2o/iopsp.c | 268 ++++++++++++++++++++++++-----------------------
sys/dev/i2o/iopspvar.h | 8 +-
sys/dev/ic/ncr5380sbc.c | 17 +--
3 files changed, 146 insertions(+), 147 deletions(-)
diffs (truncated from 499 to 300 lines):
diff -r f94c2adbb030 -r 4c414cf35fb7 sys/dev/i2o/iopsp.c
--- a/sys/dev/i2o/iopsp.c Mon Jan 22 17:58:55 2001 +0000
+++ b/sys/dev/i2o/iopsp.c Mon Jan 22 18:00:43 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: iopsp.c,v 1.2.2.4 2001/01/15 09:27:42 bouyer Exp $ */
+/* $NetBSD: iopsp.c,v 1.2.2.5 2001/01/22 18:00:43 bouyer Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -62,6 +62,7 @@
#include <dev/scsipi/scsi_disk.h>
#include <dev/scsipi/scsipi_all.h>
#include <dev/scsipi/scsiconf.h>
+#include <dev/scsipi/scsi_message.h>
#include <dev/i2o/i2o.h>
#include <dev/i2o/iopreg.h>
@@ -70,21 +71,14 @@
static void iopsp_attach(struct device *, struct device *, void *);
static void iopsp_intr(struct device *, struct iop_msg *, void *);
-static int iopsp_ioctl(struct scsipi_link *, u_long, caddr_t, int,
- struct proc *);
+static int iopsp_ioctl(struct scsipi_channel *, u_long,
+ caddr_t, int, struct proc *);
static int iopsp_match(struct device *, struct cfdata *, void *);
-static void iopsp_minphys(struct buf *);
static int iopsp_rescan(struct iopsp_softc *);
static int iopsp_reconfig(struct device *);
static int iopsp_scsi_abort(struct iopsp_softc *, int, struct iop_msg *);
-static int iopsp_scsi_cmd(struct scsipi_xfer *);
-
-static struct scsipi_device iopsp_dev = {
- NULL, /* Use default error handler */
- NULL, /* have a queue, served by this */
- NULL, /* have no async handler */
- NULL, /* Use default 'done' routine */
-};
+static void iopsp_scsipi_request(struct scsipi_channel *,
+ scsipi_adapter_req_t, void *);
struct cfattach iopsp_ca = {
sizeof(struct iopsp_softc), iopsp_match, iopsp_attach
@@ -128,7 +122,6 @@
{
struct iop_attach_args *ia;
struct iopsp_softc *sc;
- struct scsipi_link *sc_link;
struct iop_softc *iop;
struct {
struct i2o_param_op_results pr;
@@ -207,29 +200,29 @@
le32toh(param.p.sci.initiatorid));
#endif
- sc->sc_adapter.scsipi_cmd = iopsp_scsi_cmd;
- sc->sc_adapter.scsipi_minphys = iopsp_minphys;
- sc->sc_adapter.scsipi_ioctl = iopsp_ioctl;
+ sc->sc_adapter.adapt_dev = &sc->sc_dv;
+ sc->sc_adapter.adapt_nchannels = 1;
+ sc->sc_adapter.adapt_openings = iop->sc_maxqueuecnt;
+ sc->sc_adapter.adapt_max_periph = iop->sc_maxqueuecnt;
+ sc->sc_adapter.adapt_ioctl = iopsp_ioctl;
+ sc->sc_adapter.adapt_minphys = minphys;
+ sc->sc_adapter.adapt_request = iopsp_scsipi_request;
- sc_link = &sc->sc_link;
- sc_link->type = BUS_SCSI;
- sc_link->device = &iopsp_dev;
- sc_link->adapter = &sc->sc_adapter;
- sc_link->adapter_softc = sc;
- sc_link->scsipi_scsi.channel = 0;
- sc_link->scsipi_scsi.adapter_target = le32toh(param.p.sci.initiatorid);
- sc_link->scsipi_scsi.max_target =
- fcal ? IOPSP_MAX_FCAL_TARGET : param.p.sci.maxdatawidth - 1;
- sc_link->scsipi_scsi.max_lun = IOPSP_MAX_LUN;
- sc_link->openings = iop->sc_maxqueuecnt / 4; /* XXX */
+ memset(&sc->sc_channel, 0, sizeof(sc->sc_channel));
+ sc->sc_channel.chan_adapter = &sc->sc_adapter;
+ sc->sc_channel.chan_bustype = &scsi_bustype;
+ sc->sc_channel.chan_channel = 0;
+ sc->sc_channel.chan_ntargets = fcal ?
+ IOPSP_MAX_FCAL_TARGET : param.p.sci.maxdatawidth;
+ sc->sc_channel.chan_nluns = IOPSP_MAX_LUN;
+ sc->sc_channel.chan_id = le32toh(param.p.sci.initiatorid);
#ifdef I2OVERBOSE
/*
* Allocate the target map. Currently used for informational
* purposes only.
*/
- size = (sc_link->scsipi_scsi.max_target + 1) *
- sizeof(struct iopsp_target);
+ size = sc->sc_channel.chan_ntargets * sizeof(struct iopsp_target);
sc->sc_targetmap = malloc(size, M_DEVBUF, M_NOWAIT);
memset(sc->sc_targetmap, 0, size);
#endif
@@ -239,7 +232,7 @@
printf("%s: bus scan failed\n", sc->sc_dv.dv_xname);
goto bad;
}
- config_found(self, sc_link, scsiprint);
+ config_found(self, &sc->sc_channel, scsiprint);
return;
bad:
@@ -256,7 +249,7 @@
struct iopsp_softc *sc;
struct iop_softc *iop;
struct i2o_lct_entry *le;
- struct scsipi_link *sc_link;
+ struct scsipi_channel *sc_chan;
struct {
struct i2o_param_op_results pr;
struct i2o_param_read_results prr;
@@ -271,7 +264,7 @@
sc = (struct iopsp_softc *)dv;
iop = (struct iop_softc *)sc->sc_dv.dv_parent;
- sc_link = &sc->sc_link;
+ sc_chan = &sc->sc_channel;
/* Anything to do? */
if (iop->sc_lct->changeindicator == sc->sc_chgindicator)
@@ -282,14 +275,13 @@
* denote absent targets (zero is the TID of the I2O executive,
* and we never address that here).
*/
- size = (sc_link->scsipi_scsi.max_target + 1) *
- (IOPSP_MAX_LUN + 1) * sizeof(u_short);
+ size = sc_chan->chan_ntargets * (IOPSP_MAX_LUN) * sizeof(u_short);
if ((tidmap = malloc(size, M_DEVBUF, M_WAITOK)) == NULL)
return (ENOMEM);
memset(tidmap, 0, size);
#ifdef I2OVERBOSE
- for (i = 0; i <= sc_link->scsipi_scsi.max_target; i++)
+ for (i = 0; i < sc_chan->chan_ntargets; i++)
sc->sc_targetmap[i].it_flags &= ~IT_PRESENT;
#endif
@@ -362,7 +354,7 @@
}
#ifdef I2OVERBOSE
- for (i = 0; i <= sc_link->scsipi_scsi.max_target; i++)
+ for (i = 0; i < sc_chan->chan_ntargets; i++)
if ((sc->sc_targetmap[i].it_flags & IT_PRESENT) == 0)
sc->sc_targetmap[i].it_width = 0;
#endif
@@ -378,18 +370,6 @@
}
/*
- * Adjust the size of an I/O request.
- */
-static void
-iopsp_minphys(struct buf *bp)
-{
-
- if (bp->b_bcount > IOP_MAX_XFER)
- bp->b_bcount = IOP_MAX_XFER;
- minphys(bp);
-}
-
-/*
* Re-scan the bus; to be called from a higher level (e.g. scsipi).
*/
static int
@@ -440,109 +420,133 @@
/*
* Start a SCSI command.
*/
-static int
-iopsp_scsi_cmd(struct scsipi_xfer *xs)
+static void
+iopsp_scsipi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req,
+ void *arg)
{
- struct scsipi_link *sc_link;
- struct iopsp_softc *sc;
+ struct scsipi_xfer *xs;
+ struct scsipi_periph *periph;
+ struct iopsp_softc *sc = (void *)chan->chan_adapter->adapt_dev;
struct iop_msg *im;
- struct iop_softc *iop;
+ struct iop_softc *iop = (struct iop_softc *)sc->sc_dv.dv_parent;
struct i2o_scsi_scb_exec *mb;
int error, flags, tid;
- sc_link = xs->sc_link;
- flags = xs->xs_control;
- sc = sc_link->adapter_softc;
- iop = (struct iop_softc *)sc->sc_dv.dv_parent;
+ switch (req) {
+ case ADAPTER_REQ_RUN_XFER:
+ xs = arg;
+ periph = xs->xs_periph;
+ flags = xs->xs_control;
- tid = IOPSP_TIDMAP(sc->sc_tidmap, sc_link->scsipi_scsi.target,
- sc_link->scsipi_scsi.lun);
- if (tid == IOPSP_TID_ABSENT || tid == IOPSP_TID_INUSE) {
- xs->error = XS_SELTIMEOUT;
- return (COMPLETE);
- }
+ tid = IOPSP_TIDMAP(sc->sc_tidmap, periph->periph_target,
+ periph->periph_lun);
+ if (tid == IOPSP_TID_ABSENT || tid == IOPSP_TID_INUSE) {
+ xs->error = XS_SELTIMEOUT;
+ scsipi_done(xs);
+ return;
+ }
+
+ SC_DEBUG(periph, SDEV_DB2, ("iopsp_scsi_request run_xfer\n"));
- SC_DEBUG(sc_link, SDEV_DB2, ("iopsp_scsi_cmd\n"));
-
- /* Need to reset the target? */
- if ((flags & XS_CTL_RESET) != 0) {
- if (iop_simple_cmd(iop, tid, I2O_SCSI_DEVICE_RESET,
- sc->sc_ii.ii_ictx, 1, 10*1000) != 0) {
+ /* Need to reset the target? */
+ if ((flags & XS_CTL_RESET) != 0) {
+ if (iop_simple_cmd(iop, tid, I2O_SCSI_DEVICE_RESET,
+ sc->sc_ii.ii_ictx, 1, 10*1000) != 0) {
#ifdef I2ODEBUG
- printf("%s: reset failed\n", sc->sc_dv.dv_xname);
+ printf("%s: reset failed\n",
+ sc->sc_dv.dv_xname);
#endif
- xs->error = XS_DRIVER_STUFFUP;
+ xs->error = XS_DRIVER_STUFFUP;
+ } else
+ xs->error = XS_NOERROR;
+
+ scsipi_done(xs);
+ return;
}
- return (COMPLETE);
- }
#if defined(I2ODEBUG) || defined(SCSIDEBUG)
- if (xs->cmdlen > 16)
- panic("%s: CDB too large\n", sc->sc_dv.dv_xname);
+ if (xs->cmdlen > 16)
+ panic("%s: CDB too large\n", sc->sc_dv.dv_xname);
#endif
- if (iop_msg_alloc(iop, &sc->sc_ii, &im,
- (flags & (XS_CTL_POLL | XS_CTL_NOSLEEP)) != 0 ? IM_NOWAIT : 0)) {
- xs->error = XS_DRIVER_STUFFUP;
- return (TRY_AGAIN_LATER);
- }
- im->im_dvcontext = xs;
+ if (iop_msg_alloc(iop, &sc->sc_ii, &im,
+ (flags & (XS_CTL_POLL | XS_CTL_NOSLEEP)) != 0 ? IM_NOWAIT : 0)) {
+ xs->error = XS_RESOURCE_SHORTAGE;
+ scsipi_done(xs);
+ return;
+ }
+ im->im_dvcontext = xs;
+
+ mb = (struct i2o_scsi_scb_exec *)im->im_msg;
+ mb->msgflags = I2O_MSGFLAGS(i2o_scsi_scb_exec);
+ mb->msgfunc = I2O_MSGFUNC(tid, I2O_SCSI_SCB_EXEC);
+ mb->msgictx = sc->sc_ii.ii_ictx;
+ mb->msgtctx = im->im_tctx;
+ mb->flags = xs->cmdlen | I2O_SCB_FLAG_ENABLE_DISCONNECT |
+ I2O_SCB_FLAG_SENSE_DATA_IN_MESSAGE;
+ memcpy(mb->cdb, xs->cmd, xs->cmdlen);
+ mb->datalen = xs->datalen;
- mb = (struct i2o_scsi_scb_exec *)im->im_msg;
- mb->msgflags = I2O_MSGFLAGS(i2o_scsi_scb_exec);
- mb->msgfunc = I2O_MSGFUNC(tid, I2O_SCSI_SCB_EXEC);
- mb->msgictx = sc->sc_ii.ii_ictx;
- mb->msgtctx = im->im_tctx;
- mb->flags = xs->cmdlen | I2O_SCB_FLAG_ENABLE_DISCONNECT |
- I2O_SCB_FLAG_SENSE_DATA_IN_MESSAGE;
- memcpy(mb->cdb, xs->cmd, xs->cmdlen);
- mb->datalen = xs->datalen;
+ switch(xs->xs_tag_type) {
+ case MSG_ORDERED_Q_TAG:
+ flags |= I2O_SCB_FLAG_ORDERED_QUEUE_TAG;
+ break;
+ case MSG_SIMPLE_Q_TAG:
+ mb->flags |= I2O_SCB_FLAG_SIMPLE_QUEUE_TAG;
+ break;
+ case MSG_HEAD_OF_Q_TAG:
+ flags |= I2O_SCB_FLAG_HEAD_QUEUE_TAG;
+ break;
+ default:
+ break;
+ }
- if ((xs->sc_link->quirks & SDEV_NOTAG) == 0 &&
- (xs->xs_control & XS_CTL_POLL) != 0) {
- if (xs->bp != NULL && (xs->bp->b_flags & B_ASYNC) != 0)
- mb->flags |= I2O_SCB_FLAG_ORDERED_QUEUE_TAG;
Home |
Main Index |
Thread Index |
Old Index