Skip to content

Commit e973c91

Browse files
committed
nvmet: implement supported features log
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 83acb24 commit e973c91

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

drivers/nvme/target/admin-cmd.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static void nvmet_execute_get_supported_log_pages(struct nvmet_req *req)
8989
logs->lids[NVME_LOG_CHANGED_NS] = cpu_to_le32(NVME_LIDS_LSUPP);
9090
logs->lids[NVME_LOG_CMD_EFFECTS] = cpu_to_le32(NVME_LIDS_LSUPP);
9191
logs->lids[NVME_LOG_ANA] = cpu_to_le32(NVME_LIDS_LSUPP);
92+
logs->lids[NVME_LOG_FEATURES] = cpu_to_le32(NVME_LIDS_LSUPP);
9293
logs->lids[NVME_LOG_RESERVATION] = cpu_to_le32(NVME_LIDS_LSUPP);
9394

9495
status = nvmet_copy_to_sgl(req, 0, logs, sizeof(*logs));
@@ -347,6 +348,36 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
347348
nvmet_req_complete(req, status);
348349
}
349350

351+
static void nvmet_execute_get_log_page_features(struct nvmet_req *req)
352+
{
353+
struct nvme_supported_features_log *features;
354+
u16 status;
355+
356+
features = kzalloc(sizeof(*features), GFP_KERNEL);
357+
if (!features) {
358+
status = NVME_SC_INTERNAL;
359+
goto out;
360+
}
361+
362+
features->fis[NVME_FEAT_NUM_QUEUES] =
363+
cpu_to_le32(NVME_FIS_FSUPP | NVME_FIS_CSCPE);
364+
features->fis[NVME_FEAT_KATO] =
365+
cpu_to_le32(NVME_FIS_FSUPP | NVME_FIS_CSCPE);
366+
features->fis[NVME_FEAT_ASYNC_EVENT] =
367+
cpu_to_le32(NVME_FIS_FSUPP | NVME_FIS_CSCPE);
368+
features->fis[NVME_FEAT_HOST_ID] =
369+
cpu_to_le32(NVME_FIS_FSUPP | NVME_FIS_CSCPE);
370+
features->fis[NVME_FEAT_WRITE_PROTECT] =
371+
cpu_to_le32(NVME_FIS_FSUPP | NVME_FIS_NSCPE);
372+
features->fis[NVME_FEAT_RESV_MASK] =
373+
cpu_to_le32(NVME_FIS_FSUPP | NVME_FIS_NSCPE);
374+
375+
status = nvmet_copy_to_sgl(req, 0, features, sizeof(*features));
376+
kfree(features);
377+
out:
378+
nvmet_req_complete(req, status);
379+
}
380+
350381
static void nvmet_execute_get_log_page(struct nvmet_req *req)
351382
{
352383
if (!nvmet_check_transfer_len(req, nvmet_get_log_page_len(req->cmd)))
@@ -372,6 +403,8 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
372403
return nvmet_execute_get_log_cmd_effects_ns(req);
373404
case NVME_LOG_ANA:
374405
return nvmet_execute_get_log_page_ana(req);
406+
case NVME_LOG_FEATURES:
407+
return nvmet_execute_get_log_page_features(req);
375408
case NVME_LOG_RESERVATION:
376409
return nvmet_execute_get_log_page_resv(req);
377410
}

include/linux/nvme.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,7 @@ enum {
12561256
NVME_LOG_TELEMETRY_CTRL = 0x08,
12571257
NVME_LOG_ENDURANCE_GROUP = 0x09,
12581258
NVME_LOG_ANA = 0x0c,
1259+
NVME_LOG_FEATURES = 0x12,
12591260
NVME_LOG_DISC = 0x70,
12601261
NVME_LOG_RESERVATION = 0x80,
12611262
NVME_FWACT_REPL = (0 << 3),
@@ -1271,6 +1272,16 @@ enum {
12711272
NVME_LIDS_LSUPP = 1 << 0,
12721273
};
12731274

1275+
struct nvme_supported_features_log {
1276+
__le32 fis[256];
1277+
};
1278+
1279+
enum {
1280+
NVME_FIS_FSUPP = 1 << 0,
1281+
NVME_FIS_NSCPE = 1 << 20,
1282+
NVME_FIS_CSCPE = 1 << 21,
1283+
};
1284+
12741285
/* NVMe Namespace Write Protect State */
12751286
enum {
12761287
NVME_NS_NO_WRITE_PROTECT = 0,

0 commit comments

Comments
 (0)