summaryrefslogtreecommitdiffstats
path: root/nvme-print.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-31 04:13:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-31 04:13:00 +0000
commitdc3f3471f8a00ce0c8fb4cbf2a31e299696f3bbc (patch)
treee97b4f25c511372d73bdd96c389c5f468d99138a /nvme-print.c
parentAdding upstream version 2.2.1. (diff)
downloadnvme-cli-dc3f3471f8a00ce0c8fb4cbf2a31e299696f3bbc.tar.xz
nvme-cli-dc3f3471f8a00ce0c8fb4cbf2a31e299696f3bbc.zip
Adding upstream version 2.3.upstream/2.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'nvme-print.c')
-rw-r--r--nvme-print.c529
1 files changed, 454 insertions, 75 deletions
diff --git a/nvme-print.c b/nvme-print.c
index c27f087..cabce68 100644
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -169,13 +169,13 @@ static void json_nvme_id_ns(struct nvme_id_ns *ns, bool cap_only)
}
json_object_add_value_int(root, "mssrl", le16_to_cpu(ns->mssrl));
- json_object_add_value_int(root, "mcl", le32_to_cpu(ns->mcl));
+ json_object_add_value_uint(root, "mcl", le32_to_cpu(ns->mcl));
json_object_add_value_int(root, "msrc", ns->msrc);
}
json_object_add_value_int(root, "nulbaf", ns->nulbaf);
if (!cap_only) {
- json_object_add_value_int(root, "anagrpid", le32_to_cpu(ns->anagrpid));
+ json_object_add_value_uint(root, "anagrpid", le32_to_cpu(ns->anagrpid));
json_object_add_value_int(root, "endgid", le16_to_cpu(ns->endgid));
memset(eui64, 0, sizeof(eui64_buf));
@@ -247,7 +247,7 @@ static void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
json_object_add_value_uint(root, "rtd3r", le32_to_cpu(ctrl->rtd3r));
json_object_add_value_uint(root, "rtd3e", le32_to_cpu(ctrl->rtd3e));
json_object_add_value_uint(root, "oaes", le32_to_cpu(ctrl->oaes));
- json_object_add_value_int(root, "ctratt", le32_to_cpu(ctrl->ctratt));
+ json_object_add_value_uint(root, "ctratt", le32_to_cpu(ctrl->ctratt));
json_object_add_value_int(root, "rrls", le16_to_cpu(ctrl->rrls));
json_object_add_value_int(root, "cntrltype", ctrl->cntrltype);
json_object_add_value_string(root, "fguid", util_uuid_to_string(ctrl->fguid));
@@ -281,19 +281,19 @@ static void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
json_object_add_value_int(root, "hctma", le16_to_cpu(ctrl->hctma));
json_object_add_value_int(root, "mntmt", le16_to_cpu(ctrl->mntmt));
json_object_add_value_int(root, "mxtmt", le16_to_cpu(ctrl->mxtmt));
- json_object_add_value_int(root, "sanicap", le32_to_cpu(ctrl->sanicap));
- json_object_add_value_int(root, "hmminds", le32_to_cpu(ctrl->hmminds));
+ json_object_add_value_uint(root, "sanicap", le32_to_cpu(ctrl->sanicap));
+ json_object_add_value_uint(root, "hmminds", le32_to_cpu(ctrl->hmminds));
json_object_add_value_int(root, "hmmaxd", le16_to_cpu(ctrl->hmmaxd));
json_object_add_value_int(root, "nsetidmax",
le16_to_cpu(ctrl->nsetidmax));
json_object_add_value_int(root, "endgidmax", le16_to_cpu(ctrl->endgidmax));
json_object_add_value_int(root, "anatt",ctrl->anatt);
json_object_add_value_int(root, "anacap", ctrl->anacap);
- json_object_add_value_int(root, "anagrpmax",
+ json_object_add_value_uint(root, "anagrpmax",
le32_to_cpu(ctrl->anagrpmax));
- json_object_add_value_int(root, "nanagrpid",
+ json_object_add_value_uint(root, "nanagrpid",
le32_to_cpu(ctrl->nanagrpid));
- json_object_add_value_int(root, "pels", le32_to_cpu(ctrl->pels));
+ json_object_add_value_uint(root, "pels", le32_to_cpu(ctrl->pels));
json_object_add_value_int(root, "domainid", le16_to_cpu(ctrl->domainid));
json_object_add_value_uint128(root, "megcap", megcap);
json_object_add_value_int(root, "sqes", ctrl->sqes);
@@ -310,16 +310,16 @@ static void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
json_object_add_value_int(root, "nwpc", ctrl->nwpc);
json_object_add_value_int(root, "acwu", le16_to_cpu(ctrl->acwu));
json_object_add_value_int(root, "ocfs", le16_to_cpu(ctrl->ocfs));
- json_object_add_value_int(root, "sgls", le32_to_cpu(ctrl->sgls));
- json_object_add_value_int(root, "mnan", le32_to_cpu(ctrl->mnan));
+ json_object_add_value_uint(root, "sgls", le32_to_cpu(ctrl->sgls));
+ json_object_add_value_uint(root, "mnan", le32_to_cpu(ctrl->mnan));
json_object_add_value_uint128(root, "maxdna", maxdna);
- json_object_add_value_int(root, "maxcna", le32_to_cpu(ctrl->maxcna));
+ json_object_add_value_uint(root, "maxcna", le32_to_cpu(ctrl->maxcna));
if (strlen(subnqn))
json_object_add_value_string(root, "subnqn", subnqn);
- json_object_add_value_int(root, "ioccsz", le32_to_cpu(ctrl->ioccsz));
- json_object_add_value_int(root, "iorcsz", le32_to_cpu(ctrl->iorcsz));
+ json_object_add_value_uint(root, "ioccsz", le32_to_cpu(ctrl->ioccsz));
+ json_object_add_value_uint(root, "iorcsz", le32_to_cpu(ctrl->iorcsz));
json_object_add_value_int(root, "icdoff", le16_to_cpu(ctrl->icdoff));
json_object_add_value_int(root, "fcatt", ctrl->fcatt);
json_object_add_value_int(root, "msdbd", ctrl->msdbd);
@@ -422,7 +422,7 @@ static void json_nvme_resv_report(struct nvme_resv_status *status,
root = json_create_object();
- json_object_add_value_int(root, "gen", le32_to_cpu(status->gen));
+ json_object_add_value_uint(root, "gen", le32_to_cpu(status->gen));
json_object_add_value_int(root, "rtype", status->rtype);
json_object_add_value_int(root, "regctl", regctl);
json_object_add_value_int(root, "ptpls", status->ptpls);
@@ -782,7 +782,7 @@ static void json_self_test_log(struct nvme_self_test_log *self_test, __u8 dst_en
json_object_add_value_uint64(valid_attrs, "Power on hours",
le64_to_cpu(self_test->result[i].poh));
if (self_test->result[i].vdi & NVME_ST_VALID_DIAG_INFO_NSID)
- json_object_add_value_int(valid_attrs, "Namespace Identifier",
+ json_object_add_value_uint(valid_attrs, "Namespace Identifier",
le32_to_cpu(self_test->result[i].nsid));
if (self_test->result[i].vdi & NVME_ST_VALID_DIAG_INFO_FLBA) {
json_object_add_value_uint64(valid_attrs, "Failing LBA",
@@ -2292,6 +2292,358 @@ static void json_supported_cap_config_log(
json_free_object(root);
}
+static void json_nvme_fdp_configs(struct nvme_fdp_config_log *log, size_t len)
+{
+ struct json_object *root, *obj_configs;
+ uint16_t n;
+
+ void *p = log->configs;
+
+ root = json_create_object();
+ obj_configs = json_create_array();
+
+ n = le16_to_cpu(log->n);
+
+ json_object_add_value_uint(root, "n", n);
+
+ for (int i = 0; i < n + 1; i++) {
+ struct nvme_fdp_config_desc *config = p;
+
+ struct json_object *obj_config = json_create_object();
+ struct json_object *obj_ruhs = json_create_array();
+
+ json_object_add_value_uint(obj_config, "fdpa", config->fdpa);
+ json_object_add_value_uint(obj_config, "vss", config->vss);
+ json_object_add_value_uint(obj_config, "nrg", le32_to_cpu(config->nrg));
+ json_object_add_value_uint(obj_config, "nruh", le16_to_cpu(config->nruh));
+ json_object_add_value_uint(obj_config, "nnss", le32_to_cpu(config->nnss));
+ json_object_add_value_uint64(obj_config, "runs", le64_to_cpu(config->runs));
+ json_object_add_value_uint(obj_config, "erutl", le32_to_cpu(config->erutl));
+
+ for (int j = 0; j < le16_to_cpu(config->nruh); j++) {
+ struct nvme_fdp_ruh_desc *ruh = &config->ruhs[j];
+
+ struct json_object *obj_ruh = json_create_object();
+
+ json_object_add_value_uint(obj_ruh, "ruht", ruh->ruht);
+
+ json_array_add_value_object(obj_ruhs, obj_ruh);
+ }
+
+ json_array_add_value_object(obj_configs, obj_config);
+
+ p += config->size;
+ }
+
+ json_object_add_value_array(root, "configs", obj_configs);
+
+ json_print_object(root, NULL);
+ printf("\n");
+
+ json_free_object(root);
+}
+
+void nvme_show_fdp_config_fdpa(uint8_t fdpa)
+{
+ __u8 valid = (fdpa >> 7) & 0x1;
+ __u8 rsvd = (fdpa >> 5) >> 0x3;
+ __u8 fdpvwc = (fdpa >> 4) & 0x1;
+ __u8 rgif = fdpa & 0xf;
+
+ printf(" [7:7] : %#x\tFDP Configuration %sValid\n",
+ valid, valid ? "" : "Not ");
+ if (rsvd)
+ printf(" [6:5] : %#x\tReserved\n", rsvd);
+ printf(" [4:4] : %#x\tFDP Volatile Write Cache %sPresent\n",
+ fdpvwc, fdpvwc ? "" : "Not ");
+ printf(" [3:0] : %#x\tReclaim Group Identifier Format\n", rgif);
+}
+
+void nvme_show_fdp_configs(struct nvme_fdp_config_log *log, size_t len,
+ enum nvme_print_flags flags)
+{
+ void *p = log->configs;
+ int human = flags & VERBOSE;
+ uint16_t n;
+
+ if (flags & BINARY)
+ return d_raw((unsigned char *)log, len);
+ if (flags & JSON)
+ return json_nvme_fdp_configs(log, len);
+
+ n = le16_to_cpu(log->n) + 1;
+
+ for (int i = 0; i < n; i++) {
+ struct nvme_fdp_config_desc *config = p;
+
+ printf("FDP Attributes: %#x\n", config->fdpa);
+ if (human)
+ nvme_show_fdp_config_fdpa(config->fdpa);
+
+ printf("Vendor Specific Size: %u\n", config->vss);
+ printf("Number of Reclaim Groups: %"PRIu32"\n", le32_to_cpu(config->nrg));
+ printf("Number of Reclaim Unit Handles: %"PRIu16"\n", le16_to_cpu(config->nruh));
+ printf("Number of Namespaces Supported: %"PRIu32"\n", le32_to_cpu(config->nnss));
+ printf("Reclaim Unit Nominal Size: %"PRIu64"\n", le64_to_cpu(config->runs));
+ printf("Estimated Reclaim Unit Time Limit: %"PRIu32"\n", le32_to_cpu(config->erutl));
+
+ printf("Reclaim Unit Handle List:\n");
+ for (int j = 0; j < le16_to_cpu(config->nruh); j++) {
+ struct nvme_fdp_ruh_desc *ruh = &config->ruhs[j];
+
+ printf(" [%d]: %s\n", j, ruh->ruht == NVME_FDP_RUHT_INITIALLY_ISOLATED ? "Initially Isolated" : "Persistently Isolated");
+ }
+
+ p += config->size;
+ }
+}
+
+static void json_nvme_fdp_usage(struct nvme_fdp_ruhu_log *log, size_t len)
+{
+ struct json_object *root, *obj_ruhus;
+ uint16_t nruh;
+
+ root = json_create_object();
+ obj_ruhus = json_create_array();
+
+ nruh = le16_to_cpu(log->nruh);
+
+ json_object_add_value_uint(root, "nruh", nruh);
+
+ for (int i = 0; i < nruh; i++) {
+ struct nvme_fdp_ruhu_desc *ruhu = &log->ruhus[i];
+
+ struct json_object *obj_ruhu = json_create_object();
+
+ json_object_add_value_uint(obj_ruhu, "ruha", ruhu->ruha);
+
+ json_array_add_value_object(obj_ruhus, obj_ruhu);
+ }
+
+ json_object_add_value_array(root, "ruhus", obj_ruhus);
+
+ json_print_object(root, NULL);
+ printf("\n");
+
+ json_free_object(root);
+}
+
+void nvme_show_fdp_usage(struct nvme_fdp_ruhu_log *log, size_t len,
+ enum nvme_print_flags flags)
+{
+ if (flags & BINARY)
+ return d_raw((unsigned char *)log, len);
+ if (flags & JSON)
+ return json_nvme_fdp_usage(log, len);
+
+ uint16_t nruh = le16_to_cpu(log->nruh);
+
+ for (int i = 0; i < nruh; i++) {
+ struct nvme_fdp_ruhu_desc *ruhu = &log->ruhus[i];
+
+ printf("Reclaim Unit Handle %d Attributes: 0x%"PRIx8" (%s)\n", i, ruhu->ruha,
+ ruhu->ruha == 0x0 ? "Unused" : (
+ ruhu->ruha == 0x1 ? "Host Specified" : (
+ ruhu->ruha == 0x2 ? "Controller Specified" : "Unknown")));
+ }
+}
+
+static void json_nvme_fdp_stats(struct nvme_fdp_stats_log *log)
+{
+ struct json_object *root = json_create_object();
+
+ json_object_add_value_uint128(root, "hbmw", le128_to_cpu(log->hbmw));
+ json_object_add_value_uint128(root, "mbmw", le128_to_cpu(log->mbmw));
+ json_object_add_value_uint128(root, "mbe", le128_to_cpu(log->mbe));
+
+ json_print_object(root, NULL);
+ printf("\n");
+
+ json_free_object(root);
+}
+
+void nvme_show_fdp_stats(struct nvme_fdp_stats_log *log,
+ enum nvme_print_flags flags)
+{
+ if (flags & BINARY)
+ return d_raw((unsigned char*)log, sizeof(*log));
+ if (flags & JSON)
+ return json_nvme_fdp_stats(log);
+
+ printf("Host Bytes with Metadata Written (HBMW): %s\n",
+ uint128_t_to_string(le128_to_cpu(log->hbmw)));
+ printf("Media Bytes with Metadata Written (MBMW): %s\n",
+ uint128_t_to_string(le128_to_cpu(log->mbmw)));
+ printf("Media Bytes Erased (MBE): %s\n",
+ uint128_t_to_string(le128_to_cpu(log->mbe)));
+}
+
+static void json_nvme_fdp_events(struct nvme_fdp_events_log *log)
+{
+ struct json_object *root, *obj_events;
+ uint32_t n;
+
+ root = json_create_object();
+ obj_events = json_create_array();
+
+ n = le32_to_cpu(log->n);
+
+ json_object_add_value_uint(root, "n", n);
+
+ for (unsigned int i = 0; i < n; i++) {
+ struct nvme_fdp_event *event = &log->events[i];
+
+ struct json_object *obj_event = json_create_object();
+
+ json_object_add_value_uint(obj_event, "type", event->type);
+ json_object_add_value_uint(obj_event, "fdpef", event->flags);
+ json_object_add_value_uint(obj_event, "pid", le16_to_cpu(event->pid));
+ json_object_add_value_uint64(obj_event, "timestamp", le64_to_cpu(*(uint64_t *)&event->ts));
+ json_object_add_value_uint(obj_event, "nsid", le32_to_cpu(event->nsid));
+
+ if (event->type == NVME_FDP_EVENT_REALLOC) {
+ struct nvme_fdp_event_realloc *mr;
+ mr = (struct nvme_fdp_event_realloc *)&event->type_specific;
+
+ json_object_add_value_uint(obj_event, "nlbam", le16_to_cpu(mr->nlbam));
+
+ if (mr->flags & NVME_FDP_EVENT_REALLOC_F_LBAV)
+ json_object_add_value_uint64(obj_event, "lba", le64_to_cpu(mr->lba));
+ }
+
+ json_array_add_value_object(obj_events, obj_event);
+ }
+
+ json_object_add_value_array(root, "events", obj_events);
+
+ json_print_object(root, NULL);
+ printf("\n");
+
+ json_free_object(root);
+}
+
+static const char *nvme_fdp_event_to_string(enum nvme_fdp_event_type event)
+{
+ switch (event) {
+ case NVME_FDP_EVENT_RUNFW: return "Reclaim Unit Not Fully Written";
+ case NVME_FDP_EVENT_RUTLE: return "Reclaim Unit Active Time Limit Exceeded";
+ case NVME_FDP_EVENT_RESET: return "Controller Level Reset Modified Reclaim Unit Handles";
+ case NVME_FDP_EVENT_PID: return "Invalid Placement Identifier";
+ case NVME_FDP_EVENT_REALLOC: return "Media Reallocated";
+ case NVME_FDP_EVENT_MODIFY: return "Implicitly Modified Reclaim Unit Handle";
+ }
+
+ return "Unknown";
+}
+
+void nvme_show_fdp_events(struct nvme_fdp_events_log *log,
+ enum nvme_print_flags flags)
+{
+ struct tm *tm;
+ char buffer[320];
+ time_t ts;
+
+ if (flags & BINARY)
+ return d_raw((unsigned char*)log, sizeof(*log));
+ if (flags & JSON)
+ return json_nvme_fdp_events(log);
+
+ uint32_t n = le32_to_cpu(log->n);
+
+ for (unsigned int i = 0; i < n; i++) {
+ struct nvme_fdp_event *event = &log->events[i];
+
+ ts = int48_to_long(event->ts.timestamp) / 1000;
+ tm = localtime(&ts);
+
+ printf("Event[%u]\n", i);
+ printf(" Event Type: 0x%"PRIx8" (%s)\n", event->type, nvme_fdp_event_to_string(event->type));
+ printf(" Event Timestamp: %"PRIu64" (%s)\n", int48_to_long(event->ts.timestamp),
+ strftime(buffer, sizeof(buffer), "%c %Z", tm) ? buffer : "-");
+
+ if (event->flags & NVME_FDP_EVENT_F_PIV)
+ printf(" Placement Identifier (PID): 0x%"PRIx16"\n", le16_to_cpu(event->pid));
+
+ if (event->flags & NVME_FDP_EVENT_F_NSIDV)
+ printf(" Namespace Identifier (NSID): %"PRIu32"\n", le32_to_cpu(event->nsid));
+
+ if (event->type == NVME_FDP_EVENT_REALLOC) {
+ struct nvme_fdp_event_realloc *mr;
+ mr = (struct nvme_fdp_event_realloc *)&event->type_specific;
+
+ printf(" Number of LBAs Moved (NLBAM): %"PRIu16"\n", le16_to_cpu(mr->nlbam));
+
+ if (mr->flags & NVME_FDP_EVENT_REALLOC_F_LBAV) {
+ printf(" Logical Block Address (LBA): 0x%"PRIx64"\n", le64_to_cpu(mr->lba));
+ }
+ }
+
+ if (event->flags & NVME_FDP_EVENT_F_LV) {
+ printf(" Reclaim Group Identifier: %"PRIu16"\n", le16_to_cpu(event->rgid));
+ printf(" Reclaim Unit Handle Identifier %"PRIu8"\n", event->ruhid);
+ }
+
+ printf("\n");
+ }
+}
+
+static void json_nvme_fdp_ruh_status(struct nvme_fdp_ruh_status *status, size_t len)
+{
+ struct json_object *root, *obj_ruhss;
+ uint16_t nruhsd;
+
+ root = json_create_object();
+ obj_ruhss = json_create_array();
+
+ nruhsd = le16_to_cpu(status->nruhsd);
+
+ json_object_add_value_uint(root, "nruhsd", nruhsd);
+
+ for (unsigned int i = 0; i < nruhsd; i++) {
+ struct nvme_fdp_ruh_status_desc *ruhs = &status->ruhss[i];
+
+ struct json_object *obj_ruhs = json_create_object();
+
+ json_object_add_value_uint(obj_ruhs, "pid", le16_to_cpu(ruhs->pid));
+ json_object_add_value_uint(obj_ruhs, "ruhid", le16_to_cpu(ruhs->ruhid));
+ json_object_add_value_uint(obj_ruhs, "earutr", le32_to_cpu(ruhs->earutr));
+ json_object_add_value_uint64(obj_ruhs, "ruamw", le64_to_cpu(ruhs->ruamw));
+
+ json_array_add_value_object(obj_ruhss, obj_ruhs);
+ }
+
+ json_object_add_value_array(root, "ruhss", obj_ruhss);
+
+ json_print_object(root, NULL);
+ printf("\n");
+
+ json_free_object(root);
+}
+
+void nvme_show_fdp_ruh_status(struct nvme_fdp_ruh_status *status, size_t len,
+ enum nvme_print_flags flags)
+{
+ if (flags & BINARY)
+ return d_raw((unsigned char *)status, len);
+ if (flags & JSON)
+ return json_nvme_fdp_ruh_status(status, len);
+
+ uint16_t nruhsd = le16_to_cpu(status->nruhsd);
+
+ for (unsigned int i = 0; i < nruhsd; i++) {
+ struct nvme_fdp_ruh_status_desc *ruhs = &status->ruhss[i];
+
+ printf("Placement Identifier %"PRIu16"; Reclaim Unit Handle Identifier %"PRIu16"\n",
+ le16_to_cpu(ruhs->pid), le16_to_cpu(ruhs->ruhid));
+ printf(" Estimated Active Reclaim Unit Time Remaining (EARUTR): %"PRIu32"\n",
+ le32_to_cpu(ruhs->earutr));
+ printf(" Reclaim Unit Available Media Writes (RUAMW): %"PRIu64"\n",
+ le64_to_cpu(ruhs->ruamw));
+
+ printf("\n");
+ }
+}
+
void nvme_show_supported_cap_config_log(
struct nvme_supported_cap_config_list_log *cap,
enum nvme_print_flags flags)
@@ -3352,7 +3704,9 @@ static void nvme_show_id_ctrl_oaes(__le32 ctrl_oaes)
static void nvme_show_id_ctrl_ctratt(__le32 ctrl_ctratt)
{
__u32 ctratt = le32_to_cpu(ctrl_ctratt);
- __u32 rsvd = ctratt >> 16;
+ __u32 rsvd20 = (ctratt >> 20);
+ __u32 fdps = (ctratt >> 19) & 0x1;
+ __u32 rsvd16 = (ctratt >> 16) & 0x7;
__u32 elbas = (ctratt >> 15) & 0x1;
__u32 delnvmset = (ctratt >> 14) & 0x1;
__u32 delegrp = (ctratt >> 13) & 0x1;
@@ -3370,8 +3724,12 @@ static void nvme_show_id_ctrl_ctratt(__le32 ctrl_ctratt)
__u32 sqa = (ctratt & NVME_CTRL_CTRATT_SQ_ASSOCIATIONS) >> 8;
__u32 uuidlist = (ctratt & NVME_CTRL_CTRATT_UUID_LIST) >> 9;
- if (rsvd)
- printf(" [31:16] : %#x\tReserved\n", rsvd);
+ if (rsvd20)
+ printf(" [31:20] : %#x\tReserved\n", rsvd20);
+ printf(" [19:19] : %#x\tFlexible Data Placement %sSupported\n",
+ fdps, fdps ? "" : "Not ");
+ if (rsvd16)
+ printf(" [18:16] : %#x\tReserved\n", rsvd16);
printf(" [15:15] : %#x\tExtended LBA Formats %sSupported\n",
elbas, elbas ? "" : "Not ");
printf(" [14:14] : %#x\tDelete NVM Set %sSupported\n",
@@ -4209,7 +4567,7 @@ void nvme_show_id_ns(struct nvme_id_ns *ns, unsigned int nsid,
printf("nows : %u\n", le16_to_cpu(ns->nows));
}
printf("mssrl : %u\n", le16_to_cpu(ns->mssrl));
- printf("mcl : %d\n", le32_to_cpu(ns->mcl));
+ printf("mcl : %u\n", le32_to_cpu(ns->mcl));
printf("msrc : %u\n", ns->msrc);
}
printf("nulbaf : %u\n", ns->nulbaf);
@@ -4291,7 +4649,7 @@ static void json_nvme_cmd_set_independent_id_ns(
json_object_add_value_int(root, "nmic", ns->nmic);
json_object_add_value_int(root, "rescap", ns->rescap);
json_object_add_value_int(root, "fpi", ns->fpi);
- json_object_add_value_int(root, "anagrpid", le32_to_cpu(ns->anagrpid));
+ json_object_add_value_uint(root, "anagrpid", le32_to_cpu(ns->anagrpid));
json_object_add_value_int(root, "nsattr", ns->nsattr);
json_object_add_value_int(root, "nvmsetid", le16_to_cpu(ns->nvmsetid));
json_object_add_value_int(root, "endgid", le16_to_cpu(ns->endgid));
@@ -4687,7 +5045,7 @@ void nvme_show_id_ctrl(struct nvme_id_ctrl *ctrl, enum nvme_print_flags flags,
printf("sanicap : %#x\n", le32_to_cpu(ctrl->sanicap));
if (human)
nvme_show_id_ctrl_sanicap(ctrl->sanicap);
- printf("hmminds : %d\n", le32_to_cpu(ctrl->hmminds));
+ printf("hmminds : %u\n", le32_to_cpu(ctrl->hmminds));
printf("hmmaxd : %d\n", le16_to_cpu(ctrl->hmmaxd));
printf("nsetidmax : %d\n", le16_to_cpu(ctrl->nsetidmax));
printf("endgidmax : %d\n", le16_to_cpu(ctrl->endgidmax));
@@ -4695,9 +5053,9 @@ void nvme_show_id_ctrl(struct nvme_id_ctrl *ctrl, enum nvme_print_flags flags,
printf("anacap : %d\n", ctrl->anacap);
if (human)
nvme_show_id_ctrl_anacap(ctrl->anacap);
- printf("anagrpmax : %d\n", ctrl->anagrpmax);
- printf("nanagrpid : %d\n", le32_to_cpu(ctrl->nanagrpid));
- printf("pels : %d\n", le32_to_cpu(ctrl->pels));
+ printf("anagrpmax : %u\n", ctrl->anagrpmax);
+ printf("nanagrpid : %u\n", le32_to_cpu(ctrl->nanagrpid));
+ printf("pels : %u\n", le32_to_cpu(ctrl->pels));
printf("domainid : %d\n", le16_to_cpu(ctrl->domainid));
printf("megcap : %s\n",
uint128_t_to_string(le128_to_cpu(ctrl->megcap)));
@@ -4736,13 +5094,13 @@ void nvme_show_id_ctrl(struct nvme_id_ctrl *ctrl, enum nvme_print_flags flags,
printf("sgls : %#x\n", le32_to_cpu(ctrl->sgls));
if (human)
nvme_show_id_ctrl_sgls(ctrl->sgls);
- printf("mnan : %d\n", le32_to_cpu(ctrl->mnan));
+ printf("mnan : %u\n", le32_to_cpu(ctrl->mnan));
printf("maxdna : %s\n",
uint128_t_to_string(le128_to_cpu(ctrl->maxdna)));
- printf("maxcna : %d\n", le32_to_cpu(ctrl->maxcna));
+ printf("maxcna : %u\n", le32_to_cpu(ctrl->maxcna));
printf("subnqn : %-.*s\n", (int)sizeof(ctrl->subnqn), ctrl->subnqn);
- printf("ioccsz : %d\n", le32_to_cpu(ctrl->ioccsz));
- printf("iorcsz : %d\n", le32_to_cpu(ctrl->iorcsz));
+ printf("ioccsz : %u\n", le32_to_cpu(ctrl->ioccsz));
+ printf("iorcsz : %u\n", le32_to_cpu(ctrl->iorcsz));
printf("icdoff : %d\n", le16_to_cpu(ctrl->icdoff));
printf("fcatt : %#x\n", ctrl->fcatt);
if (human)
@@ -4816,8 +5174,8 @@ static void json_nvme_nvm_id_ns(struct nvme_nvm_id_ns *nvm_ns,
struct json_object *elbaf = json_create_object();
unsigned int elbaf_val = le32_to_cpu(nvm_ns->elbaf[i]);
- json_object_add_value_int(elbaf, "sts", elbaf_val & 0x7F);
- json_object_add_value_int(elbaf, "pif", (elbaf_val >> 7) & 0x3);
+ json_object_add_value_uint(elbaf, "sts", elbaf_val & 0x7F);
+ json_object_add_value_uint(elbaf, "pif", (elbaf_val >> 7) & 0x3);
json_array_add_value_object(elbafs, elbaf);
}
@@ -4919,17 +5277,17 @@ static void json_nvme_zns_id_ns(struct nvme_zns_id_ns *ns,
root = json_create_object();
json_object_add_value_int(root, "zoc", le16_to_cpu(ns->zoc));
json_object_add_value_int(root, "ozcs", le16_to_cpu(ns->ozcs));
- json_object_add_value_int(root, "mar", le32_to_cpu(ns->mar));
- json_object_add_value_int(root, "mor", le32_to_cpu(ns->mor));
- json_object_add_value_int(root, "rrl", le32_to_cpu(ns->rrl));
- json_object_add_value_int(root, "frl", le32_to_cpu(ns->frl));
- json_object_add_value_int(root, "rrl1", le32_to_cpu(ns->rrl1));
- json_object_add_value_int(root, "rrl2", le32_to_cpu(ns->rrl2));
- json_object_add_value_int(root, "rrl3", le32_to_cpu(ns->rrl3));
- json_object_add_value_int(root, "frl1", le32_to_cpu(ns->frl1));
- json_object_add_value_int(root, "frl2", le32_to_cpu(ns->frl2));
- json_object_add_value_int(root, "frl3", le32_to_cpu(ns->frl3));
- json_object_add_value_int(root, "numzrwa", le32_to_cpu(ns->numzrwa));
+ json_object_add_value_uint(root, "mar", le32_to_cpu(ns->mar));
+ json_object_add_value_uint(root, "mor", le32_to_cpu(ns->mor));
+ json_object_add_value_uint(root, "rrl", le32_to_cpu(ns->rrl));
+ json_object_add_value_uint(root, "frl", le32_to_cpu(ns->frl));
+ json_object_add_value_uint(root, "rrl1", le32_to_cpu(ns->rrl1));
+ json_object_add_value_uint(root, "rrl2", le32_to_cpu(ns->rrl2));
+ json_object_add_value_uint(root, "rrl3", le32_to_cpu(ns->rrl3));
+ json_object_add_value_uint(root, "frl1", le32_to_cpu(ns->frl1));
+ json_object_add_value_uint(root, "frl2", le32_to_cpu(ns->frl2));
+ json_object_add_value_uint(root, "frl3", le32_to_cpu(ns->frl3));
+ json_object_add_value_uint(root, "numzrwa", le32_to_cpu(ns->numzrwa));
json_object_add_value_int(root, "zrwafg", le16_to_cpu(ns->zrwafg));
json_object_add_value_int(root, "zrwasz", le16_to_cpu(ns->zrwasz));
json_object_add_value_int(root, "zrwacap", ns->zrwacap);
@@ -5358,9 +5716,9 @@ static void json_nvme_id_nvmset(struct nvme_id_nvmset_list *nvmset)
le16_to_cpu(nvmset->ent[i].nvmsetid));
json_object_add_value_int(entry, "endurance_group_id",
le16_to_cpu(nvmset->ent[i].endgid));
- json_object_add_value_int(entry, "random_4k_read_typical",
+ json_object_add_value_uint(entry, "random_4k_read_typical",
le32_to_cpu(nvmset->ent[i].rr4kt));
- json_object_add_value_int(entry, "optimal_write_size",
+ json_object_add_value_uint(entry, "optimal_write_size",
le32_to_cpu(nvmset->ent[i].ows));
json_object_add_value_uint128(entry, "total_nvmset_cap",
le128_to_cpu(nvmset->ent[i].tnvmsetcap));
@@ -5419,15 +5777,15 @@ static void json_nvme_primary_ctrl_cap(const struct nvme_primary_ctrl_cap *caps)
json_object_add_value_uint(root, "portid", le16_to_cpu(caps->portid));
json_object_add_value_uint(root, "crt", caps->crt);
- json_object_add_value_int(root, "vqfrt", le32_to_cpu(caps->vqfrt));
- json_object_add_value_int(root, "vqrfa", le32_to_cpu(caps->vqrfa));
+ json_object_add_value_uint(root, "vqfrt", le32_to_cpu(caps->vqfrt));
+ json_object_add_value_uint(root, "vqrfa", le32_to_cpu(caps->vqrfa));
json_object_add_value_int(root, "vqrfap", le16_to_cpu(caps->vqrfap));
json_object_add_value_int(root, "vqprt", le16_to_cpu(caps->vqprt));
json_object_add_value_int(root, "vqfrsm", le16_to_cpu(caps->vqfrsm));
json_object_add_value_int(root, "vqgran", le16_to_cpu(caps->vqgran));
- json_object_add_value_int(root, "vifrt", le32_to_cpu(caps->vifrt));
- json_object_add_value_int(root, "virfa", le32_to_cpu(caps->virfa));
+ json_object_add_value_uint(root, "vifrt", le32_to_cpu(caps->vifrt));
+ json_object_add_value_uint(root, "virfa", le32_to_cpu(caps->virfa));
json_object_add_value_int(root, "virfap", le16_to_cpu(caps->virfap));
json_object_add_value_int(root, "viprt", le16_to_cpu(caps->viprt));
json_object_add_value_int(root, "vifrsm", le16_to_cpu(caps->vifrsm));
@@ -5466,14 +5824,14 @@ void nvme_show_primary_ctrl_cap(const struct nvme_primary_ctrl_cap *caps,
printf("crt : %#x\n", caps->crt);
if (human)
nvme_show_primary_ctrl_caps_crt(caps->crt);
- printf("vqfrt : %d\n", le32_to_cpu(caps->vqfrt));
- printf("vqrfa : %d\n", le32_to_cpu(caps->vqrfa));
+ printf("vqfrt : %u\n", le32_to_cpu(caps->vqfrt));
+ printf("vqrfa : %u\n", le32_to_cpu(caps->vqrfa));
printf("vqrfap : %d\n", le16_to_cpu(caps->vqrfap));
printf("vqprt : %d\n", le16_to_cpu(caps->vqprt));
printf("vqfrsm : %d\n", le16_to_cpu(caps->vqfrsm));
printf("vqgran : %d\n", le16_to_cpu(caps->vqgran));
- printf("vifrt : %d\n", le32_to_cpu(caps->vifrt));
- printf("virfa : %d\n", le32_to_cpu(caps->virfa));
+ printf("vifrt : %u\n", le32_to_cpu(caps->vifrt));
+ printf("virfa : %u\n", le32_to_cpu(caps->virfa));
printf("virfap : %d\n", le16_to_cpu(caps->virfap));
printf("viprt : %d\n", le16_to_cpu(caps->viprt));
printf("vifrsm : %d\n", le16_to_cpu(caps->vifrsm));
@@ -5871,7 +6229,7 @@ void nvme_show_resv_report(struct nvme_resv_status *status, int bytes,
regctl = status->regctl[0] | (status->regctl[1] << 8);
printf("\nNVME Reservation status:\n\n");
- printf("gen : %d\n", le32_to_cpu(status->gen));
+ printf("gen : %u\n", le32_to_cpu(status->gen));
printf("rtype : %d\n", status->rtype);
printf("regctl : %d\n", regctl);
printf("ptpls : %d\n", status->ptpls);
@@ -5913,7 +6271,7 @@ void nvme_show_resv_report(struct nvme_resv_status *status, int bytes,
le64_to_cpu(status->regctl_eds[i].rkey));
printf(" hostid : ");
for (j = 0; j < 16; j++)
- printf("%x",
+ printf("%02x",
status->regctl_eds[i].hostid[j]);
printf("\n");
}
@@ -6255,10 +6613,14 @@ void nvme_show_smart_log(struct nvme_smart_log *smart, unsigned int nsid,
smart->percent_used);
printf("endurance group critical warning summary: %#x\n",
smart->endu_grp_crit_warn_sumry);
- printf("data_units_read : %s\n",
- uint128_t_to_string(le128_to_cpu(smart->data_units_read)));
- printf("data_units_written : %s\n",
- uint128_t_to_string(le128_to_cpu(smart->data_units_written)));
+ printf("Data Units Read : %s (%s)\n",
+ uint128_t_to_string(le128_to_cpu(smart->data_units_read)),
+ uint128_t_to_si_string(le128_to_cpu(smart->data_units_read),
+ 1000 * 512));
+ printf("Data Units Written : %s (%s)\n",
+ uint128_t_to_string(le128_to_cpu(smart->data_units_written)),
+ uint128_t_to_si_string(le128_to_cpu(smart->data_units_written),
+ 1000 * 512));
printf("host_read_commands : %s\n",
uint128_t_to_string(le128_to_cpu(smart->host_reads)));
printf("host_write_commands : %s\n",
@@ -6554,6 +6916,8 @@ const char *nvme_feature_to_string(enum nvme_features_id feature)
case NVME_FEAT_FID_RESV_MASK: return "Reservation Notification Mask";
case NVME_FEAT_FID_RESV_PERSIST:return "Reservation Persistence";
case NVME_FEAT_FID_WRITE_PROTECT: return "Namespace Write Protect";
+ case NVME_FEAT_FID_FDP: return "Flexible Direct Placement";
+ case NVME_FEAT_FID_FDP_EVENTS: return "Flexible Direct Placement Events";
}
/*
* We don't use the "default:" statement to let the compiler warning if
@@ -7119,6 +7483,21 @@ void nvme_feature_show_fields(enum nvme_features_id fid, unsigned int result, un
case NVME_FEAT_FID_WRITE_PROTECT:
printf("\tNamespace Write Protect: %s\n", nvme_show_ns_wp_cfg(result));
break;
+ case NVME_FEAT_FID_FDP:
+ printf("\tFlexible Direct Placement Enable (FDPE) : %s\n",
+ (result & 0x1) ? "Yes" : "No");
+ printf("\tFlexible Direct Placement Configuration Index : %u\n",
+ (result >> 8) & 0xf);
+ break;
+ case NVME_FEAT_FID_FDP_EVENTS:
+ for (unsigned int i = 0; i < result; i++) {
+ struct nvme_fdp_supported_event_desc *d;
+
+ d = &((struct nvme_fdp_supported_event_desc *)buf)[i];
+
+ printf("\t%-53s: %sEnabled\n", nvme_fdp_event_to_string(d->evt),
+ d->evta & 0x1 ? "" : "Not ");
+ }
default:
break;
}
@@ -7411,15 +7790,15 @@ static void json_detail_list(nvme_root_t r)
nvme_ctrl_for_each_ns(c, n) {
struct json_object *jns = json_create_object();
- long long lba = nvme_ns_get_lba_size(n);
- double nsze = nvme_ns_get_lba_count(n) * lba;
- double nuse = nvme_ns_get_lba_util(n) * lba;
+ int lba = nvme_ns_get_lba_size(n);
+ uint64_t nsze = nvme_ns_get_lba_count(n) * lba;
+ uint64_t nuse = nvme_ns_get_lba_util(n) * lba;
json_object_add_value_string(jns, "NameSpace", nvme_ns_get_name(n));
json_object_add_value_int(jns, "NSID", nvme_ns_get_nsid(n));
- json_object_add_value_int(jns, "UsedBytes", nuse);
- json_object_add_value_int(jns, "MaximumLBA", nvme_ns_get_lba_count(n));
- json_object_add_value_int(jns, "PhysicalSize", nsze);
+ json_object_add_value_uint64(jns, "UsedBytes", nuse);
+ json_object_add_value_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n));
+ json_object_add_value_uint64(jns, "PhysicalSize", nsze);
json_object_add_value_int(jns, "SectorSize", lba);
json_array_add_value_object(jnss, jns);
@@ -7443,15 +7822,15 @@ static void json_detail_list(nvme_root_t r)
nvme_subsystem_for_each_ns(s, n) {
struct json_object *jns = json_create_object();
- long long lba = nvme_ns_get_lba_size(n);
- double nsze = nvme_ns_get_lba_count(n) * lba;
- double nuse = nvme_ns_get_lba_util(n) * lba;
+ int lba = nvme_ns_get_lba_size(n);
+ uint64_t nsze = nvme_ns_get_lba_count(n) * lba;
+ uint64_t nuse = nvme_ns_get_lba_util(n) * lba;
json_object_add_value_string(jns, "NameSpace", nvme_ns_get_name(n));
json_object_add_value_int(jns, "NSID", nvme_ns_get_nsid(n));
- json_object_add_value_int(jns, "UsedBytes", nuse);
- json_object_add_value_int(jns, "MaximumLBA", nvme_ns_get_lba_count(n));
- json_object_add_value_int(jns, "PhysicalSize", nsze);
+ json_object_add_value_uint64(jns, "UsedBytes", nuse);
+ json_object_add_value_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n));
+ json_object_add_value_uint64(jns, "PhysicalSize", nsze);
json_object_add_value_int(jns, "SectorSize", lba);
json_array_add_value_object(jnss, jns);
@@ -7475,9 +7854,9 @@ static struct json_object *json_list_item(nvme_ns_t n)
struct json_object *jdevice = json_create_object();
char devname[128] = { 0 };
- long long lba = nvme_ns_get_lba_size(n);
- double nsze = nvme_ns_get_lba_count(n) * lba;
- double nuse = nvme_ns_get_lba_util(n) * lba;
+ int lba = nvme_ns_get_lba_size(n);
+ uint64_t nsze = nvme_ns_get_lba_count(n) * lba;
+ uint64_t nuse = nvme_ns_get_lba_util(n) * lba;
nvme_dev_full_path(n, devname, sizeof(devname));
@@ -7486,9 +7865,9 @@ static struct json_object *json_list_item(nvme_ns_t n)
json_object_add_value_string(jdevice, "Firmware", nvme_ns_get_firmware(n));
json_object_add_value_string(jdevice, "ModelNumber", nvme_ns_get_model(n));
json_object_add_value_string(jdevice, "SerialNumber", nvme_ns_get_serial(n));
- json_object_add_value_int(jdevice, "UsedBytes", nuse);
- json_object_add_value_int(jdevice, "MaximumLBA", nvme_ns_get_lba_count(n));
- json_object_add_value_int(jdevice, "PhysicalSize", nsze);
+ json_object_add_value_uint64(jdevice, "UsedBytes", nuse);
+ json_object_add_value_uint64(jdevice, "MaximumLBA", nvme_ns_get_lba_count(n));
+ json_object_add_value_uint64(jdevice, "PhysicalSize", nsze);
json_object_add_value_int(jdevice, "SectorSize", lba);
return jdevice;