summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2006-05-22 01:08:40 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2006-05-22 01:08:40 +0000
commitc4173c67ff912f5a6c323a652651d5ba63abaf70 (patch)
tree37715b0a2aff528dbb0e1ed19b6399bfcba79333 /sys/dev/ic
parent71b92a5af276d179d321e20d38b1aca8377af937 (diff)
Add first half of BIOCVOL primitive.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/mfi.c64
-rw-r--r--sys/dev/ic/mfireg.h29
-rw-r--r--sys/dev/ic/mfivar.h8
3 files changed, 92 insertions, 9 deletions
diff --git a/sys/dev/ic/mfi.c b/sys/dev/ic/mfi.c
index 79fefe77772..73ea9f79124 100644
--- a/sys/dev/ic/mfi.c
+++ b/sys/dev/ic/mfi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfi.c,v 1.47 2006/05/21 22:56:45 marco Exp $ */
+/* $OpenBSD: mfi.c,v 1.48 2006/05/22 01:08:39 marco Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
*
@@ -43,8 +43,8 @@
#ifdef MFI_DEBUG
uint32_t mfi_debug = 0
/* | MFI_D_CMD */
- | MFI_D_INTR
- | MFI_D_MISC
+/* | MFI_D_INTR */
+/* | MFI_D_MISC */
/* | MFI_D_DMA */
| MFI_D_IOCTL
/* | MFI_D_RW */
@@ -914,6 +914,7 @@ 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;
struct scsi_rw *rw;
struct scsi_rw_big *rwb;
@@ -974,6 +975,15 @@ mfi_scsi_cmd(struct scsi_xfer *xs)
/* NOTREACHED */
/* hand it of to the firmware and let it deal with it */
+ case TEST_UNIT_READY:
+ printf("%#x %#x %#x %d\n", sc, target, dev,
+ sizeof(sc->sc_ld[target].ld_dev));
+ /* save off sd? after autoconf */
+ if (!cold) /* XXX bogus */
+ strlcpy(sc->sc_ld[target].ld_dev, dev->dv_xname,
+ sizeof(sc->sc_ld[target].ld_dev));
+ /* FALLTHROUGH */
+
default:
if (mfi_scsi_ld(ccb, xs)) {
mfi_put_ccb(ccb);
@@ -1256,7 +1266,53 @@ mfi_ioctl_inq(struct mfi_softc *sc, struct bioc_inq *bi)
int
mfi_ioctl_vol(struct mfi_softc *sc, struct bioc_vol *bv)
{
- return (ENOTTY); /* XXX not yet */
+ int i, rv = EINVAL;
+
+ DNPRINTF(MFI_D_IOCTL, "%s: mfi_ioctl_vol %#x\n",
+ DEVNAME(sc), bv->bv_volid);
+
+ if (mfi_mgmt(sc, MR_DCMD_LD_GET_LIST, MFI_DATA_IN,
+ sizeof(sc->sc_ld_list), &sc->sc_ld_list))
+ goto done;
+
+ if (bv->bv_volid > sc->sc_ld_list.mll_no_ld) {
+ /* XXX go do hotspares */
+ goto done;
+ }
+
+ i = bv->bv_volid;
+
+ strlcpy(bv->bv_dev, sc->sc_ld[i].ld_dev, sizeof(bv->bv_dev));
+
+ switch(sc->sc_ld_list.mll_list[i].mll_state) {
+ case MFI_LD_OFFLINE:
+ bv->bv_status = BIOC_SVOFFLINE;
+ break;
+
+ case MFI_LD_PART_DEGRADED:
+ case MFI_LD_DEGRADED:
+ bv->bv_status = BIOC_SVDEGRADED;
+ break;
+
+ case MFI_LD_ONLINE:
+ bv->bv_status = BIOC_SVONLINE;
+ break;
+
+ default:
+ bv->bv_status = BIOC_SVINVALID;
+ DNPRINTF(MFI_D_IOCTL, "%s: invalid logical disk state %#x\n",
+ DEVNAME(sc),
+ sc->sc_ld_list.mll_list[i].mll_state);
+ }
+
+#if 0
+ bv->bv_level = 5;
+ bv->bv_nodisk = 2;
+ bv->bv_size = sc->sc_ld_list.mll_list[i].mll_size;
+#endif
+ rv = 0;
+done:
+ return (rv);
}
int
diff --git a/sys/dev/ic/mfireg.h b/sys/dev/ic/mfireg.h
index 928c35b2e5d..b08c18089e9 100644
--- a/sys/dev/ic/mfireg.h
+++ b/sys/dev/ic/mfireg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfireg.h,v 1.14 2006/05/21 14:03:01 marco Exp $ */
+/* $OpenBSD: mfireg.h,v 1.15 2006/05/22 01:08:39 marco Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
*
@@ -92,6 +92,8 @@
#define MR_DCMD_CTRL_EVENT_GET_INFO 0x01040100
#define MR_DCMD_CTRL_EVENT_GET 0x01040300
#define MR_DCMD_CTRL_EVENT_WAIT 0x01040500
+#define MR_DCMD_LD_GET_LIST 0x03010000
+#define MR_DCMD_LD_GET_INFO 0x03020000
#define MR_DCMD_LD_GET_PROPERTIES 0x03030000
#define MR_DCMD_CLUSTER 0x08000000
#define MR_DCMD_CLUSTER_RESET_ALL 0x08010100
@@ -576,7 +578,6 @@ struct mfi_info_component {
char mic_build_time[16];
} __packed;
-
/* controller info from MFI_DCMD_CTRL_GETINFO. */
struct mfi_ctrl_info {
struct mfi_info_pci mci_pci;
@@ -678,3 +679,27 @@ struct mfi_ctrl_info {
char mci_package_version[0x60];
uint8_t mci_pad[0x800 - 0x6a0];
} __packed;
+
+/* logical disk info from MR_DCMD_LD_GET_LIST */
+struct mfi_ld {
+ uint8_t mld_target;
+ uint8_t mld_res;
+ uint16_t mld_seq;
+} __packed;
+
+struct mfi_ld_list {
+ uint32_t mll_no_ld;
+ uint32_t mll_res;
+ struct {
+ struct mfi_ld mll_ld;
+ uint8_t mll_state;
+#define MFI_LD_OFFLINE 0x00
+#define MFI_LD_PART_DEGRADED 0x01
+#define MFI_LD_DEGRADED 0x02
+#define MFI_LD_ONLINE 0x03
+ uint8_t mll_res2;
+ uint8_t mll_res3;
+ uint8_t mll_res4;
+ u_quad_t mll_size;
+ } mll_list[MFI_MAX_LD];
+} __packed;
diff --git a/sys/dev/ic/mfivar.h b/sys/dev/ic/mfivar.h
index bcc1b4bbc75..c3ae7c7df51 100644
--- a/sys/dev/ic/mfivar.h
+++ b/sys/dev/ic/mfivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfivar.h,v 1.21 2006/05/21 20:20:17 marco Exp $ */
+/* $OpenBSD: mfivar.h,v 1.22 2006/05/22 01:08:39 marco Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
*
@@ -106,10 +106,11 @@ struct mfi_softc {
/* mgmt lock */
struct rwlock sc_lock;
- /* save some useful information for logical drives */
+ /* save some useful information for logical drives that is missing
+ * in sc_ld_list
+ */
struct {
uint32_t ld_present;
- quad_t ld_size; /* READ CAPICITY */
char ld_dev[16]; /* device name sd? */
} sc_ld[MFI_MAX_LD];
@@ -122,6 +123,7 @@ struct mfi_softc {
uint32_t sc_max_ld;
uint32_t sc_ld_cnt;
struct mfi_ctrl_info sc_info;
+ struct mfi_ld_list sc_ld_list;
/* all commands */
struct mfi_ccb *sc_ccb;