Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/libnvme.map
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
LIBNVME_UNRELEASED {
global:
nvme_mi_admin_get_features_arbitration;
nvme_mi_admin_get_features_power_mgmt;
nvme_mi_admin_set_features_power_mgmt;
};

LIBNVME_1_14 {
Expand Down
58 changes: 58 additions & 0 deletions src/nvme/mi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,37 @@ int nvme_mi_admin_get_features(nvme_mi_ctrl_t ctrl,
return 0;
}

static int __nvme_mi_admin_get_features(nvme_mi_ctrl_t ctrl, enum nvme_features_id fid,
enum nvme_get_features_sel sel, __u32 *result)
{
struct nvme_get_features_args args = {
.args_size = sizeof(args),
.fid = fid,
.nsid = NVME_NSID_NONE,
.sel = sel,
.cdw11 = 0,
.uuidx = NVME_UUID_NONE,
.data_len = 0,
.data = NULL,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.result = result,
};

return nvme_mi_admin_get_features(ctrl, &args);
}

int nvme_mi_admin_get_features_arbitration(nvme_mi_ctrl_t ctrl, enum nvme_get_features_sel sel,
__u32 *result)
{
return __nvme_mi_admin_get_features(ctrl, NVME_FEAT_FID_ARBITRATION, sel, result);
}

int nvme_mi_admin_get_features_power_mgmt(nvme_mi_ctrl_t ctrl, enum nvme_get_features_sel sel,
__u32 *result)
{
return __nvme_mi_admin_get_features(ctrl, NVME_FEAT_FID_POWER_MGMT, sel, result);
}

int nvme_mi_admin_set_features(nvme_mi_ctrl_t ctrl,
struct nvme_set_features_args *args)
{
Expand Down Expand Up @@ -1442,6 +1473,33 @@ int nvme_mi_admin_set_features(nvme_mi_ctrl_t ctrl,
return 0;
}

static int __nvme_mi_admin_set_features(nvme_mi_ctrl_t ctrl, __u8 fid, __u32 cdw11, bool save,
__u32 *result)
{
struct nvme_set_features_args args = {
.args_size = sizeof(args),
.nsid = NVME_NSID_NONE,
.cdw11 = cdw11,
.cdw12 = 0,
.save = save,
.uuidx = NVME_UUID_NONE,
.cdw15 = 0,
.data_len = 0,
.data = NULL,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.result = result,
};
return nvme_mi_admin_set_features(ctrl, &args);
}

int nvme_mi_admin_set_features_power_mgmt(nvme_mi_ctrl_t ctrl, __u8 ps, __u8 wh, bool save,
__u32 *result)
{
__u32 value = NVME_SET(ps, FEAT_PWRMGMT_PS) | NVME_SET(wh, FEAT_PWRMGMT_WH);

return __nvme_mi_admin_set_features(ctrl, NVME_FEAT_FID_POWER_MGMT, value, save, result);
}

int nvme_mi_admin_ns_mgmt(nvme_mi_ctrl_t ctrl,
struct nvme_ns_mgmt_args *args)
{
Expand Down
38 changes: 38 additions & 0 deletions src/nvme/mi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3137,6 +3137,30 @@ int nvme_mi_admin_security_recv(nvme_mi_ctrl_t ctrl,
int nvme_mi_admin_get_features(nvme_mi_ctrl_t ctrl,
struct nvme_get_features_args *args);

/**
* nvme_mi_admin_get_features_arbitration() - Get arbitration feature
* @ctrl: Controller to send command to
* @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
* @result: The feature data is returned in this argument
*
* Return: The nvme command status if a response was received (see
* &enum nvme_status_field) or -1 with errno set otherwise.
*/
int nvme_mi_admin_get_features_arbitration(nvme_mi_ctrl_t ctrl, enum nvme_get_features_sel sel,
__u32 *result);

/**
* nvme_mi_admin_get_features_power_mgmt() - Get power management feature
* @ctrl: Controller to send command to
* @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
* @result: The feature data is returned in this argument
*
* Return: The nvme command status if a response was received (see
* &enum nvme_status_field) or -1 with errno set otherwise.
*/
int nvme_mi_admin_get_features_power_mgmt(nvme_mi_ctrl_t ctrl, enum nvme_get_features_sel sel,
__u32 *result);

/**
* nvme_mi_admin_get_features_data() - Helper function for &nvme_mi_admin_get_features()
* @ctrl: Controller to send command to
Expand Down Expand Up @@ -3208,6 +3232,20 @@ static inline int nvme_mi_admin_get_features_simple(nvme_mi_ctrl_t ctrl,
int nvme_mi_admin_set_features(nvme_mi_ctrl_t ctrl,
struct nvme_set_features_args *args);

/**
* nvme_mi_admin_set_features_power_mgmt() - Set power management feature
* @ctrl: Controller to send command to
* @ps: Power State
* @wh: Workload Hint
* @save: Save value across power states
* @result: The feature data is returned in this argument
*
* Return: The nvme command status if a response was received (see
* &enum nvme_status_field) or -1 with errno set otherwise.
*/
int nvme_mi_admin_set_features_power_mgmt(nvme_mi_ctrl_t ctrl, __u8 ps, __u8 wh, bool save,
__u32 *result);

/**
* nvme_mi_admin_ns_mgmt - Issue a Namespace Management command
* @ctrl: Controller to send command to
Expand Down