From owner-svn-src-stable-11@freebsd.org Thu Feb 1 19:44:25 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 91703EE8845; Thu, 1 Feb 2018 19:44:25 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4454181A5F; Thu, 1 Feb 2018 19:44:25 +0000 (UTC) (envelope-from mav@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3F3F91178F; Thu, 1 Feb 2018 19:44:25 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w11JiPYM031379; Thu, 1 Feb 2018 19:44:25 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w11JiOoP031376; Thu, 1 Feb 2018 19:44:24 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201802011944.w11JiOoP031376@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 1 Feb 2018 19:44:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328725 - stable/11/sbin/nvmecontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/nvmecontrol X-SVN-Commit-Revision: 328725 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Feb 2018 19:44:25 -0000 Author: mav Date: Thu Feb 1 19:44:24 2018 New Revision: 328725 URL: https://svnweb.freebsd.org/changeset/base/328725 Log: MFC r314230 (by imp): Make nvmecontrol logpage -p help list known pages. Make -p help and -v help list all the pages we know about. Add -v to usage. Update the man page. Modified: stable/11/sbin/nvmecontrol/logpage.c stable/11/sbin/nvmecontrol/nvmecontrol.8 stable/11/sbin/nvmecontrol/nvmecontrol.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/nvmecontrol/logpage.c ============================================================================== --- stable/11/sbin/nvmecontrol/logpage.c Thu Feb 1 19:43:51 2018 (r328724) +++ stable/11/sbin/nvmecontrol/logpage.c Thu Feb 1 19:44:24 2018 (r328725) @@ -369,7 +369,7 @@ print_intel_write_lat_log(void *buf, uint32_t size) } /* - * Table 19. 5.4 SMART Attributes + * Table 19. 5.4 SMART Attributes. Samsung also implements this and some extra data not documented. */ static void print_intel_add_smart(void *buf, uint32_t size __unused) @@ -835,34 +835,39 @@ print_hgst_info_log(void *buf, uint32_t size __unused) /* * Table of log page printer / sizing. * - * This includes Intel specific pages that are widely implemented. Not - * sure how best to switch between different vendors. + * This includes Intel specific pages that are widely implemented. + * Make sure you keep all the pages of one vendor together so -v help + * lists all the vendors pages. */ static struct logpage_function { uint8_t log_page; const char *vendor; + const char *name; print_fn_t print_fn; size_t size; } logfuncs[] = { - {NVME_LOG_ERROR, NULL, print_log_error, - 0}, - {NVME_LOG_HEALTH_INFORMATION, NULL, print_log_health, - sizeof(struct nvme_health_information_page)}, - {NVME_LOG_FIRMWARE_SLOT, NULL, print_log_firmware, - sizeof(struct nvme_firmware_page)}, - {HGST_INFO_LOG, "hgst", print_hgst_info_log, - DEFAULT_SIZE}, - {HGST_INFO_LOG, "wdc", print_hgst_info_log, - DEFAULT_SIZE}, - {INTEL_LOG_TEMP_STATS, "intel", print_intel_temp_stats, - sizeof(struct intel_log_temp_stats)}, - {INTEL_LOG_READ_LAT_LOG, "intel", print_intel_read_lat_log, - DEFAULT_SIZE}, - {INTEL_LOG_WRITE_LAT_LOG, "intel", print_intel_write_lat_log, - DEFAULT_SIZE}, - {INTEL_LOG_ADD_SMART, "intel", print_intel_add_smart, - DEFAULT_SIZE}, - {0, NULL, NULL, 0}, + {NVME_LOG_ERROR, NULL, "Drive Error Log", + print_log_error, 0}, + {NVME_LOG_HEALTH_INFORMATION, NULL, "Health/SMART Data", + print_log_health, sizeof(struct nvme_health_information_page)}, + {NVME_LOG_FIRMWARE_SLOT, NULL, "Firmware Information", + print_log_firmware, sizeof(struct nvme_firmware_page)}, + {HGST_INFO_LOG, "hgst", "Detailed Health/SMART", + print_hgst_info_log, DEFAULT_SIZE}, + {HGST_INFO_LOG, "wds", "Detailed Health/SMART", + print_hgst_info_log, DEFAULT_SIZE}, + {INTEL_LOG_TEMP_STATS, "intel", "Temperature Stats", + print_intel_temp_stats, sizeof(struct intel_log_temp_stats)}, + {INTEL_LOG_READ_LAT_LOG, "intel", "Read Latencies", + print_intel_read_lat_log, DEFAULT_SIZE}, + {INTEL_LOG_WRITE_LAT_LOG, "intel", "Write Latencies", + print_intel_write_lat_log, DEFAULT_SIZE}, + {INTEL_LOG_ADD_SMART, "intel", "Extra Health/SMART Data", + print_intel_add_smart, DEFAULT_SIZE}, + {INTEL_LOG_ADD_SMART, "samsung", "Extra Health/SMART Data", + print_intel_add_smart, DEFAULT_SIZE}, + + {0, NULL, NULL, NULL, 0}, }; static void @@ -873,6 +878,23 @@ logpage_usage(void) exit(1); } +static void +logpage_help(void) +{ + struct logpage_function *f; + const char *v; + + fprintf(stderr, "\n"); + fprintf(stderr, "%-8s %-10s %s\n", "Page", "Vendor","Page Name"); + fprintf(stderr, "-------- ---------- ----------\n"); + for (f = logfuncs; f->log_page > 0; f++) { + v = f->vendor == NULL ? "-" : f->vendor; + fprintf(stderr, "0x%02x %-10s %s\n", f->log_page, v, f->name); + } + + exit(1); +} + void logpage(int argc, char *argv[]) { @@ -894,6 +916,9 @@ logpage(int argc, char *argv[]) binflag = true; break; case 'p': + if (strcmp(optarg, "help") == 0) + logpage_help(); + /* TODO: Add human-readable ASCII page IDs */ log_page = strtol(optarg, &p, 0); if (p != NULL && *p != '\0') { @@ -908,6 +933,8 @@ logpage(int argc, char *argv[]) hexflag = true; break; case 'v': + if (strcmp(optarg, "help") == 0) + logpage_help(); vendor = optarg; break; } Modified: stable/11/sbin/nvmecontrol/nvmecontrol.8 ============================================================================== --- stable/11/sbin/nvmecontrol/nvmecontrol.8 Thu Feb 1 19:43:51 2018 (r328724) +++ stable/11/sbin/nvmecontrol/nvmecontrol.8 Thu Feb 1 19:44:24 2018 (r328725) @@ -33,7 +33,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 4, 2017 +.Dd February 24, 2017 .Dt NVMECONTROL 8 .Os .Sh NAME @@ -108,6 +108,15 @@ Page 0xc1 is read latency stats for intel. Page 0xc2 is write latency stats for intel. Page 0xc5 is temperature stats for intel. Page 0xca is advanced smart information for intel. +.Pp +Specifying +.Fl p +.Ic help +will list all valid vendors and pages. +.Fl x +will print the page as hex. +.Fl b +will print the binary data for the page. .Ss wdc The various wdc command retrieve log data from the wdc/hgst drives. The Modified: stable/11/sbin/nvmecontrol/nvmecontrol.h ============================================================================== --- stable/11/sbin/nvmecontrol/nvmecontrol.h Thu Feb 1 19:43:51 2018 (r328724) +++ stable/11/sbin/nvmecontrol/nvmecontrol.h Thu Feb 1 19:44:24 2018 (r328725) @@ -58,7 +58,7 @@ struct nvme_function { " nvmecontrol reset \n" #define LOGPAGE_USAGE \ -" nvmecontrol logpage <-p page_id> [-x] \n" \ +" nvmecontrol logpage <-p page_id> [-b] [-v vendor] [-x] \n" \ #define FIRMWARE_USAGE \ " nvmecontrol firmware [-s slot] [-f path_to_firmware] [-a] \n"