From owner-svn-src-head@freebsd.org Wed Oct 25 15:25:56 2017 Return-Path: Delivered-To: svn-src-head@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 3141EE4D3BA; Wed, 25 Oct 2017 15:25:56 +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 0D8497177F; Wed, 25 Oct 2017 15:25:55 +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 v9PFPtAk017731; Wed, 25 Oct 2017 15:25:55 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9PFPttt017730; Wed, 25 Oct 2017 15:25:55 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201710251525.v9PFPttt017730@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Wed, 25 Oct 2017 15:25:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324977 - head/sbin/nvmecontrol X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sbin/nvmecontrol X-SVN-Commit-Revision: 324977 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2017 15:25:56 -0000 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);