Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Oct 2017 15:25:55 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r324977 - head/sbin/nvmecontrol
Message-ID:  <201710251525.v9PFPttt017730@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Wed Oct 25 15:25:55 2017
New Revision: 324977
URL: https://svnweb.freebsd.org/changeset/base/324977

Log:
  Add nvme_controller_data argument to all print functions.
  
  It's desirable to access controler data to inform printing log pages
  (such as limiting the printing to valid ranges).
  
  Sponsored by: Netflix

Modified:
  head/sbin/nvmecontrol/logpage.c

Modified: head/sbin/nvmecontrol/logpage.c
==============================================================================
--- head/sbin/nvmecontrol/logpage.c	Wed Oct 25 15:18:09 2017	(r324976)
+++ head/sbin/nvmecontrol/logpage.c	Wed Oct 25 15:25:55 2017	(r324977)
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
 #define DEFAULT_SIZE	(4096)
 #define MAX_FW_SLOTS	(7)
 
-typedef void (*print_fn_t)(void *buf, uint32_t size);
+typedef void (*print_fn_t)(const struct nvme_controller_data *cdata, void *buf, uint32_t size);
 
 struct kv_name
 {
@@ -75,8 +75,16 @@ kv_lookup(const struct kv_name *kv, size_t kv_count, u
 }
 
 static void
-print_bin(void *data, uint32_t length)
+print_log_hex(const struct nvme_controller_data *cdata __unused, void *data, uint32_t length)
 {
+
+	print_hex(data, length);
+}
+
+static void
+print_bin(const struct nvme_controller_data *cdata __unused, void *data, uint32_t length)
+{
+
 	write(STDOUT_FILENO, data, length);
 }
 
@@ -115,7 +123,7 @@ read_logpage(int fd, uint8_t log_page, int nsid, void 
 }
 
 static void
-print_log_error(void *buf, uint32_t size)
+print_log_error(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size)
 {
 	int					i, nentries;
 	struct nvme_error_information_entry	*entry = buf;
@@ -162,7 +170,7 @@ print_temp(uint16_t t)
 
 
 static void
-print_log_health(void *buf, uint32_t size __unused)
+print_log_health(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
 {
 	struct nvme_health_information_page *health = buf;
 	char cbuf[UINT128_DIG + 1];
@@ -224,7 +232,7 @@ print_log_health(void *buf, uint32_t size __unused)
 }
 
 static void
-print_log_firmware(void *buf, uint32_t size __unused)
+print_log_firmware(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
 {
 	int				i;
 	const char			*status;
@@ -260,7 +268,7 @@ print_log_firmware(void *buf, uint32_t size __unused)
  * offset 147: it is only 1 byte, not 6.
  */
 static void
-print_intel_temp_stats(void *buf, uint32_t size __unused)
+print_intel_temp_stats(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
 {
 	struct intel_log_temp_stats	*temp = buf;
 
@@ -287,7 +295,7 @@ print_intel_temp_stats(void *buf, uint32_t size __unus
  * Read and write stats pages have identical encoding.
  */
 static void
-print_intel_read_write_lat_log(void *buf, uint32_t size __unused)
+print_intel_read_write_lat_log(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
 {
 	const char *walker = buf;
 	int i;
@@ -303,28 +311,28 @@ print_intel_read_write_lat_log(void *buf, uint32_t siz
 }
 
 static void
-print_intel_read_lat_log(void *buf, uint32_t size)
+print_intel_read_lat_log(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size)
 {
 
 	printf("Intel Read Latency Log\n");
 	printf("======================\n");
-	print_intel_read_write_lat_log(buf, size);
+	print_intel_read_write_lat_log(cdata, buf, size);
 }
 
 static void
-print_intel_write_lat_log(void *buf, uint32_t size)
+print_intel_write_lat_log(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size)
 {
 
 	printf("Intel Write Latency Log\n");
 	printf("=======================\n");
-	print_intel_read_write_lat_log(buf, size);
+	print_intel_read_write_lat_log(cdata, buf, size);
 }
 
 /*
  * 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)
+print_intel_add_smart(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
 {
 	uint8_t *walker = buf;
 	uint8_t *end = walker + 150;
@@ -753,7 +761,7 @@ kv_indirect(void *buf, uint32_t subtype, uint8_t res, 
 }
 
 static void
-print_hgst_info_log(void *buf, uint32_t size __unused)
+print_hgst_info_log(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
 {
 	uint8_t	*walker, *end, *subpage;
 	int pages;
@@ -928,7 +936,7 @@ logpage(int argc, char *argv[])
 			    "smart/health information");
 	}
 
-	print_fn = print_hex;
+	print_fn = print_log_hex;
 	size = DEFAULT_SIZE;
 	if (binflag)
 		print_fn = print_bin;
@@ -960,7 +968,7 @@ logpage(int argc, char *argv[])
 	/* Read the log page */
 	buf = get_log_buffer(size);
 	read_logpage(fd, log_page, nsid, buf, size);
-	print_fn(buf, size);
+	print_fn(&cdata, buf, size);
 
 	close(fd);
 	exit(0);



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