The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=353cfc483dd246091c92b22f214fd16eb5de4e3b
commit 353cfc483dd246091c92b22f214fd16eb5de4e3b Author: John Baldwin <j...@freebsd.org> AuthorDate: 2025-06-02 15:05:43 +0000 Commit: John Baldwin <j...@freebsd.org> CommitDate: 2025-06-02 15:05:43 +0000 cam nvme: Decode NVMe status for NVMe command failures Similar to ATA and SCSI, log the command status (in this case the status code from the CQE) on the console for failed NVMe commands. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D50632 --- sys/cam/cam.c | 28 ++++++++++++++++++++++++++++ sys/cam/cam.h | 5 +++++ 2 files changed, 33 insertions(+) diff --git a/sys/cam/cam.c b/sys/cam/cam.c index d9cff3468da0..917197542edc 100644 --- a/sys/cam/cam.c +++ b/sys/cam/cam.c @@ -380,6 +380,20 @@ cam_error_string(struct cam_device *device, union ccb *ccb, char *str, break; } break; + case XPT_NVME_IO: + case XPT_NVME_ADMIN: + switch (proto_flags & CAM_EPF_LEVEL_MASK) { + case CAM_EPF_NONE: + break; + case CAM_EPF_ALL: + case CAM_EPF_NORMAL: + case CAM_EPF_MINIMAL: + proto_flags |= CAM_ENF_PRINT_STATUS; + /* FALLTHROUGH */ + default: + break; + } + break; default: break; } @@ -494,6 +508,20 @@ cam_error_string(struct cam_device *device, union ccb *ccb, char *str, ccb->smpio.smp_response[2]); } /* There is no SMP equivalent to SCSI sense. */ + break; + case XPT_NVME_IO: + case XPT_NVME_ADMIN: + if ((ccb->ccb_h.status & CAM_STATUS_MASK) != + CAM_NVME_STATUS_ERROR) + break; + + if (proto_flags & CAM_ESF_PRINT_STATUS) { + sbuf_cat(&sb, path_str); + sbuf_cat(&sb, "NVMe status: "); + nvme_status_sbuf(&ccb->nvmeio, &sb); + sbuf_putc(&sb, '\n'); + } + break; default: break; diff --git a/sys/cam/cam.h b/sys/cam/cam.h index 963c9798ddbc..83c1fc7b35ca 100644 --- a/sys/cam/cam.h +++ b/sys/cam/cam.h @@ -350,6 +350,11 @@ typedef enum { CAM_EAF_PRINT_RESULT = 0x20 } cam_error_ata_flags; +typedef enum { + CAM_ENF_PRINT_NONE = 0x00, + CAM_ENF_PRINT_STATUS = 0x10, +} cam_error_nvme_flags; + typedef enum { CAM_STRVIS_FLAG_NONE = 0x00, CAM_STRVIS_FLAG_NONASCII_MASK = 0x03,