]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nvmet: implement supported log pages
authorKeith Busch <kbusch@kernel.org>
Mon, 4 Nov 2024 22:00:14 +0000 (14:00 -0800)
committerKeith Busch <kbusch@kernel.org>
Mon, 11 Nov 2024 17:49:48 +0000 (09:49 -0800)
This log is required for nvme 2.1.

Reviewed-by: Matias Bjørling <matias.bjorling@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/target/admin-cmd.c
include/linux/nvme.h

index c59e21434833ecb1d9dd3061c5d9ca4e2c8a079f..cbbf911c5cc0d1380a6a6816d2922c0db9978de4 100644 (file)
@@ -71,6 +71,32 @@ 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)
+{
+       struct nvme_supported_log *logs;
+       u16 status;
+
+       logs = kzalloc(sizeof(*logs), GFP_KERNEL);
+       if (!logs) {
+               status = NVME_SC_INTERNAL;
+               goto out;
+       }
+
+       logs->lids[NVME_LOG_SUPPORTED] = cpu_to_le32(NVME_LIDS_LSUPP);
+       logs->lids[NVME_LOG_ERROR] = cpu_to_le32(NVME_LIDS_LSUPP);
+       logs->lids[NVME_LOG_SMART] = cpu_to_le32(NVME_LIDS_LSUPP);
+       logs->lids[NVME_LOG_FW_SLOT] = cpu_to_le32(NVME_LIDS_LSUPP);
+       logs->lids[NVME_LOG_CHANGED_NS] = cpu_to_le32(NVME_LIDS_LSUPP);
+       logs->lids[NVME_LOG_CMD_EFFECTS] = cpu_to_le32(NVME_LIDS_LSUPP);
+       logs->lids[NVME_LOG_ANA] = cpu_to_le32(NVME_LIDS_LSUPP);
+       logs->lids[NVME_LOG_RESERVATION] = cpu_to_le32(NVME_LIDS_LSUPP);
+
+       status = nvmet_copy_to_sgl(req, 0, logs, sizeof(*logs));
+       kfree(logs);
+out:
+       nvmet_req_complete(req, status);
+}
+
 static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
                struct nvme_smart_log *slog)
 {
@@ -327,6 +353,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:
index 26de7c5c12be75a14e419212df0ef579475e6428..e9e508bca60f0024cdf399ea720e9f266239fdef 100644 (file)
@@ -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,
@@ -1262,6 +1263,14 @@ enum {
        NVME_FWACT_ACTV         = (2 << 3),
 };
 
+struct nvme_supported_log {
+       __le32  lids[256];
+};
+
+enum {
+       NVME_LIDS_LSUPP = 1 << 0,
+};
+
 /* NVMe Namespace Write Protect State */
 enum {
        NVME_NS_NO_WRITE_PROTECT = 0,