From b79199af397fea568ccf29c3058436a7335c407b Mon Sep 17 00:00:00 2001 From: Ankit Kumar Date: Thu, 2 Jun 2022 20:52:28 +0530 Subject: [PATCH] include/nvme_spec.h: update fields for power state descriptor Adding missing fields for power state descriptor. Update identify examples file accordingly. Signed-off-by: Ankit Kumar Change-Id: I23a23179fd0dbb92120d1c3f176da61a4d981990 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12864 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- examples/nvme/identify/identify.c | 55 +++++++++++++++++++++++++++---- include/spdk/nvme_spec.h | 15 ++++++++- 2 files changed, 63 insertions(+), 7 deletions(-) diff --git a/examples/nvme/identify/identify.c b/examples/nvme/identify/identify.c index 92e0c9e3c..ec9dce7d5 100644 --- a/examples/nvme/identify/identify.c +++ b/examples/nvme/identify/identify.c @@ -1671,23 +1671,66 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_transport unsigned ps = features[SPDK_NVME_FEAT_POWER_MANAGEMENT].result & 0x1F; printf("Power Management\n"); printf("================\n"); - printf("Number of Power States: %u\n", cdata->npss + 1); - printf("Current Power State: Power State #%u\n", ps); + printf("Number of Power States: %u\n", cdata->npss + 1); + printf("Current Power State: Power State #%u\n", ps); for (i = 0; i <= cdata->npss; i++) { const struct spdk_nvme_power_state psd = cdata->psd[i]; - printf("Power State #%u: ", i); + printf("Power State #%u:\n", i); if (psd.mps) { /* MP scale is 0.0001 W */ - printf("Max Power: %u.%04u W\n", + printf(" Max Power: %u.%04u W\n", psd.mp / 10000, psd.mp % 10000); } else { /* MP scale is 0.01 W */ - printf("Max Power: %3u.%02u W\n", + printf(" Max Power: %3u.%02u W\n", psd.mp / 100, psd.mp % 100); } - /* TODO: print other power state descriptor fields */ + printf(" Non-Operational State: %s\n", + psd.nops ? "Non-Operation" : "Operational"); + printf(" Entry Latency: "); + if (psd.enlat) { + printf("%u microseconds\n", psd.enlat); + } else { + printf("Not Reported\n"); + } + printf(" Exit Latency: "); + if (psd.exlat) { + printf("%u microseconds\n", psd.exlat); + } else { + printf("Not Reported\n"); + } + printf(" Relative Read Throughput: %u\n", psd.rrt); + printf(" Relative Read Latency: %u\n", psd.rrl); + printf(" Relative Write Throughput: %u\n", psd.rwt); + printf(" Relative Write Latency: %u\n", psd.rwl); + printf(" Idle Power: "); + switch (psd.ips) { + case 1: + /* Idle Power scale is 0.0001 W */ + printf("%u.%04u W\n", psd.idlp / 10000, psd.idlp % 10000); + break; + case 2: + /* Idle Power scale is 0.01 W */ + printf("%u.%02u W\n", psd.idlp / 100, psd.idlp % 100); + break; + default: + printf(" Not Reported\n"); + } + printf(" Active Power: "); + switch (psd.aps) { + case 1: + /* Active Power scale is 0.0001 W */ + printf("%u.%04u W\n", psd.actp / 10000, psd.actp % 10000); + break; + case 2: + /* Active Power scale is 0.01 W */ + printf("%u.%02u W\n", psd.actp / 100, psd.actp % 100); + break; + default: + printf(" Not Reported\n"); + } } printf("Non-Operational Permissive Mode: %s\n", cdata->ctratt.non_operational_power_state_permissive_mode ? "Supported" : "Not Supported"); diff --git a/include/spdk/nvme_spec.h b/include/spdk/nvme_spec.h index 85adc79b9..7bccbae8c 100644 --- a/include/spdk/nvme_spec.h +++ b/include/spdk/nvme_spec.h @@ -1724,7 +1724,20 @@ struct spdk_nvme_power_state { uint8_t rwl : 5; /* bits 124:120: relative write latency */ uint8_t reserved6 : 3; - uint8_t reserved7[16]; + uint16_t idlp; /* bits 143:128: idle power */ + + uint8_t reserved7 : 6; + uint8_t ips : 2; /* bits 151:150: idle power scale */ + + uint8_t reserved8; + + uint16_t actp; /* bits 175:160: active power */ + + uint8_t apw : 3; /* bits 178:176: active power workload */ + uint8_t reserved9 : 3; + uint8_t aps : 2; /* bits 183:182: active power scale */ + + uint8_t reserved10[9]; }; SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_power_state) == 32, "Incorrect size");