summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2006-05-10 21:48:51 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2006-05-10 21:48:51 +0000
commitf85856a43bf1e03896ac249848b84689c3f9ccdf (patch)
treeafa811f8d0494d31ed734b217c74da163172ec91 /sys
parent787b2a2682f76d628dbe673665840a52ea0e3b74 (diff)
Add some airplane code.
add bio hooks. add scsi entry point for io.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/mfi.c156
-rw-r--r--sys/dev/ic/mfireg.h3
-rw-r--r--sys/dev/ic/mfivar.h12
3 files changed, 154 insertions, 17 deletions
diff --git a/sys/dev/ic/mfi.c b/sys/dev/ic/mfi.c
index be4e1d092d8..bf2bb156d2c 100644
--- a/sys/dev/ic/mfi.c
+++ b/sys/dev/ic/mfi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfi.c,v 1.24 2006/04/26 01:25:37 marco Exp $ */
+/* $OpenBSD: mfi.c,v 1.25 2006/05/10 21:48:50 marco Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
*
@@ -38,7 +38,7 @@
#if NBIO > 0
#include <dev/biovar.h>
-#endif
+#endif /* NBIO > 0 */
#ifdef MFI_DEBUG
uint32_t mfi_debug = 0
@@ -82,6 +82,17 @@ int mfi_initialize_firmware(struct mfi_softc *);
int mfi_despatch_cmd(struct mfi_softc *, struct mfi_ccb *);
int mfi_poll(struct mfi_softc *, struct mfi_ccb *);
+int mfi_start_xs(struct mfi_softc *, struct mfi_ccb *,
+ struct scsi_xfer *);
+
+#if NBIO > 0
+int mfi_ioctl(struct device *, u_long, caddr_t);
+int mfi_ioctl_inq(struct mfi_softc *, struct bioc_inq *);
+int mfi_ioctl_vol(struct mfi_softc *, struct bioc_vol *);
+int mfi_ioctl_disk(struct mfi_softc *, struct bioc_disk *);
+int mfi_ioctl_alarm(struct mfi_softc *, struct bioc_alarm *);
+int mfi_ioctl_setstate(struct mfi_softc *, struct bioc_setstate *);
+#endif /* NBIO > 0 */
struct mfi_ccb *
mfi_get_ccb(struct mfi_softc *sc)
@@ -363,7 +374,7 @@ mfiminphys(struct buf *bp)
{
DNPRINTF(MFI_D_MISC, "mfiminphys: %d\n", bp->b_bcount);
-#define MFI_MAXFER 4096
+ /* XXX currently using MFI_MAXFER = MAXPHYS */
if (bp->b_bcount > MFI_MAXFER)
bp->b_bcount = MFI_MAXFER;
minphys(bp);
@@ -435,6 +446,15 @@ mfi_attach(struct mfi_softc *sc)
/* enable interrupts */
mfi_write(sc, MFI_OMSK, MFI_ENABLE_INTR);
+#if NBIO > 0
+ if (bio_register(&sc->sc_dev, mfi_ioctl) != 0)
+ panic("%s: controller registration failed", DEVNAME(sc));
+ else
+ sc->sc_ioctl = mfi_ioctl;
+#endif /* NBIO > 0 */
+
+ config_found(&sc->sc_dev, &sc->sc_link, scsiprint);
+
return (0);
noinit:
mfi_freemem(sc, sc->sc_sense);
@@ -528,29 +548,135 @@ mfi_intr(void *arg)
}
int
+mfi_scsi_cmd(struct scsi_xfer *xs)
+{
+ struct scsi_link *link = xs->sc_link;
+ struct mfi_softc *sc = link->adapter_softc;
+ /* struct device *dev = link->device_softc; */
+ struct mfi_ccb *ccb;
+ u_int8_t target = link->target;
+
+ DNPRINTF(MFI_D_CMD, "mfi_scsi_cmd\n");
+
+ /* only issue IO through this path, create seperate path for mgmt */
+
+ if (target >= MFI_MAX_LD || !sc->sc_ld[target].ld_present ||
+ link->lun != 0) {
+ DNPRINTF(MFI_D_CMD, "%s: invalid target %d ",
+ DEVNAME(sc), target);
+ xs->error = XS_DRIVER_STUFFUP;
+ xs->flags |= ITSDONE;
+ scsi_done(xs);
+ return (COMPLETE);
+ }
+
+ xs->error = XS_NOERROR;
+
+
+ switch (xs->cmd->opcode) {
+ case READ_COMMAND: /* IO path */
+ case READ_BIG:
+ case WRITE_COMMAND:
+ case WRITE_BIG:
+ break;
+
+ default: /* the rest is a DCDB */
+ break;
+ }
+
+ return (mfi_start_xs(sc, ccb, xs));
+}
+
+int mfi_start_xs(struct mfi_softc *sc, struct mfi_ccb *ccb,
+ struct scsi_xfer *xs)
+{
+ return (1); /* XXX not yet */
+}
+
+int
mfi_scsi_ioctl(struct scsi_link *link, u_long cmd, caddr_t addr, int flag,
struct proc *p)
{
+ struct mfi_softc *sc = (struct mfi_softc *)link->adapter_softc;
+
DNPRINTF(MFI_D_IOCTL, "mfi_scsi_ioctl\n");
-#if 0
- struct ami_softc *sc = (struct ami_softc *)link->adapter_softc;
if (sc->sc_ioctl)
return (sc->sc_ioctl(link->adapter_softc, cmd, addr));
else
return (ENOTTY);
-#endif
- return (ENOTTY);
}
+#if NBIO > 0
int
-mfi_scsi_cmd(struct scsi_xfer *xs)
+mfi_ioctl(struct device *dev, u_long cmd, caddr_t addr)
{
- DNPRINTF(MFI_D_CMD, "mfi_scsi_cmd\n");
-#if 0
- struct scsi_link *link = xs->sc_link;
- struct ami_softc *sc = link->adapter_softc;
- struct device *dev = link->device_softc;
-#endif
- return (0);
+ struct mfi_softc *sc = (struct mfi_softc *)dev;
+ int error = 0;
+
+ DNPRINTF(MFI_D_IOCTL, "%s: ioctl ", DEVNAME(sc));
+
+ switch (cmd) {
+ case BIOCINQ:
+ DNPRINTF(MFI_D_IOCTL, "inq ");
+ error = mfi_ioctl_inq(sc, (struct bioc_inq *)addr);
+ break;
+
+ case BIOCVOL:
+ DNPRINTF(MFI_D_IOCTL, "vol ");
+ error = mfi_ioctl_vol(sc, (struct bioc_vol *)addr);
+ break;
+
+ case BIOCDISK:
+ DNPRINTF(MFI_D_IOCTL, "disk ");
+ error = mfi_ioctl_disk(sc, (struct bioc_disk *)addr);
+ break;
+
+ case BIOCALARM:
+ DNPRINTF(MFI_D_IOCTL, "alarm ");
+ error = mfi_ioctl_alarm(sc, (struct bioc_alarm *)addr);
+ break;
+
+ case BIOCSETSTATE:
+ DNPRINTF(MFI_D_IOCTL, "setstate ");
+ error = mfi_ioctl_setstate(sc, (struct bioc_setstate *)addr);
+ break;
+
+ default:
+ DNPRINTF(MFI_D_IOCTL, " invalid ioctl\n");
+ error = EINVAL;
+ }
+
+ return (error);
+}
+
+int
+mfi_ioctl_inq(struct mfi_softc *sc, struct bioc_inq *bi)
+{
+ return (ENOTTY); /* XXX not yet */
+}
+
+int
+mfi_ioctl_vol(struct mfi_softc *sc, struct bioc_vol *bv)
+{
+ return (ENOTTY); /* XXX not yet */
+}
+
+int
+mfi_ioctl_disk(struct mfi_softc *sc, struct bioc_disk *bd)
+{
+ return (ENOTTY); /* XXX not yet */
+}
+
+int
+mfi_ioctl_alarm(struct mfi_softc *sc, struct bioc_alarm *ba)
+{
+ return (ENOTTY); /* XXX not yet */
+}
+
+int
+mfi_ioctl_setstate(struct mfi_softc *sc, struct bioc_setstate *bs)
+{
+ return (ENOTTY); /* XXX not yet */
}
+#endif /* NBIO > 0 */
diff --git a/sys/dev/ic/mfireg.h b/sys/dev/ic/mfireg.h
index cb970cc0e0d..d917e22ad5b 100644
--- a/sys/dev/ic/mfireg.h
+++ b/sys/dev/ic/mfireg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfireg.h,v 1.9 2006/04/21 21:39:32 marco Exp $ */
+/* $OpenBSD: mfireg.h,v 1.10 2006/05/10 21:48:50 marco Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
*
@@ -21,6 +21,7 @@
#define MFI_OSTS_INTR_VALID 0x00000002 /* valid interrupt */
#define MFI_INVALID_CTX 0xffffffff
#define MFI_ENABLE_INTR 0x01
+#define MFI_MAXFER MAXPHYS /* XXX bogus */
/* register offsets */
#define MFI_IMSG0 0x10 /* inbound msg 0 */
diff --git a/sys/dev/ic/mfivar.h b/sys/dev/ic/mfivar.h
index 42d3b0c6008..8c0a244ee27 100644
--- a/sys/dev/ic/mfivar.h
+++ b/sys/dev/ic/mfivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfivar.h,v 1.13 2006/04/21 21:39:32 marco Exp $ */
+/* $OpenBSD: mfivar.h,v 1.14 2006/05/10 21:48:50 marco Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
*
@@ -93,6 +93,16 @@ struct mfi_softc {
bus_space_handle_t sc_ioh;
bus_dma_tag_t sc_dmat;
+ /* save some useful information for logical drives */
+ struct {
+ uint32_t ld_present;
+ quad_t ld_size; /* READ CAPICITY */
+ char ld_dev[16]; /* device name sd? */
+ } sc_ld[MFI_MAX_LD];
+
+ /* scsi ioctl from sd device */
+ int (*sc_ioctl)(struct device *, u_long, caddr_t);
+
/* firmware determined max and totals */
uint32_t sc_max_cmds;
uint32_t sc_max_sgl;