diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-02-28 14:48:12 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-02-28 14:48:12 +0000 |
commit | 0caff64b2726efd156e3c984ffffcceebc3014b6 (patch) | |
tree | 9d157f561e86e6be96f0fa04d0daaf4acce457bf /sys/scsi | |
parent | 5273c9d5b0262862560541c43302f48847cf3da3 (diff) |
Shuffle some SCSIDEBUG code to simplify code, tersify the
emitted verbiage, and show INQUIRY header & vendor info early so
humans can more easily determine what scsi_probe_link() will
do.
No functional change outside SCSIDEBUG.
Diffstat (limited to 'sys/scsi')
-rw-r--r-- | sys/scsi/scsi_base.c | 69 | ||||
-rw-r--r-- | sys/scsi/scsi_debug.h | 4 | ||||
-rw-r--r-- | sys/scsi/scsiconf.c | 32 |
3 files changed, 77 insertions, 28 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index 3fa4a126ce6..299509c7bc7 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.279 2021/05/13 02:22:33 krw Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.280 2022/02/28 14:48:11 krw Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -864,10 +864,14 @@ again: received = xs->datalen - xs->resid; scsi_xs_put(xs); - if (error != 0) + if (error != 0) { + SC_DEBUG(link, SDEV_DB2, ("INQUIRE error %d\n", error)); return error; - if (received < SID_SCSI2_HDRLEN) + } + if (received < SID_SCSI2_HDRLEN) { + SC_DEBUG(link, SDEV_DB2, ("INQUIRE data < SID_SCSI2_HDRLEN\n")); return EINVAL; + } avail = SID_SCSI2_HDRLEN + inqbuf->additional_length; @@ -882,6 +886,10 @@ again: printf("got %d of %d bytes of inquiry data:\n", received, avail); scsi_show_mem((u_char *)inqbuf, received); + sc_print_addr(link); + scsi_show_inquiry_header(inqbuf); + sc_print_addr(link); + scsi_show_inquiry_match(inqbuf); #endif /* SCSIDEBUG */ if (avail > received) @@ -2841,4 +2849,59 @@ scsi_show_flags(u_int32_t flags, const char **names) printf("%s0x%08x", first ? "" : ", ", unnamed); printf(">"); } + +void +scsi_show_inquiry_header(struct scsi_inquiry_data *inqbuf) +{ + switch (inqbuf->device & SID_QUAL) { + case SID_QUAL_RSVD: + printf("SID_QUAL_RSVD, "); + break; + case SID_QUAL_BAD_LU: + printf("SID_QUAL_BAD_LU, "); + break; + case SID_QUAL_LU_OFFLINE: + printf("SID_QUAL_LU_OFFLINE, "); + break; + case SID_QUAL_LU_OK: + printf("SID_QUAL_LU_OK, "); + break; + default: + printf("SID_QUAL = 0x%02x, ", inqbuf->device & SID_QUAL); + break; + } + printf("%s, ", devicetypenames[inqbuf->device & SID_TYPE]); + if (ISSET(inqbuf->dev_qual2, SID_REMOVABLE)) + printf("T_REMOV, "); + else + printf("T_FIXED, "); + printf("SID_ANSII_REV %u, SID_RESPONSE_DATA_FMT %u\n", + SID_ANSII_REV(inqbuf), + inqbuf->response_format & SID_RESPONSE_DATA_FMT); +} + +void +scsi_show_inquiry_match(struct scsi_inquiry_data *inqbuf) +{ + char visbuf[65]; + unsigned int inqbytes; + + inqbytes = SID_SCSI2_HDRLEN + inqbuf->additional_length; + printf("<"); + if (inqbytes >= offsetof(struct scsi_inquiry_data, product)) + scsi_strvis(visbuf, inqbuf->vendor, sizeof(inqbuf->vendor)); + else + visbuf[0] = '\0'; + printf("\"%s\", ", visbuf); + if (inqbytes >= offsetof(struct scsi_inquiry_data, revision)) + scsi_strvis(visbuf, inqbuf->product, sizeof(inqbuf->product)); + else + visbuf[0] = '\0'; + printf("\"%s\", ", visbuf); + if (inqbytes >= offsetof(struct scsi_inquiry_data, extra)) + scsi_strvis(visbuf, inqbuf->revision, sizeof(inqbuf->revision)); + else + visbuf[0] = '\0'; + printf("\"%s\">\n", visbuf); +} #endif /* SCSIDEBUG */ diff --git a/sys/scsi/scsi_debug.h b/sys/scsi/scsi_debug.h index b150306ce04..58cfb542de4 100644 --- a/sys/scsi/scsi_debug.h +++ b/sys/scsi/scsi_debug.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_debug.h,v 1.22 2020/07/27 19:19:50 krw Exp $ */ +/* $OpenBSD: scsi_debug.h,v 1.23 2022/02/28 14:48:11 krw Exp $ */ /* $NetBSD: scsi_debug.h,v 1.7 1996/10/12 23:23:16 christos Exp $ */ /* @@ -46,6 +46,8 @@ void scsi_show_sense(struct scsi_xfer *); void scsi_show_xs(struct scsi_xfer *); void scsi_show_mem(u_char *, int); void scsi_show_flags(u_int32_t, const char **); +void scsi_show_inquiry_header(struct scsi_inquiry_data *); +void scsi_show_inquiry_match(struct scsi_inquiry_data *); /* * This is the usual debug macro for use with the above bits diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 92dfba2793f..7a74a66cd9d 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.238 2021/10/24 16:57:30 mpi Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.239 2022/02/28 14:48:11 krw Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -497,8 +497,7 @@ scsi_probe_link(struct scsibus_softc *sb, int target, int lun, int dumbscan) link = malloc(sizeof(*link), M_DEVBUF, M_NOWAIT); if (link == NULL) { - SC_DEBUG(link, SDEV_DB2, ("Bad LUN. can't allocate " - "scsi_link.\n")); + SC_DEBUG(link, SDEV_DB2, ("malloc(scsi_link) failed.\n")); return EINVAL; } @@ -525,8 +524,7 @@ scsi_probe_link(struct scsibus_softc *sb, int target, int lun, int dumbscan) if (sb->sb_adapter->dev_probe != NULL && sb->sb_adapter->dev_probe(link) != 0) { if (lun == 0) { - SC_DEBUG(link, SDEV_DB2, ("Bad LUN 0. dev_probe() " - "failed.\n")); + SC_DEBUG(link, SDEV_DB2, ("dev_probe(link) failed.\n")); rslt = EINVAL; } goto free; @@ -540,8 +538,7 @@ scsi_probe_link(struct scsibus_softc *sb, int target, int lun, int dumbscan) link->pool = malloc(sizeof(*link->pool), M_DEVBUF, M_NOWAIT); if (link->pool == NULL) { - SC_DEBUG(link, SDEV_DB2, ("Bad LUN. can't allocate " - "link->pool.\n")); + SC_DEBUG(link, SDEV_DB2, ("malloc(pool) failed.\n")); rslt = ENOMEM; goto bad; } @@ -581,18 +578,15 @@ scsi_probe_link(struct scsibus_softc *sb, int target, int lun, int dumbscan) /* Now go ask the device all about itself. */ inqbuf = dma_alloc(sizeof(*inqbuf), PR_NOWAIT | PR_ZERO); if (inqbuf == NULL) { - SC_DEBUG(link, SDEV_DB2, ("Bad LUN. can't allocate inqbuf.\n")); + SC_DEBUG(link, SDEV_DB2, ("dma_alloc(inqbuf) failed.\n")); rslt = ENOMEM; goto bad; } rslt = scsi_inquire(link, inqbuf, scsi_autoconf | SCSI_SILENT); if (rslt != 0) { - if (lun == 0) { - SC_DEBUG(link, SDEV_DB2, ("Bad LUN 0. inquiry rslt = " - "%i\n", rslt)); + if (lun == 0) rslt = EINVAL; - } dma_free(inqbuf, sizeof(*inqbuf)); goto bad; } @@ -613,24 +607,15 @@ scsi_probe_link(struct scsibus_softc *sb, int target, int lun, int dumbscan) case SID_QUAL_RSVD: case SID_QUAL_BAD_LU: case SID_QUAL_LU_OFFLINE: - SC_DEBUG(link, SDEV_DB1, ("Bad LUN. SID_QUAL = 0x%02x\n", - inqbuf->device & SID_QUAL)); goto bad; - case SID_QUAL_LU_OK: break; - default: - SC_DEBUG(link, SDEV_DB1, ("Vendor-specific SID_QUAL = 0x%02x\n", - inqbuf->device & SID_QUAL)); break; } - if ((inqbuf->device & SID_TYPE) == T_NODEVICE) { - SC_DEBUG(link, SDEV_DB1, - ("Bad LUN. SID_TYPE = T_NODEVICE\n")); + if ((inqbuf->device & SID_TYPE) == T_NODEVICE) goto bad; - } scsi_devid(link); @@ -644,8 +629,7 @@ scsi_probe_link(struct scsibus_softc *sb, int target, int lun, int dumbscan) else if (dumbscan == 1 && memcmp(inqbuf, &link0->inqdata, sizeof(*inqbuf)) == 0) { /* The device doesn't distinguish between LUNs. */ - SC_DEBUG(link, SDEV_DB1, ("Bad LUN. IDENTIFY not supported." - "\n")); + SC_DEBUG(link, SDEV_DB1, ("IDENTIFY not supported.\n")); rslt = EINVAL; goto free_devid; } |