Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Jul 2023 04:32:34 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 774ab87cf27b - main - cam: Add CAM_NVME_STATUS_ERROR error code
Message-ID:  <202307210432.36L4WYir014800@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

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

commit 774ab87cf27beb3669693f14b9c89ebaf542eaf3
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-07-21 04:22:37 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-07-21 04:32:31 +0000

    cam: Add CAM_NVME_STATUS_ERROR error code
    
    Add CAM_NVME_STATUS_ERROR error code. Flag all NVME commands that
    completed with an error status as CAM_NVME_STATUS_ERROR (a new value)
    instaead of CAM_REQ_CMP_ERR. This indicates to the upper layers of CAM
    that the 'cpl' field for nvmeio CCBs is valid and can be examined for
    error recovery, if desired.
    
    No functional change. nda will still see these as errors, call
    ndaerror() to get the error recovery action, etc. cam_periph_error will
    select the same case as before (even w/o the change, though the change
    makes it explicit).
    
    Sponsored by:           Netflix
    Reviewed by:            chuck, mav, jhb
    Differential Revision:  https://reviews.freebsd.org/D41085
---
 sys/cam/cam.h           | 7 ++++++-
 sys/cam/cam_periph.c    | 1 +
 sys/cam/nvme/nvme_da.c  | 1 +
 sys/dev/nvme/nvme_sim.c | 2 +-
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/sys/cam/cam.h b/sys/cam/cam.h
index 99f7b6a7f5c2..eacf3a248ce9 100644
--- a/sys/cam/cam.h
+++ b/sys/cam/cam.h
@@ -240,7 +240,12 @@ typedef enum {
 	CAM_REQ_SOFTTIMEOUT	= 0x1f,
 
 	/*
-	 * 0x20 - 0x32 are unassigned
+	 * NVME error, look at errro code in CCB
+	 */
+	CAM_NVME_STATUS_ERROR	= 0x20,
+
+	/*
+	 * 0x21 - 0x32 are unassigned
 	 */
 
 	/* Initiator Detected Error */
diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c
index fe256e84cd2c..8defdc9ecbe6 100644
--- a/sys/cam/cam_periph.c
+++ b/sys/cam/cam_periph.c
@@ -1996,6 +1996,7 @@ cam_periph_error(union ccb *ccb, cam_flags camflags,
 		relsim_flags = RELSIM_RELEASE_AFTER_TIMEOUT;
 		/* FALLTHROUGH */
 	case CAM_ATA_STATUS_ERROR:
+	case CAM_NVME_STATUS_ERROR:
 	case CAM_SMP_STATUS_ERROR:
 	case CAM_REQ_CMP_ERR:
 	case CAM_CMD_TIMEOUT:
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
index f2fb1b79f452..9beef786f320 100644
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -1285,6 +1285,7 @@ ndaerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
 #endif
 		break;
 	case CAM_REQ_CMP_ERR:
+	case CAM_NVME_STATUS_ERROR:
 #ifdef CAM_IO_STATS
 		softc->errors++;
 #endif
diff --git a/sys/dev/nvme/nvme_sim.c b/sys/dev/nvme/nvme_sim.c
index ec8cc03cb774..ad6783adf181 100644
--- a/sys/dev/nvme/nvme_sim.c
+++ b/sys/dev/nvme/nvme_sim.c
@@ -74,7 +74,7 @@ nvme_sim_nvmeio_done(void *ccb_arg, const struct nvme_completion *cpl)
 	memcpy(&ccb->nvmeio.cpl, cpl, sizeof(*cpl));
 	ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
 	if (nvme_completion_is_error(cpl)) {
-		ccb->ccb_h.status = CAM_REQ_CMP_ERR;
+		ccb->ccb_h.status = CAM_NVME_STATUS_ERROR;
 		xpt_done(ccb);
 	} else {
 		ccb->ccb_h.status = CAM_REQ_CMP;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307210432.36L4WYir014800>