From owner-svn-src-all@freebsd.org Fri Dec 2 14:44:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 97968C628B6; Fri, 2 Dec 2016 14:44:46 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 59EA11F7A; Fri, 2 Dec 2016 14:44:46 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uB2EijDc062121; Fri, 2 Dec 2016 14:44:45 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uB2EijxT062120; Fri, 2 Dec 2016 14:44:45 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201612021444.uB2EijxT062120@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 2 Dec 2016 14:44:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r309413 - head/sbin/nvmecontrol X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Dec 2016 14:44:46 -0000 Author: imp Date: Fri Dec 2 14:44:45 2016 New Revision: 309413 URL: https://svnweb.freebsd.org/changeset/base/309413 Log: Flag the vendor specific pages as such. This allows different decoding for the same page number as different vendors encode vendor specific pages differently. Modified: head/sbin/nvmecontrol/logpage.c Modified: head/sbin/nvmecontrol/logpage.c ============================================================================== --- head/sbin/nvmecontrol/logpage.c Fri Dec 2 14:44:38 2016 (r309412) +++ head/sbin/nvmecontrol/logpage.c Fri Dec 2 14:44:45 2016 (r309413) @@ -793,23 +793,23 @@ print_hgst_info_log(void *buf, uint32_t */ static struct logpage_function { uint8_t log_page; + const char *vendor; print_fn_t print_fn; size_t size; } logfuncs[] = { - {NVME_LOG_ERROR, print_log_error, + {NVME_LOG_ERROR, NULL, print_log_error, 0}, - {NVME_LOG_HEALTH_INFORMATION, print_log_health, + {NVME_LOG_HEALTH_INFORMATION, NULL, print_log_health, 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)}, - {INTEL_LOG_TEMP_STATS, print_intel_temp_stats, + {INTEL_LOG_TEMP_STATS, "intel", print_intel_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}, - {HGST_INFO_LOG, print_hgst_info_log, + {HGST_INFO_LOG, "hgst", print_hgst_info_log, DEFAULT_SIZE}, - {0, NULL, - 0}, + {0, NULL, NULL, 0}, }; static void @@ -830,11 +830,12 @@ logpage(int argc, char *argv[]) char cname[64]; uint32_t size; void *buf; + const char *vendor = NULL; struct logpage_function *f; struct nvme_controller_data cdata; print_fn_t print_fn; - while ((ch = getopt(argc, argv, "p:x")) != -1) { + while ((ch = getopt(argc, argv, "p:xv:")) != -1) { switch (ch) { case 'p': /* TODO: Add human-readable ASCII page IDs */ @@ -850,6 +851,9 @@ logpage(int argc, char *argv[]) case 'x': hexflag = true; break; + case 'v': + vendor = optarg; + break; } } @@ -893,18 +897,21 @@ logpage(int argc, char *argv[]) size = DEFAULT_SIZE; if (!hexflag) { /* - * See if there is a pretty print function for the - * specified log page. If one isn't found, we - * just revert to the default (print_hex). + * See if there is a pretty print function for the specified log + * page. If one isn't found, we just revert to the default + * (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; - while (f->log_page > 0) { - if (log_page == f->log_page) { - print_fn = f->print_fn; - size = f->size; - break; - } - f++; + for (f = logfuncs; f->log_page > 0; f++) { + if (f->vendor != NULL && vendor != NULL && + strcmp(f->vendor, vendor) != 0) + continue; + if (log_page != f->log_page) + continue; + print_fn = f->print_fn; + size = f->size; + break; } }