15202 nvme should recognise Format-in-progress generic status
Reviewed by: Robert Mustacchi <rm+illumos@fingolfin.org>
Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Approved by: Rich Lowe <richlowe@richlowe.net>
diff --git a/usr/src/uts/common/io/nvme/nvme.c b/usr/src/uts/common/io/nvme/nvme.c
index 2aa8760..fe8e31c 100644
--- a/usr/src/uts/common/io/nvme/nvme.c
+++ b/usr/src/uts/common/io/nvme/nvme.c
@@ -1536,6 +1536,15 @@
 			bd_error(cmd->nc_xfer, BD_ERR_NTRDY);
 		return (EIO);
 
+	case NVME_CQE_SC_GEN_NVM_FORMATTING:
+		/* Format in progress (1.2) */
+		if (!NVME_VERSION_ATLEAST(&cmd->nc_nvme->n_version, 1, 2))
+			return (nvme_check_unknown_cmd_status(cmd));
+		atomic_inc_32(&cmd->nc_nvme->n_nvm_ns_formatting);
+		if (cmd->nc_xfer != NULL)
+			bd_error(cmd->nc_xfer, BD_ERR_NTRDY);
+		return (EIO);
+
 	default:
 		return (nvme_check_unknown_cmd_status(cmd));
 	}
diff --git a/usr/src/uts/common/io/nvme/nvme_var.h b/usr/src/uts/common/io/nvme/nvme_var.h
index ca3e7ef..464fd3c 100644
--- a/usr/src/uts/common/io/nvme/nvme_var.h
+++ b/usr/src/uts/common/io/nvme/nvme_var.h
@@ -240,6 +240,7 @@
 	uint32_t n_abort_sq_del;
 	uint32_t n_nvm_cap_exc;
 	uint32_t n_nvm_ns_notrdy;
+	uint32_t n_nvm_ns_formatting;
 	uint32_t n_inv_cq_err;
 	uint32_t n_inv_qid_err;
 	uint32_t n_max_qsz_exc;
diff --git a/usr/src/uts/common/sys/nvme.h b/usr/src/uts/common/sys/nvme.h
index e7a685b..1827ef6 100644
--- a/usr/src/uts/common/sys/nvme.h
+++ b/usr/src/uts/common/sys/nvme.h
@@ -975,6 +975,7 @@
 #define	NVME_CQE_SC_GEN_NVM_CAP_EXC	0x81	/* Capacity Exceeded */
 #define	NVME_CQE_SC_GEN_NVM_NS_NOTRDY	0x82	/* Namespace Not Ready */
 #define	NVME_CQE_SC_GEN_NVM_RSV_CNFLCT	0x83	/* Reservation Conflict */
+#define	NVME_CQE_SC_GEN_NVM_FORMATTING	0x84	/* Format in progress (1.2) */
 
 /* NVMe completion status code (command specific) */
 #define	NVME_CQE_SC_SPC_INV_CQ		0x0	/* Completion Queue Invalid */