Skip to content

Commit

Permalink
hw/nvme: add Identify Endurance Group List
Browse files Browse the repository at this point in the history
Commit 73064ed ("hw/nvme: flexible data placement emulation")
intorudced NVMe FDP feature to nvme-subsys and nvme-ctrl with a
single endurance group #1 supported.  This means that controller should
return proper identify data to host with Identify Endurance Group List
(CNS 19h).  But, yes, only just for the endurance group #1.  This patch
allows host applications to ask for which endurance group is available
and utilize FDP through that endurance group.

Reviewed-by: Klaus Jensen <[email protected]>
Signed-off-by: Minwoo Im <[email protected]>
Signed-off-by: Klaus Jensen <[email protected]>
  • Loading branch information
minwooim authored and birkelund committed Jul 11, 2024
1 parent 8ab8a6d commit 6471556
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions hw/nvme/ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -5629,6 +5629,26 @@ static uint16_t nvme_identify_nslist_csi(NvmeCtrl *n, NvmeRequest *req,
return nvme_c2h(n, list, data_len, req);
}

static uint16_t nvme_endurance_group_list(NvmeCtrl *n, NvmeRequest *req)
{
uint16_t list[NVME_CONTROLLER_LIST_SIZE] = {};
uint16_t *nr_ids = &list[0];
uint16_t *ids = &list[1];
uint16_t endgid = le32_to_cpu(req->cmd.cdw11) & 0xffff;

/*
* The current nvme-subsys only supports Endurance Group #1.
*/
if (!endgid) {
*nr_ids = 1;
ids[0] = 1;
} else {
*nr_ids = 0;
}

return nvme_c2h(n, list, sizeof(list), req);
}

static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req)
{
NvmeNamespace *ns;
Expand Down Expand Up @@ -5744,6 +5764,8 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeRequest *req)
return nvme_identify_nslist(n, req, false);
case NVME_ID_CNS_CS_NS_ACTIVE_LIST:
return nvme_identify_nslist_csi(n, req, true);
case NVME_ID_CNS_ENDURANCE_GROUP_LIST:
return nvme_endurance_group_list(n, req);
case NVME_ID_CNS_CS_NS_PRESENT_LIST:
return nvme_identify_nslist_csi(n, req, false);
case NVME_ID_CNS_NS_DESCR_LIST:
Expand Down
1 change: 1 addition & 0 deletions include/block/nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ enum NvmeIdCns {
NVME_ID_CNS_CTRL_LIST = 0x13,
NVME_ID_CNS_PRIMARY_CTRL_CAP = 0x14,
NVME_ID_CNS_SECONDARY_CTRL_LIST = 0x15,
NVME_ID_CNS_ENDURANCE_GROUP_LIST = 0x19,
NVME_ID_CNS_CS_NS_PRESENT_LIST = 0x1a,
NVME_ID_CNS_CS_NS_PRESENT = 0x1b,
NVME_ID_CNS_IO_COMMAND_SET = 0x1c,
Expand Down

0 comments on commit 6471556

Please sign in to comment.