Skip to content

Commit 7c600df

Browse files
minwooimPatchew Applier
authored and
Patchew Applier
committed
hw/nvme: add Identify Endurance Group List
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]> Message-Id: <[email protected]>
1 parent 0142093 commit 7c600df

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

hw/nvme/ctrl.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5629,6 +5629,26 @@ static uint16_t nvme_identify_nslist_csi(NvmeCtrl *n, NvmeRequest *req,
56295629
return nvme_c2h(n, list, data_len, req);
56305630
}
56315631

5632+
static uint16_t nvme_endurance_group_list(NvmeCtrl *n, NvmeRequest *req)
5633+
{
5634+
uint16_t list[NVME_CONTROLLER_LIST_SIZE] = {};
5635+
uint16_t *nr_ids = &list[0];
5636+
uint16_t *ids = &list[1];
5637+
uint16_t endgid = le32_to_cpu(req->cmd.cdw11) & 0xffff;
5638+
5639+
/*
5640+
* The current nvme-subsys only supports Endurance Group #1.
5641+
*/
5642+
if (!endgid) {
5643+
*nr_ids = 1;
5644+
ids[0] = 1;
5645+
} else {
5646+
*nr_ids = 0;
5647+
}
5648+
5649+
return nvme_c2h(n, list, sizeof(list), req);
5650+
}
5651+
56325652
static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req)
56335653
{
56345654
NvmeNamespace *ns;
@@ -5744,6 +5764,8 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeRequest *req)
57445764
return nvme_identify_nslist(n, req, false);
57455765
case NVME_ID_CNS_CS_NS_ACTIVE_LIST:
57465766
return nvme_identify_nslist_csi(n, req, true);
5767+
case NVME_ID_CNS_ENDURANCE_GROUP_LIST:
5768+
return nvme_endurance_group_list(n, req);
57475769
case NVME_ID_CNS_CS_NS_PRESENT_LIST:
57485770
return nvme_identify_nslist_csi(n, req, false);
57495771
case NVME_ID_CNS_NS_DESCR_LIST:

include/block/nvme.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ enum NvmeIdCns {
10741074
NVME_ID_CNS_CTRL_LIST = 0x13,
10751075
NVME_ID_CNS_PRIMARY_CTRL_CAP = 0x14,
10761076
NVME_ID_CNS_SECONDARY_CTRL_LIST = 0x15,
1077+
NVME_ID_CNS_ENDURANCE_GROUP_LIST = 0x19,
10771078
NVME_ID_CNS_CS_NS_PRESENT_LIST = 0x1a,
10781079
NVME_ID_CNS_CS_NS_PRESENT = 0x1b,
10791080
NVME_ID_CNS_IO_COMMAND_SET = 0x1c,

0 commit comments

Comments
 (0)