From nobody Tue Aug 27 01:06:36 2024 X-Original-To: dev-commits-src-all@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 4Wt8Wd3zrhz5Thsj; Tue, 27 Aug 2024 01:06:37 +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 4Wt8Wd1Cv1z4lnG; Tue, 27 Aug 2024 01:06:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724720797; 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=P1xfbSZAQI84PkblpNl787qSMuMRDysuuufwPD3tFUc=; b=WyyXAGMTHutr9Aru47jnfkf9h/QhsahYi4Ler0Vni5id9pA+Gi+HaayELoyBrvkiePQM0G wUqX2Wmz0ZyqBIMKgqA4YHZk7HdIY/ORIwpmM/Pmljs9iP7y10JOJ0cx0Z70npdY6pLhwT BSDT5v6seEBiU1FbVAkeHPPieDLX4qZlLbF3pqrfqfLa43pRS8hhu35T9+Jm46mBtRMjf7 yv/d1zlkWcNcguypUZNnz7OkF8BrSpByOPm6y5nXf+xEUnngizJXyn1DRi+xtjMPxTkjLt rggaGefL6SdqOyjNoYhgh9Kzs4ZXx1K+MZfJLhpUNyPMGR/RpfwBKyV+7IHjyg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724720797; a=rsa-sha256; cv=none; b=S23P7JYQEEYliGqJ1v9C6XXjcs3DvHhTNEh1YuaxNAZ9GDYJSm0pA7fhjVTMzJvIQFobo5 I1qkGZtF1TF1F6/DAKlQqZS5Ppbfo9YKgE/UVocdem1vL9J+sS8COkbdMTurkBABuyNd3I hp/zeDBxb8E6qRB3s9ehglMmpC8ih9DxfCKSBwUO9jqqVeIq57LeUCPXZpbhYiu3gmckn5 KVAS9H1e3ss9+md8rbzwk9EDNb4R3+3JA7HtTjTmJ1iodkI3QyoeTY85vruHGLgidpWV51 1JySFJd8g79q1KMSiz8V9sDMi22+/7WbRjJybeWsAUZzCmuNANlMuSbBvDliwA== 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=1724720797; 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=P1xfbSZAQI84PkblpNl787qSMuMRDysuuufwPD3tFUc=; b=RJEsC3XEDLS+k0Yv3j8WzWZcyHmpLbBsyA8ArdNCp7oejzLUmxreyM2DKFe/HMkhKjKTtt ZwlLmeowfZO7F87sP4d5qA5W0PIyx/8kdBBwqtgY9NnbDw04pkWVSC/A38yy345vJPy7mr D9WCEh7uH79n7ShuodjyMOyt8NfawgpN2h4W24BxVR9cgT/lp9bwER+vYuINlmYvYTPX4w OUi9XN2rXvklhZrmN4i0Ee3ZO1fx7begMzcAp4y6h7IZfafUebZZ2NzZe1bQzaEmPzeYKV qGrMhtA1H7GAczowR7cA44pAK0Yst3vwKG0DlftpYEndTV1xR7XAunGe+G8o8A== 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 4Wt8Wd0S2fzSkH; Tue, 27 Aug 2024 01:06:37 +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 47R16aFD056987; Tue, 27 Aug 2024 01:06:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47R16aZP056984; Tue, 27 Aug 2024 01:06:36 GMT (envelope-from git) Date: Tue, 27 Aug 2024 01:06:36 GMT Message-Id: <202408270106.47R16aZP056984@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: d20b149786cb - stable/14 - nvmecontrol: Make the error log page work on native format List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: d20b149786cbd2c983eeaffce9c51c0a767cadc7 Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d20b149786cbd2c983eeaffce9c51c0a767cadc7 commit d20b149786cbd2c983eeaffce9c51c0a767cadc7 Author: Warner Losh AuthorDate: 2024-04-16 22:35:46 +0000 Commit: John Baldwin CommitDate: 2024-08-26 18:31:02 +0000 nvmecontrol: Make the error log page work on native format As the number of page types proliferates, it becomes untennable to convert them in read_logpage (especailly since new UUID page types will need to be supported). Convert the error page printing code to operate on little endian data. Sponsored by: Netflix Reviewed by: chuck Differential Revision: https://reviews.freebsd.org/D44680 (cherry picked from commit 85656a9a015339f3d412e5b1888e798bb3e7d4ba) --- sbin/nvmecontrol/logpage.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/sbin/nvmecontrol/logpage.c b/sbin/nvmecontrol/logpage.c index 6bdf83abefea..a6242bd4a440 100644 --- a/sbin/nvmecontrol/logpage.c +++ b/sbin/nvmecontrol/logpage.c @@ -194,8 +194,7 @@ read_logpage(int fd, uint8_t log_page, uint32_t nsid, uint8_t lsp, uint16_t lsi, uint8_t rae, void *payload, uint32_t payload_size) { struct nvme_pt_command pt; - struct nvme_error_information_entry *err_entry; - u_int i, err_pages, numd; + u_int numd; numd = payload_size / sizeof(uint32_t) - 1; memset(&pt, 0, sizeof(pt)); @@ -221,12 +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_ERROR: - err_entry = (struct nvme_error_information_entry *)payload; - err_pages = payload_size / sizeof(struct nvme_error_information_entry); - for (i = 0; i < err_pages; i++) - nvme_error_information_entry_swapbytes(err_entry++); - break; case NVME_LOG_HEALTH_INFORMATION: nvme_health_information_page_swapbytes( (struct nvme_health_information_page *)payload); @@ -273,17 +266,17 @@ print_log_error(const struct nvme_controller_data *cdata __unused, void *buf, ui printf("Error Information Log\n"); printf("=====================\n"); - if (entry->error_count == 0) { + if (LE2H(entry->error_count) == 0) { printf("No error entries found\n"); return; } - nentries = size/sizeof(struct nvme_error_information_entry); + nentries = size / sizeof(struct nvme_error_information_entry); for (i = 0; i < nentries; i++, entry++) { - if (entry->error_count == 0) + if (LE2H(entry->error_count) == 0) break; - status = entry->status; + status = LE2H(entry->status); p = NVME_STATUS_GET_P(status); sc = NVME_STATUS_GET_SC(status); @@ -293,9 +286,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", entry->error_count); - printf(" Submission queue ID: %u\n", entry->sqid); - printf(" Command ID: %u\n", entry->cid); + 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)); /* TODO: Export nvme_status_string structures from kernel? */ printf(" Status:\n"); printf(" Phase tag: %d\n", p); @@ -303,13 +296,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", entry->error_location); - printf(" LBA: %ju\n", entry->lba); - printf(" Namespace ID: %u\n", entry->nsid); - printf(" Vendor specific info: %u\n", entry->vendor_specific); - printf(" Transport type: %u\n", entry->trtype); - printf(" Command specific info:%ju\n", entry->csi); - printf(" Transport specific: %u\n", entry->ttsi); + 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)); } }