summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew@openbsd.org>2011-06-21 20:23:49 +0000
committermatthew <matthew@openbsd.org>2011-06-21 20:23:49 +0000
commit75e877fdeb0a44ad216b15f3504f2006973b6a78 (patch)
tree9b1d8367c2f9f8fce7f674d6bc518142e5f2da9d
parentConvert SO_RTABLE's protocol level to the SOL_SOCKET; ok claudio (diff)
downloadwireguard-openbsd-75e877fdeb0a44ad216b15f3504f2006973b6a78.tar.xz
wireguard-openbsd-75e877fdeb0a44ad216b15f3504f2006973b6a78.zip
Two dpt(4) fixes:
1. Change adapter_softc to point to a per-channel intermediary object instead of pointing to the dpt_softc directly. This removes dpt(4) dependency on scsibus unit numbers. 2. Fix dpt(4) to use a struct scsibus_attach_args instead of a struct scsi_link for attaching the scsibus. (Evidently no one has tried using dpt(4) since Nov 2006...) ok krw@, miod@
-rw-r--r--sys/dev/ic/dpt.c31
-rw-r--r--sys/dev/ic/dptvar.h8
2 files changed, 30 insertions, 9 deletions
diff --git a/sys/dev/ic/dpt.c b/sys/dev/ic/dpt.c
index 52dd9a00791..5f212a4dad6 100644
--- a/sys/dev/ic/dpt.c
+++ b/sys/dev/ic/dpt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dpt.c,v 1.32 2011/04/26 22:55:58 matthew Exp $ */
+/* $OpenBSD: dpt.c,v 1.33 2011/06/21 20:23:49 matthew Exp $ */
/* $NetBSD: dpt.c,v 1.12 1999/10/23 16:26:33 ad Exp $ */
/*-
@@ -357,18 +357,29 @@ dpt_init(sc, intrstr)
/* Fill in each link and attach in turn */
for (i = 0; i <= ec->ec_maxchannel; i++) {
+ struct scsibus_attach_args saa;
+ struct dpt_channel *ch;
struct scsi_link *link;
+
sc->sc_hbaid[i] = ec->ec_hba[3 - i];
+
+ ch = &sc->sc_channel[i];
+ ch->ch_sc = sc;
+ ch->ch_index = i;
+
link = &sc->sc_link[i];
- link->scsibus = i;
link->adapter_target = sc->sc_hbaid[i];
link->luns = ec->ec_maxlun + 1;
link->adapter_buswidth = ec->ec_maxtarget + 1;
link->adapter = &dpt_switch;
- link->adapter_softc = sc;
+ link->adapter_softc = ch;
link->openings = sc->sc_nccbs;
link->pool = &sc->sc_iopool;
- config_found(&sc->sc_dv, link, scsiprint);
+
+ bzero(&saa, sizeof(saa));
+ saa.saa_sc_link = link;
+
+ config_found(&sc->sc_dv, &saa, scsiprint);
}
}
@@ -788,6 +799,7 @@ dpt_scsi_cmd(struct scsi_xfer *xs)
{
int error, i, flags, s;
struct scsi_link *sc_link;
+ struct dpt_channel *ch;
struct dpt_softc *sc;
struct dpt_ccb *ccb;
struct eata_sg *sg;
@@ -797,7 +809,8 @@ dpt_scsi_cmd(struct scsi_xfer *xs)
sc_link = xs->sc_link;
flags = xs->flags;
- sc = sc_link->adapter_softc;
+ ch = sc_link->adapter_softc;
+ sc = ch->ch_sc;
dmat = sc->sc_dmat;
SC_DEBUG(sc_link, SDEV_DB2, ("dpt_scsi_cmd\n"));
@@ -827,7 +840,7 @@ dpt_scsi_cmd(struct scsi_xfer *xs)
cp->cp_ccbid = ccb->ccb_id;
cp->cp_id = sc_link->target;
cp->cp_lun = sc_link->lun;
- cp->cp_channel = sc_link->scsibus;
+ cp->cp_channel = ch->ch_index;
cp->cp_senselen = sizeof(ccb->ccb_sense);
cp->cp_stataddr = htobe32(sc->sc_sppa);
cp->cp_dispri = 1;
@@ -835,7 +848,7 @@ dpt_scsi_cmd(struct scsi_xfer *xs)
cp->cp_autosense = 1;
cp->cp_datain = ((xs->flags & SCSI_DATA_IN) != 0);
cp->cp_dataout = ((xs->flags & SCSI_DATA_OUT) != 0);
- cp->cp_interpret = (sc->sc_hbaid[sc_link->scsibus] == sc_link->target);
+ cp->cp_interpret = (sc->sc_hbaid[ch->ch_index] == sc_link->target);
/* Synchronous xfers musn't write-back through the cache */
if (xs->bp != NULL && (xs->bp->b_flags & (B_ASYNC | B_READ)) == 0)
@@ -943,6 +956,7 @@ dpt_timeout(arg)
{
struct scsi_link *sc_link;
struct scsi_xfer *xs;
+ struct dpt_channel *ch;
struct dpt_softc *sc;
struct dpt_ccb *ccb;
int s;
@@ -950,7 +964,8 @@ dpt_timeout(arg)
ccb = arg;
xs = ccb->ccb_xs;
sc_link = xs->sc_link;
- sc = sc_link->adapter_softc;
+ ch = sc_link->adapter_softc;
+ sc = ch->ch_sc;
sc_print_addr(sc_link);
printf("timed out (status:%02x aux status:%02x)",
diff --git a/sys/dev/ic/dptvar.h b/sys/dev/ic/dptvar.h
index be4b8672608..6731633e6f6 100644
--- a/sys/dev/ic/dptvar.h
+++ b/sys/dev/ic/dptvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dptvar.h,v 1.9 2011/04/26 22:55:58 matthew Exp $ */
+/* $OpenBSD: dptvar.h,v 1.10 2011/06/21 20:23:49 matthew Exp $ */
/* $NetBSD: dptvar.h,v 1.5 1999/10/23 16:26:32 ad Exp $ */
/*
@@ -54,10 +54,16 @@ struct dpt_ccb {
struct scsi_xfer *ccb_xs;
};
+struct dpt_channel {
+ struct dpt_softc *ch_sc;
+ int ch_index;
+};
+
struct dpt_softc {
struct device sc_dv; /* generic device data */
bus_space_handle_t sc_ioh; /* bus space handle */
struct scsi_link sc_link[3]; /* prototype link for each channel */
+ struct dpt_channel sc_channel[3];
struct eata_cfg sc_ec; /* EATA configuration data */
bus_space_tag_t sc_iot; /* bus space tag */
bus_dma_tag_t sc_dmat; /* bus DMA tag */