Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions examples/mi-mctp-csi-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void hexdump(const unsigned char *buf, int len)

int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
{
struct nvme_get_log_args args = { 0 };
enum nvme_cmd_get_log_lid lid;
struct nvme_link *link;
uint8_t buf[4096];
uint16_t ctrl_id;
Expand All @@ -75,15 +75,11 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)

ctrl_id = tmp & 0xffff;

args.args_size = sizeof(args);
args.log = buf;
args.len = sizeof(buf);

if (argc > 2) {
tmp = atoi(argv[2]);
args.lid = tmp & 0xff;
lid = tmp & 0xff;
} else {
args.lid = 0x1;
lid = 0x1;
}

link = nvme_mi_init_link(ep, ctrl_id);
Expand All @@ -92,14 +88,17 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
return -1;
}

rc = nvme_get_log(link, &args);
rc = nvme_get_log(link, false, NVME_LOG_LSP_NONE,
lid, NVME_LOG_LSI_NONE, NVME_CSI_NVM, false,
NVME_UUID_NONE, NVME_NSID_NONE,
sizeof(buf), sizeof(buf), 0, buf, NULL);
if (rc) {
warn("can't perform Get Log page command");
return -1;
}

printf("Get log page (log id = 0x%02x) data:\n", args.lid);
hexdump(buf, args.len);
printf("Get log page (log id = 0x%02x) data:\n", lid);
hexdump(buf, sizeof(buf));

return 0;
}
Expand Down
37 changes: 16 additions & 21 deletions examples/mi-mctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ static const char *__copy_id_str(const void *field, size_t size,

int do_identify(nvme_mi_ep_t ep, int argc, char **argv)
{
struct nvme_identify_args id_args = { 0 };
struct nvme_link *link;
struct nvme_id_ctrl id;
uint16_t ctrl_id;
Expand Down Expand Up @@ -207,23 +206,20 @@ int do_identify(nvme_mi_ep_t ep, int argc, char **argv)
return -1;
}

id_args.data = &id;
id_args.args_size = sizeof(id_args);
id_args.cns = NVME_IDENTIFY_CNS_CTRL;
id_args.nsid = NVME_NSID_NONE;
id_args.cntid = 0;
id_args.csi = NVME_CSI_NVM;

/* for this example code, we can either do a full or partial identify;
* since we're only printing the fields before the 'rab' member,
* these will be equivalent, aside from the size of the MI
* response.
*/
if (partial) {
rc = nvme_identify_partial(link, offsetof(struct nvme_id_ctrl, rab),
&id_args);
rc = nvme_identify_partial(link, 0, NVME_IDENTIFY_CNS_CTRL,
NVME_CSI_NVM, 0, 0, NVME_NSID_NONE,
offsetof(struct nvme_id_ctrl, rab),
&id, NULL);
} else {
rc = nvme_identify(link, &id_args);
rc = nvme_identify(link, 0, NVME_IDENTIFY_CNS_CTRL,
NVME_CSI_NVM, 0, 0, NVME_NSID_NONE,
&id, NULL);
}

if (rc) {
Expand Down Expand Up @@ -373,7 +369,7 @@ void hexdump(const unsigned char *buf, int len)

int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
{
struct nvme_get_log_args args = { 0 };
enum nvme_cmd_get_log_lid lid;
struct nvme_link *link;
uint8_t buf[512];
uint16_t ctrl_id;
Expand All @@ -392,15 +388,11 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)

ctrl_id = tmp & 0xffff;

args.args_size = sizeof(args);
args.log = buf;
args.len = sizeof(buf);

if (argc > 2) {
tmp = atoi(argv[2]);
args.lid = tmp & 0xff;
lid = tmp & 0xff;
} else {
args.lid = 0x1;
lid = 0x1;
}

link = nvme_mi_init_link(ep, ctrl_id);
Expand All @@ -409,14 +401,17 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv)
return -1;
}

rc = nvme_get_log(link, &args);
rc = nvme_get_log(link, false, NVME_LOG_LSP_NONE,
lid, NVME_LOG_LSI_NONE, NVME_CSI_NVM, false,
NVME_UUID_NONE, NVME_NSID_NONE,
sizeof(buf), sizeof(buf), 0, buf, NULL);
if (rc) {
warn("can't perform Get Log page command");
return -1;
}

