Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Aug 2024 01:06:51 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: efb91b313c64 - stable/14 - nvmecontrol: Add nvme 2.0 fields to read_logpage
Message-ID:  <202408270106.47R16pnU057683@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=efb91b313c644c6bd50b24685a16cff83eb41a07

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

    nvmecontrol: Add nvme 2.0 fields to read_logpage
    
    Add the lpo, ot, csi and uuid_index fields to read_logpage. The logpage
    command has not been updated to allow these to be specified.
    
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D44683
    
    (cherry picked from commit 98ab7d0a30f8d0fc9c51e1e97ac29f87750b526c)
---
 sbin/nvmecontrol/firmware.c    |  3 ++-
 sbin/nvmecontrol/logpage.c     | 15 ++++++++++-----
 sbin/nvmecontrol/nvmecontrol.h |  3 ++-
 sbin/nvmecontrol/sanitize.c    |  3 ++-
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/sbin/nvmecontrol/firmware.c b/sbin/nvmecontrol/firmware.c
index 8fcc4ba4f46e..74d185313f50 100644
--- a/sbin/nvmecontrol/firmware.c
+++ b/sbin/nvmecontrol/firmware.c
@@ -103,7 +103,8 @@ slot_has_valid_firmware(int fd, int slot)
 	int				has_fw = false;
 
 	read_logpage(fd, NVME_LOG_FIRMWARE_SLOT,
-	    NVME_GLOBAL_NAMESPACE_TAG, 0, 0, 0, &fw, sizeof(fw));
+	    NVME_GLOBAL_NAMESPACE_TAG, 0, 0, 0, 0, 0, 0, 0,
+	    &fw, sizeof(fw));
 
 	if (fw.revision[slot-1][0] != '\0')
 		has_fw = true;
diff --git a/sbin/nvmecontrol/logpage.c b/sbin/nvmecontrol/logpage.c
index 385b7d70c2aa..770eed3d7848 100644
--- a/sbin/nvmecontrol/logpage.c
+++ b/sbin/nvmecontrol/logpage.c
@@ -191,7 +191,8 @@ get_log_buffer(uint32_t size)
 
 void
 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)
+    uint16_t lsi, uint8_t rae, uint64_t lpo, uint8_t csi, uint8_t ot,
+    uint16_t uuid_index, void *payload, uint32_t payload_size)
 {
 	struct nvme_pt_command	pt;
 	u_int numd;
@@ -208,9 +209,12 @@ read_logpage(int fd, uint8_t log_page, uint32_t nsid, uint8_t lsp,
 	pt.cmd.cdw11 = htole32(
 	    ((uint32_t)lsi << 16) |		/* LSI */
 	    (numd >> 16));			/* NUMDU */
-	pt.cmd.cdw12 = 0;			/* LPOL */
-	pt.cmd.cdw13 = 0;			/* LPOU */
-	pt.cmd.cdw14 = 0;			/* UUID Index */
+	pt.cmd.cdw12 = htole32(lpo & 0xffffffff); /* LPOL */
+	pt.cmd.cdw13 = htole32(lpo >> 32);	/* LPOU */
+	pt.cmd.cdw14 = htole32(
+	    (csi << 24) | 			/* CSI */
+	    (ot << 23) |			/* OT */
+	    uuid_index);			/* UUID Index */
 	pt.buf = payload;
 	pt.len = payload_size;
 	pt.is_read = 1;
@@ -795,7 +799,8 @@ logpage(const struct cmd *f, int argc, char *argv[])
 
 	/* Read the log page */
 	buf = get_log_buffer(size);
-	read_logpage(fd, opt.page, nsid, opt.lsp, opt.lsi, opt.rae, buf, size);
+	read_logpage(fd, opt.page, nsid, opt.lsp, opt.lsi, opt.rae,
+	    0, 0, 0, 0, buf, size);
 	print_fn(&cdata, buf, size);
 
 	close(fd);
diff --git a/sbin/nvmecontrol/nvmecontrol.h b/sbin/nvmecontrol/nvmecontrol.h
index 4187c9bee432..2ce4ad4c5c2b 100644
--- a/sbin/nvmecontrol/nvmecontrol.h
+++ b/sbin/nvmecontrol/nvmecontrol.h
@@ -84,7 +84,8 @@ int read_namespace_data(int fd, uint32_t nsid, struct nvme_namespace_data *nsdat
 void print_hex(void *data, uint32_t length);
 void print_namespace(struct nvme_namespace_data *nsdata);
 void 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);
+    uint16_t lsi, uint8_t rae, uint64_t lpo, uint8_t csi, uint8_t ot,
+    uint16_t uuid_index, void *payload, uint32_t payload_size);
 void print_temp_C(uint16_t t);
 void print_temp_K(uint16_t t);
 void print_intel_add_smart(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused);
diff --git a/sbin/nvmecontrol/sanitize.c b/sbin/nvmecontrol/sanitize.c
index 4611a6964a4d..52e1b0f4dad7 100644
--- a/sbin/nvmecontrol/sanitize.c
+++ b/sbin/nvmecontrol/sanitize.c
@@ -183,7 +183,8 @@ sanitize(const struct cmd *f, int argc, char *argv[])
 
 wait:
 	read_logpage(fd, NVME_LOG_SANITIZE_STATUS,
-	    NVME_GLOBAL_NAMESPACE_TAG, 0, 0, 0, &ss, sizeof(ss));
+	    NVME_GLOBAL_NAMESPACE_TAG, 0, 0, 0,
+	    0, 0, 0, 0, &ss, sizeof(ss));
 	switch (NVMEV(NVME_SS_PAGE_SSTAT_STATUS, ss.sstat)) {
 	case NVME_SS_PAGE_SSTAT_STATUS_NEVER:
 		printf("Never sanitized");



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