]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print: print the new fields added in TP4142
authorFrancis Pravin <francis.p@samsung.com>
Fri, 16 Aug 2024 06:42:36 +0000 (12:12 +0530)
committerDaniel Wagner <wagi@monom.org>
Mon, 19 Aug 2024 08:55:40 +0000 (10:55 +0200)
Print the new fields added in Identify Controller Data Structure.
Also, print the field added in Temperature Threshold feature.

Signed-off-by: Francis Pravin <francis.p@samsung.com>
Reviewed-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
nvme-print-json.c
nvme-print-stdout.c

index ce094ec40b8b1ef7a15acbb807b7776441dbf662..af90eba04f1f994d53c2bd3f345be60a3f788d7e 100644 (file)
@@ -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));
 
index acecd1ac3d3e818b4241ac40401793e7a2bc0a13..e23739a394839710d83961f91e9e7734b7e2c1b0 100644 (file)
@@ -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: