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
2 changes: 2 additions & 0 deletions src/libnvme.map
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
LIBNVME_UNRELEASED {
global:
nvme_get_features_temp_thresh2;
nvme_set_features_temp_thresh2;
nvme_subsystem_get_serial;
};

Expand Down
33 changes: 33 additions & 0 deletions src/nvme/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,19 @@ int nvme_set_features_temp_thresh(int fd, __u16 tmpth, __u8 tmpsel,
result);
}

int nvme_set_features_temp_thresh2(int fd, __u16 tmpth, __u8 tmpsel,
enum nvme_feat_tmpthresh_thsel thsel, __u8 tmpthh,
bool save, __u32 *result)
{
__u32 value = NVME_SET(tmpth, FEAT_TT_TMPTH) |
NVME_SET(tmpsel, FEAT_TT_TMPSEL) |
NVME_SET(thsel, FEAT_TT_THSEL) |
NVME_SET(tmpthh, FEAT_TT_TMPTHH);

return __nvme_set_features(fd, NVME_FEAT_FID_TEMP_THRESH, value, save,
result);
}

int nvme_set_features_err_recovery(int fd, __u32 nsid, __u16 tler, bool dulbe,
bool save, __u32 *result)
{
Expand Down Expand Up @@ -1078,6 +1091,26 @@ int nvme_get_features_temp_thresh(int fd, enum nvme_get_features_sel sel,
return __nvme_get_features(fd, NVME_FEAT_FID_TEMP_THRESH, sel, result);
}

int nvme_get_features_temp_thresh2(int fd, enum nvme_get_features_sel sel, __u8 tmpsel,
enum nvme_feat_tmpthresh_thsel thsel, __u32 *result)
{
struct nvme_get_features_args args = {
.args_size = sizeof(args),
.fd = fd,
.fid = NVME_FEAT_FID_TEMP_THRESH,
.nsid = NVME_NSID_NONE,
.sel = sel,
.cdw11 = NVME_SET(tmpsel, FEAT_TT_TMPSEL) | NVME_SET(thsel, FEAT_TT_THSEL),
.uuidx = NVME_UUID_NONE,
.data_len = 0,
.data = NULL,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.result = result,
};

return nvme_get_features(&args);
}

int nvme_get_features_err_recovery(int fd, enum nvme_get_features_sel sel,
__u32 *result)
{
Expand Down
31 changes: 31 additions & 0 deletions src/nvme/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2721,6 +2721,23 @@ int nvme_set_features_temp_thresh(int fd, __u16 tmpth, __u8 tmpsel,
enum nvme_feat_tmpthresh_thsel thsel,
bool save, __u32 *result);

/**
* nvme_set_features_temp_thresh2() - Set temperature threshold feature
* @fd: File descriptor of nvme device
* @tmpth: Temperature Threshold
* @tmpsel: Threshold Temperature Select
* @thsel: Threshold Type Select
* @tmpthh: Temperature Threshold Hysteresis
* @save: Save value across power states
* @result: The command completion result from CQE dword0
*
* Return: The nvme command status if a response was received (see
* &enum nvme_status_field) or -1 with errno set otherwise.
*/
int nvme_set_features_temp_thresh2(int fd, __u16 tmpth, __u8 tmpsel,
enum nvme_feat_tmpthresh_thsel thsel, __u8 tmpthh,
bool save, __u32 *result);

/**
* nvme_set_features_err_recovery() - Set error recovery feature
* @fd: File descriptor of nvme device
Expand Down Expand Up @@ -3208,6 +3225,20 @@ int nvme_get_features_lba_range2(int fd, enum nvme_get_features_sel sel,
int nvme_get_features_temp_thresh(int fd, enum nvme_get_features_sel sel,
__u32 *result);

/**
* nvme_get_features_temp_thresh2() - Get temperature threshold feature
* @fd: File descriptor of nvme device
* @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
* @tmpsel: Threshold Temperature Select
* @thsel: Threshold Type Select
* @result: The command completion result from CQE dword0
*
* Return: The nvme command status if a response was received (see
* &enum nvme_status_field) or -1 with errno set otherwise.
*/
int nvme_get_features_temp_thresh2(int fd, enum nvme_get_features_sel sel, __u8 tmpsel,
enum nvme_feat_tmpthresh_thsel thsel, __u32 *result);

/**
* nvme_get_features_err_recovery() - Get error recovery feature
*
Expand Down
4 changes: 4 additions & 0 deletions src/nvme/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8796,6 +8796,8 @@ enum nvme_features_id {
* @NVME_FEAT_TT_TMPSEL_MASK:
* @NVME_FEAT_TT_THSEL_SHIFT:
* @NVME_FEAT_TT_THSEL_MASK:
* @NVME_FEAT_TT_TMPTHH_SHIFT:
* @NVME_FEAT_TT_TMPTHH_MASK:
* @NVME_FEAT_ERROR_RECOVERY_TLER_SHIFT:
* @NVME_FEAT_ERROR_RECOVERY_TLER_MASK:
* @NVME_FEAT_ERROR_RECOVERY_DULBE_SHIFT:
Expand Down Expand Up @@ -8940,6 +8942,8 @@ enum nvme_feat {
NVME_FEAT_TT_TMPSEL_MASK = 0xf,
NVME_FEAT_TT_THSEL_SHIFT = 20,
NVME_FEAT_TT_THSEL_MASK = 0x3,
NVME_FEAT_TT_TMPTHH_SHIFT = 22,
NVME_FEAT_TT_TMPTHH_MASK = 0x7,
NVME_FEAT_ERROR_RECOVERY_TLER_SHIFT = 0,
NVME_FEAT_ERROR_RECOVERY_TLER_MASK = 0xffff,
NVME_FEAT_ERROR_RECOVERY_DULBE_SHIFT = 16,
Expand Down
5 changes: 4 additions & 1 deletion src/nvme/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,16 @@ static inline void nvme_feature_decode_lba_range(__u32 value, __u8 *num)
#define NVME_FEAT_TT_TMPTH(v) NVME_GET(v, FEAT_TT_TMPTH)
#define NVME_FEAT_TT_TMPSEL(v) NVME_GET(v, FEAT_TT_TMPSEL)
#define NVME_FEAT_TT_THSEL(v) NVME_GET(v, FEAT_TT_THSEL)
#define NVME_FEAT_TT_TMPTHH(v) NVME_GET(v, FEAT_TT_TMPTHH)

static inline void nvme_feature_decode_temp_threshold(__u32 value, __u16 *tmpth,
__u8 *tmpsel, __u8 *thsel)
__u8 *tmpsel, __u8 *thsel,
__u8 *tmpthh)
{
*tmpth = NVME_FEAT_TT_TMPTH(value);
*tmpsel = NVME_FEAT_TT_TMPSEL(value);
*thsel = NVME_FEAT_TT_THSEL(value);
*tmpthh = NVME_FEAT_TT_TMPTHH(value);
}

#define NVME_FEAT_ER_TLER(v) NVME_GET(v, FEAT_ERROR_RECOVERY_TLER)
Expand Down