From: Francis Pravin Date: Fri, 16 Aug 2024 06:42:36 +0000 (+0530) Subject: nvme-print: print the new fields added in TP4142 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=7ad9d9adc4b61654b9ef1722f054555da1777224;p=users%2Fsagi%2Fnvme-cli.git nvme-print: print the new fields added in TP4142 Print the new fields added in Identify Controller Data Structure. Also, print the field added in Temperature Threshold feature. Signed-off-by: Francis Pravin Reviewed-by: Steven Seungcheol Lee --- diff --git a/nvme-print-json.c b/nvme-print-json.c index ce094ec4..af90eba0 100644 --- a/nvme-print-json.c +++ b/nvme-print-json.c @@ -400,6 +400,7 @@ void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl, obj_add_uint(r, "pels", le32_to_cpu(ctrl->pels)); obj_add_int(r, "domainid", le16_to_cpu(ctrl->domainid)); obj_add_uint128(r, "megcap", megcap); + obj_add_int(r, "tmpthha", ctrl->tmpthha); obj_add_int(r, "sqes", ctrl->sqes); obj_add_int(r, "cqes", ctrl->cqes); obj_add_int(r, "maxcmd", le16_to_cpu(ctrl->maxcmd)); @@ -3298,9 +3299,17 @@ static void json_feature_show_fields_lba_range(struct json_object *r, __u8 field static void json_feature_show_fields_temp_thresh(struct json_object *r, unsigned int result) { - __u8 field = (result & 0x300000) >> 20; char json_str[STR_LEN]; + __u8 field; + field = (result & 0x1c00000) >> 22; + sprintf(json_str, "%s", nvme_degrees_string(field)); + obj_add_str(r, "Temperature Threshold Hysteresis (TMPTHH)", json_str); + + sprintf(json_str, "%u K", field); + obj_add_str(r, "TMPTHH kelvin", json_str); + + field = (result & 0x300000) >> 20; obj_add_uint(r, "Threshold Type Select (THSEL)", field); obj_add_str(r, "THSEL description", nvme_feature_temp_type_to_string(field)); diff --git a/nvme-print-stdout.c b/nvme-print-stdout.c index acecd1ac..e23739a3 100644 --- a/nvme-print-stdout.c +++ b/nvme-print-stdout.c @@ -1684,7 +1684,8 @@ static void stdout_id_ctrl_oaes(__le32 ctrl_oaes) __u32 disc = (oaes >> 31) & 0x1; __u32 rsvd0 = (oaes & 0x70000000) >> 28; __u32 zicn = (oaes & 0x08000000) >> 27; - __u32 rsvd1 = (oaes & 0x07FF0000) >> 16; + __u32 rsvd1 = (oaes & 0x7fe0000) >> 17; + __u32 tthr = (oaes & 0x10000) >> 16; __u32 normal_shn = (oaes >> 15) & 0x1; __u32 egealpcn = (oaes & 0x4000) >> 14; __u32 lbasin = (oaes & 0x2000) >> 13; @@ -1702,7 +1703,9 @@ static void stdout_id_ctrl_oaes(__le32 ctrl_oaes) printf(" [27:27] : %#x\tZone Descriptor Changed Notices %sSupported\n", zicn, zicn ? "" : "Not "); if (rsvd1) - printf(" [26:16] : %#x\tReserved\n", rsvd1); + printf(" [26:17] : %#x\tReserved\n", rsvd1); + printf(" [16:16] : %#x\tTemperature Threshold Hysteresis Recovery %sSupported\n", + tthr, tthr ? "" : "Not "); printf(" [15:15] : %#x\tNormal NSS Shutdown Event %sSupported\n", normal_shn, normal_shn ? "" : "Not "); printf(" [14:14] : %#x\tEndurance Group Event Aggregate Log Page"\ @@ -2118,6 +2121,18 @@ static void stdout_id_ctrl_anacap(__u8 anacap) printf("\n"); } +static void stdout_id_ctrl_tmpthha(__u8 tmpthha) +{ + __u8 rsvd3 = (tmpthha & 0xf8) >> 3; + __u8 tmpthmh = tmpthha & 0x7; + + if (rsvd3) + printf(" [7:3] : %#x\tReserved\n", rsvd3); + printf(" [2:0] : %#x\tTemperature Threshold Maximum Hysteresis\n", + tmpthmh); + printf("\n"); +} + static void stdout_id_ctrl_sqes(__u8 sqes) { __u8 msqes = (sqes & 0xF0) >> 4; @@ -2992,6 +3007,9 @@ static void stdout_id_ctrl(struct nvme_id_ctrl *ctrl, printf("domainid : %d\n", le16_to_cpu(ctrl->domainid)); printf("megcap : %s\n", uint128_t_to_l10n_string(le128_to_cpu(ctrl->megcap))); + printf("tmpthha : %#x\n", ctrl->tmpthha); + if (human) + stdout_id_ctrl_tmpthha(ctrl->tmpthha); printf("sqes : %#x\n", ctrl->sqes); if (human) stdout_id_ctrl_sqes(ctrl->sqes); @@ -4495,13 +4513,16 @@ static void stdout_feature_show_fields(enum nvme_features_id fid, stdout_lba_range((struct nvme_lba_range_type *)buf, field); break; case NVME_FEAT_FID_TEMP_THRESH: + field = (result & 0x1c00000) >> 22; + printf("\tTemperature Threshold Hysteresis(TMPTHH): %s (%u K)\n", + nvme_degrees_string(field), field); field = (result & 0x00300000) >> 20; - printf("\tThreshold Type Select (THSEL): %u - %s\n", field, + printf("\tThreshold Type Select (THSEL): %u - %s\n", field, nvme_feature_temp_type_to_string(field)); field = (result & 0x000f0000) >> 16; - printf("\tThreshold Temperature Select (TMPSEL): %u - %s\n", + printf("\tThreshold Temperature Select (TMPSEL): %u - %s\n", field, nvme_feature_temp_sel_to_string(field)); - printf("\tTemperature Threshold (TMPTH): %s (%u K)\n", + printf("\tTemperature Threshold (TMPTH): %s (%u K)\n", nvme_degrees_string(result & 0x0000ffff), result & 0x0000ffff); break; case NVME_FEAT_FID_ERR_RECOVERY: