Skip to content

Commit 3d39019

Browse files
author
Praveen Kumar B/Praveen Kumar B
committed
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 <[email protected]> Reviewed-by: Arunpandian J <[email protected]> Signed-off-by: Praveen Kumar B/Praveen Kumar B <[email protected]>
1 parent ceaa310 commit 3d39019

3 files changed

Lines changed: 135 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
nvme-ocp-get-idle-wakeup-time(1)
2+
=========================================
3+
4+
NAME
5+
----
6+
nvme-ocp-get-idle-wakeup-time - Define and print idle-wakeup-time value
7+
8+
SYNOPSIS
9+
--------
10+
[verse]
11+
'nvme ocp get-idle-wakeup-time' <device> [--sel=<select> | -s <select>] [--namespace-id=<nsid> | -n <namespace-id>]
12+
13+
DESCRIPTION
14+
-----------
15+
Define get-idle-wakeup-time.
16+
No argument prints current mode.
17+
18+
The <device> parameter is mandatory and may be either the NVMe character
19+
device (ex: /dev/nvme0) or block device (ex: /dev/nvme0n1).
20+
21+
This will only work on OCP compliant devices supporting this feature.
22+
Results for any other device are undefined.
23+
24+
On success it returns 0, error code otherwise.
25+
26+
OPTIONS
27+
-------
28+
29+
-s <select>::
30+
--sel=<select>::
31+
Select (SEL): This field specifies which value of the attributes
32+
to return in the provided data:
33+
34+
-n <namespace-id>::
35+
--namespace-id=<namespace-id>::
36+
namespace-id (namespace-id): This field specifies which value of the attributes
37+
to return in the provided data:
38+
+
39+
[]
40+
|==================
41+
|Select|Description
42+
|0|Current
43+
|1|Default
44+
|2|Saved
45+
|3|Supported capabilities
46+
|4-7|Reserved
47+
|==================
48+
49+
EXAMPLES
50+
--------
51+
* Has the program issue a get-idle-wakeup-time to retrieve the 0xCA get features.
52+
+
53+
------------
54+
# nvme ocp get-idle-wakeup-time /dev/nvme0
55+
------------
56+
57+
NVME
58+
----
59+
Part of the nvme-user suite.

plugins/ocp/ocp-nvme.c

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,3 +3097,76 @@ static int ocp_get_persistent_event_log(int argc, char **argv,
30973097

30983098
return err;
30993099
}
3100+
3101+
///////////////////////////////////////////////////////////////////////////////
3102+
///////////////////////////////////////////////////////////////////////////////
3103+
///////////////////////////////////////////////////////////////////////////////
3104+
///////////////////////////////////////////////////////////////////////////////
3105+
/// Idle Wake Up Time Configuration (Feature Identifier CAh) Get Feature
3106+
static int ocp_get_idle_wakeup_time_config_feature(int argc, char **argv,
3107+
struct command *acmd,
3108+
struct plugin *plugin)
3109+
{
3110+
const char *desc = "Define Issue Get Feature cmd (FID: 0xCA) IWUT";
3111+
const char *sel = "[0-3]: current/default/saved/supported/";
3112+
const char *nsid = "Byte[04-07]: NSID Valid/Invalid/Inactive";
3113+
3114+
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
3115+
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
3116+
3117+
3118+
__u64 result;
3119+
int err;
3120+
bool uuid;
3121+
__u8 uuid_index = 0;
3122+
3123+
struct config {
3124+
__u8 sel;
3125+
__u32 nsid;
3126+
};
3127+
3128+
struct config cfg = {
3129+
.sel = 0,
3130+
.nsid = 0,
3131+
};
3132+
3133+
OPT_ARGS(opts) = {
3134+
OPT_BYTE("sel", 's', &cfg.sel, sel),
3135+
OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid),
3136+
OPT_FLAG("no-uuid", 'u', NULL, no_uuid),
3137+
OPT_END()
3138+
};
3139+
3140+
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
3141+
if (err)
3142+
return err;
3143+
3144+
uuid = !argconfig_parse_seen(opts, "no-uuid");
3145+
3146+
if (uuid) {
3147+
/* OCP 2.0 requires UUID index support */
3148+
err = ocp_get_uuid_index(hdl, &uuid_index);
3149+
if (err || !uuid_index) {
3150+
nvme_show_error("ERROR: No OCP UUID index found");
3151+
return err;
3152+
}
3153+
}
3154+
3155+
err = nvme_get_features(hdl, cfg.nsid, OCP_FID_IWTC, cfg.sel, 0,
3156+
uuid_index, NULL, 0, &result);
3157+
if (!err) {
3158+
if (result == 0) {
3159+
printf("get-feature:CAh,SEL=%s,IWUT Disabled: %#016"PRIx64"\n",
3160+
nvme_select_to_string(cfg.sel), (uint64_t)result);
3161+
} else {
3162+
printf("get-feature:CAh SEL=%s,IWUT is: %#016"PRIx64"\n",
3163+
nvme_select_to_string(cfg.sel), (uint64_t)result);
3164+
}
3165+
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
3166+
nvme_show_select_result(0xCA, result);
3167+
} else {
3168+
nvme_show_error("Could not get feature: 0xCA");
3169+
}
3170+
3171+
return err;
3172+
}

plugins/ocp/ocp-nvme.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", OCP_PLUGIN_VERSION),
5050
ocp_get_telemetry_profile_feature)
5151
ENTRY("persistent-event-log", "Retrieve Persistent Event Log with OCP events",
5252
ocp_get_persistent_event_log)
53+
ENTRY("get-idle-wakeup-time", "Get Idle Wake Up Time Config",
54+
ocp_get_idle_wakeup_time_config_feature)
5355
)
5456
);
5557

@@ -281,6 +283,7 @@ enum ocp_dssd_feature_id {
281283
OCP_FID_DSSDPS, /* DSSD Power State */
282284
OCP_FID_TEL_CFG, /* Telemetry Profile */
283285
OCP_FID_DAEC, /* DSSD Asynchronous Event Configuration */
286+
OCP_FID_IWTC, /* Idle Wake Up Time Configuration */
284287
};
285288

286289
/*

0 commit comments

Comments
 (0)