[PATCHv3 04/11] nvmet: implement supported features log

Keith Busch kbusch at meta.com
Tue Nov 5 09:48:57 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 | 25 +++++++++++++++++++++++++
 include/linux/nvme.h            |  1 +
 2 files changed, 26 insertions(+)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index b8229d6c9998d..c9b38d593fda5 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -344,6 +344,29 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
 	nvmet_req_complete(req, status);
 }
 
+static void nvmet_execute_get_log_page_features(struct nvmet_req *req)
+{
+	__le32 *features;
+	u16 status;
+
+	features = kzalloc(1024, GFP_KERNEL);
+	if (!features) {
+		status = NVME_SC_INTERNAL;
+		goto out;
+	}
+
+	features[NVME_FEAT_NUM_QUEUES] = cpu_to_le32(1 << 21 | 1);
+	features[NVME_FEAT_KATO] = cpu_to_le32(1 << 21 | 1);
+	features[NVME_FEAT_ASYNC_EVENT] = cpu_to_le32(1 << 21 | 1);
+	features[NVME_FEAT_HOST_ID] = cpu_to_le32(1 << 21 | 1);
+	features[NVME_FEAT_WRITE_PROTECT] = cpu_to_le32(1 << 20 | 1);
+
+	status = nvmet_copy_to_sgl(req, 0, features, 1024);
+	kfree(features);
+out:
+	nvmet_req_complete(req, status);
+}
+
 static void nvmet_execute_get_log_page(struct nvmet_req *req)
 {
 	if (!nvmet_check_transfer_len(req, nvmet_get_log_page_len(req->cmd)))
@@ -369,6 +392,8 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
 		return nvmet_execute_get_log_cmd_effects_ns(req);
 	case NVME_LOG_ANA:
 		return nvmet_execute_get_log_page_ana(req);
+	case NVME_LOG_FEATURES:
+		return nvmet_execute_get_log_page_features(req);
 	}
 	pr_debug("unhandled lid %d on qid %d\n",
 	       req->cmd->get_log_page.lid, req->sq->qid);
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index a94e2280d350e..b1238691bd491 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -1256,6 +1256,7 @@ enum {
 	NVME_LOG_TELEMETRY_CTRL = 0x08,
 	NVME_LOG_ENDURANCE_GROUP = 0x09,
 	NVME_LOG_ANA		= 0x0c,
+	NVME_LOG_FEATURES	= 0x12,
 	NVME_LOG_DISC		= 0x70,
 	NVME_LOG_RESERVATION	= 0x80,
 	NVME_FWACT_REPL		= (0 << 3),
-- 
2.43.5




More information about the Linux-nvme mailing list