Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Aug 2024 01:06:42 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 067abd7d0b06 - stable/14 - nvmecontrol: Move self test status page printing to little endian orderinng
Message-ID:  <202408270106.47R16guu057262@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=067abd7d0b0678cba0dede7e1813660e9e269d6e

commit 067abd7d0b0678cba0dede7e1813660e9e269d6e
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-04-16 22:36:19 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-08-26 18:31:02 +0000

    nvmecontrol: Move self test status page printing to little endian orderinng
    
    Also, add printing vnedor_specific field, which doesn't have a valid
    bit, so is always valid.
    
    Sponsored by:           Netflix
    Reviewed by:            chuck
    Differential Revision:  https://reviews.freebsd.org/D44654
    
    (cherry picked from commit 98f841efd8ce387d9cd060174b9dcc9ff9850648)
---
 sbin/nvmecontrol/logpage.c | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/sbin/nvmecontrol/logpage.c b/sbin/nvmecontrol/logpage.c
index 845dad0cd539..897bb7a59118 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_DEVICE_SELF_TEST:
-		nvme_device_self_test_swapbytes(
-		    (struct nvme_device_self_test_page *)payload);
-		break;
 	case NVME_LOG_COMMAND_EFFECT:
 		nvme_command_effects_page_swapbytes(
 		    (struct nvme_command_effects_page *)payload);
@@ -574,13 +570,14 @@ print_log_self_test_status(const struct nvme_controller_data *cdata __unused,
 {
 	struct nvme_device_self_test_page *dst;
 	uint32_t r;
+	uint16_t vs;
 
 	dst = buf;
 	printf("Device Self-test Status\n");
 	printf("=======================\n");
 
 	printf("Current Operation: ");
-	switch (dst->curr_operation) {
+	switch (letoh(dst->curr_operation)) {
 	case 0x0:
 		printf("No device self-test operation in progress\n");
 		break;
@@ -594,19 +591,20 @@ print_log_self_test_status(const struct nvme_controller_data *cdata __unused,
 		printf("Vendor specific\n");
 		break;
 	default:
-		printf("Reserved (0x%x)\n", dst->curr_operation);
+		printf("Reserved (0x%x)\n", letoh(dst->curr_operation));
 	}
 
-	if (dst->curr_operation != 0)
-		printf("Current Completion: %u%%\n", dst->curr_compl & 0x7f);
+	if (letoh(dst->curr_operation) != 0)
+		printf("Current Completion: %u%%\n", letoh(dst->curr_compl) & 0x7f);
 
 	printf("Results\n");
 	for (r = 0; r < 20; r++) {
 		uint64_t failing_lba;
-		uint8_t code, res;
+		uint8_t code, res, status;
 
-		code = (dst->result[r].status >> 4) & 0xf;
-		res  = dst->result[r].status & 0xf;
+		status = letoh(dst->result[r].status);
+		code = (status >> 4) & 0xf;
+		res  = status & 0xf;
 
 		if (res == 0xf)
 			continue;
@@ -631,21 +629,24 @@ print_log_self_test_status(const struct nvme_controller_data *cdata __unused,
 			printf(" Reserved status 0x%x", res);
 
 		if (res == 7)
-			printf(" starting in segment %u", dst->result[r].segment_num);
+			printf(" starting in segment %u",
+			    letoh(dst->result[r].segment_num));
 
 #define BIT(b) (1 << (b))
-		if (dst->result[r].valid_diag_info & BIT(0))
-			printf(" NSID=0x%x", dst->result[r].nsid);
-		if (dst->result[r].valid_diag_info & BIT(1)) {
+		if (letoh(dst->result[r].valid_diag_info) & BIT(0))
+			printf(" NSID=0x%x", letoh(dst->result[r].nsid));
+		if (letoh(dst->result[r].valid_diag_info) & BIT(1)) {
 			memcpy(&failing_lba, dst->result[r].failing_lba,
 			    sizeof(failing_lba));
-			printf(" FLBA=0x%jx", failing_lba);
+			printf(" FLBA=0x%jx", (uintmax_t)letoh(failing_lba));
 		}
-		if (dst->result[r].valid_diag_info & BIT(2))
-			printf(" SCT=0x%x", dst->result[r].status_code_type);
-		if (dst->result[r].valid_diag_info & BIT(3))
-			printf(" SC=0x%x", dst->result[r].status_code);
+		if (letoh(dst->result[r].valid_diag_info) & BIT(2))
+			printf(" SCT=0x%x", letoh(dst->result[r].status_code_type));
+		if (letoh(dst->result[r].valid_diag_info) & BIT(3))
+			printf(" SC=0x%x", letoh(dst->result[r].status_code));
 #undef BIT
+		memcpy(&vs, dst->result[r].vendor_specific, sizeof(vs));
+		printf(" VENDOR_SPECIFIC=0x%x", letoh(vs));
 		printf("\n");
 	}
 }



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