From nobody Tue Aug 27 01:06:40 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Wt8Wh6W2sz5TjR9; Tue, 27 Aug 2024 01:06:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wt8Wh4Fbgz4ltP; Tue, 27 Aug 2024 01:06:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724720800; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZpgxZAWZRKN5eNiep8VR+EvHSqnpZsc1LxSV+rD36sk=; b=Rkul/MD+0oqbZRyW/u5iTfVCYKvzOUqj2scWdAMRfsEY00sC1VtqDmckIfNdsl+Hr1GImn Gles4UdntPOlu4pGJF5qOIKusjqa4VwyVsP7+mmmXsvEohv9z6UUlzjC6msyIpxdwQY9Ks fasLSYEmEM0Apn3NhC0ruEvNs8F8j2BaAXD0B2/lCYxlyjcfHD3mgLPknP6fyp/XkI83K5 GVtQ2jpYlbuu3xEk3cLbM1L3IILh4avqJJeeSvq8bSu3G1YJMp1v51uRErldNfSdZg2Bf4 7QGV4GQGBvrCeOPaTI3N1u79ozgxXRGk7X5zx2kRXroilaJypj+ZMkIueO6FLw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724720800; a=rsa-sha256; cv=none; b=qnOFP+VGxUkMjJFfCIzA83lfXuQBNqF2g+5Xh5mNTrE3lo1BeZw2NNoE57RyPc32wxraYy LQisg3vw6eicjBgcRFbuvXcD8fsYOJvRLeDXlbjTjM8nbVfZ69bRfWlet4uc6ZKP7l2Wa2 KgiWoBu22KpXJaGeU0ZVC678Uv9HU9Y251u5SWPurUsJjBJx6D7gUxnTAA1886sn40NaMc Fj5p+R36Gt9Y98Ixy9Ry6vJ4k0FDLCsFVURbBNgGxgR0Qfh02e4kkTt6wbmlGrH5RIZAyU 9KZ63J42s+PY5jcpMNpsUOHTtZ5KowVCPsZ3wNfhs7ukpqb6RwG0VkUESc3F5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724720800; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZpgxZAWZRKN5eNiep8VR+EvHSqnpZsc1LxSV+rD36sk=; b=k0M+DB1m4l5T4KzB+2Neff0WlFjQjwE9Cf/JkJw3vSDX+XpV9e1/pJwEPTdKk9HZrEktmO UhkSv1/Vhq7ayBqQHrF0W8ETSANtD1cOIAUKKnZOR5UEk1Zg7dqwqkrdauE3J3zHm4J/Jx PzQdv3zYrN3pXbmMOFzJ6HuE1BLIwxBo9PS63/xA6cjeQZ6slhRjyrivzxgEHBIT6Ik9DR d6yzHbSoNH8UlhqJvR9F+PgHFSG20HffAS98TNG5qwvDnMnBn6bC64hKavaUkeM19rCwp8 kIDoBa2hjoNC37+Nj0VylJQncr/zgxI0wM/Xof6i3GSrs2Q7SuBE0n1v32bx2A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Wt8Wh36wxzSkK; Tue, 27 Aug 2024 01:06:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47R16eSu057146; Tue, 27 Aug 2024 01:06:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47R16e6v057143; Tue, 27 Aug 2024 01:06:40 GMT (envelope-from git) Date: Tue, 27 Aug 2024 01:06:40 GMT Message-Id: <202408270106.47R16e6v057143@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 4d144d4ceb1c - stable/14 - nvmecontrol: Move smart/health printing to little endian orderinng List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 4d144d4ceb1c7df824ba66929c396faa83638edf Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4d144d4ceb1c7df824ba66929c396faa83638edf commit 4d144d4ceb1c7df824ba66929c396faa83638edf Author: Warner Losh AuthorDate: 2024-04-16 22:36:05 +0000 Commit: John Baldwin CommitDate: 2024-08-26 18:31:02 +0000 nvmecontrol: Move smart/health printing to little endian orderinng Move health printing to little endian ordering... Sponsored by: Netflix Reviewed by: chuck Differential Revision: https://reviews.freebsd.org/D44652 (cherry picked from commit 729ee4c88f2af4560adec39fd709ff89bb597e4a) --- sbin/nvmecontrol/logpage.c | 56 +++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/sbin/nvmecontrol/logpage.c b/sbin/nvmecontrol/logpage.c index a6242bd4a440..0ed19222ba1a 100644 --- a/sbin/nvmecontrol/logpage.c +++ b/sbin/nvmecontrol/logpage.c @@ -220,10 +220,6 @@ read_logpage(int fd, uint8_t log_page, uint32_t nsid, uint8_t lsp, /* Convert data to host endian */ switch (log_page) { - case NVME_LOG_HEALTH_INFORMATION: - nvme_health_information_page_swapbytes( - (struct nvme_health_information_page *)payload); - break; case NVME_LOG_CHANGED_NAMESPACE: nvme_ns_list_swapbytes((struct nvme_ns_list *)payload); break; @@ -266,17 +262,17 @@ print_log_error(const struct nvme_controller_data *cdata __unused, void *buf, ui printf("Error Information Log\n"); printf("=====================\n"); - if (LE2H(entry->error_count) == 0) { + if (letoh(entry->error_count) == 0) { printf("No error entries found\n"); return; } nentries = size / sizeof(struct nvme_error_information_entry); for (i = 0; i < nentries; i++, entry++) { - if (LE2H(entry->error_count) == 0) + if (letoh(entry->error_count) == 0) break; - status = LE2H(entry->status); + status = letoh(entry->status); p = NVME_STATUS_GET_P(status); sc = NVME_STATUS_GET_SC(status); @@ -286,9 +282,9 @@ print_log_error(const struct nvme_controller_data *cdata __unused, void *buf, ui printf("Entry %02d\n", i + 1); printf("=========\n"); - printf(" Error count: %ju\n", LE2H(entry->error_count)); - printf(" Submission queue ID: %u\n", LE2H(entry->sqid)); - printf(" Command ID: %u\n", LE2H(entry->cid)); + printf(" Error count: %ju\n", letoh(entry->error_count)); + printf(" Submission queue ID: %u\n", letoh(entry->sqid)); + printf(" Command ID: %u\n", letoh(entry->cid)); /* TODO: Export nvme_status_string structures from kernel? */ printf(" Status:\n"); printf(" Phase tag: %d\n", p); @@ -296,13 +292,13 @@ print_log_error(const struct nvme_controller_data *cdata __unused, void *buf, ui printf(" Status code type: %d\n", sct); printf(" More: %d\n", m); printf(" DNR: %d\n", dnr); - printf(" Error location: %u\n", LE2H(entry->error_location)); - printf(" LBA: %ju\n", LE2H(entry->lba)); - printf(" Namespace ID: %u\n", LE2H(entry->nsid)); - printf(" Vendor specific info: %u\n", LE2H(entry->vendor_specific)); - printf(" Transport type: %u\n", LE2H(entry->trtype)); - printf(" Command specific info:%ju\n", LE2H(entry->csi)); - printf(" Transport specific: %u\n", LE2H(entry->ttsi)); + printf(" Error location: %u\n", letoh(entry->error_location)); + printf(" LBA: %ju\n", letoh(entry->lba)); + printf(" Namespace ID: %u\n", letoh(entry->nsid)); + printf(" Vendor specific info: %u\n", letoh(entry->vendor_specific)); + printf(" Transport type: %u\n", letoh(entry->trtype)); + printf(" Command specific info:%ju\n", letoh(entry->csi)); + printf(" Transport specific: %u\n", letoh(entry->ttsi)); } } @@ -326,7 +322,7 @@ print_log_health(const struct nvme_controller_data *cdata __unused, void *buf, u uint8_t warning; int i; - warning = health->critical_warning; + warning = letoh(health->critical_warning); printf("SMART/Health Information Log\n"); printf("============================\n"); @@ -343,13 +339,13 @@ print_log_health(const struct nvme_controller_data *cdata __unused, void *buf, u printf(" Volatile memory backup: %d\n", !!(warning & NVME_CRIT_WARN_ST_VOLATILE_MEMORY_BACKUP)); printf("Temperature: "); - print_temp_K(health->temperature); + print_temp_K(letoh(health->temperature)); printf("Available spare: %u\n", - health->available_spare); + letoh(health->available_spare)); printf("Available spare threshold: %u\n", - health->available_spare_threshold); + letoh(health->available_spare_threshold)); printf("Percentage used: %u\n", - health->percentage_used); + letoh(health->percentage_used)); printf("Data units (512,000 byte) read: %s\n", uint128_to_str(to128(health->data_units_read), cbuf, sizeof(cbuf))); @@ -372,18 +368,18 @@ print_log_health(const struct nvme_controller_data *cdata __unused, void *buf, u printf("No. error info log entries: %s\n", uint128_to_str(to128(health->num_error_info_log_entries), cbuf, sizeof(cbuf))); - printf("Warning Temp Composite Time: %d\n", health->warning_temp_time); - printf("Error Temp Composite Time: %d\n", health->error_temp_time); + printf("Warning Temp Composite Time: %d\n", letoh(health->warning_temp_time)); + printf("Error Temp Composite Time: %d\n", letoh(health->error_temp_time)); for (i = 0; i < 8; i++) { - if (health->temp_sensor[i] == 0) + if (letoh(health->temp_sensor[i]) == 0) continue; printf("Temperature Sensor %d: ", i + 1); - print_temp_K(health->temp_sensor[i]); + print_temp_K(letoh(health->temp_sensor[i])); } - printf("Temperature 1 Transition Count: %d\n", health->tmt1tc); - printf("Temperature 2 Transition Count: %d\n", health->tmt2tc); - printf("Total Time For Temperature 1: %d\n", health->ttftmt1); - printf("Total Time For Temperature 2: %d\n", health->ttftmt2); + printf("Temperature 1 Transition Count: %d\n", letoh(health->tmt1tc)); + printf("Temperature 2 Transition Count: %d\n", letoh(health->tmt2tc)); + printf("Total Time For Temperature 1: %d\n", letoh(health->ttftmt1)); + printf("Total Time For Temperature 2: %d\n", letoh(health->ttftmt2)); } static void