Skip to content

Commit

Permalink
nvme-print: print the new fields added in Sanitize log - TP4152
Browse files Browse the repository at this point in the history
Print the new fields added in Sanitize log as part of TP4152.
TP4152 - Post-Sanitize Media Verification 2024.04.01 Ratified.

Signed-off-by: Francis Pravin <[email protected]>
Reviewed-by: Steven Seungcheol Lee <[email protected]>
  • Loading branch information
francispravin5 committed Nov 14, 2024
1 parent d81cd5e commit bc0f18b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
24 changes: 22 additions & 2 deletions nvme-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,16 +1375,22 @@ static void json_sanitize_log(struct nvme_sanitize_log_page *sanitize_log,
struct json_object *r = json_create_object();
struct json_object *dev = json_create_object();
struct json_object *sstat = json_create_object();
__u16 status = le16_to_cpu(sanitize_log->sstat);
struct json_object *ssi = json_create_object();
const char *status_str;
__u16 status, sos;
__u8 fails, sans;
char str[128];

status = le16_to_cpu(sanitize_log->sstat);

obj_add_int(dev, "sprog", le16_to_cpu(sanitize_log->sprog));
obj_add_int(sstat, "media_verification_canceled", NVME_GET(status, SANITIZE_SSTAT_MVCNCLD));
obj_add_int(sstat, "global_erased", NVME_GET(status, SANITIZE_SSTAT_GLOBAL_DATA_ERASED));
obj_add_int(sstat, "no_cmplted_passes", NVME_GET(status, SANITIZE_SSTAT_COMPLETED_PASSES));

sos = NVME_GET(status, SANITIZE_SSTAT_STATUS);
status_str = nvme_sstat_status_to_string(status);
sprintf(str, "(%d) %s", NVME_GET(status, SANITIZE_SSTAT_STATUS), status_str);
sprintf(str, "(%d) %s", sos, status_str);
obj_add_str(sstat, "status", str);

obj_add_obj(dev, "sstat", sstat);
Expand All @@ -1395,7 +1401,21 @@ static void json_sanitize_log(struct nvme_sanitize_log_page *sanitize_log,
obj_add_uint(dev, "time_over_write_no_dealloc", le32_to_cpu(sanitize_log->etond));
obj_add_uint(dev, "time_block_erase_no_dealloc", le32_to_cpu(sanitize_log->etbend));
obj_add_uint(dev, "time_crypto_erase_no_dealloc", le32_to_cpu(sanitize_log->etcend));
obj_add_uint(dev, "time_post_verification_dealloc", le32_to_cpu(sanitize_log->etpvds));

sans = NVME_GET(sanitize_log->ssi, SANITIZE_SSI_SANS);
status_str = nvme_ssi_state_to_string(sans);
sprintf(str, "(%d) %s", sans, status_str);
obj_add_str(ssi, "sanitize_state", str);

if (sos == NVME_SANITIZE_SSTAT_STATUS_COMPLETED_FAILED) {
fails = NVME_GET(sanitize_log->ssi, SANITIZE_SSI_FAILS);
status_str = nvme_ssi_state_to_string(fails);
sprintf(str, "(%d) %s", fails, status_str);
obj_add_str(ssi, "failure_state", str);
}

obj_add_obj(dev, "sanitize_state_information", ssi);
obj_add_obj(r, devname, dev);

json_print(r);
Expand Down
29 changes: 28 additions & 1 deletion nvme-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -4187,7 +4187,7 @@ static void stdout_sanitize_log_sprog(__u32 sprog)
static void stdout_sanitize_log_sstat(__u16 status)
{
const char *str = nvme_sstat_status_to_string(status);
__u16 gde;
__u16 gde, mvcncld;

printf(" [2:0] : Sanitize Operation Status : %#x\t%s\n",
NVME_GET(status, SANITIZE_SSTAT_STATUS), str);
Expand All @@ -4202,6 +4202,10 @@ static void stdout_sanitize_log_sstat(__u16 status)
str = "User data has been written in the NVM subsystem or"\
" PMR has been enabled in the NVM subsystem";
printf(" [8:8] : Global Data Erased : %#x\t%s\n", gde, str);

mvcncld = NVME_GET(status, SANITIZE_SSTAT_MVCNCLD);
printf(" [9:9] : Media Verification Canceled: %#x\t%scanceled\n", mvcncld, mvcncld ? "" : "Not ");

Check failure on line 4207 in nvme-print-stdout.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 107 exceeds 100 columns
printf("\n");
}

static void stdout_estimate_sanitize_time(const char *text, uint32_t value)
Expand All @@ -4210,6 +4214,23 @@ static void stdout_estimate_sanitize_time(const char *text, uint32_t value)
value == 0xffffffff ? " (No time period reported)" : "");
}

static void stdout_sanitize_log_ssi(__u8 ssi, __u16 status)
{
__u8 sans, fails;
const char *str;

sans = NVME_GET(ssi, SANITIZE_SSI_SANS);
str = nvme_ssi_state_to_string(sans);
printf(" [3:0] : Sanitize State : %#x\t%s\n", sans, str);

if (status == NVME_SANITIZE_SSTAT_STATUS_COMPLETED_FAILED) {
fails = NVME_GET(ssi, SANITIZE_SSI_FAILS);
str = nvme_ssi_state_to_string(fails);
printf(" [7:4] : Failure State : %#x\t%s\n", fails, str);
}
printf("\n");
}

static void stdout_sanitize_log(struct nvme_sanitize_log_page *sanitize,
const char *devname)
{
Expand Down Expand Up @@ -4243,6 +4264,12 @@ static void stdout_sanitize_log(struct nvme_sanitize_log_page *sanitize,
le32_to_cpu(sanitize->etbend));
stdout_estimate_sanitize_time("Estimated Time For Crypto Erase (No-Deallocate)",
le32_to_cpu(sanitize->etcend));
stdout_estimate_sanitize_time("Estimated Time For Post-Verification Deallocation",
le32_to_cpu(sanitize->etpvds));

printf("Sanitize State Information (SSI) : %#x\n", sanitize->ssi);
if (human)
stdout_sanitize_log_ssi(sanitize->ssi, status);
}

static void stdout_select_result(enum nvme_features_id fid, __u32 result)
Expand Down
22 changes: 22 additions & 0 deletions nvme-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,28 @@ const char *nvme_pel_ehai_pit_to_string(enum nvme_pel_ehai_pit pit)
return "Reserved";
}

const char *nvme_ssi_state_to_string(__u8 state)
{
switch (state) {
case NVME_SANITIZE_SSI_IDLE:
return "Idle state";
case NVME_SANITIZE_SSI_RESTRICT_PROCESSING:
return "Restricted Processing State";
case NVME_SANITIZE_SSI_RESTRICT_FAILURE:
return "Restricted Failure State";
case NVME_SANITIZE_SSI_UNRESTRICT_PROCESSING:
return "Unrestricted Processing State";
case NVME_SANITIZE_SSI_UNRESTRICT_FAILURE:
return "Unrestricted Failure State";
case NVME_SANITIZE_SSI_MEDIA_VERIFICATION:
return "Media Verification State";
case NVME_SANITIZE_SSI_POST_VERIF_DEALLOC:
return "Post-Verification Deallocation State";
default:
return "Reserved";
}
}

const char *nvme_register_symbol_to_string(int offset)
{
switch (offset) {
Expand Down
1 change: 1 addition & 0 deletions nvme-print.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ const char *nvme_plm_window_to_string(__u32 plm);
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);

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

0 comments on commit bc0f18b

Please sign in to comment.