Skip to contentSkip to conversation

nvme-cli: Implemented primary and secondary controller

PATCH New Revanth Rajashekar 2 participants 2 messages Jun 18, 2018 – Jun 19, 2018 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-cli: Implemented primary and secondary controller

Signed-off-by Revanth Rajashekar <revanth.rajashekar at intel.com>
---
 linux/nvme.h   |  11 +++--
 nvme-builtin.h |   2 +
 nvme-ioctl.c   |  22 +++++++++
 nvme-ioctl.h   |   3 ++
 nvme-print.c   | 120 +++++++++++++++++++++++++++++++++++++++++++++++++
 nvme-print.h   |   7 +++
 nvme.c         | 109 ++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 270 insertions(+), 4 deletions(-)
linux/nvme.h +7 -4
index 97204f3..d6f99d9 100644
@@ -272,7 +272,7 @@ struct nvme_id_ctrl {
 	__u8			vs[1024];
 };
 
-struct nvme_id_primary_cntrlr {
+struct nvme_id_primary_ctrl {
 	__le16	cntlid;
 	__le16	portid;
 	__u8	crt;
@@ -293,7 +293,7 @@ struct nvme_id_primary_cntrlr {
 	__u8	rsvd80[4016];
 };
 
-struct nvme_secondary_cntrlr_entry {
+struct nvme_secondary_ctrl_entry {
 	__le16	scid;
 	__le16 	pcid;
 	__u8 	scs;
@@ -304,10 +304,10 @@ struct nvme_secondary_cntrlr_entry {
 	__u8 	rsvd14[18];
 };
 
-struct nvme_secondary_cntrlr_list {
+struct nvme_id_secondary_ctrl_list {
 	__u8 	num_of_identifiers;
 	__u8	rsvd1[31];
-	struct  nvme_secondary_cntrlr_entry sc[NVME_SECONDARY_CONTROLLER_MAX];
+	struct  nvme_secondary_ctrl_entry sc[NVME_SECONDARY_CONTROLLER_MAX];
 };
 
 enum {
@@ -377,6 +377,8 @@ enum {
 	NVME_ID_CNS_NS_PRESENT		= 0x11,
 	NVME_ID_CNS_CTRL_NS_LIST	= 0x12,
 	NVME_ID_CNS_CTRL_LIST		= 0x13,
+	NVME_ID_CNS_PIMARY_CTRL_CAP 		= 0x14,
+	NVME_ID_CNS_SECONDARY_CTRL_LIST 	= 0x15,
 };
 
 enum {
@@ -974,6 +976,7 @@ struct nvme_identify {
 };
 
 #define NVME_IDENTIFY_DATA_SIZE 4096
+#define NVME_VIRTUAL_CTRL_DATA_SIZE 4096
 
 struct nvme_features {
 	__u8			opcode;
nvme-builtin.h +2 -0
index 86b0fff..0b81193 100644
@@ -63,6 +63,8 @@ COMMAND_LIST(
 	ENTRY("gen-hostnqn", "Generate NVMeoF host NQN", gen_hostnqn_cmd)
 	ENTRY("dir-receive", "Submit a Directive Receive command, return results", dir_receive)
 	ENTRY("dir-send", "Submit a Directive Send command, return results", dir_send)
+	ENTRY("id-primary-ctrl", "Obtain the primary controller capabilities structure", id_primary_ctrl)
+	ENTRY("id-secondary-ctrl", "Obtain a Secondary Controller list associated with the primary controller", id_secondary_ctrl)
 );
 
 #endif
nvme-ioctl.c +22 -0
index 63ff8fb..493f643 100644
@@ -393,6 +393,28 @@ int nvme_identify_nvmset(int fd, __u16 nvmset_id, void *data)
 	return nvme_identify13(fd, 0, NVME_ID_CNS_NVMSET_LIST, nvmset_id, data);
 }
 
+int nvme_ctrl(int fd, __u32 cdw10, void *data)
+{
+	struct nvme_admin_cmd cmd = {
+		.opcode 	= nvme_admin_virtual_mgmt,
+		.addr 		= (__u64)(uintptr_t) data,
+		.data_len	= NVME_VIRTUAL_CTRL_DATA_SIZE,
+		.cdw10 		= cdw10,
+	};
+
+	return nvme_submit_admin_passthru(fd, &cmd);
+}
+
+int nvme_id_primary_ctrl(int fd, void *data)
+{
+	return nvme_ctrl(fd, NVME_ID_CNS_PIMARY_CTRL_CAP, data);
+}
+
+int nvme_id_secondary_ctrl(int fd, void *data)
+{
+	return nvme_ctrl(fd, NVME_ID_CNS_SECONDARY_CTRL_LIST, data);
+}
+
 int nvme_get_log13(int fd, __u32 nsid, __u8 log_id, __u8 lsp, __u64 lpo,
                  __u16 lsi, __u32 data_len, void *data)
 {
nvme-ioctl.h +3 -0
index 6d4ac95..4919020 100644
@@ -138,4 +138,7 @@ int nvme_sanitize(int fd, __u8 sanact, __u8 ause, __u8 owpass, __u8 oipbp,
 		  __u8 no_dealloc, __u32 ovrpat);
 int nvme_self_test_start(int fd, __u32 nsid, __u32 cdw10);
 int nvme_self_test_log(int fd, struct nvme_self_test_log *self_test_log);
+int nvme_ctrl(int fd, __u32 cdw10, void *data);
+int nvme_id_primary_ctrl(int fd, void *data);
+int nvme_id_secondary_ctrl(int fd, void *data);
 #endif				/* _NVME_LIB_H */
nvme-print.c +120 -0

132 lines not on this page · raw message

nvme-print.h +7 -0
index 7dd5f34..2d5ab8c 100644
@@ -58,6 +58,13 @@ void json_nvme_id_ns_descs(void *data);
 void json_print_nvme_subsystem_list(struct subsys_list_item *slist, int n);
 void json_self_test_log(struct nvme_self_test_log *self_test, const char *devname);
 void json_nvme_id_nvmset(struct nvme_id_nvmset *nvmset, const char *devname);
+void show_nvme_id_primary_ctrl_crt(__u8 crt);
+void show_nvme_id_primary_ctrl(struct nvme_id_primary_ctrl *ctrl);
+void show_nvme_id_secondary_ctrl_entry_scs(__u8 scs);
+void show_nvme_id_secondary_ctrl_entry(struct nvme_secondary_ctrl_entry *ctrl);
+void show_nvme_id_secondary_ctrl_list(struct nvme_id_secondary_ctrl_list *ctrl);
+void json_nvme_id_primary_ctrl(struct nvme_id_primary_ctrl *ctrl);
+void json_nvme_id_secondary_ctrl(struct nvme_id_secondary_ctrl_list *ctrl);
 
 
 #endif
nvme.c +109 -0

115 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 nvme-cli: Implemented primary and secondary controller

linux/nvme.h struct nvme_id_ctrl { · line 275

Quoted 2 lines · Revanth Rajashekar
linux/nvme.h +1 -1
-struct nvme_id_primary_cntrlr {
+struct nvme_id_primary_ctrl {

Could you rebase your patch so that it doesn't have dependencies on your previous version?