git: 1bc8c6d40dc1 - stable/14 - nvmecontrol: Move sanitize status page printing to little endian orderinng

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 27 Aug 2024 01:06:46 UTC
The branch stable/14 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=1bc8c6d40dc19cc9a42abe2e8834e8a5dc3855d6

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

    nvmecontrol: Move sanitize status page printing to little endian orderinng
    
    Sponsored by:           Netflix
    Reviewed by:            chuck
    Differential Revision:  https://reviews.freebsd.org/D44657
    
    (cherry picked from commit 55a1679ece1f56beda5f68e929a6b2fc553fb501)
---
 sbin/nvmecontrol/logpage.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/sbin/nvmecontrol/logpage.c b/sbin/nvmecontrol/logpage.c
index b4f9996b10c2..a01ce8d0f237 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_SANITIZE_STATUS:
-		nvme_sanitize_status_page_swapbytes(
-		    (struct nvme_sanitize_status_page *)payload);
-		break;
 	case INTEL_LOG_TEMP_STATS:
 		intel_log_temp_stats_swapbytes(
 		    (struct intel_log_temp_stats *)payload);
@@ -499,15 +495,18 @@ print_log_sanitize_status(const struct nvme_controller_data *cdata __unused,
 {
 	struct nvme_sanitize_status_page *ss;
 	u_int p;
+	uint16_t sprog, sstat;
 
 	ss = (struct nvme_sanitize_status_page *)buf;
 	printf("Sanitize Status\n");
 	printf("===============\n");
 
+	sprog = letoh(ss->sprog);
 	printf("Sanitize Progress:                   %u%% (%u/65535)\n",
-	    (ss->sprog * 100 + 32768) / 65536, ss->sprog);
+	    (sprog * 100 + 32768) / 65536, sprog);
 	printf("Sanitize Status:                     ");
-	switch (NVMEV(NVME_SS_PAGE_SSTAT_STATUS, ss->sstat)) {
+	sstat = letoh(ss->sstat);
+	switch (NVMEV(NVME_SS_PAGE_SSTAT_STATUS, sstat)) {
 	case NVME_SS_PAGE_SSTAT_STATUS_NEVER:
 		printf("Never sanitized");
 		break;
@@ -524,22 +523,22 @@ print_log_sanitize_status(const struct nvme_controller_data *cdata __unused,
 		printf("Completed with deallocation");
 		break;
 	default:
-		printf("Unknown");
+		printf("Unknown 0x%x", sstat);
 		break;
 	}
-	p = NVMEV(NVME_SS_PAGE_SSTAT_PASSES, ss->sstat);
+	p = NVMEV(NVME_SS_PAGE_SSTAT_PASSES, sstat);
 	if (p > 0)
 		printf(", %d passes", p);
-	if (NVMEV(NVME_SS_PAGE_SSTAT_GDE, ss->sstat) != 0)
+	if (NVMEV(NVME_SS_PAGE_SSTAT_GDE, sstat) != 0)
 		printf(", Global Data Erased");
 	printf("\n");
-	printf("Sanitize Command Dword 10:           0x%x\n", ss->scdw10);
-	printf("Time For Overwrite:                  %u sec\n", ss->etfo);
-	printf("Time For Block Erase:                %u sec\n", ss->etfbe);
-	printf("Time For Crypto Erase:               %u sec\n", ss->etfce);
-	printf("Time For Overwrite No-Deallocate:    %u sec\n", ss->etfownd);
-	printf("Time For Block Erase No-Deallocate:  %u sec\n", ss->etfbewnd);
-	printf("Time For Crypto Erase No-Deallocate: %u sec\n", ss->etfcewnd);
+	printf("Sanitize Command Dword 10:           0x%x\n", letoh(ss->scdw10));
+	printf("Time For Overwrite:                  %u sec\n", letoh(ss->etfo));
+	printf("Time For Block Erase:                %u sec\n", letoh(ss->etfbe));
+	printf("Time For Crypto Erase:               %u sec\n", letoh(ss->etfce));
+	printf("Time For Overwrite No-Deallocate:    %u sec\n", letoh(ss->etfownd));
+	printf("Time For Block Erase No-Deallocate:  %u sec\n", letoh(ss->etfbewnd));
+	printf("Time For Crypto Erase No-Deallocate: %u sec\n", letoh(ss->etfcewnd));
 }
 
 static const char *