Skip to content

Commit f6ac264

Browse files
jeff-lien-sndkigaw
authored andcommitted
sndk: Add support for retrieving data area 4
This change will check if data area 4 is supported and set the etdas bit in feature id 0x16 if supported. Signed-off-by: jeff-lien-sndk <[email protected]>
1 parent 51a3c2e commit f6ac264

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

plugins/sandisk/sandisk-nvme.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ static int sndk_do_cap_telemetry_log(struct nvme_dev *dev, const char *file,
4141
struct nvme_id_ctrl ctrl;
4242
__u64 capabilities = 0;
4343
nvme_root_t r;
44+
bool host_behavior_changed = false;
45+
struct nvme_feat_host_behavior prev = {0};
46+
__u32 result;
47+
48+
4449

4550
memset(&ctrl, 0, sizeof(struct nvme_id_ctrl));
4651
err = nvme_identify_ctrl(dev_fd(dev), &ctrl);
@@ -60,6 +65,23 @@ static int sndk_do_cap_telemetry_log(struct nvme_dev *dev, const char *file,
6065
if (type == SNDK_TELEMETRY_TYPE_HOST) {
6166
host_gen = 1;
6267
ctrl_init = 0;
68+
69+
if (data_area == 4) {
70+
if (!(ctrl.lpa & 0x40)) {
71+
fprintf(stderr, "Telemetry data area 4 not supported by device\n");
72+
return -EINVAL;
73+
}
74+
75+
int err = nvme_get_features_host_behavior(dev_fd(dev), 0, &prev, &result);
76+
77+
if (!err && !prev.etdas) {
78+
struct nvme_feat_host_behavior da4_enable = prev;
79+
80+
da4_enable.etdas = 1;
81+
nvme_set_features_host_behavior(dev_fd(dev), 0, &da4_enable);
82+
host_behavior_changed = true;
83+
}
84+
}
6385
} else if (type == SNDK_TELEMETRY_TYPE_CONTROLLER) {
6486
if (capabilities & SNDK_DRIVE_CAP_INTERNAL_LOG) {
6587
err = sndk_check_ctrl_telemetry_option_disabled(dev);
@@ -135,6 +157,9 @@ static int sndk_do_cap_telemetry_log(struct nvme_dev *dev, const char *file,
135157
err = -1;
136158
}
137159

160+
if (host_behavior_changed)
161+
nvme_set_features_host_behavior(dev_fd(dev), 0, &prev);
162+
138163
free(log);
139164
close_output:
140165
close(output);

plugins/sandisk/sandisk-nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#if !defined(SANDISK_NVME) || defined(CMD_HEADER_MULTI_READ)
66
#define SANDISK_NVME
77

8-
#define SANDISK_PLUGIN_VERSION "3.0.1"
8+
#define SANDISK_PLUGIN_VERSION "3.0.2"
99
#include "cmd.h"
1010

1111
PLUGIN(NAME("sndk", "Sandisk vendor specific extensions", SANDISK_PLUGIN_VERSION),

0 commit comments

Comments
 (0)