]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Add Intel temperature statistics
authorKeith Busch <keith.busch@intel.com>
Wed, 8 Jun 2016 18:43:31 +0000 (12:43 -0600)
committerKeith Busch <keith.busch@intel.com>
Wed, 8 Jun 2016 23:32:19 +0000 (17:32 -0600)
Defined as per public P3xxx datasheet.

Signed-off-by: Keith Busch <keith.busch@intel.com>
intel-nvme.c
intel-nvme.h

index 0c004d2a2b9ba9bd3de7364daa3dab275bc95a02..c944243eb5a6a96562a3fce28a5b71a5fc5c3b24 100644 (file)
@@ -115,3 +115,63 @@ static int get_market_log(int argc, char **argv, struct command *cmd, struct plu
                                        nvme_status_to_string(err), err);
        return err;
 }
+
+
+struct intel_temp_stats {
+       __u64   curr;
+       __u64   last_overtemp;
+       __u64   life_overtemp;
+       __u64   highest_temp;
+       __u64   lowest_temp;
+       __u8    rsvd[40];
+       __u64   max_operating_temp;
+       __u64   min_operating_temp;
+       __u64   est_offset;
+};
+
+static void show_temp_stats(struct intel_temp_stats *stats)
+{
+       printf("  Intel Temperature Statistics\n");
+       printf("--------------------------------\n");
+       printf("Current temperature         : %llu\n", stats->curr);
+       printf("Last critical overtemp flag : %llu\n", stats->last_overtemp);
+       printf("Life critical overtemp flag : %llu\n", stats->life_overtemp);
+       printf("Highest temperature         : %llu\n", stats->highest_temp);
+       printf("Lowest temperature          : %llu\n", stats->lowest_temp);
+       printf("Max operating temperature   : %llu\n", stats->max_operating_temp);
+       printf("Min operating temperature   : %llu\n", stats->min_operating_temp);
+       printf("Estimated offset            : %llu\n", stats->est_offset);
+}
+
+static int get_temp_stats_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
+{
+       struct intel_temp_stats stats;
+       int err, fd;
+
+       char *desc = "Get Intel Marketing Name log and show it.";
+       const char *raw = "dump output in binary format";
+       struct config {
+               int  raw_binary;
+       };
+
+       struct config cfg = {
+       };
+
+       const struct argconfig_commandline_options command_line_options[] = {
+               {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw},
+               {0}
+       };
+
+       fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
+
+       err = nvme_get_log(fd, 0xffffffff, 0xc5, sizeof(stats), &stats);
+       if (!err) {
+               if (!cfg.raw_binary)
+                       show_temp_stats(&stats);
+               else
+                       d_raw((unsigned char *)&stats, sizeof(stats));
+       } else if (err > 0)
+               fprintf(stderr, "NVMe Status:%s(%x)\n",
+                                       nvme_status_to_string(err), err);
+       return err;
+}
index 2bd269b185896a7a098080c756b2ff60a0b6bf72..fa57bba2173d3e11fd7195775600051669187f04 100644 (file)
@@ -10,6 +10,7 @@ COMMAND_LIST(
        ENTRY("id-ctrl", "Send NVMe Identify Controller", id_ctrl)
        ENTRY("smart-log-add", "Retrieve Intel SMART Log, show it", get_additional_smart_log)
        ENTRY("market-name", "Retrieve Intel Marketing Name log, show it", get_market_log)
+       ENTRY("temp-stats", "Retrieve Intel Temperature Statistics log, show it", get_temp_stats_log)
 );
 
 #endif