Skip to content

Commit 83acb24

Browse files
committed
nvmet: implement supported log pages
This log is required for nvme 2.1. Reviewed-by: Matias Bjørling <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 61c9967 commit 83acb24

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

drivers/nvme/target/admin-cmd.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,32 @@ static void nvmet_execute_get_log_page_error(struct nvmet_req *req)
7171
nvmet_req_complete(req, 0);
7272
}
7373

74+
static void nvmet_execute_get_supported_log_pages(struct nvmet_req *req)
75+
{
76+
struct nvme_supported_log *logs;
77+
u16 status;
78+
79+
logs = kzalloc(sizeof(*logs), GFP_KERNEL);
80+
if (!logs) {
81+
status = NVME_SC_INTERNAL;
82+
goto out;
83+
}
84+
85+
logs->lids[NVME_LOG_SUPPORTED] = cpu_to_le32(NVME_LIDS_LSUPP);
86+
logs->lids[NVME_LOG_ERROR] = cpu_to_le32(NVME_LIDS_LSUPP);
87+
logs->lids[NVME_LOG_SMART] = cpu_to_le32(NVME_LIDS_LSUPP);
88+
logs->lids[NVME_LOG_FW_SLOT] = cpu_to_le32(NVME_LIDS_LSUPP);
89+
logs->lids[NVME_LOG_CHANGED_NS] = cpu_to_le32(NVME_LIDS_LSUPP);
90+
logs->lids[NVME_LOG_CMD_EFFECTS] = cpu_to_le32(NVME_LIDS_LSUPP);
91+
logs->lids[NVME_LOG_ANA] = cpu_to_le32(NVME_LIDS_LSUPP);
92+
logs->lids[NVME_LOG_RESERVATION] = cpu_to_le32(NVME_LIDS_LSUPP);
93+
94+
status = nvmet_copy_to_sgl(req, 0, logs, sizeof(*logs));
95+
kfree(logs);
96+
out:
97+
nvmet_req_complete(req, status);
98+
}
99+
74100
static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
75101
struct nvme_smart_log *slog)
76102
{
@@ -327,6 +353,8 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
327353
return;
328354

329355
switch (req->cmd->get_log_page.lid) {
356+
case NVME_LOG_SUPPORTED:
357+
return nvmet_execute_get_supported_log_pages(req);
330358
case NVME_LOG_ERROR:
331359
return nvmet_execute_get_log_page_error(req);
332360
case NVME_LOG_SMART:

include/linux/nvme.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,7 @@ enum {
12451245
NVME_FEAT_WRITE_PROTECT = 0x84,
12461246
NVME_FEAT_VENDOR_START = 0xC0,
12471247
NVME_FEAT_VENDOR_END = 0xFF,
1248+
NVME_LOG_SUPPORTED = 0x00,
12481249
NVME_LOG_ERROR = 0x01,
12491250
NVME_LOG_SMART = 0x02,
12501251
NVME_LOG_FW_SLOT = 0x03,
@@ -1262,6 +1263,14 @@ enum {
12621263
NVME_FWACT_ACTV = (2 << 3),
12631264
};
12641265

1266+
struct nvme_supported_log {
1267+
__le32 lids[256];
1268+
};
1269+
1270+
enum {
1271+
NVME_LIDS_LSUPP = 1 << 0,
1272+
};
1273+
12651274
/* NVMe Namespace Write Protect State */
12661275
enum {
12671276
NVME_NS_NO_WRITE_PROTECT = 0,

0 commit comments

Comments
 (0)