Skip to content

Commit a57edc3

Browse files
Praveen Kumar B/Praveen Kumar Bigaw
authored andcommitted
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 <karthik.b82@samsung.com> Reviewed-by: Arunpandian J <arun.j@samsung.com> Signed-off-by: Praveen Kumar B/Praveen Kumar B <praveen.kb@samsungds.net> [wagi: replaced OPT_ARGS with NVME_ARGS] Signed-off-by: Daniel Wagner <wagi@kernel.org>
1 parent f5ce3bc commit a57edc3

File tree

3 files changed

+133
-0
lines changed

3 files changed

+133
-0
lines changed
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: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3039,3 +3039,74 @@ static int ocp_get_persistent_event_log(int argc, char **argv,
30393039

30403040
return err;
30413041
}
3042+
3043+
///////////////////////////////////////////////////////////////////////////////
3044+
///////////////////////////////////////////////////////////////////////////////
3045+
///////////////////////////////////////////////////////////////////////////////
3046+
///////////////////////////////////////////////////////////////////////////////
3047+
/// Idle Wake Up Time Configuration (Feature Identifier CAh) Get Feature
3048+
static int ocp_get_idle_wakeup_time_config_feature(int argc, char **argv,
3049+
struct command *acmd,
3050+
struct plugin *plugin)
3051+
{
3052+
const char *desc = "Define Issue Get Feature cmd (FID: 0xCA) IWUT";
3053+
const char *sel = "[0-3]: current/default/saved/supported/";
3054+
const char *nsid = "Byte[04-07]: NSID Valid/Invalid/Inactive";
3055+
3056+
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
3057+
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
3058+
3059+
3060+
__u64 result;
3061+
int err;
3062+
bool uuid;
3063+
__u8 uuid_index = 0;
3064+
3065+
struct config {
3066+
__u8 sel;
3067+
__u32 nsid;
3068+
};
3069+
3070+
struct config cfg = {
3071+
.sel = 0,
3072+
.nsid = 0,
3073+
};
3074+
3075+
NVME_ARGS(opts,
3076+
OPT_BYTE("sel", 's', &cfg.sel, sel),
3077+
OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid),
3078+
OPT_FLAG("no-uuid", 'u', NULL, no_uuid));
3079+
3080+
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
3081+
if (err)
3082+
return err;
3083+
3084+
uuid = !argconfig_parse_seen(opts, "no-uuid");
3085+
3086+
if (uuid) {
3087+
/* OCP 2.0 requires UUID index support */
3088+
err = ocp_get_uuid_index(hdl, &uuid_index);
3089+
if (err || !uuid_index) {
3090+
nvme_show_error("ERROR: No OCP UUID index found");
3091+
return err;
3092+
}
3093+
}
3094+
3095+
err = nvme_get_features(hdl, cfg.nsid, OCP_FID_IWTC, cfg.sel, 0,
3096+
uuid_index, NULL, 0, &result);
3097+
if (!err) {
3098+
if (result == 0) {
3099+
printf("get-feature:CAh,SEL=%s,IWUT Disabled: %#016"PRIx64"\n",
3100+
nvme_select_to_string(cfg.sel), (uint64_t)result);
3101+
} else {
3102+
printf("get-feature:CAh SEL=%s,IWUT is: %#016"PRIx64"\n",
3103+
nvme_select_to_string(cfg.sel), (uint64_t)result);
3104+
}
3105+
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
3106+
nvme_show_select_result(0xCA, result);
3107+
} else {
3108+
nvme_show_error("Could not get feature: 0xCA");
3109+
}
3110+
3111+
return err;
3112+
}

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)