]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Add Intel IO statistics log page
authorKeith Busch <keith.busch@intel.com>
Wed, 8 Jun 2016 23:24:57 +0000 (17:24 -0600)
committerKeith Busch <keith.busch@intel.com>
Wed, 8 Jun 2016 23:32:22 +0000 (17:32 -0600)
Defined as per public P3xxx data sheet.

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

index c944243eb5a6a96562a3fce28a5b71a5fc5c3b24..4fc9d0749f9236d23e994ba6a3b985a0c262a4a9 100644 (file)
@@ -175,3 +175,69 @@ static int get_temp_stats_log(int argc, char **argv, struct command *cmd, struct
                                        nvme_status_to_string(err), err);
        return err;
 }
+
+struct intel_lat_stats {
+       __u16   maj;
+       __u16   min;
+       __u32   bucket_1[32];
+       __u32   bucket_2[31];
+       __u32   bucket_3[31];
+};
+
+static void show_lat_stats(struct intel_lat_stats *stats, int write)
+{
+       int i;
+
+       printf(" Intel IO %s Command Latency Statistics\n", write ? "Write" : "Read");
+       printf("-------------------------------------\n");
+       printf("Major Revision : %u\n", stats->maj);
+       printf("Minor Revision : %u\n", stats->min);
+
+       printf("\nGroup 1: Range is 0-1ms, step is 32us\n");
+       for (i = 0; i < 32; i++)
+               printf("Bucket %2d: %u\n", i, stats->bucket_1[i]);
+
+       printf("\nGroup 2: Range is 1-32ms, step is 1ms\n");
+       for (i = 0; i < 31; i++)
+               printf("Bucket %2d: %u\n", i, stats->bucket_1[i]);
+
+       printf("\nGroup 3: Range is 32-1s, step is 32ms:\n");
+       for (i = 0; i < 31; i++)
+               printf("Bucket %2d: %u\n", i, stats->bucket_1[i]);
+}
+
+static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
+{
+       struct intel_lat_stats stats;
+       int err, fd;
+
+       char *desc = "Get Intel Latency Statistics log and show it.";
+       const char *raw = "dump output in binary format";
+       const char *write = "Get write statistics (read default)";
+       struct config {
+               int  raw_binary;
+               int  write;
+       };
+
+       struct config cfg = {
+       };
+
+       const struct argconfig_commandline_options command_line_options[] = {
+               {"write",      'w', "", CFG_NONE, &cfg.write,      no_argument, write},
+               {"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, write ? 0xc2 : 0xc1, sizeof(stats), &stats);
+       if (!err) {
+               if (!cfg.raw_binary)
+                       show_lat_stats(&stats, cfg.write);
+               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 fa57bba2173d3e11fd7195775600051669187f04..62b9af810115b00e94fe96baf8fccbccd0b9ac42 100644 (file)
@@ -11,6 +11,7 @@ COMMAND_LIST(
        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)
+       ENTRY("lat-stats", "Retrieve Intel IO Latancy Statistics log, show it", get_lat_stats_log)
 );
 
 #endif