diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-09-23 15:21:18 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-09-23 15:21:18 +0000 |
commit | e32c35f2955502f4d44610338cf72c9f800ce3ec (patch) | |
tree | fbd9ce325ef9b9736845736fb37757952e36aa2f /sys | |
parent | 63cc1ce8a91b21a1b4178f7e0fabf714c4eab8e4 (diff) |
When printing the scsi_link info under SCSIDEBUG show state, luns,
openings, flags and quirks.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/scsi/scsi_base.c | 21 | ||||
-rw-r--r-- | sys/scsi/scsiconf.c | 129 | ||||
-rw-r--r-- | sys/scsi/scsiconf.h | 8 |
3 files changed, 117 insertions, 41 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index 6be48bb0c0d..fa3562e25f4 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.231 2019/09/21 00:12:15 krw Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.232 2019/09/23 15:21:17 krw Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -2552,6 +2552,25 @@ scsi_show_mem(u_char *address, int num) } printf("\n------------------------------\n"); } + +void +scsi_show_flags(u_int16_t flags, const char **names) +{ + int i, first; + + first = 1; + printf("<"); + for (i = 0; i < 16; i++) { + if (ISSET(flags, 1 << i)) { + if (first == 0) + printf(", "); + else + first = 0; + printf("%s", names[i]); + } + } + printf(">"); +} #endif /* SCSIDEBUG */ void diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 70fb4129afb..dd2da1e61a6 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.213 2019/09/16 16:34:14 krw Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.214 2019/09/23 15:21:17 krw Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -699,6 +699,45 @@ const struct scsi_quirk_inquiry_pattern scsi_quirk_patterns[] = { "UJDCD8730", "", "1.14"}, ADEV_NODOORLOCK}, /* Acer */ }; +#ifdef SCSIDEBUG +const char *flagnames[16] = { + "REMOVABLE", + "MEDIA LOADED", + "READONLY", + "OPEN", + "DB1", + "DB2", + "DB3", + "DB4", + "EJECTING", + "ATAPI", + "2NDBUS", + "UMASS", + "VIRTUAL", + "OWN", + "FLAG0x4000", + "FLAG0x8000" +}; + +const char *quirknames[16] = { + "AUTOSAVE", + "NOSYNC", + "NOWIDE", + "NOTAGS", + "QUIRKx0010", + "QUIRKx0020", + "QUIRKx0040", + "QUIRKx0080", + "NOSYNCCACHE", + "NOSENSE", + "LITTLETOC", + "NOCAPACITY", + "QUIRK0x1000", + "NODOORLOCK", + "ONLYBIG", + "QUIRKx8000", +}; +#endif /* SCSIDEBUG */ void scsibus_printlink(struct scsi_link *link) @@ -733,47 +772,61 @@ scsibus_printlink(struct scsi_link *link) if ((link->flags & SDEV_REMOVABLE) != 0) printf(" removable"); - if (link->id == NULL || link->id->d_type == DEVID_NONE) - return; - - id = (u_int8_t *)(link->id + 1); - switch (link->id->d_type) { - case DEVID_NAA: - printf(" naa."); - break; - case DEVID_EUI: - printf(" eui."); - break; - case DEVID_T10: - printf(" t10."); - break; - case DEVID_SERIAL: - printf(" serial."); - break; - case DEVID_WWN: - printf(" wwn."); - break; - } + if (link->id != NULL && link->id->d_type != DEVID_NONE) { + id = (u_int8_t *)(link->id + 1); + switch (link->id->d_type) { + case DEVID_NAA: + printf(" naa."); + break; + case DEVID_EUI: + printf(" eui."); + break; + case DEVID_T10: + printf(" t10."); + break; + case DEVID_SERIAL: + printf(" serial."); + break; + case DEVID_WWN: + printf(" wwn."); + break; + } - if (ISSET(link->id->d_flags, DEVID_F_PRINT)) { - for (i = 0; i < link->id->d_len; i++) { - if (id[i] == '\0' || id[i] == ' ') { - /* skip leading blanks */ - /* collapse multiple blanks into one */ - if (i > 0 && id[i-1] != id[i]) - printf("_"); - } else if (id[i] < 0x20 || id[i] >= 0x80) { - /* non-printable characters */ - printf("~"); - } else { - /* normal characters */ - printf("%c", id[i]); + if (ISSET(link->id->d_flags, DEVID_F_PRINT)) { + for (i = 0; i < link->id->d_len; i++) { + if (id[i] == '\0' || id[i] == ' ') { + /* skip leading blanks */ + /* collapse multiple blanks into one */ + if (i > 0 && id[i-1] != id[i]) + printf("_"); + } else if (id[i] < 0x20 || id[i] >= 0x80) { + /* non-printable characters */ + printf("~"); + } else { + /* normal characters */ + printf("%c", id[i]); + } } + } else { + for (i = 0; i < link->id->d_len; i++) + printf("%02x", id[i]); } - } else { - for (i = 0; i < link->id->d_len; i++) - printf("%02x", id[i]); } +#ifdef SCSIDEBUG + printf("\n"); + sc_print_addr(link); + printf("state %u, luns %u, openings %u\n", + link->state, link->luns, link->openings); + + sc_print_addr(link); + printf("flags (0x%04x) ", link->flags); + scsi_show_flags(link->flags, flagnames); + printf("\n"); + + sc_print_addr(link); + printf("quirks (0x%04x) ", link->quirks); + scsi_show_flags(link->quirks, quirknames); +#endif /* SCSIDEBUG */ } /* diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h index 6b21846f3f2..4b19af074f3 100644 --- a/sys/scsi/scsiconf.h +++ b/sys/scsi/scsiconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.h,v 1.173 2019/09/19 17:48:21 krw Exp $ */ +/* $OpenBSD: scsiconf.h,v 1.174 2019/09/23 15:21:17 krw Exp $ */ /* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */ /* @@ -501,9 +501,13 @@ int scsi_report_luns(struct scsi_link *, int, void scsi_minphys(struct buf *, struct scsi_link *); int scsi_interpret_sense(struct scsi_xfer *); +#ifdef SCSIDEBUG void scsi_xs_show(struct scsi_xfer *); -void scsi_print_sense(struct scsi_xfer *); void scsi_show_mem(u_char *, int); +void scsi_show_flags(u_int16_t, const char **); +#endif /* SCSIDEBUG */ + +void scsi_print_sense(struct scsi_xfer *); void scsi_strvis(u_char *, u_char *, int); int scsi_delay(struct scsi_xfer *, int); |