-/* $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 $ */
/*
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;
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)
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 */
-/* $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 $ */
/*
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
-/* $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 $ */
/*
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;
}
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;
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;
}
/* 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;
}
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);
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;
}