Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Feb 2018 19:44:24 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
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
Message-ID:  <201802011944.w11JiOoP031376@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <controller id>\n"
 
 #define LOGPAGE_USAGE							       \
-"       nvmecontrol logpage <-p page_id> [-x] <controller id|namespace id>\n"  \
+"       nvmecontrol logpage <-p page_id> [-b] [-v vendor] [-x] <controller id|namespace id>\n"  \
 
 #define FIRMWARE_USAGE							       \
 "       nvmecontrol firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802011944.w11JiOoP031376>