diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2009-12-07 00:09:28 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2009-12-07 00:09:28 +0000 |
commit | 58a4e7b7de70e518b1c79dc925ae9fe43c19d0a1 (patch) | |
tree | 913d7f667a8e320e2b81cb770fb90f52e4f65e53 | |
parent | 6d262f975b7e28d7b49723dfd00cbb96963b8943 (diff) |
Re-enable SCSIDEBUG display of commands and data. Original diff
from dlg@, tweaking by me to make it compile.
ok dlg@
-rw-r--r-- | sys/scsi/scsi_base.c | 74 | ||||
-rw-r--r-- | sys/scsi/sd.c | 12 |
2 files changed, 79 insertions, 7 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index 97b74b62c0e..70fbf7b546d 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.145 2009/12/01 01:50:35 dlg Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.146 2009/12/07 00:09:27 krw Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -716,6 +716,14 @@ scsi_xs_exec(struct scsi_xfer *xs) xs->resid = xs->datalen; xs->status = 0; +#ifdef SCSIDEBUG + if (xs->sc_link->flags & SDEV_DB1) { + show_scsi_xs(xs); + if (xs->datalen && (xs->flags & SCSI_DATA_OUT)) + show_mem(xs->data, min(64, xs->datalen)); + } +#endif /* SCSIDEBUG */ + /* * scsi_xs_exec() guarantees that scsi_done() will be called on the xs * it was given. The adapter is responsible for calling scsi_done() @@ -750,6 +758,15 @@ scsi_done(struct scsi_xfer *xs) xs->flags |= ITSDONE; +#ifdef SCSIDEBUG + if (xs->sc_link->flags & SDEV_DB1) { + if (xs->datalen && (xs->flags & SCSI_DATA_IN)) + show_mem(xs->data, min(64, xs->datalen)); + if (xs->status == XS_SENSE || xs->status == XS_SHORTSENSE) + show_mem((u_char *)&xs->sense, sizeof(xs->sense)); + } +#endif /* SCSIDEBUG */ + xs->done(xs); } @@ -1852,3 +1869,58 @@ scsi_decode_sense(struct scsi_sense_data *sense, int flag) return (rqsbuf); } + +#ifdef SCSIDEBUG +/* + * Given a scsi_xfer, dump the request, in all its glory + */ +void +show_scsi_xs(struct scsi_xfer *xs) +{ + u_char *b = (u_char *)xs->cmd; + int i = 0; + + sc_print_addr(xs->sc_link); + + printf("xs(%p): ", xs); + + printf("flg(0x%x)", xs->flags); + printf("sc_link(%p)", xs->sc_link); + printf("retr(0x%x)", xs->retries); + printf("timo(0x%x)", xs->timeout); + printf("cmd(%p)", xs->cmd); + printf("len(0x%x)", xs->cmdlen); + printf("data(%p)", xs->data); + printf("len(0x%x)", xs->datalen); + printf("res(0x%x)", xs->resid); + printf("err(0x%x)", xs->error); + printf("bp(%p)\n", xs->bp); + + printf("command: "); + + if ((xs->flags & SCSI_RESET) == 0) { + while (i < xs->cmdlen) { + if (i) + printf(","); + printf("%x", b[i++]); + } + printf("-[%d bytes]\n", xs->datalen); + } else + printf("-RESET-\n"); +} + +void +show_mem(u_char *address, int num) +{ + int x; + + printf("------------------------------"); + for (x = 0; x < num; x++) { + if ((x % 16) == 0) + printf("\n%03d: ", x); + printf("%02x ", *address++); + } + printf("\n------------------------------\n"); +} +#endif /* SCSIDEBUG */ + diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index f532a6cf945..824729f8cb2 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.172 2009/12/06 17:24:28 krw Exp $ */ +/* $OpenBSD: sd.c,v 1.173 2009/12/07 00:09:27 krw Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -691,7 +691,7 @@ sdstart(void *v) if (sc->flags & SDF_DYING) return; - SC_DEBUG(sc_link, SDEV_DB2, ("sdstart\n")); + SC_DEBUG(link, SDEV_DB2, ("sdstart\n")); mtx_enter(&sc->sc_start_mtx); if (ISSET(sc->flags, SDF_STARTING)) { @@ -1492,7 +1492,7 @@ sd_flush(struct sd_softc *sc, int flags) xs = scsi_xs_get(link, flags); if (xs == NULL) { - SC_DEBUG(sc_link, SDEV_DB1, ("cache sync failed to get xs\n")); + SC_DEBUG(link, SDEV_DB1, ("cache sync failed to get xs\n")); return; } @@ -1512,10 +1512,10 @@ sd_flush(struct sd_softc *sc, int flags) } } while (xs->status == XS_NO_CCB); - if (xs->error != XS_NOERROR) - SC_DEBUG(sc_link, SDEV_DB1, ("cache sync failed\n")); - else + if (xs->error == XS_NOERROR) sc->flags &= ~SDF_DIRTY; + else + SC_DEBUG(link, SDEV_DB1, ("cache sync failed\n")); scsi_xs_put(xs); } |