Skip to content

Commit ba77d94

Browse files
2 parents d3eb3e3 + 1e858be commit ba77d94

3 files changed

Lines changed: 68 additions & 20 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ steps:
113113
otherwise you will see information about each NVMe device installed
114114
in the system.
115115

116+
### OpenEmbedded/Yocto
117+
118+
An [nvme-cli recipe](https://layers.openembedded.org/layerindex/recipe/88631/)
119+
is available as part of the `meta-openembeded` layer collection.
120+
116121
### Other Distros
117122

118123
TBD

nvme-topology.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ static int verify_legacy_ns(struct nvme_namespace *n)
263263
return ret;
264264

265265
if (memcmp(id.mn, c->id.mn, sizeof(id.mn)) ||
266-
memcmp(id.sn, c->id.mn, sizeof(id.sn)))
266+
memcmp(id.sn, c->id.sn, sizeof(id.sn)))
267267
return -ENODEV;
268268
return 0;
269269
}
@@ -307,6 +307,18 @@ static int legacy_list(struct nvme_topology *t)
307307
alphasort);
308308
c->namespaces = calloc(c->nr_namespaces, sizeof(*n));
309309

310+
ret = asprintf(&path, "%s%s", dev, c->name);
311+
if (ret < 0)
312+
continue;
313+
ret = 0;
314+
315+
fd = open(path, O_RDONLY);
316+
if (fd > 0) {
317+
nvme_identify_ctrl(fd, &c->id);
318+
close(fd);
319+
}
320+
free(path);
321+
310322
for (j = 0; j < c->nr_namespaces; j++) {
311323
n = &c->namespaces[j];
312324
n->name = strdup(namespaces[j]->d_name);
@@ -319,18 +331,6 @@ static int legacy_list(struct nvme_topology *t)
319331
while (j--)
320332
free(namespaces[j]);
321333
free(namespaces);
322-
323-
ret = asprintf(&path, "%s%s", dev, c->name);
324-
if (ret < 0)
325-
continue;
326-
ret = 0;
327-
328-
fd = open(path, O_RDONLY);
329-
if (fd > 0) {
330-
nvme_identify_ctrl(fd, &c->id);
331-
close(fd);
332-
}
333-
free(path);
334334
}
335335

336336
free:

plugins/intel/intel-nvme.c

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,68 @@ struct nvme_additional_smart_log {
5858
struct nvme_additional_smart_log_item host_bytes_written;
5959
};
6060

61+
struct nvme_vu_id_ctrl_field { //CDR MR5
62+
__u8 rsvd1[3];
63+
__u8 ss;
64+
__u8 health[20];
65+
__u8 cls;
66+
__u8 nlw;
67+
__u8 scap;
68+
__u8 sstat;
69+
__u8 bl[8];
70+
__u8 rsvd2[38];
71+
__u8 ww[8]; //little endian
72+
__u8 mic_bl[4];
73+
__u8 mic_fw[4];
74+
};
75+
6176
static void intel_id_ctrl(__u8 *vs, struct json_object *root)
6277
{
78+
struct nvme_vu_id_ctrl_field* log = (struct nvme_vu_id_ctrl_field *)vs;
79+
80+
char health[21];
6381
char bl[9];
64-
char health[21];
82+
char ww[19];
83+
char mic_bl[5];
84+
char mic_fw[5];
6585

66-
memcpy(bl, &vs[28], sizeof(bl));
67-
memcpy(health, &vs[4], sizeof(health));
86+
memcpy(bl, log->bl, sizeof(bl));
87+
memcpy(health, log->health, sizeof(health));
88+
memcpy(mic_bl, log->mic_bl, sizeof(mic_bl));
89+
memcpy(mic_fw, log->mic_fw, sizeof(mic_fw));
6890

6991
bl[sizeof(bl) - 1] = '\0';
7092
health[sizeof(health) - 1] = '\0';
93+
mic_bl[sizeof(mic_bl) - 1] = '\0';
94+
mic_fw[sizeof(mic_fw) - 1] = '\0';
95+
96+
snprintf(ww, 19, "%02X%02X%02X%02X%02X%02X%02X%02X", log->ww[7],
97+
log->ww[6], log->ww[5], log->ww[4], log->ww[3], log->ww[2],
98+
log->ww[1], log->ww[0]);
99+
71100

72101
if (root) {
73-
json_object_add_value_int(root, "ss", vs[3]);
102+
json_object_add_value_int(root, "ss", log->ss);
74103
json_object_add_value_string(root, "health", health[0] ? health : "healthy");
104+
json_object_add_value_int(root, "cls", log->cls);
105+
json_object_add_value_int(root, "nlw", log->nlw);
106+
json_object_add_value_int(root, "scap", log->scap);
107+
json_object_add_value_int(root, "sstat", log->sstat);
75108
json_object_add_value_string(root, "bl", bl);
109+
json_object_add_value_string(root, "ww", ww);
110+
json_object_add_value_string(root, "mic_bl", mic_bl);
111+
json_object_add_value_string(root, "mic_fw", mic_fw);
76112
} else {
77-
printf("ss : %d\n", vs[3]);
78-
printf("health : %s\n", health[0] ? health : "healthy");
79-
printf("bl : %s\n", bl);
113+
printf("ss : %d\n", log->ss);
114+
printf("health : %s\n", log->health[0] ? health : "healthy");
115+
printf("cls : %d\n", log->cls);
116+
printf("nlw : %d\n", log->nlw);
117+
printf("scap : %d\n", log->scap);
118+
printf("sstat : %d\n", log->sstat);
119+
printf("bl : %s\n", bl);
120+
printf("ww : %s\n", ww);
121+
printf("mic_bl : %s\n", mic_bl);
122+
printf("mic_fw : %s\n", mic_fw);
80123
}
81124
}
82125

0 commit comments

Comments
 (0)