Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions nvme-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,12 @@ void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
obj_add_int(psd, "active_power", le16_to_cpu(ctrl->psd[i].actp));
obj_add_int(psd, "active_power_work", ctrl->psd[i].apws & 7);
obj_add_int(psd, "active_scale", nvme_psd_power_scale(ctrl->psd[i].apws));
obj_add_int(psd, "emerg_power_fail_recover_time", ctrl->psd[i].epfrt);
obj_add_int(psd, "emerg_power_fail_recover_scale", ctrl->psd[i].epfr_fqv_ts & 0xf);
obj_add_int(psd, "force_quiesce_vault_time", ctrl->psd[i].fqvt);
obj_add_int(psd, "force_quiesce_vault_scale", ctrl->psd[i].epfr_fqv_ts >> 4);
obj_add_int(psd, "emerg_power_fail_vault_time", ctrl->psd[i].epfvt);
obj_add_int(psd, "emerg_power_fail_vault_scale", ctrl->psd[i].epfvts & 0xf);

array_add_obj(psds, psd);
}
Expand Down
28 changes: 27 additions & 1 deletion nvme-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -3020,6 +3020,27 @@ static void print_ps_power_and_scale(__le16 ctr_power, __u8 scale)
}
}

static void print_psd_time(const char *desc, __u8 time, __u8 ts)
{
int width = 12 + strlen(desc);
char value[STR_LEN] = { 0 };

switch (time) {
case 0:
snprintf(value, sizeof(value), "-");
break;
case 1 ... 99:
snprintf(value, sizeof(value), "%d (unit: %s)", time,
nvme_time_scale_to_string(ts));
break;
default:
snprintf(value, sizeof(value), "reserved");
break;
}

printf("%*s: %s\n", width, desc, value);
}

static void stdout_id_ctrl_power(struct nvme_id_ctrl *ctrl)
{
int i;
Expand Down Expand Up @@ -3051,7 +3072,12 @@ static void stdout_id_ctrl_power(struct nvme_id_ctrl *ctrl)
printf("\n active_power_workload:");
print_psd_workload(ctrl->psd[i].apws);
printf("\n");

print_psd_time("emergency power fail recovery time", ctrl->psd[i].epfrt,
ctrl->psd[i].epfr_fqv_ts & 0xf);
print_psd_time("forced quiescence vault time", ctrl->psd[i].fqvt,
ctrl->psd[i].epfr_fqv_ts >> 4);
print_psd_time("emergency power fail vault time", ctrl->psd[i].epfvt,
ctrl->psd[i].epfvts & 0xf);
}
}

Expand Down
36 changes: 36 additions & 0 deletions nvme-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,42 @@ const char *nvme_register_symbol_to_string(int offset)
return "unknown";
}

const char *nvme_time_scale_to_string(__u8 ts)
{
switch (ts) {
case 0:
return "1 microsecond";
case 1:
return "10 microseconds";
case 2:
return "100 microseconds";
case 3:
return "1 millisecond";
case 4:
return "10 milliseconds";
case 5:
return "100 milliseconds";
case 6:
return "1 second";
case 7:
return "10 seconds";
case 8:
return "100 seconds";
case 9:
return "1,000 seconds";
case 0xa:
return "10,000 seconds";
case 0xb:
return "100,000 seconds";
case 0xc:
return "1,000,000 seconds";
default:
break;
}

return "Reserved";
}

void nvme_feature_show(enum nvme_features_id fid, int sel, unsigned int result)
{
nvme_print(show_feature, NORMAL, fid, sel, result);
Expand Down
1 change: 1 addition & 0 deletions nvme-print.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ const char *nvme_ns_wp_cfg_to_string(enum nvme_ns_write_protect_cfg state);
const char *nvme_pel_rci_rcpit_to_string(enum nvme_pel_rci_rcpit rcpit);
const char *nvme_pel_ehai_pit_to_string(enum nvme_pel_ehai_pit pit);
const char *nvme_ssi_state_to_string(__u8 state);
const char *nvme_time_scale_to_string(__u8 ts);

void nvme_dev_full_path(nvme_ns_t n, char *path, size_t len);
void nvme_generic_full_path(nvme_ns_t n, char *path, size_t len);
Expand Down
2 changes: 0 additions & 2 deletions util/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ struct json_object;
#define json_object_add_value_array(o, k, v) json_object_object_add(o, k, v)
#define json_object_add_value_object(o, k, v) json_object_object_add(o, k, v)

#define STR_LEN 100

void json_object_add_uint_02x(struct json_object *o, const char *k, __u32 v);
void json_object_add_uint_0x(struct json_object *o, const char *k, __u32 v);
void json_object_add_byte_array(struct json_object *o, const char *k, unsigned char *buf, int len);
Expand Down
2 changes: 2 additions & 0 deletions util/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#define ABSOLUTE_ZERO_CELSIUS -273

#define STR_LEN 100

static inline long kelvin_to_celsius(long t)
{
return t + ABSOLUTE_ZERO_CELSIUS;
Expand Down
Loading