Skip to content

Commit 2e24266

Browse files
committed
types: add temperature threshold feature TMPTHH field
The field supported by NVMe revision 2.1. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 97f4883 commit 2e24266

5 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/nvme/ioctl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,12 +711,13 @@ int nvme_set_features_lba_range(int fd, __u32 nsid, __u8 nr_ranges, bool save,
711711
}
712712

713713
int nvme_set_features_temp_thresh(int fd, __u16 tmpth, __u8 tmpsel,
714-
enum nvme_feat_tmpthresh_thsel thsel,
714+
enum nvme_feat_tmpthresh_thsel thsel, __u8 tmpthh,
715715
bool save, __u32 *result)
716716
{
717717
__u32 value = NVME_SET(tmpth, FEAT_TT_TMPTH) |
718718
NVME_SET(tmpsel, FEAT_TT_TMPSEL) |
719-
NVME_SET(thsel, FEAT_TT_THSEL);
719+
NVME_SET(thsel, FEAT_TT_THSEL) |
720+
NVME_SET(tmpthh, FEAT_TT_TMPTHH);
720721

721722
return __nvme_set_features(fd, NVME_FEAT_FID_TEMP_THRESH, value, save,
722723
result);

src/nvme/ioctl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2711,14 +2711,15 @@ int nvme_set_features_lba_range(int fd, __u32 nsid, __u8 nr_ranges, bool save,
27112711
* @tmpth: Temperature Threshold
27122712
* @tmpsel: Threshold Temperature Select
27132713
* @thsel: Threshold Type Select
2714+
* @tmpthh: Temperature Threshold Hysteresis
27142715
* @save: Save value across power states
27152716
* @result: The command completion result from CQE dword0
27162717
*
27172718
* Return: The nvme command status if a response was received (see
27182719
* &enum nvme_status_field) or -1 with errno set otherwise.
27192720
*/
27202721
int nvme_set_features_temp_thresh(int fd, __u16 tmpth, __u8 tmpsel,
2721-
enum nvme_feat_tmpthresh_thsel thsel,
2722+
enum nvme_feat_tmpthresh_thsel thsel, __u8 tmpthh,
27222723
bool save, __u32 *result);
27232724

27242725
/**

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:
@@ -8936,6 +8938,8 @@ enum nvme_feat {
89368938
NVME_FEAT_TT_TMPSEL_MASK = 0xf,
89378939
NVME_FEAT_TT_THSEL_SHIFT = 20,
89388940
NVME_FEAT_TT_THSEL_MASK = 0x3,
8941+
NVME_FEAT_TT_TMPTHH_SHIFT = 22,
8942+
NVME_FEAT_TT_TMPTHH_MASK = 0x7,
89398943
NVME_FEAT_ERROR_RECOVERY_TLER_SHIFT = 0,
89408944
NVME_FEAT_ERROR_RECOVERY_TLER_MASK = 0xffff,
89418945
NVME_FEAT_ERROR_RECOVERY_DULBE_SHIFT = 16,

src/nvme/util.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,15 @@ 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, __u8 *tmpthh)
269270
{
270271
*tmpth = NVME_FEAT_TT_TMPTH(value);
271272
*tmpsel = NVME_FEAT_TT_TMPSEL(value);
272273
*thsel = NVME_FEAT_TT_THSEL(value);
274+
*tmpthh = NVME_FEAT_TT_TMPTHH(value);
273275
}
274276

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

test/ioctl/features.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,19 +335,20 @@ static void test_set_temp_thresh(void)
335335
uint8_t TMPSEL = 0x8;
336336
enum nvme_feat_tmpthresh_thsel THSEL =
337337
NVME_FEATURE_TEMPTHRESH_THSEL_UNDER;
338+
uint8_t TMPTHH = 0x4;
338339
struct mock_cmd mock_admin_cmd = {
339340
.opcode = nvme_admin_set_features,
340341
.cdw10 = (uint32_t)1 << 31 /* SAVE */
341342
| NVME_FEAT_FID_TEMP_THRESH,
342-
.cdw11 = THSEL << 20 | TMPSEL << 16 | TMPTH,
343+
.cdw11 = TMPTHH << 22 | THSEL << 20 | TMPSEL << 16 | TMPTH,
343344
.result = TEST_RESULT,
344345
};
345346
uint32_t result = 0;
346347
int err;
347348

348349
set_mock_admin_cmds(&mock_admin_cmd, 1);
349350
err = nvme_set_features_temp_thresh(
350-
TEST_FD, TMPTH, TMPSEL, THSEL, true, &result);
351+
TEST_FD, TMPTH, TMPSEL, THSEL, TMPTHH, true, &result);
351352
end_mock_cmds();
352353
check(err == 0, "set features returned error %d, errno %m", err);
353354
check(result == TEST_RESULT,

0 commit comments

Comments
 (0)