Skip to content

Commit

Permalink
types: Add Identify for CNS 08h NVMe spec 2.0a based
Browse files Browse the repository at this point in the history
I/O Command Set Independent Identify Namespace data structure (CNS
08h) Most of data comes from existing data of id-ns which is common
from All I/O command set

Signed-off-by: Steven Seungcheol Lee <[email protected]>
[dwagner: ported from nvme-cli-monolithic]
Signed-off-by: Daniel Wagner <[email protected]>
  • Loading branch information
sc108-lee authored and igaw committed Nov 16, 2021
1 parent 6b52540 commit 4948dd9
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/libnvme.map
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
nvme_identify_ctrl;
nvme_identify_ctrl_list;
nvme_identify_domain_list;
nvme_identify_independent_identify_ns;
nvme_identify_iocs;
nvme_identify_ns;
nvme_identify_ns_descs;
Expand Down
11 changes: 10 additions & 1 deletion src/nvme/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,16 @@ int nvme_identify_domain_list(int fd, __u16 domid,
domid, NVME_UUID_NONE, NVME_CSI_NVM, list);
}

int nvme_identify_independent_identify_ns(int fd, __u32 nsid,
struct nvme_id_independent_id_ns *ns)
{
BUILD_ASSERT(sizeof(struct nvme_id_independent_id_ns) == 4096);
return nvme_identify(fd, NVME_IDENTIFY_CNS_CSI_INDEPENDENT_ID_NS,
nsid, NVME_CNTLID_NONE, NVME_NVMSETID_NONE,
NVME_DOMID_NONE, NVME_UUID_NONE, NVME_CSI_NVM,
ns);
}

int nvme_identify_iocs(int fd, __u16 cntlid, struct nvme_id_iocs *iocs)
{
BUILD_ASSERT(sizeof(struct nvme_id_iocs) == 4096);
Expand All @@ -555,7 +565,6 @@ int nvme_zns_identify_ctrl(int fd, struct nvme_zns_id_ctrl *id)
return nvme_identify_ctrl_csi(fd, NVME_CSI_ZNS, id);
}


int nvme_nvm_identify_ctrl(int fd, struct nvme_id_ctrl_nvm *id)
{
BUILD_ASSERT(sizeof(struct nvme_id_ctrl_nvm ) == 4096);
Expand Down
13 changes: 13 additions & 0 deletions src/nvme/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,19 @@ int nvme_identify_active_ns_list_csi(int fd, __u32 nsid, __u8 csi,
int nvme_identify_allocated_ns_list_csi(int fd, __u32 nsid, __u8 csi,
struct nvme_ns_list *list);

/**
* nvme_identify_independent_identify_ns() -
* @fd: File descriptor of nvme device
* @nsid: Return namespaces greater than this identifier
* @ns: I/O Command Set Independent Identify Namespace data
* structure
*
* Return: The nvme command status if a response was received (see
* &enum nvme_status_field) or -1 with errno set otherwise.
*/
int nvme_identify_independent_identify_ns(int fd, __u32 nsid,
struct nvme_id_independent_id_ns *ns);

/**
* nvme_identify_ctrl_nvm() -
* @fd: File descriptor of nvme device
Expand Down
28 changes: 28 additions & 0 deletions src/nvme/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,32 @@ struct nvme_id_nvmset_list {
struct nvme_nvmset_attr ent[NVME_ID_NVMSET_LIST_MAX];
};

/**
* struct nvme_id_independent_id_ns -
* @nsfeat:
* @nmic:
* @rescap:
* @fpi:
* @anagrpid:
* @nsattr:
* @nvmsetid:
* @endgid:
* @nstat:
*/
struct nvme_id_independent_id_ns {
__u8 nsfeat;
__u8 nmic;
__u8 rescap;
__u8 fpi;
__le32 anagrpid;
__u8 nsattr;
__u8 rsvd9;
__le16 nvmsetid;
__le16 endgid;
__u8 nstat;
__u8 rsvd15[4081];
};

/**
* struct nvme_id_ns_granularity_desc -
* @nszegran:
Expand Down Expand Up @@ -4942,6 +4968,7 @@ enum nvme_admin_opcode {
* @NVME_IDENTIFY_CNS_CSI_NS:
* @NVME_IDENTIFY_CNS_CSI_CTRL:
* @NVME_IDENTIFY_CNS_CSI_CSI_NS_ACTIVE_LIST:
* @NVME_IDENTIFY_CNS_CSI_INDEPENDENT_ID_NS:
* @NVME_IDENTIFY_CNS_ALLOCATED_NS_LIST:
* @NVME_IDENTIFY_CNS_ALLOCATED_NS:
* @NVME_IDENTIFY_CNS_NS_CTRL_LIST:
Expand All @@ -4963,6 +4990,7 @@ enum nvme_identify_cns {
NVME_IDENTIFY_CNS_CSI_NS = 0x05,
NVME_IDENTIFY_CNS_CSI_CTRL = 0x06,
NVME_IDENTIFY_CNS_CSI_NS_ACTIVE_LIST = 0x07,
NVME_IDENTIFY_CNS_CSI_INDEPENDENT_ID_NS = 0x08,
NVME_IDENTIFY_CNS_ALLOCATED_NS_LIST = 0x10,
NVME_IDENTIFY_CNS_ALLOCATED_NS = 0x11,
NVME_IDENTIFY_CNS_NS_CTRL_LIST = 0x12,
Expand Down

0 comments on commit 4948dd9

Please sign in to comment.