git: d3e79182960a - main - cam: decode and print direct accecss block device sense data
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 10 Dec 2025 21:41:51 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=d3e79182960ae56f52b5b3fbbfa6f4c2bbc53246
commit d3e79182960ae56f52b5b3fbbfa6f4c2bbc53246
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-12-07 11:07:21 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-12-10 21:37:40 +0000
cam: decode and print direct accecss block device sense data
A more efficient way to include multiple bits of data in a sense
decriptor was defined in SBC4 in 2020. Decode and print it.
Sponsored by: Netflix
---
sys/cam/scsi/scsi_all.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
sys/cam/scsi/scsi_all.h | 23 +++++++++++++++++++++++
2 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c
index 6cfc390ed187..4ea2ab7d4acd 100644
--- a/sys/cam/scsi/scsi_all.c
+++ b/sys/cam/scsi/scsi_all.c
@@ -4789,6 +4789,32 @@ scsi_sense_forwarded_sbuf(struct sbuf *sb, struct scsi_sense_data *sense,
sense_key_desc, asc, ascq, asc_desc);
}
+void
+scsi_sense_dabd_sbuf(struct sbuf *sb, struct scsi_sense_data *sense,
+ u_int sense_len, uint8_t *cdb, int cdb_len,
+ struct scsi_inquiry_data *inq_data,
+ struct scsi_sense_desc_header *header)
+{
+ struct scsi_sense_direct_access_block_device *dabd;
+ int error_code, sense_key, asc, ascq;
+
+ dabd = (struct scsi_sense_direct_access_block_device *)header;
+
+ sbuf_printf(sb, "Direct Access Block Device: fru: %d ",
+ dabd->fru);
+ if (dabd->sks_byte & SSD_DESC_DABD_SKS_VALID) {
+ scsi_extract_sense_len(sense, sense_len, &error_code, &sense_key,
+ &asc, &ascq, /*show_errors*/ 1);
+ scsi_sks_sbuf(sb, sense_key, dabd->data);
+ }
+ if (dabd->byte2 & SSD_DESC_DABD_VALID) {
+ scsi_info_sbuf(sb, cdb, cdb_len, inq_data,
+ scsi_8btou64(dabd->info));
+ scsi_command_sbuf(sb, cdb, cdb_len, inq_data,
+ scsi_8btou64(dabd->command_info));
+ }
+}
+
/*
* Generic sense descriptor printing routine. This is used when we have
* not yet implemented a specific printing routine for this descriptor.
@@ -4837,7 +4863,8 @@ struct scsi_sense_desc_printer {
{SSD_DESC_BLOCK, scsi_sense_block_sbuf},
{SSD_DESC_ATA, scsi_sense_ata_sbuf},
{SSD_DESC_PROGRESS, scsi_sense_progress_sbuf},
- {SSD_DESC_FORWARDED, scsi_sense_forwarded_sbuf}
+ {SSD_DESC_DABD, scsi_sense_dabd_sbuf},
+ {SSD_DESC_FORWARDED, scsi_sense_forwarded_sbuf},
};
void
@@ -9507,7 +9534,7 @@ scsi_format_sense_devd(struct ccb_scsiio *csio, struct sbuf *sb)
struct scsi_sense_fru *fru;
fru = (struct scsi_sense_fru *)hdr;
- sbuf_printf(sb, "fru=%ju ", (uintmax_t)fru->fru);
+ sbuf_printf(sb, "fru=%u ", fru->fru);
break;
}
case SSD_DESC_ATA:
@@ -9536,6 +9563,22 @@ scsi_format_sense_devd(struct ccb_scsiio *csio, struct sbuf *sb)
sbuf_printf(sb, "count=%d lba=0x%jx ", count, (uintmax_t)lba);
break;
}
+ case SSD_DESC_DABD:
+ {
+ struct scsi_sense_direct_access_block_device *dabd;
+
+ dabd = (struct scsi_sense_direct_access_block_device *)hdr;
+
+ if (dabd->sks_byte & SSD_DESC_DABD_SKS_VALID)
+ decode_sks(sb, sk, dabd->data);
+ sbuf_printf(sb, "fru=%u ", dabd->fru);
+ if (dabd->byte2 & SSD_DESC_DABD_VALID) {
+ sbuf_printf(sb, "info=0x%jx ",
+ scsi_8btou64(dabd->info));
+ sbuf_printf(sb, "cmd_info=0x%jx ",
+ scsi_8btou64(dabd->command_info));
+ }
+ }
default:
{
uint8_t *cp;
diff --git a/sys/cam/scsi/scsi_all.h b/sys/cam/scsi/scsi_all.h
index 045fbca2de80..cadf2d1f2835 100644
--- a/sys/cam/scsi/scsi_all.h
+++ b/sys/cam/scsi/scsi_all.h
@@ -3653,6 +3653,25 @@ struct scsi_sense_forwarded
uint8_t sense_data[];
};
+/*
+ * Direct Access Block Specific Sense Data
+ */
+struct scsi_sense_direct_access_block_device
+{
+ uint8_t desc_type;
+#define SSD_DESC_DABD 0x0d
+ uint8_t length;
+ uint8_t byte2;
+#define SSD_DESC_DABD_VALID 0x80
+ uint8_t reserved3;
+ uint8_t sks_byte;
+#define SSD_DESC_DABD_SKS_VALID 0x80
+ uint8_t data[2]; /* Same as SSD_DESC_SKS extra data */
+ uint8_t fru;
+ uint8_t info[8]; /* if SSD_DESC_DA_VALID */
+ uint8_t command_info[8];
+};
+
/*
* Vendor-specific sense descriptor. The desc_type field will be in the
* range between MIN and MAX inclusive.
@@ -3889,6 +3908,10 @@ void scsi_sense_forwarded_sbuf(struct sbuf *sb, struct scsi_sense_data *sense,
u_int sense_len, uint8_t *cdb, int cdb_len,
struct scsi_inquiry_data *inq_data,
struct scsi_sense_desc_header *header);
+void scsi_sense_dabd_sbuf(struct sbuf *sb, struct scsi_sense_data *sense,
+ u_int sense_len, uint8_t *cdb, int cdb_len,
+ struct scsi_inquiry_data *inq_data,
+ struct scsi_sense_desc_header *header);
void scsi_sense_generic_sbuf(struct sbuf *sb, struct scsi_sense_data *sense,
u_int sense_len, uint8_t *cdb, int cdb_len,
struct scsi_inquiry_data *inq_data,