git: bdd4dbb070ac - stable/13 - nvme: Print CRD, M and DNR status bits on errors.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Mon, 15 Aug 2022 17:57:25 UTC
The branch stable/13 has been updated by mav:

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

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

    nvme: Print CRD, M and DNR status bits on errors.
    
    It may help with some issues debugging.
    
    MFC after:      1 week
    
    (cherry picked from commit a69c0964625f4e20a7d5f22d51e036e13eedbeeb)
---
 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 f36125ba247b..512345ac9d8e 100644
--- a/sys/dev/nvme/nvme.c
+++ b/sys/dev/nvme/nvme.c
@@ -100,7 +100,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);
@@ -108,13 +108,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 f2ef2467c9b1..177f18f916c1 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -201,6 +201,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 175975b2b3ac..ad6c1be91c3f 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