summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2014-01-18 07:36:35 +0000
committerdlg <dlg@openbsd.org>2014-01-18 07:36:35 +0000
commitcace1783b57d1a67bfeb1b310eb379e1e60abb0e (patch)
treebdc472890c9232ee403ed50ff7956e9e8a0e7f77
parentFix comment re size of input buffer. (diff)
downloadwireguard-openbsd-cace1783b57d1a67bfeb1b310eb379e1e60abb0e.tar.xz
wireguard-openbsd-cace1783b57d1a67bfeb1b310eb379e1e60abb0e.zip
replace XS_NO_CCB with iopools.
compiled and tweaked by martin@
-rw-r--r--sys/dev/ic/ncr5380sbc.c64
-rw-r--r--sys/dev/ic/ncr5380var.h5
2 files changed, 50 insertions, 19 deletions
diff --git a/sys/dev/ic/ncr5380sbc.c b/sys/dev/ic/ncr5380sbc.c
index 984727c6410..887dd966b28 100644
--- a/sys/dev/ic/ncr5380sbc.c
+++ b/sys/dev/ic/ncr5380sbc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ncr5380sbc.c,v 1.30 2011/07/17 22:46:48 matthew Exp $ */
+/* $OpenBSD: ncr5380sbc.c,v 1.31 2014/01/18 07:36:35 dlg Exp $ */
/* $NetBSD: ncr5380sbc.c,v 1.13 1996/10/13 01:37:25 christos Exp $ */
/*
@@ -88,6 +88,9 @@
#include <dev/ic/ncr5380reg.h>
#include <dev/ic/ncr5380var.h>
+static void * ncr5380_io_get(void *);
+static void ncr5380_io_put(void *, void *);
+
static void ncr5380_sched(struct ncr5380_softc *);
static void ncr5380_done(struct ncr5380_softc *);
@@ -362,14 +365,17 @@ ncr5380_init(sc)
for (i = 0; i < SCI_OPENINGS; i++) {
sr = &sc->sc_ring[i];
- sr->sr_xs = NULL;
+ sr->sr_flags = SR_FREE;
timeout_set(&sr->sr_timeout, ncr5380_cmd_timeout, sr);
}
for (i = 0; i < 8; i++)
for (j = 0; j < 8; j++)
sc->sc_matrix[i][j] = NULL;
+ scsi_iopool_init(&sc->sc_iopool, sc, ncr5380_io_get, ncr5380_io_put);
+
sc->sc_link.openings = 2; /* XXX - Not SCI_OPENINGS */
+ sc->sc_link.pool = &sc->sc_iopool;
sc->sc_prevphase = PHASE_INVALID;
sc->sc_state = NCR_IDLE;
@@ -585,6 +591,43 @@ out:
*****************************************************************/
+void *
+ncr5380_io_get(void *xsc)
+{
+ struct ncr5380_softc *sc = xsc;
+ struct sci_req *sr = NULL;
+ int s, i;
+
+ /*
+ * Find lowest empty slot in ring buffer.
+ * XXX: What about "fairness" and cmd order?
+ */
+
+ s = splbio();
+ for (i = 0; i < SCI_OPENINGS; i++) {
+ if (sc->sc_ring[i].sr_flags == SR_FREE) {
+ sr = &sc->sc_ring[i];
+ sr->sr_flags = 0;
+ sc->sc_ncmds++;
+ break;
+ }
+ }
+ splx(s);
+
+ return (sr);
+}
+
+void
+ncr5380_io_put(void *xsc, void *xsr)
+{
+ struct sci_req *sr = xsr;
+ int s;
+
+ s = splbio();
+ sr->sr_flags = SR_FREE;
+ splx(s);
+}
+
/*
* Enter a new SCSI command into the "issue" queue, and
* if there is work to do, start it going.
@@ -622,22 +665,8 @@ ncr5380_scsi_cmd(xs)
}
}
- /*
- * Find lowest empty slot in ring buffer.
- * XXX: What about "fairness" and cmd order?
- */
- for (i = 0; i < SCI_OPENINGS; i++)
- if (sc->sc_ring[i].sr_xs == NULL)
- goto new;
-
- xs->error = XS_NO_CCB;
- scsi_done(xs);
- NCR_TRACE("scsi_cmd: no openings\n", 0);
- goto out;
-
-new:
/* Create queue entry */
- sr = &sc->sc_ring[i];
+ sr = xs->io;
sr->sr_xs = xs;
sr->sr_target = xs->sc_link->target;
sr->sr_lun = xs->sc_link->lun;
@@ -674,7 +703,6 @@ new:
#endif
}
-out:
splx(s);
}
diff --git a/sys/dev/ic/ncr5380var.h b/sys/dev/ic/ncr5380var.h
index 9e6361dc285..bcb41a4c44b 100644
--- a/sys/dev/ic/ncr5380var.h
+++ b/sys/dev/ic/ncr5380var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ncr5380var.h,v 1.12 2010/03/25 13:18:03 otto Exp $ */
+/* $OpenBSD: ncr5380var.h,v 1.13 2014/01/18 07:36:35 dlg Exp $ */
/* $NetBSD: ncr5380var.h,v 1.6 1996/05/10 18:04:06 gwr Exp $ */
/*
@@ -71,6 +71,7 @@ struct sci_req {
#define SR_SENSE 2 /* We are getting sense */
#define SR_OVERDUE 4 /* Timeout while not current */
#define SR_ERROR 8 /* Error occurred */
+#define SR_FREE 16 /* We are free */
int sr_status; /* Status code from last cmd */
struct timeout sr_timeout;
@@ -145,6 +146,8 @@ struct ncr5380_softc {
struct sci_req sc_ring[SCI_OPENINGS];
int sc_rr; /* Round-robin scan pointer */
+ struct scsi_iopool sc_iopool;
+
/* Active requests, by target/LUN */
struct sci_req *sc_matrix[8][8];