From: Gollu Appalanaidu Date: Fri, 5 Nov 2021 16:35:24 +0000 (+0100) Subject: types: add identify endurance group list (cns 0x19) support X-Git-Tag: v1.0-rc0~54^2~4 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b35d13046bd65e104cd5b41a7fd00a0718fc489c;p=users%2Fsagi%2Flibnvme.git types: add identify endurance group list (cns 0x19) support Signed-off-by: Gollu Appalanaidu [dwagner: ported from nvme-cli-monolithic] Signed-off-by: Daniel Wagner --- diff --git a/src/libnvme.map b/src/libnvme.map index 82304c83..aeed21c0 100644 --- a/src/libnvme.map +++ b/src/libnvme.map @@ -143,6 +143,7 @@ nvme_identify_ctrl; nvme_identify_ctrl_list; nvme_identify_domain_list; + nvme_identify_endurance_group_list; nvme_identify_independent_identify_ns; nvme_identify_iocs; nvme_identify_ns; diff --git a/src/nvme/ioctl.c b/src/nvme/ioctl.c index d5d8207d..d1060ded 100644 --- a/src/nvme/ioctl.c +++ b/src/nvme/ioctl.c @@ -531,6 +531,16 @@ int nvme_identify_domain_list(int fd, __u16 domid, domid, NVME_UUID_NONE, NVME_CSI_NVM, list); } +int nvme_identify_endurance_group_list(int fd, __u16 endgrp_id, + struct nvme_id_endurance_group_list *list) +{ + BUILD_ASSERT(sizeof(struct nvme_id_endurance_group_list) == 4096); + return nvme_identify(fd, NVME_IDENTIFY_CNS_ENDURANCE_GROUP_ID, + NVME_NSID_NONE, NVME_CNTLID_NONE, + NVME_NVMSETID_NONE, endgrp_id, NVME_UUID_NONE, + NVME_CSI_NVM, list); +} + int nvme_identify_independent_identify_ns(int fd, __u32 nsid, struct nvme_id_independent_id_ns *ns) { diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index 82c1ea0d..0a0e3046 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -724,6 +724,18 @@ int nvme_nvm_identify_ctrl(int fd, struct nvme_id_ctrl_nvm *id); int nvme_identify_domain_list(int fd, __u16 domid, struct nvme_id_domain_list *list); +/** + * nvme_identifiy_endurance_group_list() - + * @fd: File descriptor of nvme device + * @endgrp_id: Endurance group identifier + * @list: Array of endurance group identifiers + * + * Return: The nvme command status if a response was received (see + * &enum nvme_status_field) or -1 with errno set otherwise. + */ +int nvme_identify_endurance_group_list(int fd, __u16 endgrp_id, + struct nvme_id_endurance_group_list *list); + /** * nvme_identify_iocs() - * @fd: File descriptor of nvme device diff --git a/src/nvme/types.h b/src/nvme/types.h index bdbcb7b9..f020bab0 100644 --- a/src/nvme/types.h +++ b/src/nvme/types.h @@ -98,6 +98,7 @@ enum nvme_constants { NVME_ID_NS_LIST_MAX = 1024, NVME_ID_SECONDARY_CTRL_MAX = 127, NVME_ID_DOMAIN_LIST_MAX = 31, + NVME_ID_ENDURANCE_GROUP_LIST_MAX = 2047, NVME_ID_ND_DESCRIPTOR_MAX = 16, NVME_FEAT_LBA_RANGE_MAX = 64, NVME_LOG_ST_MAX_RESULTS = 20, @@ -2210,6 +2211,16 @@ struct nvme_id_domain_list { struct nvme_id_domain_attr domain_attr[NVME_ID_DOMAIN_LIST_MAX]; }; +/** + * struct nvme_id_endurance_group_list - + * @num: + * @identifier: + */ +struct nvme_id_endurance_group_list { + __le16 num; + __le16 identifier[NVME_ID_ENDURANCE_GROUP_LIST_MAX]; +}; + /** * struct nvme_supported_log_pages - * @lid_support: @@ -5066,6 +5077,7 @@ enum nvme_admin_opcode { * @NVME_IDENTIFY_CNS_NS_GRANULARITY: * @NVME_IDENTIFY_CNS_UUID_LIST: * @NVME_IDENTIFY_CNS_DOMAIN_LIST: + * @NVME_IDENTIFY_CNS_ENDURANCE_GROUP_ID: * @NVME_IDENTIFY_CNS_CSI_ALLOCATED_NS_LIST: * @NVME_IDENTIFY_CNS_COMMAND_SET_STRUCTURE: Base Specification 2.0a section 5.17.2.21 */ @@ -5088,6 +5100,7 @@ enum nvme_identify_cns { NVME_IDENTIFY_CNS_NS_GRANULARITY = 0x16, NVME_IDENTIFY_CNS_UUID_LIST = 0x17, NVME_IDENTIFY_CNS_DOMAIN_LIST = 0x18, + NVME_IDENTIFY_CNS_ENDURANCE_GROUP_ID = 0x19, NVME_IDENTIFY_CNS_CSS_ALLOCATED_NS_LIST = 0x1A, NVME_IDENTIFY_CNS_COMMAND_SET_STRUCTURE = 0x1C, };