From ee6a50d479dfdb26126d0be5440e488cfb248484 Mon Sep 17 00:00:00 2001 From: Kenneth Heitke Date: Tue, 11 Jun 2019 12:13:14 -0600 Subject: [PATCH] nvme-print: add JSON for NVMe 1.4 NPWG, NPWA, NPDG, NPDA and NOWS fields --- nvme-print.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nvme-print.c b/nvme-print.c index 17478f98..5ffc1b75 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -523,12 +523,15 @@ static void show_nvme_id_ctrl_ctrattr(__u8 ctrattr) static void show_nvme_id_ns_nsfeat(__u8 nsfeat) { - __u8 rsvd = (nsfeat & 0xF8) >> 3; + __u8 rsvd = (nsfeat & 0xE0) >> 5; + __u8 ioopt = (nsfeat & 0x10) >> 4; __u8 dulbe = (nsfeat & 0x4) >> 2; __u8 na = (nsfeat & 0x2) >> 1; __u8 thin = nsfeat & 0x1; if (rsvd) - printf(" [7:3] : %#x\tReserved\n", rsvd); + printf(" [7:5] : %#x\tReserved\n", rsvd); + printf(" [4:4] : %#x\tNPWG, NPWA, NPDG, NPDA, and NOWS are %sSupported\n", + ioopt, ioopt ? "" : "Not "); printf(" [2:2] : %#x\tDeallocated or Unwritten Logical Block error %sSupported\n", dulbe, dulbe ? "" : "Not "); printf(" [1:1] : %#x\tNamespace uses %s\n", @@ -2296,6 +2299,14 @@ void json_nvme_id_ns(struct nvme_id_ns *ns, unsigned int mode) json_object_add_value_int(root, "nsattr", ns->nsattr); json_object_add_value_int(root, "nvmsetid", le16_to_cpu(ns->nvmsetid)); + if (ns->nsfeat & 0x10) { + json_object_add_value_int(root, "npwg", le16_to_cpu(ns->npwg)); + json_object_add_value_int(root, "npwa", le16_to_cpu(ns->npwa)); + json_object_add_value_int(root, "npdg", le16_to_cpu(ns->npdg)); + json_object_add_value_int(root, "npda", le16_to_cpu(ns->npda)); + json_object_add_value_int(root, "nows", le16_to_cpu(ns->nows)); + } + json_object_add_value_int(root, "anagrpid", le32_to_cpu(ns->anagrpid)); json_object_add_value_int(root, "endgid", le16_to_cpu(ns->endgid)); -- 2.50.1