Index: sbin/nvmecontrol/logpage.c =================================================================== --- sbin/nvmecontrol/logpage.c +++ sbin/nvmecontrol/logpage.c @@ -695,56 +695,56 @@ * Make sure you keep all the pages of one vendor together so -v help * lists all the vendors pages. */ -NVME_LOGPAGE(error, - NVME_LOG_ERROR, NULL, "Drive Error Log", +NVME_LOGPAGE(error, 0, NULL, + NVME_LOG_ERROR, "Drive Error Log", print_log_error, 0); -NVME_LOGPAGE(health, - NVME_LOG_HEALTH_INFORMATION, NULL, "Health/SMART Data", +NVME_LOGPAGE(health, 0, NULL, + NVME_LOG_HEALTH_INFORMATION, "Health/SMART Data", print_log_health, sizeof(struct nvme_health_information_page)); -NVME_LOGPAGE(fw, - NVME_LOG_FIRMWARE_SLOT, NULL, "Firmware Information", +NVME_LOGPAGE(fw, 0, NULL, + NVME_LOG_FIRMWARE_SLOT, "Firmware Information", print_log_firmware, sizeof(struct nvme_firmware_page)); -NVME_LOGPAGE(ns, - NVME_LOG_CHANGED_NAMESPACE, NULL, "Changed Namespace List", +NVME_LOGPAGE(ns, 0, NULL, + NVME_LOG_CHANGED_NAMESPACE, "Changed Namespace List", print_log_ns, sizeof(struct nvme_ns_list)); -NVME_LOGPAGE(ce, - NVME_LOG_COMMAND_EFFECT, NULL, "Commands Supported and Effects", +NVME_LOGPAGE(ce, 0, NULL, + NVME_LOG_COMMAND_EFFECT, "Commands Supported and Effects", print_log_command_effects, sizeof(struct nvme_command_effects_page)); -NVME_LOGPAGE(dst, - NVME_LOG_DEVICE_SELF_TEST, NULL, "Device Self-test", +NVME_LOGPAGE(dst, 0, NULL, + NVME_LOG_DEVICE_SELF_TEST, "Device Self-test", print_log_self_test_status, sizeof(struct nvme_device_self_test_page)); -NVME_LOGPAGE(thi, - NVME_LOG_TELEMETRY_HOST_INITIATED, NULL, "Telemetry Host-Initiated", +NVME_LOGPAGE(thi, 0, NULL, + NVME_LOG_TELEMETRY_HOST_INITIATED, "Telemetry Host-Initiated", NULL, DEFAULT_SIZE); -NVME_LOGPAGE(tci, - NVME_LOG_TELEMETRY_CONTROLLER_INITIATED, NULL, "Telemetry Controller-Initiated", +NVME_LOGPAGE(tci, 0, NULL, + NVME_LOG_TELEMETRY_CONTROLLER_INITIATED, "Telemetry Controller-Initiated", NULL, DEFAULT_SIZE); -NVME_LOGPAGE(egi, - NVME_LOG_ENDURANCE_GROUP_INFORMATION, NULL, "Endurance Group Information", +NVME_LOGPAGE(egi, 0, NULL, + NVME_LOG_ENDURANCE_GROUP_INFORMATION, "Endurance Group Information", NULL, DEFAULT_SIZE); -NVME_LOGPAGE(plpns, - NVME_LOG_PREDICTABLE_LATENCY_PER_NVM_SET, NULL, "Predictable Latency Per NVM Set", +NVME_LOGPAGE(plpns, 0, NULL, + NVME_LOG_PREDICTABLE_LATENCY_PER_NVM_SET, "Predictable Latency Per NVM Set", NULL, DEFAULT_SIZE); -NVME_LOGPAGE(ple, - NVME_LOG_PREDICTABLE_LATENCY_EVENT_AGGREGATE, NULL, "Predictable Latency Event Aggregate", +NVME_LOGPAGE(ple, 0, NULL, + NVME_LOG_PREDICTABLE_LATENCY_EVENT_AGGREGATE,"Predictable Latency Event Aggregate", NULL, DEFAULT_SIZE); -NVME_LOGPAGE(ana, - NVME_LOG_ASYMMETRIC_NAMESPAVE_ACCESS, NULL, "Asymmetric Namespace Access", +NVME_LOGPAGE(ana, 0, NULL, + NVME_LOG_ASYMMETRIC_NAMESPAVE_ACCESS, "Asymmetric Namespace Access", NULL, DEFAULT_SIZE); -NVME_LOGPAGE(pel, - NVME_LOG_PERSISTENT_EVENT_LOG, NULL, "Persistent Event Log", +NVME_LOGPAGE(pel, 0, NULL, + NVME_LOG_PERSISTENT_EVENT_LOG, "Persistent Event Log", NULL, DEFAULT_SIZE); -NVME_LOGPAGE(lbasi, - NVME_LOG_LBA_STATUS_INFORMATION, NULL, "LBA Status Information", +NVME_LOGPAGE(lbasi, 0, NULL, + NVME_LOG_LBA_STATUS_INFORMATION, "LBA Status Information", NULL, DEFAULT_SIZE); -NVME_LOGPAGE(egea, - NVME_LOG_ENDURANCE_GROUP_EVENT_AGGREGATE, NULL, "Endurance Group Event Aggregate", +NVME_LOGPAGE(egea, 0, NULL, + NVME_LOG_ENDURANCE_GROUP_EVENT_AGGREGATE, "Endurance Group Event Aggregate", NULL, DEFAULT_SIZE); -NVME_LOGPAGE(res_notification, - NVME_LOG_RES_NOTIFICATION, NULL, "Reservation Notification", +NVME_LOGPAGE(res_notification, 0, NULL, + NVME_LOG_RES_NOTIFICATION, "Reservation Notification", print_log_res_notification, sizeof(struct nvme_res_notification_page)); -NVME_LOGPAGE(sanitize_status, - NVME_LOG_SANITIZE_STATUS, NULL, "Sanitize Status", +NVME_LOGPAGE(sanitize_status, 0, NULL, + NVME_LOG_SANITIZE_STATUS, "Sanitize Status", print_log_sanitize_status, sizeof(struct nvme_sanitize_status_page)); static void @@ -752,13 +752,15 @@ { const struct logpage_function *f; const char *v; + char vid[7]; fprintf(stderr, "\n"); - fprintf(stderr, "%-8s %-10s %s\n", "Page", "Vendor","Page Name"); - fprintf(stderr, "-------- ---------- ----------\n"); + fprintf(stderr, "%-8s %-10s %-10s %s\n", "Page", "Vendor Id", "Vendor", "Page Name"); + fprintf(stderr, "-------- ---------- ---------- ----------\n"); SLIST_FOREACH(f, &logpages, link) { v = f->vendor == NULL ? "-" : f->vendor; - fprintf(stderr, "0x%02x %-10s %s\n", f->log_page, v, f->name); + f->vid > 0 ? snprintf(vid, sizeof(vid), "0x%04x", f->vid) : sprintf(vid, "-"); + fprintf(stderr, "0x%02x %-8s %-10s %s\n", f->log_page, vid, v, f->name); } exit(EX_USAGE); @@ -833,6 +835,9 @@ * unless the vendors match. */ SLIST_FOREACH(lpf, &logpages, link) { + if (lpf->vendor != NULL && opt.vendor == NULL && + lpf->vid != cdata.vid) + continue; if (lpf->vendor != NULL && opt.vendor != NULL && strcmp(lpf->vendor, opt.vendor) != 0) continue; Index: sbin/nvmecontrol/modules/intel/intel.c =================================================================== --- sbin/nvmecontrol/modules/intel/intel.c +++ sbin/nvmecontrol/modules/intel/intel.c @@ -181,15 +181,15 @@ } } -NVME_LOGPAGE(intel_temp, - INTEL_LOG_TEMP_STATS, "intel", "Temperature Stats", +NVME_LOGPAGE(intel_temp, 0x8086, "intel", + INTEL_LOG_TEMP_STATS, "Temperature Stats", print_intel_temp_stats, sizeof(struct intel_log_temp_stats)); -NVME_LOGPAGE(intel_rlat, - INTEL_LOG_READ_LAT_LOG, "intel", "Read Latencies", +NVME_LOGPAGE(intel_rlat, 0x8086, "intel", + INTEL_LOG_READ_LAT_LOG, "Read Latencies", print_intel_read_lat_log, DEFAULT_SIZE); -NVME_LOGPAGE(intel_wlat, - INTEL_LOG_WRITE_LAT_LOG, "intel", "Write Latencies", +NVME_LOGPAGE(intel_wlat, 0x8086, "intel", + INTEL_LOG_WRITE_LAT_LOG, "Write Latencies", print_intel_write_lat_log, DEFAULT_SIZE); -NVME_LOGPAGE(intel_smart, - INTEL_LOG_ADD_SMART, "intel", "Extra Health/SMART Data", +NVME_LOGPAGE(intel_smart, 0x8086, "intel", + INTEL_LOG_ADD_SMART, "Extra Health/SMART Data", print_intel_add_smart, DEFAULT_SIZE); Index: sbin/nvmecontrol/modules/wdc/wdc.c =================================================================== --- sbin/nvmecontrol/modules/wdc/wdc.c +++ sbin/nvmecontrol/modules/wdc/wdc.c @@ -811,9 +811,9 @@ } } -NVME_LOGPAGE(hgst_info, - HGST_INFO_LOG, "hgst", "Detailed Health/SMART", +NVME_LOGPAGE(hgst_info, 0x1b96, "hgst", + HGST_INFO_LOG, "Detailed Health/SMART", print_hgst_info_log, DEFAULT_SIZE); -NVME_LOGPAGE(wdc_info, - HGST_INFO_LOG, "wdc", "Detailed Health/SMART", +NVME_LOGPAGE(wdc_info, 0x15b7, "wdc", + HGST_INFO_LOG, "Detailed Health/SMART", print_hgst_info_log, DEFAULT_SIZE); Index: sbin/nvmecontrol/nvmecontrol.h =================================================================== --- sbin/nvmecontrol/nvmecontrol.h +++ sbin/nvmecontrol/nvmecontrol.h @@ -38,18 +38,20 @@ struct logpage_function { SLIST_ENTRY(logpage_function) link; - uint8_t log_page; + uint32_t vid; const char *vendor; + uint8_t log_page; const char *name; print_fn_t print_fn; size_t size; }; -#define NVME_LOGPAGE(unique, lp, vend, nam, fn, sz) \ +#define NVME_LOGPAGE(unique, id, vend, lp, na, fn, sz) \ static struct logpage_function unique ## _lpf = { \ - .log_page = lp, \ + .vid = id, \ .vendor = vend, \ - .name = nam, \ + .log_page = lp, \ + .name = na, \ .print_fn = fn, \ .size = sz, \ } ; \ Index: sbin/nvmecontrol/nvmecontrol.8 =================================================================== --- sbin/nvmecontrol/nvmecontrol.8 +++ sbin/nvmecontrol/nvmecontrol.8 @@ -245,6 +245,8 @@ .Ss logpage The logpage command knows how to print log pages of various types. It also knows about vendor specific log pages from hgst/wdc and intel. +When printing a vendor specific log page while the vendor name is not specified, +the controller's vid will be used to choose the formating function. Note that some vendors use the same log page numbers for different data. .Pp .Bl -tag -compact -width "Page 0x00"