printf("Get log page (log id = 0x%02x) data:\n", args.lid);
hexdump(buf, args.len);
printf("Get log page (log id = 0x%02x) data:\n", lid);
hexdump(buf, sizeof(buf));

return 0;
}
Expand Down
8 changes: 0 additions & 8 deletions src/libnvme.map
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,19 @@ LIBNVME_2_0 {
nvme_directive_send;
nvme_directive_send_id_endir;
nvme_disconnect_ctrl;
nvme_dsm;
nvme_dump_config;
nvme_dump_tree;
nvme_errno_to_string;
nvme_export_tls_key;
nvme_export_tls_key_versioned;
nvme_first_host;
nvme_first_subsystem;
nvme_format_nvm;
nvme_free_ctrl;
nvme_free_host;
nvme_free_ns;
nvme_free_root;
nvme_free_subsystem;
nvme_free_uri;
nvme_fw_commit;
nvme_fw_download;
nvme_fw_download_seq;
nvme_gen_dhchap_key;
nvme_generate_tls_key_identity;
Expand Down Expand Up @@ -129,7 +125,6 @@ LIBNVME_2_0 {
nvme_get_features_write_protect;
nvme_get_host_telemetry;
nvme_get_lba_status;
nvme_get_log;
nvme_get_log_page;
nvme_get_logging_level;
nvme_get_logical_block_size;
Expand All @@ -153,8 +148,6 @@ LIBNVME_2_0 {
nvme_host_set_dhchap_key;
nvme_host_set_hostsymname;
nvme_host_set_pdc_enabled;
nvme_identify;
nvme_identify_partial;
nvme_import_tls_key;
nvme_import_tls_key_versioned;
nvme_init_copy_range;
Expand Down Expand Up @@ -261,7 +254,6 @@ LIBNVME_2_0 {
nvme_ns_get_sysfs_dir;
nvme_ns_get_uuid;
nvme_ns_identify;
nvme_ns_mgmt;
nvme_ns_read;
nvme_ns_release_link;
nvme_ns_rescan;
Expand Down
183 changes: 0 additions & 183 deletions src/nvme/api-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,6 @@ void nvme_free_root(nvme_root_t r);
* be set to zero.
*/

/**
* struct nvme_identify_args - Arguments for the NVMe Identify command
* @result: The command completion result from CQE dword0
* @data: User space destination address to transfer the data
* @args_size: Size of &struct nvme_identify_args
* @timeout: Timeout in ms (0 for default timeout)
* @cns: The Controller or Namespace structure, see @enum nvme_identify_cns
* @csi: Command Set Identifier
* @nsid: Namespace identifier, if applicable
* @cntid: The Controller Identifier, if applicable
* @cns_specific_id: Identifier that is required for a particular CNS value
* @uuidx: UUID Index if controller supports this id selection method
*/
struct nvme_identify_args {
__u32 *result;
void *data;
int args_size;
__u32 timeout;
enum nvme_identify_cns cns;
enum nvme_csi csi;
__u32 nsid;
__u16 cntid;
__u16 cns_specific_id;
__u8 uuidx;
};

/**
* struct nvme_get_log_args - Arguments for the NVMe Admin Get Log command
* @lpo: Log page offset for partial log transfers
Expand Down Expand Up @@ -171,143 +145,6 @@ struct nvme_get_features_args {
__u8 uuidx;
};

/**
* struct nvme_format_nvm_args - Arguments for the Format Nvme Namespace command
* @result: The command completion result from CQE dword0
* @args_size: Size of &struct nvme_format_nvm_args
* @timeout: Set to override default timeout to this value in milliseconds;
* useful for long running formats. 0 will use system default.
* @nsid: Namespace ID to format
* @mset: Metadata settings (extended or separated), true if extended
* @pi: Protection information type
* @pil: Protection information location (beginning or end), true if end
* @ses: Secure erase settings
* @lbaf: Logical block address format least significant 4 bits
* @rsvd1: Reserved
* @lbafu: Logical block address format most significant 2 bits
*/
struct nvme_format_nvm_args {
__u32 *result;
int args_size;
__u32 timeout;
__u32 nsid;
enum nvme_cmd_format_mset mset;
enum nvme_cmd_format_pi pi;
enum nvme_cmd_format_pil pil;
enum nvme_cmd_format_ses ses;
__u8 lbaf;
__u8 rsvd1[7];
__u8 lbafu;
};

/**
* struct nvme_ns_mgmt_args - Arguments for NVMe Namespace Management command
* @result: NVMe command result
* @ns: Namespace identification descriptors
* @args_size: Size of &struct nvme_ns_mgmt_args
* @timeout: Timeout in ms
* @nsid: Namespace identifier
* @sel: Type of management operation to perform
* @csi: Command Set Identifier
* @rsvd1: Reserved
* @rsvd2: Reserved
* @data: Host Software Specified Fields
*/
struct nvme_ns_mgmt_args {
__u32 *result;
struct nvme_id_ns *ns;
int args_size;
__u32 timeout;
__u32 nsid;
enum nvme_ns_mgmt_sel sel;
__u8 csi;
__u8 rsvd1[3];
void *rsvd2;
struct nvme_ns_mgmt_host_sw_specified *data;
};

/**
* struct nvme_ns_attach_args - Arguments for Nvme Namespace Management command
* @result: NVMe command result
* @ctrlist: Controller list to modify attachment state of nsid
* @args_size: Size of &struct nvme_ns_attach_args
* @timeout: Timeout in ms
* @nsid: Namespace ID to execute attach selection
* @sel: Attachment selection, see &enum nvme_ns_attach_sel
*/
struct nvme_ns_attach_args {
__u32 *result;
struct nvme_ctrl_list *ctrlist;
int args_size;
__u32 timeout;
__u32 nsid;
enum nvme_ns_attach_sel sel;
};

/**
* struct nvme_fw_download_args - Arguments for the NVMe Firmware Download command
* @args_size: Size of &struct nvme_fw_download_args
* @result: The command completion result from CQE dword0
* @timeout: Timeout in ms
* @offset: Offset in the firmware data
* @data: Userspace address of the firmware data
* @data_len: Length of data in this command in bytes
*/
struct nvme_fw_download_args {
__u32 *result;
void *data;
int args_size;
__u32 timeout;
__u32 offset;
__u32 data_len;
};

/**
* struct nvme_fw_commit_args - Arguments for the NVMe Firmware Commit command
* @args_size: Size of &struct nvme_fw_commit_args
* @action: Action to use for the firmware image, see &enum nvme_fw_commit_ca
* @timeout: Timeout in ms
* @result: The command completion result from CQE dword0
* @slot: Firmware slot to commit the downloaded image
* @bpid: Set to true to select the boot partition id
*/
struct nvme_fw_commit_args {
__u32 *result;
int args_size;
__u32 timeout;
enum nvme_fw_commit_ca action;
__u8 slot;
bool bpid;
};

/**
* struct nvme_security_send_args - Arguments for the NVMe Security Send command
* @result: The command completion result from CQE dword0
* @data: Security data payload to send
* @args_size: Size of &struct nvme_security_send_args
* @timeout: Timeout in ms
* @nsid: Namespace ID to issue security command on
* @tl: Protocol specific transfer length
* @data_len: Data length of the payload in bytes
* @nssf: NVMe Security Specific field
* @spsp0: Security Protocol Specific field
* @spsp1: Security Protocol Specific field
* @secp: Security Protocol
*/
struct nvme_security_send_args {
__u32 *result;
void *data;
int args_size;
__u32 timeout;
__u32 nsid;
__u32 tl;
__u32 data_len;
__u8 nssf;
__u8 spsp0;
__u8 spsp1;
__u8 secp;
};

/**
* struct nvme_security_receive_args - Arguments for the NVMe Security Receive command
* @result: The command completion result from CQE dword0
Expand Down Expand Up @@ -612,26 +449,6 @@ struct nvme_io_args {
__u8 pif;
};

/**
* struct nvme_dsm_args - Arguments for the NVMe Dataset Management command
* @result: The command completion result from CQE dword0
* @dsm: The data set management attributes
* @args_size: Size of &struct nvme_dsm_args
* @timeout: Timeout in ms
* @nsid: Namespace identifier
* @attrs: DSM attributes, see &enum nvme_dsm_attributes
* @nr_ranges: Number of block ranges in the data set management attributes
*/
struct nvme_dsm_args {
__u32 *result;
struct nvme_dsm_range *dsm;
int args_size;
__u32 timeout;
__u32 nsid;
__u32 attrs;
__u16 nr_ranges;
};

/**
* struct nvme_copy_args - Arguments for the NVMe Copy command
* @sdlba: Start destination LBA
Expand Down
Loading