Flag the vendor specific pages as such. This allows different decoding

for the same page number as different vendors encode vendor specific
pages differently.
This commit is contained in:
Warner Losh 2016-12-02 14:44:45 +00:00
parent 158c18ffb4
commit 5619c99fb3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=309413

View File

@ -793,23 +793,23 @@ print_hgst_info_log(void *buf, uint32_t size __unused)
*/ */
static struct logpage_function { static struct logpage_function {
uint8_t log_page; uint8_t log_page;
const char *vendor;
print_fn_t print_fn; print_fn_t print_fn;
size_t size; size_t size;
} logfuncs[] = { } logfuncs[] = {
{NVME_LOG_ERROR, print_log_error, {NVME_LOG_ERROR, NULL, print_log_error,
0}, 0},
{NVME_LOG_HEALTH_INFORMATION, print_log_health, {NVME_LOG_HEALTH_INFORMATION, NULL, print_log_health,
sizeof(struct nvme_health_information_page)}, sizeof(struct nvme_health_information_page)},
{NVME_LOG_FIRMWARE_SLOT, print_log_firmware, {NVME_LOG_FIRMWARE_SLOT, NULL, print_log_firmware,
sizeof(struct nvme_firmware_page)}, sizeof(struct nvme_firmware_page)},
{INTEL_LOG_TEMP_STATS, print_intel_temp_stats, {INTEL_LOG_TEMP_STATS, "intel", print_intel_temp_stats,
sizeof(struct intel_log_temp_stats)}, sizeof(struct intel_log_temp_stats)},
{INTEL_LOG_ADD_SMART, print_intel_add_smart, {INTEL_LOG_ADD_SMART, "intel", print_intel_add_smart,
DEFAULT_SIZE}, DEFAULT_SIZE},
{HGST_INFO_LOG, print_hgst_info_log, {HGST_INFO_LOG, "hgst", print_hgst_info_log,
DEFAULT_SIZE}, DEFAULT_SIZE},
{0, NULL, {0, NULL, NULL, 0},
0},
}; };
static void static void
@ -830,11 +830,12 @@ logpage(int argc, char *argv[])
char cname[64]; char cname[64];
uint32_t size; uint32_t size;
void *buf; void *buf;
const char *vendor = NULL;
struct logpage_function *f; struct logpage_function *f;
struct nvme_controller_data cdata; struct nvme_controller_data cdata;
print_fn_t print_fn; print_fn_t print_fn;
while ((ch = getopt(argc, argv, "p:x")) != -1) { while ((ch = getopt(argc, argv, "p:xv:")) != -1) {
switch (ch) { switch (ch) {
case 'p': case 'p':
/* TODO: Add human-readable ASCII page IDs */ /* TODO: Add human-readable ASCII page IDs */
@ -850,6 +851,9 @@ logpage(int argc, char *argv[])
case 'x': case 'x':
hexflag = true; hexflag = true;
break; break;
case 'v':
vendor = optarg;
break;
} }
} }
@ -893,18 +897,21 @@ logpage(int argc, char *argv[])
size = DEFAULT_SIZE; size = DEFAULT_SIZE;
if (!hexflag) { if (!hexflag) {
/* /*
* See if there is a pretty print function for the * See if there is a pretty print function for the specified log
* specified log page. If one isn't found, we * page. If one isn't found, we just revert to the default
* just revert to the default (print_hex). * (print_hex). If there was a vendor specified bt the user, and
* the page is vendor specific, don't match the print function
* unless the vendors match.
*/ */
f = logfuncs; for (f = logfuncs; f->log_page > 0; f++) {
while (f->log_page > 0) { if (f->vendor != NULL && vendor != NULL &&
if (log_page == f->log_page) { strcmp(f->vendor, vendor) != 0)
print_fn = f->print_fn; continue;
size = f->size; if (log_page != f->log_page)
break; continue;
} print_fn = f->print_fn;
f++; size = f->size;
break;
} }
} }