Fix the shift of status bits 2:0 to 11:9 from <<8 to <<9.
authorkrw <krw@openbsd.org>
Mon, 11 Dec 2023 14:27:09 +0000 (14:27 +0000)
committerkrw <krw@openbsd.org>
Mon, 11 Dec 2023 14:27:09 +0000 (14:27 +0000)
Fix the mask of shifted 8 bit field from 0x7f to 0xff.

Allows proper decoding of status fields SCT and SC.

From mlelstv@netbsd via NetBSD.

ok miod@

sys/dev/ic/nvmereg.h

index 1c73115..4296b54 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: nvmereg.h,v 1.11 2016/11/15 12:01:11 mpi Exp $ */
+/*     $OpenBSD: nvmereg.h,v 1.12 2023/12/11 14:27:09 krw Exp $ */
 
 /*
  * Copyright (c) 2014 David Gwynne <dlg@openbsd.org>
@@ -204,12 +204,12 @@ struct nvme_cqe {
        u_int16_t       flags;
 #define NVME_CQE_DNR           (1 << 15)
 #define NVME_CQE_M             (1 << 14)
-#define NVME_CQE_SCT(_f)       ((_f) & (0x07 << 8))
-#define  NVME_CQE_SCT_GENERIC          (0x00 << 8)
-#define  NVME_CQE_SCT_COMMAND          (0x01 << 8)
-#define  NVME_CQE_SCT_MEDIAERR         (0x02 << 8)
-#define  NVME_CQE_SCT_VENDOR           (0x07 << 8)
-#define NVME_CQE_SC(_f)                ((_f) & (0x7f << 1))
+#define NVME_CQE_SCT(_f)       ((_f) & (0x07 << 9))
+#define  NVME_CQE_SCT_GENERIC          (0x00 << 9)
+#define  NVME_CQE_SCT_COMMAND          (0x01 << 9)
+#define  NVME_CQE_SCT_MEDIAERR         (0x02 << 9)
+#define  NVME_CQE_SCT_VENDOR           (0x07 << 9)
+#define NVME_CQE_SC(_f)                ((_f) & (0xff << 1))
 #define  NVME_CQE_SC_SUCCESS           (0x00 << 1)
 #define  NVME_CQE_SC_INVALID_OPCODE    (0x01 << 1)
 #define  NVME_CQE_SC_INVALID_FIELD     (0x02 << 1)