git: a69c0964625f - main - nvme: Print CRD, M and DNR status bits on errors.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Fri, 05 Aug 2022 15:02:00 UTC
The branch main has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=a69c0964625f4e20a7d5f22d51e036e13eedbeeb

commit a69c0964625f4e20a7d5f22d51e036e13eedbeeb
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2022-08-05 14:58:19 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-08-05 14:58:19 +0000

    nvme: Print CRD, M and DNR status bits on errors.
    
    It may help with some issues debugging.
    
    MFC after:      1 week
---
 sys/dev/nvme/nvme.c       |  7 ++++---
 sys/dev/nvme/nvme.h       |  1 +
 sys/dev/nvme/nvme_qpair.c | 14 +++++++++-----
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/sys/dev/nvme/nvme.c b/sys/dev/nvme/nvme.c
index 6ad010dae1b8..fc491eb72f1c 100644
--- a/sys/dev/nvme/nvme.c
+++ b/sys/dev/nvme/nvme.c
@@ -98,7 +98,7 @@ nvme_dump_command(struct nvme_command *cmd)
 void
 nvme_dump_completion(struct nvme_completion *cpl)
 {
-	uint8_t p, sc, sct, m, dnr;
+	uint8_t p, sc, sct, crd, m, dnr;
 	uint16_t status;
 
 	status = le16toh(cpl->status);
@@ -106,13 +106,14 @@ nvme_dump_completion(struct nvme_completion *cpl)
 	p = NVME_STATUS_GET_P(status);
 	sc = NVME_STATUS_GET_SC(status);
 	sct = NVME_STATUS_GET_SCT(status);
+	crd = NVME_STATUS_GET_CRD( status);
 	m = NVME_STATUS_GET_M(status);
 	dnr = NVME_STATUS_GET_DNR(status);
 
 	printf("cdw0:%08x sqhd:%04x sqid:%04x "
-	    "cid:%04x p:%x sc:%02x sct:%x m:%x dnr:%x\n",
+	    "cid:%04x p:%x sc:%02x sct:%x crd:%x m:%x dnr:%x\n",
 	    le32toh(cpl->cdw0), le16toh(cpl->sqhd), le16toh(cpl->sqid),
-	    cpl->cid, p, sc, sct, m, dnr);
+	    cpl->cid, p, sc, sct, crd, m, dnr);
 }
 
 int
diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index 9aefc5c47973..94b20069c12e 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -204,6 +204,7 @@
 #define NVME_STATUS_GET_P(st)				(((st) >> NVME_STATUS_P_SHIFT) & NVME_STATUS_P_MASK)
 #define NVME_STATUS_GET_SC(st)				(((st) >> NVME_STATUS_SC_SHIFT) & NVME_STATUS_SC_MASK)
 #define NVME_STATUS_GET_SCT(st)				(((st) >> NVME_STATUS_SCT_SHIFT) & NVME_STATUS_SCT_MASK)
+#define NVME_STATUS_GET_CRD(st)				(((st) >> NVME_STATUS_CRD_SHIFT) & NVME_STATUS_CRD_MASK)
 #define NVME_STATUS_GET_M(st)				(((st) >> NVME_STATUS_M_SHIFT) & NVME_STATUS_M_MASK)
 #define NVME_STATUS_GET_DNR(st)				(((st) >> NVME_STATUS_DNR_SHIFT) & NVME_STATUS_DNR_MASK)
 
diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c
index 3b20a7e209fa..e0b3517529d5 100644
--- a/sys/dev/nvme/nvme_qpair.c
+++ b/sys/dev/nvme/nvme_qpair.c
@@ -344,14 +344,18 @@ static void
 nvme_qpair_print_completion(struct nvme_qpair *qpair,
     struct nvme_completion *cpl)
 {
-	uint16_t sct, sc;
+	uint8_t sct, sc, crd, m, dnr;
 
 	sct = NVME_STATUS_GET_SCT(cpl->status);
 	sc = NVME_STATUS_GET_SC(cpl->status);
-
-	nvme_printf(qpair->ctrlr, "%s (%02x/%02x) sqid:%d cid:%d cdw0:%x\n",
-	    get_status_string(sct, sc), sct, sc, cpl->sqid, cpl->cid,
-	    cpl->cdw0);
+	crd = NVME_STATUS_GET_CRD(cpl->status);
+	m = NVME_STATUS_GET_M(cpl->status);
+	dnr = NVME_STATUS_GET_DNR(cpl->status);
+
+	nvme_printf(qpair->ctrlr, "%s (%02x/%02x) crd:%x m:%x dnr:%x "
+	    "sqid:%d cid:%d cdw0:%x\n",
+	    get_status_string(sct, sc), sct, sc, crd, m, dnr,
+	    cpl->sqid, cpl->cid, cpl->cdw0);
 }
 
 static bool