Index: sbin/nvmecontrol/logpage.c =================================================================== --- sbin/nvmecontrol/logpage.c +++ sbin/nvmecontrol/logpage.c @@ -164,6 +164,17 @@ return bad; } +static const char * +vid_lookup(const struct kv_name *kv, size_t kv_count, uint32_t key) +{ + size_t i; + + for (i = 0; i < kv_count; i++, kv++) + if (kv->key == key) + return kv->name; + return NULL; +} + static void print_log_hex(const struct nvme_controller_data *cdata __unused, void *data, uint32_t length) { @@ -764,6 +775,14 @@ exit(EX_USAGE); } +static struct kv_name vids[] = +{ + { 0x1344, "micron" }, + { 0x144d, "samsung" }, + { 0x1b96, "wdc" }, + { 0x8086, "intel" }, +}; + static void logpage(const struct cmd *f, int argc, char *argv[]) { @@ -825,6 +844,9 @@ if (opt.binary) print_fn = print_bin; if (!opt.binary && !opt.hex) { + /* lookup vendor name based on controller's vid */ + if (opt.vendor == NULL) + opt.vendor = vid_lookup(vids, nitems(vids), cdata.vid); /* * See if there is a pretty print function for the specified log * page. If one isn't found, we just revert to the default