Skip to content

Commit 8914e64

Browse files
ikegami-tigaw
authored andcommitted
types: add temperature threshold feature TMPTHH field
The field supported by NVMe revision 2.1. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 1c5c394 commit 8914e64

5 files changed

Lines changed: 39 additions & 1 deletion

File tree

src/libnvme.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: LGPL-2.1-or-later
22
LIBNVME_UNRELEASED {
33
global:
4+
nvme_set_features_temp_thresh2;
45
nvme_subsystem_get_serial;
56
};
67

src/nvme/ioctl.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,19 @@ int nvme_set_features_temp_thresh(int fd, __u16 tmpth, __u8 tmpsel,
722722
result);
723723
}
724724

725+
int nvme_set_features_temp_thresh2(int fd, __u16 tmpth, __u8 tmpsel,
726+
enum nvme_feat_tmpthresh_thsel thsel, __u8 tmpthh,
727+
bool save, __u32 *result)
728+
{
729+
__u32 value = NVME_SET(tmpth, FEAT_TT_TMPTH) |
730+
NVME_SET(tmpsel, FEAT_TT_TMPSEL) |
731+
NVME_SET(thsel, FEAT_TT_THSEL) |
732+
NVME_SET(tmpthh, FEAT_TT_TMPTHH);
733+
734+
return __nvme_set_features(fd, NVME_FEAT_FID_TEMP_THRESH, value, save,
735+
result);
736+
}
737+
725738
int nvme_set_features_err_recovery(int fd, __u32 nsid, __u16 tler, bool dulbe,
726739
bool save, __u32 *result)
727740
{

src/nvme/ioctl.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,6 +2721,23 @@ int nvme_set_features_temp_thresh(int fd, __u16 tmpth, __u8 tmpsel,
27212721
enum nvme_feat_tmpthresh_thsel thsel,
27222722
bool save, __u32 *result);
27232723

2724+
/**
2725+
* nvme_set_features_temp_thresh2() - Set temperature threshold feature
2726+
* @fd: File descriptor of nvme device
2727+
* @tmpth: Temperature Threshold
2728+
* @tmpsel: Threshold Temperature Select
2729+
* @thsel: Threshold Type Select
2730+
* @tmpthh: Temperature Threshold Hysteresis
2731+
* @save: Save value across power states
2732+
* @result: The command completion result from CQE dword0
2733+
*
2734+
* Return: The nvme command status if a response was received (see
2735+
* &enum nvme_status_field) or -1 with errno set otherwise.
2736+
*/
2737+
int nvme_set_features_temp_thresh2(int fd, __u16 tmpth, __u8 tmpsel,
2738+
enum nvme_feat_tmpthresh_thsel thsel, __u8 tmpthh,
2739+
bool save, __u32 *result);
2740+
27242741
/**
27252742
* nvme_set_features_err_recovery() - Set error recovery feature
27262743
* @fd: File descriptor of nvme device

src/nvme/types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8796,6 +8796,8 @@ enum nvme_features_id {
87968796
* @NVME_FEAT_TT_TMPSEL_MASK:
87978797
* @NVME_FEAT_TT_THSEL_SHIFT:
87988798
* @NVME_FEAT_TT_THSEL_MASK:
8799+
* @NVME_FEAT_TT_TMPTHH_SHIFT:
8800+
* @NVME_FEAT_TT_TMPTHH_MASK:
87998801
* @NVME_FEAT_ERROR_RECOVERY_TLER_SHIFT:
88008802
* @NVME_FEAT_ERROR_RECOVERY_TLER_MASK:
88018803
* @NVME_FEAT_ERROR_RECOVERY_DULBE_SHIFT:
@@ -8940,6 +8942,8 @@ enum nvme_feat {
89408942
NVME_FEAT_TT_TMPSEL_MASK = 0xf,
89418943
NVME_FEAT_TT_THSEL_SHIFT = 20,
89428944
NVME_FEAT_TT_THSEL_MASK = 0x3,
8945+
NVME_FEAT_TT_TMPTHH_SHIFT = 22,
8946+
NVME_FEAT_TT_TMPTHH_MASK = 0x7,
89438947
NVME_FEAT_ERROR_RECOVERY_TLER_SHIFT = 0,
89448948
NVME_FEAT_ERROR_RECOVERY_TLER_MASK = 0xffff,
89458949
NVME_FEAT_ERROR_RECOVERY_DULBE_SHIFT = 16,

src/nvme/util.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,16 @@ static inline void nvme_feature_decode_lba_range(__u32 value, __u8 *num)
263263
#define NVME_FEAT_TT_TMPTH(v) NVME_GET(v, FEAT_TT_TMPTH)
264264
#define NVME_FEAT_TT_TMPSEL(v) NVME_GET(v, FEAT_TT_TMPSEL)
265265
#define NVME_FEAT_TT_THSEL(v) NVME_GET(v, FEAT_TT_THSEL)
266+
#define NVME_FEAT_TT_TMPTHH(v) NVME_GET(v, FEAT_TT_TMPTHH)
266267

267268
static inline void nvme_feature_decode_temp_threshold(__u32 value, __u16 *tmpth,
268-
__u8 *tmpsel, __u8 *thsel)
269+
__u8 *tmpsel, __u8 *thsel,
270+
__u8 *tmpthh)
269271
{
270272
*tmpth = NVME_FEAT_TT_TMPTH(value);
271273
*tmpsel = NVME_FEAT_TT_TMPSEL(value);
272274
*thsel = NVME_FEAT_TT_THSEL(value);
275+
*tmpthh = NVME_FEAT_TT_TMPTHH(value);
273276
}
274277

275278
#define NVME_FEAT_ER_TLER(v) NVME_GET(v, FEAT_ERROR_RECOVERY_TLER)

0 commit comments

Comments
 (0)