From ead5894e983b1a34c4a5e89cfe84985027ca0f20 Mon Sep 17 00:00:00 2001 From: Praveen Kumar B/Praveen Kumar B Date: Thu, 12 Feb 2026 19:24:13 +0530 Subject: [PATCH] pulgin/ocp: Added the OCP2.7 supported Get feature FID=CAh command api Implemented the OCP 2.7 spec supported Get Feature FID=CAh command api to fetch idle wake up time configuration. Reviewed-by: Karthik Balan Reviewed-by: Arunpandian J Signed-off-by: Praveen Kumar B/Praveen Kumar B [wagi: replaced OPT_ARGS with NVME_ARGS] Signed-off-by: Daniel Wagner --- .../nvme-ocp-get-idle-wakeup-time.txt | 59 +++++++++++++++ plugins/ocp/ocp-nvme.c | 71 +++++++++++++++++++ plugins/ocp/ocp-nvme.h | 3 + 3 files changed, 133 insertions(+) create mode 100644 Documentation/nvme-ocp-get-idle-wakeup-time.txt diff --git a/Documentation/nvme-ocp-get-idle-wakeup-time.txt b/Documentation/nvme-ocp-get-idle-wakeup-time.txt new file mode 100644 index 0000000000..7749ab8a5b --- /dev/null +++ b/Documentation/nvme-ocp-get-idle-wakeup-time.txt @@ -0,0 +1,59 @@ +nvme-ocp-get-idle-wakeup-time(1) +========================================= + +NAME +---- +nvme-ocp-get-idle-wakeup-time - Define and print idle-wakeup-time value + +SYNOPSIS +-------- +[verse] +'nvme ocp get-idle-wakeup-time' [--sel=] [--namespace-id= | -n ] + +DESCRIPTION +----------- +Define get-idle-wakeup-time. +No argument prints current mode. + +The parameter is mandatory and may be either the NVMe character +device (ex: /dev/nvme0) or block device (ex: /dev/nvme0n1). + +This will only work on OCP compliant devices supporting this feature. +Results for any other device are undefined. + +On success it returns 0, error code otherwise. + +OPTIONS +------- + +-s :: + Select (SEL): This field specifies which value of the attributes + to return in the provided data: + +-n :: +--namespace-id=:: + namespace-id (namespace-id): This field specifies which value of the attributes + to return in the provided data: ++ +[] +|================== +|Select|Description +|0|Current +|1|Default +|2|Saved +|3|Supported capabilities +|4-7|Reserved +|================== + +EXAMPLES +-------- +* Has the program issue a get-idle-wakeup-time to retrieve the 0xCA get features. ++ +------------ +# nvme ocp get-idle-wakeup-time /dev/nvme0 +------------ + +NVME +---- +Part of the nvme-user suite. diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c index d4db801215..cca55ddff4 100644 --- a/plugins/ocp/ocp-nvme.c +++ b/plugins/ocp/ocp-nvme.c @@ -3039,3 +3039,74 @@ static int ocp_get_persistent_event_log(int argc, char **argv, return err; } + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +/// Idle Wake Up Time Configuration (Feature Identifier CAh) Get Feature +static int ocp_get_idle_wakeup_time_config_feature(int argc, char **argv, + struct command *acmd, + struct plugin *plugin) +{ + const char *desc = "Define Issue Get Feature cmd (FID: 0xCA) IWUT"; + const char *sel = "[0-3]: current/default/saved/supported/"; + const char *nsid = "Byte[04-07]: NSID Valid/Invalid/Inactive"; + + _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; + _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; + + + __u64 result; + int err; + bool uuid; + __u8 uuid_index = 0; + + struct config { + __u8 sel; + __u32 nsid; + }; + + struct config cfg = { + .sel = 0, + .nsid = 0, + }; + + NVME_ARGS(opts, + OPT_BYTE("sel", 's', &cfg.sel, sel), + OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid), + OPT_FLAG("no-uuid", 'u', NULL, no_uuid)); + + err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts); + if (err) + return err; + + uuid = !argconfig_parse_seen(opts, "no-uuid"); + + if (uuid) { + /* OCP 2.0 requires UUID index support */ + err = ocp_get_uuid_index(hdl, &uuid_index); + if (err || !uuid_index) { + nvme_show_error("ERROR: No OCP UUID index found"); + return err; + } + } + + err = nvme_get_features(hdl, cfg.nsid, OCP_FID_IWTC, cfg.sel, 0, + uuid_index, NULL, 0, &result); + if (!err) { + if (result == 0) { + printf("get-feature:CAh,SEL=%s,IWUT Disabled: %#016"PRIx64"\n", + nvme_select_to_string(cfg.sel), (uint64_t)result); + } else { + printf("get-feature:CAh SEL=%s,IWUT is: %#016"PRIx64"\n", + nvme_select_to_string(cfg.sel), (uint64_t)result); + } + if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED) + nvme_show_select_result(0xCA, result); + } else { + nvme_show_error("Could not get feature: 0xCA"); + } + + return err; +} diff --git a/plugins/ocp/ocp-nvme.h b/plugins/ocp/ocp-nvme.h index 1f38353965..d43cfb5bbe 100644 --- a/plugins/ocp/ocp-nvme.h +++ b/plugins/ocp/ocp-nvme.h @@ -50,6 +50,8 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", OCP_PLUGIN_VERSION), ocp_get_telemetry_profile_feature) ENTRY("persistent-event-log", "Retrieve Persistent Event Log with OCP events", ocp_get_persistent_event_log) + ENTRY("get-idle-wakeup-time", "Get Idle Wake Up Time Config", + ocp_get_idle_wakeup_time_config_feature) ) ); @@ -281,6 +283,7 @@ enum ocp_dssd_feature_id { OCP_FID_DSSDPS, /* DSSD Power State */ OCP_FID_TEL_CFG, /* Telemetry Profile */ OCP_FID_DAEC, /* DSSD Asynchronous Event Configuration */ + OCP_FID_IWTC, /* Idle Wake Up Time Configuration */ }; /*