[PATCHv3 03/11] nvmet: implement supported log pages
Keith Busch
kbusch at meta.com
Tue Nov 5 09:48:56 PST 2024
From: Keith Busch <kbusch at kernel.org>
This log is required for nvme 2.1.
Signed-off-by: Keith Busch <kbusch at kernel.org>
---
drivers/nvme/target/admin-cmd.c | 29 +++++++++++++++++++++++++++++
include/linux/nvme.h | 1 +
2 files changed, 30 insertions(+)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index a13242e791c0f..b8229d6c9998d 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -71,6 +71,33 @@ static void nvmet_execute_get_log_page_error(struct nvmet_req *req)
nvmet_req_complete(req, 0);
}
+static void nvmet_execute_get_supported_log_pages(struct nvmet_req *req)
+{
+ __le32 *logs;
+ u16 status;
+
+ logs = kzalloc(1024, GFP_KERNEL);
+ if (!logs) {
+ status = NVME_SC_INTERNAL;
+ goto out;
+ }
+
+ logs[NVME_LOG_SUPPORTED] = cpu_to_le32(1);
+ logs[NVME_LOG_ERROR] = cpu_to_le32(1);
+ logs[NVME_LOG_SMART] = cpu_to_le32(1);
+ logs[NVME_LOG_FW_SLOT] = cpu_to_le32(1);
+ logs[NVME_LOG_CHANGED_NS] = cpu_to_le32(1);
+ logs[NVME_LOG_CMD_EFFECTS] = cpu_to_le32(1);
+ logs[NVME_LOG_ENDURANCE_GROUP] = cpu_to_le32(1);
+ logs[NVME_LOG_ANA] = cpu_to_le32(1);
+ logs[NVME_LOG_RMI] = cpu_to_le32(1);
+
+ status = nvmet_copy_to_sgl(req, 0, logs, 1024);
+ kfree(logs);
+out:
+ nvmet_req_complete(req, 0);
+}
+
static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
struct nvme_smart_log *slog)
{
@@ -323,6 +350,8 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
return;
switch (req->cmd->get_log_page.lid) {
+ case NVME_LOG_SUPPORTED:
+ return nvmet_execute_get_supported_log_pages(req);
case NVME_LOG_ERROR:
return nvmet_execute_get_log_page_error(req);
case NVME_LOG_SMART:
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 0f263c7e63192..a94e2280d350e 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -1245,6 +1245,7 @@ enum {
NVME_FEAT_WRITE_PROTECT = 0x84,
NVME_FEAT_VENDOR_START = 0xC0,
NVME_FEAT_VENDOR_END = 0xFF,
+ NVME_LOG_SUPPORTED = 0x00,
NVME_LOG_ERROR = 0x01,
NVME_LOG_SMART = 0x02,
NVME_LOG_FW_SLOT = 0x03,
--
2.43.5
More information about the Linux-nvme
mailing list