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, first pass. Does...
details: https://anonhg.NetBSD.org/src/rev/58bc8d698d64
branches: thorpej_scsipi
changeset: 477454:58bc8d698d64
user: bouyer <bouyer%NetBSD.org@localhost>
date: Mon Apr 02 07:41:55 2001 +0000
description:
Port to thorpej_scsipi, first pass. Doesn't handle ADAPTER_REQ_SET_XFER_MODE
and doesn't report its xfer mode yet, so tagged queuing isn't used yet.
diffstat:
sys/dev/ic/aic7xxx.c | 583 ++++++++++++++++++-----------------------------
sys/dev/ic/aic7xxxvar.h | 11 +-
2 files changed, 222 insertions(+), 372 deletions(-)
diffs (truncated from 1112 to 300 lines):
diff -r c1a85efb1abe -r 58bc8d698d64 sys/dev/ic/aic7xxx.c
--- a/sys/dev/ic/aic7xxx.c Mon Apr 02 07:34:14 2001 +0000
+++ b/sys/dev/ic/aic7xxx.c Mon Apr 02 07:41:55 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: aic7xxx.c,v 1.37.2.11 2001/03/12 13:30:12 bouyer Exp $ */
+/* $NetBSD: aic7xxx.c,v 1.37.2.12 2001/04/02 07:41:55 bouyer Exp $ */
/*
* Generic driver for the aic7xxx based adaptec SCSI controllers
@@ -118,12 +118,12 @@
#define ALL_TARGETS_MASK 0xFFFF
#define INITIATOR_WILDCARD (~0)
-#define SIM_IS_SCSIBUS_B(ahc, sc_link) \
- ((sc_link)->scsipi_scsi.scsibus == (ahc)->sc_link_b.scsipi_scsi.scsibus)
-#define SIM_CHANNEL(ahc, sc_link) \
- (SIM_IS_SCSIBUS_B(ahc, sc_link) ? 'B' : 'A')
-#define SIM_SCSI_ID(ahc, sc_link) \
- (SIM_IS_SCSIBUS_B(ahc, sc_link) ? ahc->our_id_b : ahc->our_id)
+#define SIM_IS_SCSIBUS_B(ahc, periph) \
+ ((periph)->periph_channel->chan_channel == 1)
+#define SIM_CHANNEL(ahc, periph) \
+ (SIM_IS_SCSIBUS_B(ahc, periph) ? 'B' : 'A')
+#define SIM_SCSI_ID(ahc, periph) \
+ (SIM_IS_SCSIBUS_B(ahc, periph) ? ahc->our_id_b : ahc->our_id)
#define SCB_IS_SCSIBUS_B(scb) \
(((scb)->hscb->tcl & SELBUSB) != 0)
#define SCB_TARGET(scb) \
@@ -144,9 +144,9 @@
#define TCL_LUN(tcl) ((tcl) & LID)
#define XS_TCL(ahc, xs) \
- ((((xs)->sc_link->scsipi_scsi.target << 4) & 0xF0) \
- | (SIM_IS_SCSIBUS_B((ahc), (xs)->sc_link) ? SELBUSB : 0) \
- | ((xs)->sc_link->scsipi_scsi.lun & 0x07))
+ ((((xs)->xs_periph->periph_target << 4) & 0xF0) \
+ | (SIM_IS_SCSIBUS_B((ahc), (xs)->xs_periph) ? SELBUSB : 0) \
+ | ((xs)->xs_periph->periph_lun & 0x07))
const char * const ahc_chip_names[] =
{
@@ -201,14 +201,15 @@
static void ahc_dump_targcmd(struct target_cmd *);
#endif
static void ahc_shutdown(void *arg);
-static int32_t ahc_action(struct scsipi_xfer *);
-static int ahc_ioctl(struct scsipi_link *, u_long, caddr_t, int,
+static void ahc_action(struct scsipi_channel *,
+ scsipi_adapter_req_t, void *);
+static int ahc_ioctl(struct scsipi_channel *, u_long, caddr_t, int,
struct proc *);
-static int ahc_execute_scb(void *, bus_dma_segment_t *, int);
+static void ahc_execute_scb(void *, bus_dma_segment_t *, int);
static int ahc_poll(struct ahc_softc *, int);
-static int ahc_setup_data(struct ahc_softc *, struct scsipi_xfer *,
+static void ahc_setup_data(struct ahc_softc *, struct scsipi_xfer *,
struct scb *);
-static void ahc_freeze_devq(struct ahc_softc *, struct scsipi_link *);
+static void ahc_freeze_devq(struct ahc_softc *, struct scsipi_periph *);
static void ahcallocscbs(struct ahc_softc *);
#if UNUSED
static void ahc_scb_devinfo(struct ahc_softc *, struct ahc_devinfo *,
@@ -235,10 +236,10 @@
struct ahc_devinfo *);
static void ahc_clear_msg_state(struct ahc_softc *);
static void ahc_handle_message_phase(struct ahc_softc *,
- struct scsipi_link *);
+ struct scsipi_periph *);
static int ahc_sent_msg(struct ahc_softc *, u_int, int);
-static int ahc_parse_msg(struct ahc_softc *, struct scsipi_link *,
+static int ahc_parse_msg(struct ahc_softc *, struct scsipi_periph *,
struct ahc_devinfo *);
static void ahc_handle_ign_wide_residue(struct ahc_softc *,
struct ahc_devinfo *);
@@ -322,7 +323,6 @@
caddr_t, bus_dma_segment_t *, int);
static void ahcminphys(struct buf *);
-static __inline struct scsipi_xfer *ahc_first_xs(struct ahc_softc *);
static __inline void ahc_swap_hscb(struct hardware_scb *);
static __inline void ahc_swap_sg(struct ahc_dma_seg *);
#ifndef AHC_NO_TAGS
@@ -334,39 +334,6 @@
static void ahc_dumptinfo(struct ahc_softc *, struct ahc_initiator_tinfo *);
#endif
-static struct scsipi_device ahc_dev =
-{
- NULL, /* Use default error handler */
- NULL, /* have a queue, served by this */
- NULL, /* have no async handler */
- NULL, /* Use default 'done' routine */
-};
-
-/*
- * Pick the first xs for a non-blocked target.
- */
-static __inline struct scsipi_xfer *
-ahc_first_xs(struct ahc_softc *ahc)
-{
- int target;
- struct scsipi_xfer *xs = TAILQ_FIRST(&ahc->sc_q);
-
- if (ahc->queue_blocked)
- return NULL;
-
- while (xs != NULL) {
- target = xs->sc_link->scsipi_scsi.target;
- if (ahc->devqueue_blocked[target] == 0 &&
- (ahc_istagged_device(ahc, xs, 0) ||
- ahc_index_busy_tcl(ahc, XS_TCL(ahc, xs), FALSE) ==
- SCB_LIST_NULL))
- break;
- xs = TAILQ_NEXT(xs, adapter_q);
- }
-
- return xs;
-}
-
static __inline void
ahc_swap_hscb(struct hardware_scb *hscb)
{
@@ -504,12 +471,9 @@
ahc_freeze_ccb(struct scb *scb)
{
struct scsipi_xfer *xs = scb->xs;
- struct ahc_softc *ahc = (struct ahc_softc *)xs->sc_link->adapter_softc;
- int target;
-
- target = xs->sc_link->scsipi_scsi.target;
+
if (!(scb->flags & SCB_FREEZE_QUEUE)) {
- ahc->devqueue_blocked[target]++;
+ scsipi_periph_freeze(xs->xs_periph, 1);
scb->flags |= SCB_FREEZE_QUEUE;
}
}
@@ -569,7 +533,7 @@
scb->xs->resid = 0;
#ifdef AHC_DEBUG
if (ahc_debug & AHC_SHOWSCBS) {
- scsi_print_addr(scb->xs->sc_link);
+ scsipi_printaddr(scb->xs->xs_periph);
printf("run_qoutfifo: SCB %x complete\n",
scb->hscb->tag);
}
@@ -601,7 +565,9 @@
if ((ahc->flags & AHC_RESOURCE_SHORTAGE) != 0 ||
(scb->flags & SCB_RECOVERY_SCB) != 0) {
ahc->flags &= ~AHC_RESOURCE_SHORTAGE;
- ahc->queue_blocked = 0;
+ scsipi_channel_thaw(&ahc->sc_channel, 1);
+ if (ahc->features & AHC_TWIN)
+ scsipi_channel_thaw(&ahc->sc_channel_b, 1);
}
/* Clean up for the next user */
@@ -1407,36 +1373,35 @@
int
ahc_attach(struct ahc_softc *ahc)
{
- TAILQ_INIT(&ahc->sc_q);
-
- ahc->sc_adapter.scsipi_cmd = ahc_action;
- ahc->sc_adapter.scsipi_minphys = ahcminphys;
- ahc->sc_adapter.scsipi_ioctl = ahc_ioctl;
- ahc->sc_link.type = BUS_SCSI;
- ahc->sc_link.scsipi_scsi.adapter_target = ahc->our_id;
- ahc->sc_link.scsipi_scsi.channel = 0;
- ahc->sc_link.scsipi_scsi.max_target =
- (ahc->features & AHC_WIDE) ? 15 : 7;
- ahc->sc_link.scsipi_scsi.max_lun = 7;
- ahc->sc_link.adapter_softc = ahc;
- ahc->sc_link.adapter = &ahc->sc_adapter;
- ahc->sc_link.openings = 2;
- ahc->sc_link.device = &ahc_dev;
-
+ ahc->sc_adapter.adapt_dev = &ahc->sc_dev;
+ ahc->sc_adapter.adapt_nchannels = (ahc->features & AHC_TWIN) ? 2 : 1;
+ ahc->sc_adapter.adapt_openings = AHC_SCB_MAX;
+ ahc->sc_adapter.adapt_max_periph = AHC_SCB_MAX;
+ ahc->sc_adapter.adapt_ioctl = ahc_ioctl;
+ ahc->sc_adapter.adapt_minphys = ahcminphys;
+ ahc->sc_adapter.adapt_request = ahc_action;
+
+ ahc->sc_channel.chan_adapter = &ahc->sc_adapter;
+ ahc->sc_channel.chan_bustype = &scsi_bustype;
+ ahc->sc_channel.chan_channel = 0;
+ ahc->sc_channel.chan_ntargets = (ahc->features & AHC_WIDE) ? 16 : 8;
+ ahc->sc_channel.chan_nluns = 8;
+ ahc->sc_channel.chan_id = ahc->our_id;
+
if (ahc->features & AHC_TWIN) {
- ahc->sc_link_b = ahc->sc_link;
- ahc->sc_link_b.scsipi_scsi.adapter_target = ahc->our_id_b;
- ahc->sc_link_b.scsipi_scsi.channel = 1;
+ ahc->sc_channel_b = ahc->sc_channel;
+ ahc->sc_channel_b.chan_id = ahc->our_id_b;
+ ahc->sc_channel_b.chan_channel = 1;
}
if ((ahc->flags & AHC_CHANNEL_B_PRIMARY) == 0) {
- ahc->sc_link_b.scsipi_scsi.scsibus = 0xff;
- config_found((void *)ahc, &ahc->sc_link, scsiprint);
+ config_found((void *)ahc, &ahc->sc_channel, scsiprint);
if (ahc->features & AHC_TWIN)
- config_found((void *)ahc, &ahc->sc_link_b, scsiprint);
+ config_found((void *)ahc, &ahc->sc_channel_b,
+ scsiprint);
} else {
- config_found((void *)ahc, &ahc->sc_link_b, scsiprint);
- config_found((void *)ahc, &ahc->sc_link, scsiprint);
+ config_found((void *)ahc, &ahc->sc_channel_b, scsiprint);
+ config_found((void *)ahc, &ahc->sc_channel, scsiprint);
}
return 1;
}
@@ -1765,7 +1730,7 @@
break;
}
/* Freeze the queue unit the client sees the error. */
- ahc_freeze_devq(ahc, xs->sc_link);
+ ahc_freeze_devq(ahc, xs->xs_periph);
ahc_freeze_ccb(scb);
xs->status = hscb->status;
switch (hscb->status) {
@@ -1777,7 +1742,7 @@
case SCSI_STATUS_CHECK_COND:
#if defined(AHC_DEBUG)
if (ahc_debug & AHC_SHOWSENSE) {
- scsi_print_addr(xs->sc_link);
+ scsipi_printaddr(xs->xs_periph);
printf("Check Status, resid %d datalen %d\n",
xs->resid, xs->datalen);
}
@@ -1802,7 +1767,7 @@
#ifdef AHC_DEBUG
if (ahc_debug & AHC_SHOWSENSE) {
- scsi_print_addr(xs->sc_link);
+ scsipi_printaddr(xs->xs_periph);
printf("Sending Sense\n");
}
#endif
@@ -1834,7 +1799,7 @@
ahc_calc_residual(scb);
#if defined(AHC_DEBUG)
if (ahc_debug & AHC_SHOWSENSE) {
- scsi_print_addr(xs->sc_link);
+ scsipi_printaddr(xs->xs_periph);
printf("Sense: datalen %d resid %d"
"chan %d id %d targ %d\n",
xs->datalen, xs->resid,
@@ -1884,15 +1849,8 @@
}
break;
case SCSI_STATUS_QUEUE_FULL:
- scsi_print_addr(xs->sc_link);
- printf("queue full\n");
case SCSI_STATUS_BUSY:
- /*
- * XXX middle layer doesn't handle XS_BUSY well.
- * So, requeue this ourselves internally.
- */
xs->error = XS_BUSY;
- scb->flags |= SCB_REQUEUE;
break;
}
break;
@@ -2017,12 +1975,12 @@
if (lastphase == phase_table[i].phase)
break;
}
- scsi_print_addr(scb->xs->sc_link);
+ scsipi_printaddr(scb->xs->xs_periph);
printf("data overrun detected %s."
" Tag == 0x%x.\n",
phase_table[i].phasemsg,
scb->hscb->tag);
- scsi_print_addr(scb->xs->sc_link);
+ scsipi_printaddr(scb->xs->xs_periph);
printf("%s seen Data Phase. Length = %d. NumSGs = %d.\n",
ahc_inb(ahc, SEQ_FLAGS) & DPHASE ? "Have" : "Haven't",
scb->xs->datalen, scb->sg_count);
@@ -2038,7 +1996,7 @@
* Set this and it will take affect when the
* target does a command complete.
*/
- ahc_freeze_devq(ahc, scb->xs->sc_link);
+ ahc_freeze_devq(ahc, scb->xs->xs_periph);
ahcsetccbstatus(scb->xs, XS_DRIVER_STUFFUP);
ahc_freeze_ccb(scb);
break;
@@ -2187,7 +2145,7 @@
}
mesg_out = phase_table[i].mesg_out;
if (scb != NULL)
- scsi_print_addr(scb->xs->sc_link);
+ scsipi_printaddr(scb->xs->xs_periph);
Home |
Main Index |
Thread Index |
Old Index