summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/ic/ami.c69
-rw-r--r--sys/dev/ic/amivar.h7
2 files changed, 74 insertions, 2 deletions
diff --git a/sys/dev/ic/ami.c b/sys/dev/ic/ami.c
index a5527e6d537..c7adec3d62d 100644
--- a/sys/dev/ic/ami.c
+++ b/sys/dev/ic/ami.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ami.c,v 1.143 2006/04/06 10:16:45 dlg Exp $ */
+/* $OpenBSD: ami.c,v 1.144 2006/04/18 04:15:44 marco Exp $ */
/*
* Copyright (c) 2001 Michael Shalayeff
@@ -68,6 +68,7 @@
#if NBIO > 0
#include <dev/biovar.h>
+#include <sys/sensors.h>
#endif
/*#define AMI_DEBUG */
@@ -165,6 +166,7 @@ int ami_ioctl_vol(struct ami_softc *, struct bioc_vol *);
int ami_ioctl_disk(struct ami_softc *, struct bioc_disk *);
int ami_ioctl_alarm(struct ami_softc *, struct bioc_alarm *);
int ami_ioctl_setstate(struct ami_softc *, struct bioc_setstate *);
+void ami_refresh(void *);
#endif /* NBIO > 0 */
#define DEVNAME(_s) ((_s)->sc_dev.dv_xname)
@@ -573,6 +575,9 @@ ami_attach(struct ami_softc *sc)
printf("%s: controller registration failed", DEVNAME(sc));
else
sc->sc_ioctl = ami_ioctl;
+
+ if (sensor_task_register(sc, ami_refresh, 10))
+ printf("%s: unable to register update task\n", DEVNAME(sc));
#endif /* NBIO > 0 */
config_found(&sc->sc_dev, &sc->sc_link, scsiprint);
@@ -1008,6 +1013,7 @@ ami_runqueue(void *arg)
s = splbio();
while ((ccb = TAILQ_FIRST(&sc->sc_ccb_preq)) != NULL) {
if (sc->sc_exec(sc, &ccb->ccb_cmd) != 0) {
+ /* this is now raceable too with other incomming io */
timeout_add(&sc->sc_run_tmo, 1);
break;
}
@@ -1025,6 +1031,11 @@ ami_poll(struct ami_softc *sc, struct ami_ccb *ccb)
int error;
int s;
+ /* XXX this is broken, shall drain IO or consider this
+ * a normal completion which can complete async and
+ * polled commands until the polled commands completes
+ */
+
s = splbio();
error = sc->sc_poll(sc, &ccb->ccb_cmd);
splx(s);
@@ -1115,6 +1126,7 @@ ami_stimeout(void *v)
break;
case AMI_CCB_QUEUED:
+ /* XXX create a list to save ccb to and print the whole list */
printf("%s: timeout ccb %d\n", DEVNAME(sc), cmd->acc_id);
s = splbio();
TAILQ_REMOVE(&sc->sc_ccb_runq, ccb, ccb_link);
@@ -2426,6 +2438,61 @@ bail:
return (EINVAL);
}
+
+void
+ami_refresh(void *arg)
+{
+ struct ami_softc *sc = arg;
+ int i;
+
+ if (sc->sc_first_poll == 0) {
+ sc->sc_first_poll = 1;
+ sc->sc_sens_ld = malloc(sizeof(struct sensor) * sc->sc_nunits,
+ M_DEVBUF, M_WAITOK);
+ sc->sc_bd = malloc(sizeof *sc->sc_bd, M_DEVBUF, M_WAITOK);
+
+ for (i = 0; i < sc->sc_nunits; i++) {
+ strlcpy(sc->sc_sens_ld[i].device, sc->sc_hdr[i].dev,
+ sizeof(sc->sc_sens_ld[i].device));
+ strlcpy(sc->sc_sens_ld[i].desc, "logical disk",
+ sizeof(sc->sc_sens_ld[i].desc));
+ sc->sc_sens_ld[i].type = SENSOR_DRIVE;
+ sensor_add(&sc->sc_sens_ld[i]);
+ sc->sc_sens_ld[i].value = SENSOR_DRIVE_ONLINE;
+ sc->sc_sens_ld[i].status = SENSOR_S_OK;
+ }
+ }
+
+ if (ami_mgmt(sc, AMI_FCOP, AMI_FC_RDCONF, 0, 0, sizeof *sc->sc_bd,
+ sc->sc_bd)) {
+ sc->sc_sens_ld[i].value = 0xffff; /* unknown */
+ sc->sc_sens_ld[i].status = SENSOR_S_UNKNOWN;
+ return;
+ }
+
+ for (i = 0; i < sc->sc_nunits; i++) {
+ switch (sc->sc_bd->ald[i].adl_status) {
+ case AMI_RDRV_OFFLINE:
+ sc->sc_sens_ld[i].value = SENSOR_DRIVE_FAIL;
+ sc->sc_sens_ld[i].status = SENSOR_S_CRIT;
+ break;
+
+ case AMI_RDRV_DEGRADED:
+ sc->sc_sens_ld[i].value = SENSOR_DRIVE_PFAIL;
+ sc->sc_sens_ld[i].status = SENSOR_S_WARN;
+ break;
+
+ case AMI_RDRV_OPTIMAL:
+ sc->sc_sens_ld[i].value = SENSOR_DRIVE_ONLINE;
+ sc->sc_sens_ld[i].status = SENSOR_S_OK;
+ break;
+
+ default:
+ sc->sc_sens_ld[i].value = 0xffff; /* unknown */
+ sc->sc_sens_ld[i].status = SENSOR_S_UNKNOWN;
+ }
+ }
+}
#endif /* NBIO > 0 */
#ifdef AMI_DEBUG
diff --git a/sys/dev/ic/amivar.h b/sys/dev/ic/amivar.h
index e04304f54a5..0a3bba308a4 100644
--- a/sys/dev/ic/amivar.h
+++ b/sys/dev/ic/amivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: amivar.h,v 1.44 2006/03/29 13:38:05 dlg Exp $ */
+/* $OpenBSD: amivar.h,v 1.45 2006/04/18 04:15:44 marco Exp $ */
/*
* Copyright (c) 2001 Michael Shalayeff
@@ -138,6 +138,11 @@ struct ami_softc {
char dev[16];
} sc_hdr[AMI_BIG_MAX_LDRIVES];
struct ami_rawsoftc *sc_rawsoftcs;
+#if NBIO > 0
+ int sc_first_poll;
+ struct sensor *sc_sens_ld;
+ struct ami_big_diskarray *sc_bd;
+#endif /* NBIO > 0 */
};
int ami_attach(struct ami_softc *sc);