From nobody Wed Apr 17 03:33:45 2024 X-Original-To: dev-commits-src-main@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 4VK62K5wQKz5HjSc; Wed, 17 Apr 2024 03:33:45 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VK62K3l1tz4Qk5; Wed, 17 Apr 2024 03:33:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713324825; 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=bGuWswC+stepEtRcOhaJBN1HScVXtxlLNBMwu45RJdU=; b=MQpRqL6p5vqp/SVDppE1iHEfhADkaDiWfGTMUjqmS2mbV2fN9LK5OS3njsvulvGuCdYEJy 3k7l0DJTIO4SXtyctQAl708sb0mCBRcQdZAcyABlU0rDqBkJtDGDFtc9Cpviz/Ck5YOz3j awGCDoXHrdP0MZRK/UQ61CMq8wofw3BVOft92sS7/gBKx74/JhE+ue1PVeg/EcFn6JRB87 nFKu1O4heNI0UH3O1LbmgCrsTGvuHaX9zGi1gct5yIwDju61E1Gu+jYleK1CbKTOGs/h3H VxHIIq9OmmetdlnfcwSojlwbV0KO58s6IU/4XmiZ4mjf/NHi/Ivy//JHQY5DFA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713324825; a=rsa-sha256; cv=none; b=O1rwDfwMXF0HKfN7n8PMEvaskKNfWgOn9PbUVld9ZJVPoxqmwGHj+hYT1IXkyx2D6rrbNQ PTtJxgsu0La2DMCSoCkzDo63N57GrL5dg9KDkWdCd9AJX3eyi0jb58msIIXp1jljKNV/GR 3AD3SyYsopwpns/5eLjtMZvjJD56r6kwYxwYDW2xlufAgixEFSPppXWyqoCpyCSynPvZw4 YVPMZN+Sd7Ki9fVWL8ic30NjZEfYUA9yFbH8YHnhd6b7YomE25Rkkmln8V2z+SnbO+8Fcg 5je1W3qfAKCfcuaxEjgTmkspLJgLtlwGkxOuoTkqGQNrw6upXGVsIV42SRw/7Q== 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=1713324825; 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=bGuWswC+stepEtRcOhaJBN1HScVXtxlLNBMwu45RJdU=; b=DEyl46IeDSUToVSKcqbMK0poxpy4iEZUfIg7hx9ntAaszptIjScNyYNGx7oFPc2xvOq+hT ho1GWn8hzqHCcTYCEtocZHgSa8+HBG5OF2MwTrgdwod9wqc8FlhR7KYfuiWFRJXTIuip4a RrKJw2Jw70UYmsfQLc4KTIeqRSf4GWo05nFWZvAZkukY1ZlfCzgYg+p+Za7ntHSgxL8Y/j VuVGE+FkO1XRjlbHgVPNrerGzuxfWGtm3ZJJic5DNruMyM0mFtiaMOwhLVT4fcQs1tgyir 4VaZy/JVK/0OvkyKRHk0xnzptHztHdYcZGqEBkPTGwCE7fG9EnoR+zJJl8ilGQ== 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 4VK62K3JnGz18vK; Wed, 17 Apr 2024 03:33:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43H3Xj2R086816; Wed, 17 Apr 2024 03:33:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43H3XjG2086813; Wed, 17 Apr 2024 03:33:45 GMT (envelope-from git) Date: Wed, 17 Apr 2024 03:33:45 GMT Message-Id: <202404170333.43H3XjG2086813@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 729ee4c88f2a - main - nvmecontrol: Move smart/health printing to little endian orderinng List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 729ee4c88f2af4560adec39fd709ff89bb597e4a Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=729ee4c88f2af4560adec39fd709ff89bb597e4a commit 729ee4c88f2af4560adec39fd709ff89bb597e4a Author: Warner Losh AuthorDate: 2024-04-16 22:36:05 +0000 Commit: Warner Losh CommitDate: 2024-04-17 03:30:18 +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 --- 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 276932d363e5..0ae2c52155b4 100644 --- a/sbin/nvmecontrol/logpage.c +++ b/sbin/nvmecontrol/logpage.c @@ -219,10 +219,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; @@ -265,17 +261,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); @@ -285,9 +281,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); @@ -295,13 +291,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)); } } @@ -325,7 +321,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"); @@ -342,13 +338,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))); @@ -371,18 +367,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