From: Keith Busch Date: Fri, 14 Feb 2020 23:20:13 +0000 (-0800) Subject: Fill in more documentation details X-Git-Tag: v1.0-rc0~170 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e84081c9d80afb6cab43585f34d7926debd2f8f8;p=users%2Fsagi%2Flibnvme.git Fill in more documentation details And start adding more cross references. Signed-off-by: Keith Busch --- diff --git a/examples/telemetry-listen.c b/examples/telemetry-listen.c index 1bc250b5..7d1f260b 100644 --- a/examples/telemetry-listen.c +++ b/examples/telemetry-listen.c @@ -38,11 +38,11 @@ static void save_telemetry(nvme_ctrl_t c) char buf[0x1000]; __u32 log_size; int ret, fd; - void *log; + struct nvme_telemetry_log *log; time_t s; /* Clear the log (rae == false) at the end to see new telemetry events later */ - ret = nvme_get_ctrl_telemetry(nvme_ctrl_get_fd(c), false, &log, &log_size); + ret = nvme_get_ctrl_telemetry(nvme_ctrl_get_fd(c), false, &log); if (ret) return; @@ -53,6 +53,7 @@ static void save_telemetry(nvme_ctrl_t c) free(log); return; } + log_size = (le16_to_cpu(log->dalb3) + 1) * NVME_LOG_TELEM_BLOCK_SIZE; fd = open(buf, O_CREAT|O_WRONLY, S_IRUSR|S_IRGRP); if (fd < 0) { diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index 9744f037..836e4634 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -44,7 +44,6 @@ static int add_bool_argument(char **argstr, char *tok, bool arg) if (!arg) return 0; - if (asprintf(&nstr, "%s,%s", *argstr, tok) < 0) { errno = ENOMEM; return -1; @@ -55,19 +54,19 @@ static int add_bool_argument(char **argstr, char *tok, bool arg) return 0; } -static int add_int_argument(char **argstr, char *tok, int arg, - bool allow_zero) +static int add_int_argument(char **argstr, char *tok, int arg, bool allow_zero) { char *nstr; - if ((arg && !allow_zero) || (arg != -1 && allow_zero)) { - if (asprintf(&nstr, "%s,%s=%d", *argstr, tok, arg) < 0) { - errno = ENOMEM; - return -1; - } - free(*argstr); - *argstr = nstr; + if (arg < 0 || (!arg && !allow_zero)) + return 0; + if (asprintf(&nstr, "%s,%s=%d", *argstr, tok, arg) < 0) { + errno = ENOMEM; + return -1; } + free(*argstr); + *argstr = nstr; + return 0; } @@ -83,6 +82,7 @@ static int add_argument(char **argstr, const char *tok, const char *arg) } free(*argstr); *argstr = nstr; + return 0; } diff --git a/src/nvme/fabrics.h b/src/nvme/fabrics.h index 8af57bcc..1ca4eb53 100644 --- a/src/nvme/fabrics.h +++ b/src/nvme/fabrics.h @@ -64,78 +64,61 @@ struct nvme_fabrics_config { /** * nvmf_add_ctrl_opts() - + * @cfg: + * + * Return: */ int nvmf_add_ctrl_opts(struct nvme_fabrics_config *cfg); /** * nvmf_add_ctrl() - + * @cfg: + * + * Return: */ nvme_ctrl_t nvmf_add_ctrl(struct nvme_fabrics_config *cfg); /** * nvmf_get_discovery_log() - + * @c: + * @logp: + * @max_retries: + * + * Return: */ int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp, int max_retries); /** - * nvmf_hostnqn_generate() - + * nvmf_hostnqn_generate() - Generate a machine specific host nqn + * Returns: An nvm namespace qualifieid name string based on the machine + * identifier, or NULL if not successful. */ char *nvmf_hostnqn_generate(); /** - * nvmf_hostnqn_from_file() - + * nvmf_hostnqn_from_file() - Reads the host nvm qualified name from the config + * default location in /etc/nvme/ + * Return: The host nqn, or NULL if unsuccessful. If found, the caller + * is responsible to free the string. */ char *nvmf_hostnqn_from_file(); /** - * nvmf_hostid_from_file() - + * nvmf_hostid_from_file() - Reads the host identifier from the config default + * location in /etc/nvme/. + * Return: The host identifier, or NULL if unsuccessful. If found, the caller + * is responsible to free the string. */ char *nvmf_hostid_from_file(); -/** - * nvmf_trtype_str() - - */ -const char *nvmf_trtype_str(__u8 trtype); - -/** - * nvmf_adrfam_str() - - */ -const char *nvmf_adrfam_str(__u8 adrfam); - -/** - * nvmf_subtype_str() - - */ -const char *nvmf_subtype_str(__u8 subtype); - -/** - * nvmf_treq_str() - - */ -const char *nvmf_treq_str(__u8 treq); - -/** - * nvmf_sectype_str() - - */ -const char *nvmf_sectype_str(__u8 sectype); - -/** - * nvmf_prtype_str() - - */ -const char *nvmf_prtype_str(__u8 prtype); - -/** - * nvmf_qptype_str() - - */ -const char *nvmf_qptype_str(__u8 qptype); - -/** - * nvmf_cms_str() - - */ -const char *nvmf_cms_str(__u8 cm); - - /** * nvmf_connect_disc_entry() - + * @e: + * @defcfg: + * @discover: + * + * Return: */ nvme_ctrl_t nvmf_connect_disc_entry(struct nvmf_disc_log_entry *e, const struct nvme_fabrics_config *defcfg, bool *discover); diff --git a/src/nvme/ioctl.c b/src/nvme/ioctl.c index 0f0a8dd0..3b9f035d 100644 --- a/src/nvme/ioctl.c +++ b/src/nvme/ioctl.c @@ -1428,7 +1428,7 @@ int nvme_directive_recv_stream_allocate(int fd, __u32 nsid, __u16 nsr, int nvme_set_property(int fd, int offset, __u64 value) { - __u32 cdw10 = is_64bit_reg(offset); + __u32 cdw10 = nvme_is_64bit_reg(offset); struct nvme_passthru_cmd cmd = { .opcode = nvme_admin_fabrics, @@ -1444,7 +1444,7 @@ int nvme_set_property(int fd, int offset, __u64 value) int nvme_get_property(int fd, int offset, __u64 *value) { - __u32 cdw10 = is_64bit_reg(offset); + __u32 cdw10 = nvme_is_64bit_reg(offset); struct nvme_passthru_cmd64 cmd = { .opcode = nvme_admin_fabrics, diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index 57e1c84f..c96c24d8 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -126,8 +126,8 @@ struct nvme_passthru_cmd64 { * * Uses NVME_IOCTL_ADMIN64_CMD for the ioctl request. * - * Return: The nvme command status if a response was received or -1 - * with errno set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_submit_admin_passthru64(int fd, struct nvme_passthru_cmd64 *cmd, __u64 *result); @@ -159,8 +159,8 @@ int nvme_submit_admin_passthru64(int fd, struct nvme_passthru_cmd64 *cmd, * * Known values for @opcode are defined in &enum nvme_admin_opcode. * - * Return: The nvme command status if a response was received or -1 - * with errno set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_admin_passthru64(int fd, __u8 opcode, __u8 flags, __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, @@ -176,8 +176,8 @@ int nvme_admin_passthru64(int fd, __u8 opcode, __u8 flags, __u16 rsvd, * * Uses NVME_IOCTL_ADMIN_CMD for the ioctl request. * - * Return: The nvme command status if a response was received or -1 - * with errno set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_submit_admin_passthru(int fd, struct nvme_passthru_cmd *cmd, __u32 *result); @@ -209,8 +209,8 @@ int nvme_submit_admin_passthru(int fd, struct nvme_passthru_cmd *cmd, * * Known values for @opcode are defined in &enum nvme_admin_opcode. * - * Return: The nvme command status if a response was received or -1 - * with errno set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_admin_passthru(int fd, __u8 opcode, __u8 flags, __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, @@ -226,8 +226,8 @@ int nvme_admin_passthru(int fd, __u8 opcode, __u8 flags, __u16 rsvd, * * Uses NVME_IOCTL_IO64_CMD for the ioctl request. * - * Return: The nvme command status if a response was received or -1 - * with errno set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_submit_io_passthru64(int fd, struct nvme_passthru_cmd64 *cmd, __u64 *result); @@ -259,8 +259,8 @@ int nvme_submit_io_passthru64(int fd, struct nvme_passthru_cmd64 *cmd, * * Known values for @opcode are defined in &enum nvme_io_opcode. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_io_passthru64(int fd, __u8 opcode, __u8 flags, __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, @@ -277,8 +277,8 @@ int nvme_io_passthru64(int fd, __u8 opcode, __u8 flags, __u16 rsvd, * * Uses NVME_IOCTL_IO_CMD for the ioctl request. * - * Return: The nvme command status if a response was received or -1 - * with errno set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_submit_io_passthru(int fd, struct nvme_passthru_cmd *cmd, __u32 *result); @@ -310,8 +310,8 @@ int nvme_submit_io_passthru(int fd, struct nvme_passthru_cmd *cmd, * * Known values for @opcode are defined in &enum nvme_io_opcode. * - * Return: The nvme command status if a response was received or -1 - * with errno set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_io_passthru(int fd, __u8 opcode, __u8 flags, __u16 rsvd, __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11, @@ -361,10 +361,6 @@ int nvme_ns_rescan(int fd); */ int nvme_get_nsid(int fd); -/** - * DOC: NVMe Admin command enums - */ - /** * enum nvme_admin_opcode - Known NVMe admin opcodes * @nvme_admin_delete_sq: @@ -770,8 +766,8 @@ enum nvme_virt_mgmt_rt { * The Identify command returns a data buffer that describes information about * the NVM subsystem, the controller or the namespace(s). * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify(int fd, enum nvme_identify_cns cns, __u32 nsid, __u16 cntid, __u16 nvmsetid, __u8 uuidx, void *data); @@ -785,8 +781,8 @@ int nvme_identify(int fd, enum nvme_identify_cns cns, __u32 nsid, * * See &struct nvme_id_ctrl for details on the data returned. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify_ctrl(int fd, struct nvme_id_ctrl *id); @@ -807,8 +803,8 @@ int nvme_identify_ctrl(int fd, struct nvme_id_ctrl *id); * * See &struct nvme_id_ns for details on the structure returned. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify_ns(int fd, __u32 nsid, struct nvme_id_ns *ns); @@ -819,8 +815,8 @@ int nvme_identify_ns(int fd, __u32 nsid, struct nvme_id_ns *ns); * @nsid: Namespace to identify * @ns: User space destination address to transfer the data * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify_allocated_ns(int fd, __u32 nsid, struct nvme_id_ns *ns); @@ -836,8 +832,8 @@ int nvme_identify_allocated_ns(int fd, __u32 nsid, struct nvme_id_ns *ns); * * See &struct nvme_ns_list for the definition of the returned structure. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify_active_ns_list(int fd, __u32 nsid, struct nvme_ns_list *list); @@ -853,8 +849,8 @@ int nvme_identify_active_ns_list(int fd, __u32 nsid, struct nvme_ns_list *list); * * See &struct nvme_ns_list for the definition of the returned structure. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify_allocated_ns_list(int fd, __u32 nsid, struct nvme_ns_list *list); @@ -871,8 +867,8 @@ int nvme_identify_allocated_ns_list(int fd, __u32 nsid, * * See &struct nvme_ctrl_list for a definition of the structure returned. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify_ctrl_list(int fd, __u16 cntid, struct nvme_ctrl_list *ctrlist); @@ -890,7 +886,8 @@ int nvme_identify_ctrl_list(int fd, __u16 cntid, * * See &struct nvme_ctrl_list for a definition of the structure returned. * - * Return: The nvme command status if a response was received or -1 + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 */ int nvme_identify_nsid_ctrl_list(int fd, __u32 nsid, __u16 cntid, struct nvme_ctrl_list *ctrlist); @@ -909,8 +906,8 @@ int nvme_identify_nsid_ctrl_list(int fd, __u32 nsid, __u16 cntid, * * See &struct nvme_ns_id_desc for the definition of the returned structure. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify_ns_descs(int fd, __u32 nsid, struct nvme_ns_id_desc *descs); @@ -927,8 +924,8 @@ int nvme_identify_ns_descs(int fd, __u32 nsid, struct nvme_ns_id_desc *descs); * * See &struct nvme_id_nvmset_list for the defintion of the returned structure. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify_nvmset_list(int fd, __u16 nvmsetid, struct nvme_id_nvmset_list *nvmset); @@ -942,8 +939,8 @@ int nvme_identify_nvmset_list(int fd, __u16 nvmsetid, * * See &struct nvme_primary_ctrl_cap for the defintion of the returned structure, @cap. * - * Return: The nvme command status if a response was received or -1 - * with errno set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify_primary_ctrl(int fd, __u16 cntid, struct nvme_primary_ctrl_cap *cap); @@ -962,8 +959,8 @@ int nvme_identify_primary_ctrl(int fd, __u16 cntid, * See &struct nvme_secondary_ctrls_list for a defintion of the returned * structure. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify_secondary_ctrl_list(int fd, __u16 cntid, struct nvme_secondary_ctrl_list *list); @@ -981,8 +978,8 @@ int nvme_identify_secondary_ctrl_list(int fd, __u16 cntid, * See &struct nvme_id_ns_granularity_list for the definition of the returned * structure. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify_ns_granularity(int fd, struct nvme_id_ns_granularity_list *list); @@ -996,8 +993,8 @@ int nvme_identify_ns_granularity(int fd, struct nvme_id_ns_granularity_list *lis * * See &struct nvme_id_uuid_list for the definition of the returned structure. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_identify_uuid(int fd, struct nvme_id_uuid_list *list); @@ -1014,8 +1011,8 @@ int nvme_identify_uuid(int fd, struct nvme_id_uuid_list *list); * @len: Length of provided user buffer to hold the log data in bytes * @log: User space destination address to transfer the data * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log(int fd, enum nvme_cmd_get_log_lid lid, __u32 nsid, __u64 lpo, __u8 lsp, __u16 lsi, bool rae, __u8 uuidx, __u32 len, void *log); @@ -1031,8 +1028,8 @@ int nvme_get_log(int fd, enum nvme_cmd_get_log_lid lid, __u32 nsid, __u64 lpo, * that completed with error, or may report an error that is not specific to a * particular command. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_error(int fd, unsigned nr_entries, bool rae, struct nvme_error_log_page *log); @@ -1051,8 +1048,8 @@ int nvme_get_log_error(int fd, unsigned nr_entries, bool rae, * requesting the log page on a per namespace basis, as indicated by bit 0 of * the LPA field in the Identify Controller data structure. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_smart(int fd, __u32 nsid, bool rae, struct nvme_smart_log *log); @@ -1066,8 +1063,8 @@ int nvme_get_log_smart(int fd, __u32 nsid, bool rae, struct nvme_smart_log *log) * firmware slot supported. The firmware revision is indicated as an ASCII * string. The log page also indicates the active slot number. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_fw_slot(int fd, bool rae, struct nvme_firmware_slot *log); @@ -1081,8 +1078,8 @@ int nvme_get_log_fw_slot(int fd, bool rae, struct nvme_firmware_slot *log); * that have changed since the last time the namespace was identified, been * added, or deleted. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_changed_ns_list(int fd, bool rae, struct nvme_ns_list *log); @@ -1094,8 +1091,8 @@ int nvme_get_log_changed_ns_list(int fd, bool rae, struct nvme_ns_list *log); * This log page is used to describe the commands that the controller supports * and the effects of those commands on the state of the NVM subsystem. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_cmd_effects(int fd, struct nvme_cmd_effects_log *log); @@ -1109,8 +1106,8 @@ int nvme_get_log_cmd_effects(int fd, struct nvme_cmd_effects_log *log); * the percent complete of that operation, and the results of the previous 20 * self-test operations. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_device_self_test(int fd, struct nvme_self_test_log *log); @@ -1129,8 +1126,8 @@ int nvme_get_log_create_telemetry_host(int fd, struct nvme_telemetry_log *log); * Retreives the Telemetry Host-Initiated log page at the requested offset * using the previously existing capture. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_telemetry_host(int fd, __u64 offset, __u32 len, void *log); @@ -1158,8 +1155,8 @@ int nvme_get_log_telemetry_ctrl(int fd, bool rae, __u64 offset, __u32 len, * generated when an entry for an Endurance Group is newly added to this log * page. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_endurance_group(int fd, __u16 endgid, struct nvme_endurance_group_log *log); @@ -1169,8 +1166,8 @@ int nvme_get_log_endurance_group(int fd, __u16 endgid, * @fd: * @nvmsetid: * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_predictable_lat_nvmset(int fd, __u16 nvmsetid, struct nvme_nvmset_predictable_lat_log *log); @@ -1205,8 +1202,8 @@ enum nvme_log_ana_lsp { * * See &struct nvme_ana_rsp_hdr for the defintion of the returned structure. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_ana(int fd, enum nvme_log_ana_lsp lsp, bool rae, __u64 offset, __u32 len, void *log); @@ -1248,8 +1245,8 @@ int nvme_get_log_endurance_grp_evt(int fd, bool rae, __u32 offset, __u32 len, * Supported only by fabrics discovery controllers, returning discovery * records. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_discovery(int fd, bool rae, __u32 offset, __u32 len, void *log); @@ -1270,8 +1267,8 @@ int nvme_get_log_reservation(int fd, bool rae, * The Sanitize Status log page is used to report sanitize operation time * estimates and information about the most recent sanitize operation. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_sanitize(int fd, bool rae, struct nvme_sanitize_log_page *log); @@ -1290,8 +1287,8 @@ int nvme_get_log_sanitize(int fd, bool rae, * @data: User address of feature data, if applicable * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features(int fd, __u8 fid, __u32 nsid, __u32 cdw11, __u32 cdw12, bool save, __u8 uuidx, __u32 cdw15, __u32 data_len, @@ -1303,8 +1300,8 @@ int nvme_set_features(int fd, __u8 fid, __u32 nsid, __u32 cdw11, __u32 cdw12, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_arbitration(int fd, __u8 ab, __u8 lpw, __u8 mpw, __u8 hpw, bool save, __u32 *result); @@ -1315,8 +1312,8 @@ int nvme_set_features_arbitration(int fd, __u8 ab, __u8 lpw, __u8 mpw, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_power_mgmt(int fd, __u8 ps, __u8 wh, bool save, __u32 *result); @@ -1327,8 +1324,8 @@ int nvme_set_features_power_mgmt(int fd, __u8 ps, __u8 wh, bool save, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_lba_range(int fd, __u32 nsid, __u32 nr_ranges, bool save, struct nvme_lba_range_type *data, __u32 *result); @@ -1348,8 +1345,8 @@ enum nvme_feat_tmpthresh_thsel { * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_temp_thresh(int fd, __u16 tmpth, __u8 tmpsel, enum nvme_feat_tmpthresh_thsel thsel, @@ -1361,8 +1358,8 @@ int nvme_set_features_temp_thresh(int fd, __u16 tmpth, __u8 tmpsel, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_err_recovery(int fd, __u32 nsid, __u16 tler, bool dulbe, bool save, __u32 *result); @@ -1374,8 +1371,8 @@ int nvme_set_features_err_recovery(int fd, __u32 nsid, __u16 tler, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_volatile_wc(int fd, bool wce, bool save, __u32 *result); @@ -1386,8 +1383,8 @@ int nvme_set_features_volatile_wc(int fd, bool wce, bool save, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_irq_coalesce(int fd, __u8 thr, __u8 time, bool save, __u32 *result); @@ -1398,8 +1395,8 @@ int nvme_set_features_irq_coalesce(int fd, __u8 thr, __u8 time, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_irq_config(int fd, __u16 iv, bool cd, bool save, __u32 *result); @@ -1411,8 +1408,8 @@ int nvme_set_features_irq_config(int fd, __u16 iv, bool cd, bool save, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_write_atomic(int fd, bool dn, bool save, __u32 *result); @@ -1443,8 +1440,8 @@ enum nvme_features_async_event_config_flags { * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_async_event(int fd, __u32 events, bool save, __u32 *result); @@ -1456,8 +1453,8 @@ int nvme_set_features_async_event(int fd, __u32 events, bool save, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_auto_pst(int fd, bool apste, bool save, struct nvme_feat_auto_pst *apst, @@ -1469,8 +1466,8 @@ int nvme_set_features_auto_pst(int fd, bool apste, bool save, * @save: Save value across power states * @timestamp: The current timestamp value to assign to this this feature * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_timestamp(int fd, bool save, __u64 timestamp); @@ -1481,8 +1478,8 @@ int nvme_set_features_timestamp(int fd, bool save, __u64 timestamp); * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_hctm(int fd, __u16 tmt2, __u16 tmt1, bool save, __u32 *result); @@ -1498,8 +1495,8 @@ int nvme_set_features_nopsc(int fd, bool noppme, bool save, __u32 *result); * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_rrl(int fd, __u8 rrl, __u16 nvmsetid, bool save, __u32 *result); @@ -1510,8 +1507,8 @@ int nvme_set_features_rrl(int fd, __u8 rrl, __u16 nvmsetid, bool save, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_plm_config(int fd, bool enable, __u16 nvmsetid, bool save, struct nvme_plm_config *data, @@ -1531,8 +1528,8 @@ enum nvme_feat_plm_window_select { * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_plm_window(int fd, enum nvme_feat_plm_window_select sel, __u16 nvmsetid, bool save, __u32 *result); @@ -1544,8 +1541,8 @@ int nvme_set_features_plm_window(int fd, enum nvme_feat_plm_window_select sel, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_lba_sts_interval(int fd, __u16 lsiri, __u16 lsipi, bool save, __u32 *result); @@ -1556,8 +1553,8 @@ int nvme_set_features_lba_sts_interval(int fd, __u16 lsiri, __u16 lsipi, * @fd: File descriptor of nvme device * @save: Save value across power states * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_host_behavior(int fd, bool save, struct nvme_feat_host_behavior *data); @@ -1568,8 +1565,8 @@ int nvme_set_features_host_behavior(int fd, bool save, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_sanitize(int fd, bool nodrm, bool save, __u32 *result); @@ -1581,8 +1578,8 @@ int nvme_set_features_sanitize(int fd, bool nodrm, bool save, __u32 *result); * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_endurance_evt_cfg(int fd, __u16 endgid, __u8 egwarn, bool save, __u32 *result); @@ -1593,8 +1590,8 @@ int nvme_set_features_endurance_evt_cfg(int fd, __u16 endgid, __u8 egwarn, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_sw_progress(int fd, __u8 pbslc, bool save, __u32 *result); @@ -1606,8 +1603,8 @@ int nvme_set_features_sw_progress(int fd, __u8 pbslc, bool save, * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_host_id(int fd, bool exhid, bool save, __u8 *hostid); @@ -1626,8 +1623,8 @@ enum nvme_feat_resv_notify_flags { * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_resv_mask(int fd, __u32 mask, bool save, __u32 *result); @@ -1637,8 +1634,8 @@ int nvme_set_features_resv_mask(int fd, __u32 mask, bool save, __u32 *result); * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_resv_persist(int fd, bool ptpl, bool save, __u32 *result); @@ -1662,8 +1659,8 @@ enum nvme_feat_nswpcfg_state { * @save: Save value across power states * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_features_write_protect(int fd, enum nvme_feat_nswpcfg_state state, bool save, __u32 *result); @@ -1680,8 +1677,8 @@ int nvme_set_features_write_protect(int fd, enum nvme_feat_nswpcfg_state state, * @data: User address of feature data, if applicable * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features(int fd, enum nvme_features_id fid, __u32 nsid, enum nvme_get_features_sel sel, __u32 cdw11, __u8 uuidx, @@ -1693,8 +1690,8 @@ int nvme_get_features(int fd, enum nvme_features_id fid, __u32 nsid, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_arbitration(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1705,8 +1702,8 @@ int nvme_get_features_arbitration(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_power_mgmt(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1717,8 +1714,8 @@ int nvme_get_features_power_mgmt(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_lba_range(int fd, enum nvme_get_features_sel sel, struct nvme_lba_range_type *data, @@ -1730,8 +1727,8 @@ int nvme_get_features_lba_range(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_temp_thresh(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1742,8 +1739,8 @@ int nvme_get_features_temp_thresh(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_err_recovery(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1754,8 +1751,8 @@ int nvme_get_features_err_recovery(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_volatile_wc(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1766,8 +1763,8 @@ int nvme_get_features_volatile_wc(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_num_queues(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1778,8 +1775,8 @@ int nvme_get_features_num_queues(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_irq_coalesce(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1790,8 +1787,8 @@ int nvme_get_features_irq_coalesce(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_irq_config(int fd, enum nvme_get_features_sel sel, __u16 iv, __u32 *result); @@ -1802,8 +1799,8 @@ int nvme_get_features_irq_config(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_write_atomic(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1814,8 +1811,8 @@ int nvme_get_features_write_atomic(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_async_event(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1826,8 +1823,8 @@ int nvme_get_features_async_event(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_auto_pst(int fd, enum nvme_get_features_sel sel, struct nvme_feat_auto_pst *apst, __u32 *result); @@ -1838,8 +1835,8 @@ int nvme_get_features_auto_pst(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_host_mem_buf(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1850,8 +1847,8 @@ int nvme_get_features_host_mem_buf(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_timestamp(int fd, enum nvme_get_features_sel sel, struct nvme_timestamp *ts); @@ -1862,8 +1859,8 @@ int nvme_get_features_timestamp(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_kato(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1873,8 +1870,8 @@ int nvme_get_features_kato(int fd, enum nvme_get_features_sel sel, __u32 *result * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_hctm(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1884,8 +1881,8 @@ int nvme_get_features_hctm(int fd, enum nvme_get_features_sel sel, __u32 *result * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_nopsc(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1895,8 +1892,8 @@ int nvme_get_features_nopsc(int fd, enum nvme_get_features_sel sel, __u32 *resul * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_rrl(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1906,8 +1903,8 @@ int nvme_get_features_rrl(int fd, enum nvme_get_features_sel sel, __u32 *result) * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_plm_config(int fd, enum nvme_get_features_sel sel, __u16 nvmsetid, struct nvme_plm_config *data, @@ -1919,8 +1916,8 @@ int nvme_get_features_plm_config(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_plm_window(int fd, enum nvme_get_features_sel sel, __u16 nvmsetid, __u32 *result); @@ -1931,8 +1928,8 @@ int nvme_get_features_plm_window(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_lba_sts_interval(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1943,8 +1940,8 @@ int nvme_get_features_lba_sts_interval(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_host_behavior(int fd, enum nvme_get_features_sel sel, struct nvme_feat_host_behavior *data, @@ -1956,8 +1953,8 @@ int nvme_get_features_host_behavior(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_sanitize(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1968,8 +1965,8 @@ int nvme_get_features_sanitize(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_endurance_event_cfg(int fd, enum nvme_get_features_sel sel, __u16 endgid, __u32 *result); @@ -1980,8 +1977,8 @@ int nvme_get_features_endurance_event_cfg(int fd, enum nvme_get_features_sel sel * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_sw_progress(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -1992,8 +1989,8 @@ int nvme_get_features_sw_progress(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_host_id(int fd, enum nvme_get_features_sel sel, bool exhid, __u32 len, __u8 *hostid); @@ -2004,8 +2001,8 @@ int nvme_get_features_host_id(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_resv_mask(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -2016,8 +2013,8 @@ int nvme_get_features_resv_mask(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_resv_persist(int fd, enum nvme_get_features_sel sel, __u32 *result); @@ -2029,8 +2026,8 @@ int nvme_get_features_resv_persist(int fd, enum nvme_get_features_sel sel, * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_features_write_protect(int fd, __u32 nsid, enum nvme_get_features_sel sel, @@ -2054,8 +2051,8 @@ int nvme_get_features_write_protect(int fd, __u32 nsid, * size. A low level format may destroy all data and metadata associated with * all namespaces or only the specific namespace associated with the command * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_format_nvm(int fd, __u32 nsid, __u8 lbaf, enum nvme_cmd_format_mset mset, @@ -2083,8 +2080,8 @@ int nvme_ns_mgmt(int fd, __u32 nsid, enum nvme_ns_mgmt_sel sel, * attached to any controller. Use the nvme_ns_attach_ctrls() to assign the * namespace to one or more controllers. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_ns_mgmt_create(int fd, struct nvme_id_ns *ns, __u32 *nsid, __u32 timeout); @@ -2098,8 +2095,8 @@ int nvme_ns_mgmt_create(int fd, struct nvme_id_ns *ns, __u32 *nsid, * controller. Use the nvme_ns_detach_ctrls() first if the namespace is still * attached. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_ns_mgmt_delete(int fd, __u32 nsid); @@ -2122,12 +2119,12 @@ int nvme_ns_attach(int fd, __u32 nsid, enum nvme_ns_attach_sel sel, int nvme_ns_attach_ctrls(int fd, __u32 nsid, struct nvme_ctrl_list *ctrlist); /** - * nvme_ns_dettach_ctrls() - + * nvme_ns_detach_ctrls() - * @fd: File descriptor of nvme device - * @nsid: Namespace ID to dettach + * @nsid: Namespace ID to detach * @ctrlist: Controller list to modify attachment state of nsid */ -int nvme_ns_dettach_ctrls(int fd, __u32 nsid, struct nvme_ctrl_list *ctrlist); +int nvme_ns_detach_ctrls(int fd, __u32 nsid, struct nvme_ctrl_list *ctrlist); /** * nvme_fw_download() - Download part or all of a firmware image to the @@ -2150,8 +2147,8 @@ int nvme_ns_dettach_ctrls(int fd, __u32 nsid, struct nvme_ctrl_list *ctrlist); * Download command. Use the nvme_fw_commit() to activate a newly downloaded * image. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_fw_download(int fd, __u32 offset, __u32 data_len, void *data); @@ -2165,8 +2162,9 @@ int nvme_fw_download(int fd, __u32 offset, __u32 data_len, void *data); * The Firmware Commit command is used to modify the firmware image or Boot * Partitions. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. The command status response may specify additional + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. The command status + * response may specify additional * reset actions required to complete the commit process. */ int nvme_fw_commit(int fd, __u8 slot, enum nvme_fw_commit_ca action, bool bpid); @@ -2193,8 +2191,8 @@ int nvme_fw_commit(int fd, __u8 slot, enum nvme_fw_commit_ca action, bool bpid); * The security data is protocol specific and is not defined by the NVMe * specification. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_security_send(int fd, __u32 nsid, __u8 nssf, __u8 spsp0, __u8 spsp1, __u8 secp, __u32 tl, __u32 data_len, void *data, @@ -2213,8 +2211,8 @@ int nvme_security_send(int fd, __u32 nsid, __u8 nssf, __u8 spsp0, __u8 spsp1, * @data: Security data payload to send * @result: The command completion result from CQE dword0 * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_security_receive(int fd, __u32 nsid, __u8 nssf, __u8 spsp0, __u8 spsp1, __u8 secp, __u32 al, __u32 data_len, @@ -2234,8 +2232,8 @@ int nvme_security_receive(int fd, __u32 nsid, __u8 nssf, __u8 spsp0, * The Get LBA Status command requests information about Potentially * Unrecoverable LBAs. Refer to the specification for action type descriptions. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_lba_status(int fd, __u32 nsid, __u64 slba, __u32 mndw, __u16 rl, enum nvme_lba_status_atype atype, @@ -2259,8 +2257,8 @@ int nvme_get_lba_status(int fd, __u32 nsid, __u64 slba, __u32 mndw, __u16 rl, * * See the NVMe specification for more information. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_directive_send(int fd, __u32 nsid, __u16 dspec, enum nvme_directive_send_doper doper, @@ -2272,8 +2270,8 @@ int nvme_directive_send(int fd, __u32 nsid, __u16 dspec, * @fd: File descriptor of nvme device * @nsid: Namespace ID * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_directive_send_id_endir(int fd, __u32 nsid, bool endir, enum nvme_directive_dtype dtype, @@ -2284,8 +2282,8 @@ int nvme_directive_send_id_endir(int fd, __u32 nsid, bool endir, * @fd: File descriptor of nvme device * @nsid: Namespace ID * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_directive_send_stream_release_identifier(int fd, __u32 nsid, __u16 stream_id); @@ -2295,8 +2293,8 @@ int nvme_directive_send_stream_release_identifier(int fd, __u32 nsid, * @fd: File descriptor of nvme device * @nsid: Namespace ID * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_directive_send_stream_release_resource(int fd, __u32 nsid); @@ -2312,8 +2310,8 @@ int nvme_directive_send_stream_release_resource(int fd, __u32 nsid); * @data: Usespace address of data payload in bytes * @result: If successful, the CQE dword0 value * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_directive_recv(int fd, __u32 nsid, __u16 dspec, enum nvme_directive_receive_doper doper, @@ -2325,8 +2323,8 @@ int nvme_directive_recv(int fd, __u32 nsid, __u16 dspec, * @fd: File descriptor of nvme device * @nsid: Namespace ID * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_directive_recv_identify_parameters(int fd, __u32 nsid, struct nvme_id_directives *id); @@ -2336,8 +2334,8 @@ int nvme_directive_recv_identify_parameters(int fd, __u32 nsid, * @fd: File descriptor of nvme device * @nsid: Namespace ID * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_directive_recv_stream_parameters(int fd, __u32 nsid, struct nvme_streams_directive_params *parms); @@ -2347,8 +2345,8 @@ int nvme_directive_recv_stream_parameters(int fd, __u32 nsid, * @fd: File descriptor of nvme device * @nsid: Namespace ID * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_directive_recv_stream_status(int fd, __u32 nsid, unsigned nr_entries, struct nvme_streams_directive_status *id); @@ -2358,8 +2356,8 @@ int nvme_directive_recv_stream_status(int fd, __u32 nsid, unsigned nr_entries, * @fd: File descriptor of nvme device * @nsid: Namespace ID * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_directive_recv_stream_allocate(int fd, __u32 nsid, __u16 nsr, __u32 *result); @@ -2391,8 +2389,8 @@ enum nvme_fctype { * This is an NVMe-over-Fabrics specific command, not applicable to PCIe. These * properties align to the PCI MMIO controller registers. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_set_property(int fd, int offset, __u64 value); @@ -2405,8 +2403,8 @@ int nvme_set_property(int fd, int offset, __u64 value); * This is an NVMe-over-Fabrics specific command, not applicable to PCIe. These * properties align to the PCI MMIO controller registers. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_property(int fd, int offset, __u64 *value); @@ -2430,8 +2428,8 @@ int nvme_get_property(int fd, int offset, __u64 *value); * sanitize operations are processed in the background, i.e., completion of the * sanitize command does not indicate completion of the sanitize operation. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_sanitize_nvm(int fd, enum nvme_sanitize_sanact sanact, bool ause, __u8 owpass, bool oipbp, bool nodas, __u32 ovrpat); @@ -2453,8 +2451,8 @@ int nvme_sanitize_nvm(int fd, enum nvme_sanitize_sanact sanact, bool ause, * 0xffffffff to test all namespaces. All other values tests a specific * namespace, if present. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_dev_self_test(int fd, __u32 nsid, enum nvme_dst_stc stc); @@ -2475,17 +2473,13 @@ int nvme_dev_self_test(int fd, __u32 nsid, enum nvme_dst_stc stc); * - Assigning Flexible Resources for secondary controllers * - Setting the Online and Offline state for secondary controllers * - * Return: The nvme command status if a response was received or -1 - * with errno set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_virtual_mgmt(int fd, enum nvme_virt_mgmt_act act, enum nvme_virt_mgmt_rt rt, __u16 cntlid, __u16 nr, __u32 *result); -/** - * DOC: NVMe IO command - */ - /** * enum nvme_io_opcode - * @nvme_cmd_flush: @@ -2524,8 +2518,8 @@ enum nvme_io_opcode { * The Flush command is used to request that the contents of volatile write * cache be made non-volatile. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_flush(int fd, __u32 nsid); @@ -2609,8 +2603,8 @@ enum nvme_io_dsm_flags { * metadata_len:Length of user buffer, @metadata, in bytes * @metadata: Pointer to user address of the metadata buffer * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_read(int fd, __u32 nsid, __u64 slba, __u16 nlb, __u16 control, __u8 dsm, __u32 reftag, __u16 apptag, __u16 appmask, @@ -2639,8 +2633,8 @@ int nvme_read(int fd, __u32 nsid, __u64 slba, __u16 nlb, __u16 control, * metadata_len:Length of user buffer, @metadata, in bytes * @metadata: Pointer to user address of the metadata buffer * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_write(int fd, __u32 nsid, __u64 slba, __u16 nlb, __u16 control, __u8 dsm, __u16 dspec, __u32 reftag, __u16 apptag, @@ -2668,8 +2662,8 @@ int nvme_write(int fd, __u32 nsid, __u64 slba, __u16 nlb, __u16 control, * metadata_len:Length of user buffer, @metadata, in bytes * @metadata: Pointer to user address of the metadata buffer * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_compare(int fd, __u32 nsid, __u64 slba, __u16 nlb, __u16 control, __u32 reftag, __u16 apptag, __u16 appmask, __u32 data_len, @@ -2697,8 +2691,8 @@ int nvme_compare(int fd, __u32 nsid, __u64 slba, __u16 nlb, __u16 control, * subsequent reads of logical blocks in this range shall be all bytes cleared * to 0h until a write occurs to this LBA range. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_write_zeros(int fd, __u32 nsid, __u64 slba, __u16 nlb, __u16 control, __u32 reftag, __u16 apptag, __u16 appmask); @@ -2716,8 +2710,8 @@ int nvme_write_zeros(int fd, __u32 nsid, __u64 slba, __u16 nlb, __u16 control, * invalid logical block status, a write operation on those logical blocks is * required. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_write_uncorrectable(int fd, __u32 nsid, __u64 slba, __u16 nlb); @@ -2742,8 +2736,8 @@ int nvme_write_uncorrectable(int fd, __u32 nsid, __u64 slba, __u16 nlb); * and metadata, if applicable, for the LBAs indicated without transferring any * data or metadata to the host. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_verify(int fd, __u32 nsid, __u64 slba, __u16 nlb, __u16 control, __u32 reftag, __u16 apptag, __u16 appmask); @@ -2774,8 +2768,8 @@ enum nvme_dsm_attributes { * to optimize performance and reliability, and may be used to * deallocate/unmap/trim those logical blocks. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_dsm(int fd, __u32 nsid, __u32 attrs, __u16 nr_ranges, struct nvme_dsm_range *dsm); @@ -2825,8 +2819,8 @@ enum nvme_reservation_racqa { * namespace, preempt a reservation held on a namespace, and abort a * reservation held on a namespace. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_resv_acquire(int fd, __u32 nsid, enum nvme_reservation_rtype rtype, enum nvme_reservation_racqa racqa, bool iekey, @@ -2870,8 +2864,8 @@ enum nvme_reservation_cptpl { * The Reservation Register command is used to register, unregister, or replace * a reservation key. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_resv_register(int fd, __u32 nsid, enum nvme_reservation_rrega rrega, enum nvme_reservation_cptpl cptpl, bool iekey, @@ -2896,8 +2890,8 @@ enum nvme_reservation_rrela { * @iekey: Set to ignore the existing key * @crkey: The current reservation key to release * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_resv_release(int fd, __u32 nsid, enum nvme_reservation_rtype rtype, enum nvme_reservation_rrela rrela, bool iekey, @@ -2915,8 +2909,8 @@ int nvme_resv_release(int fd, __u32 nsid, enum nvme_reservation_rtype rtype, * registration and reservation status of a namespace. See the defintion for * the returned structure, &struct nvme_reservation_status, for more details. * - * Return: The nvme command status if a response was received or -1 with errno - * set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_resv_report(int fd, __u32 nsid, bool eds, __u32 len, struct nvme_reservation_status *report); diff --git a/src/nvme/tree.c b/src/nvme/tree.c index f4218a39..05bfe74b 100644 --- a/src/nvme/tree.c +++ b/src/nvme/tree.c @@ -23,6 +23,9 @@ #include "filters.h" #include "util.h" +/* XXX: Make a place for private declarations */ +extern int nvme_set_attr(const char *dir, const char *attr, const char *value); + struct nvme_path { struct list_node entry; struct list_node nentry; diff --git a/src/nvme/types.h b/src/nvme/types.h index cc139c4f..02b3a6dc 100644 --- a/src/nvme/types.h +++ b/src/nvme/types.h @@ -22,30 +22,55 @@ #define __force #endif +/** + * cpu_to_le16() - + * @x: 16-bit CPU value to turn to little endian. + */ static inline __le16 cpu_to_le16(uint16_t x) { return (__force __le16)htole16(x); } +/** + * cpu_to_le32() - + * @x: 32-bit CPU value to turn little endian. + */ static inline __le32 cpu_to_le32(uint32_t x) { return (__force __le32)htole32(x); } +/** + * cpu_to_le64() - + * @x: 64-bit CPU value to turn little endian. + */ static inline __le64 cpu_to_le64(uint64_t x) { return (__force __le64)htole64(x); } +/** + * le16_to_cpu() - + * @x: 16-bit little endian value to turn to CPU. + */ static inline uint16_t le16_to_cpu(__le16 x) { return le16toh((__force __u16)x); } +/** + * le32_to_cpu() - + * @x: 32-bit little endian value to turn to CPU. + */ static inline uint32_t le32_to_cpu(__le32 x) { - return le32toh((__force __u32)x); } + return le32toh((__force __u32)x); +} +/** + * le64_to_cpu() - + * @x: 64-bit little endian value to turn to CPU. + */ static inline uint64_t le64_to_cpu(__le64 x) { return le64toh((__force __u64)x); @@ -77,8 +102,12 @@ static inline uint64_t le64_to_cpu(__le64 x) * lba range type * @NVME_LOG_ST_MAX_RESULTS: The largest possible self test result index in the * device self test log + * @NVME_LOG_TELEM_BLOCK_SIZE: Specification defined size of Telemetry Data Blocks * @NVME_DSM_MAX_RANGES: The largest possible range index in a data-set * management command + * @NVME_NQN_LENGTH: Max length for NVMe Qualified Name. + * @NVMF_TRADDR_SIZE: + * @NVMF_TSAS_SIZE: */ enum nvme_constants { NVME_NSID_ALL = 0xffffffff, @@ -97,7 +126,11 @@ enum nvme_constants { NVME_ID_ND_DESCRIPTOR_MAX = 16, NVME_FEAT_LBA_RANGE_MAX = 64, NVME_LOG_ST_MAX_RESULTS = 20, + NVME_LOG_TELEM_BLOCK_SIZE = 512, NVME_DSM_MAX_RANGES = 256, + NVME_NQN_LENGTH = 256, + NVMF_TRADDR_SIZE = 256, + NVMF_TSAS_SIZE = 256, }; /** @@ -208,7 +241,8 @@ enum { }; /** - * is_64bit_reg() - Checks if offset of the controller register is 64bit or not. + * nvme_is_64bit_reg() - Checks if offset of the controller register is a know + * 64bit value. * @offset: Offset of controller register field in bytes * * This function does not care about transport so that the offset is not going @@ -218,7 +252,7 @@ enum { * * Returns true if given offset is 64bit register, otherwise it returns false. */ -static inline bool is_64bit_reg(__u32 offset) +static inline bool nvme_is_64bit_reg(__u32 offset) { switch (offset) { case NVME_REG_CAP: @@ -619,7 +653,7 @@ struct nvme_id_ctrl { __le32 sgls; __le32 mnan; __u8 rsvd544[224]; - char subnqn[256]; + char subnqn[NVME_NQN_LENGTH]; __u8 rsvd1024[768]; /* Fabrics Only */ @@ -2189,7 +2223,7 @@ struct nvme_persistent_event_log { __le16 ssvid; char sn[20]; char mn[40]; - char subnqn[256]; + char subnqn[NVME_NQN_LENGTH]; __u8 rsvd372; __u8 seb[32]; }; @@ -2771,14 +2805,9 @@ enum nvme_subsys_type { #define NVME_DISC_SUBSYS_NAME "nqn.2014-08.org.nvmexpress.discovery" #define NVME_RDMA_IP_PORT 4420 -/* NQN names in commands fields specified one size */ -#define NVMF_NQN_FIELD_LEN 256 - /* However the max length of a qualified name is another size */ #define NVMF_NQN_SIZE 223 #define NVMF_TRSVCID_SIZE 32 -#define NVMF_TRADDR_SIZE 256 -#define NVMF_TSAS_SIZE 256 /** * struct nvmf_disc_log_entry - Discovery log page entry @@ -2810,7 +2839,7 @@ struct nvmf_disc_log_entry { __u8 resv10[22]; char trsvcid[NVMF_TRSVCID_SIZE]; __u8 resv64[192]; - char subnqn[NVMF_NQN_FIELD_LEN]; + char subnqn[NVME_NQN_LENGTH]; char traddr[NVMF_TRADDR_SIZE]; union tsas { char common[NVMF_TSAS_SIZE]; @@ -2949,8 +2978,8 @@ struct nvmf_connect_data { __u8 hostid[16]; __le16 cntlid; char resv4[238]; - char subsysnqn[NVMF_NQN_FIELD_LEN]; - char hostnqn[NVMF_NQN_FIELD_LEN]; + char subsysnqn[NVME_NQN_LENGTH]; + char hostnqn[NVME_NQN_LENGTH]; char resv5[256]; }; @@ -3267,14 +3296,14 @@ struct nvme_mi_vpd_tra { /** * struct nvme_mi_vpd_mr_common - - * @type; - * @rf; - * @rlen; - * @rchksum; - * @hchksum; -nmra; - * @ppmra; - * @tmra; + * @type: + * @rf: + * @rlen: + * @rchksum: + * @hchksum: + * @nmra: + * @ppmra: + * @tmra: */ struct nvme_mi_vpd_mr_common { __u8 type; @@ -3314,21 +3343,374 @@ struct nvme_mi_vpd_hdr { }; /** - * enum - - */ -enum { + * enum nvme_status_code - Defines all parts of the nvme status field: status + * code, status code type, and additional flags. + * @NVME_SCT_MASK: Mask to get the value of the Status Code Type + * @NVME_SCT_GENERIC: Generic errors applicable to multiple opcodes + * @NVME_SCT_CMD_SPECIFIC: Errors associated to a specific opcode + * @NVME_SCT_MEDIA: Errors associated with media and data integrity + * @NVME_SCT_PATH: Errors associated with the paths connection + * @NVME_SCT_VS: Vendor specific errors + * @NVME_SC_MASK: Mask to get the value of the status code. + * @NVME_SC_SUCCESS: Successful Completion: The command + * completed without error. + * @NVME_SC_INVALID_OPCODE: Invalid Command Opcode: A reserved coded + * value or an unsupported value in the command opcode field. + * @NVME_SC_INVALID_FIELD: Invalid Field in Command: A reserved + * coded value or an unsupported value in a defined field. + * @NVME_SC_CMDID_CONFLICT: Command ID Conflict: The command + * identifier is already in use. + * @NVME_SC_DATA_XFER_ERROR: Data Transfer Error: Transferring the + * data or metadata associated with a command experienced an error. + * @NVME_SC_POWER_LOSS: Commands Aborted due to Power Loss + * Notification: Indicates that the command + * was aborted due to a power loss + * notification. + * @NVME_SC_INTERNAL: Internal Error: The command was not + * completed successfully due to an internal error. + * @NVME_SC_ABORT_REQ: Command Abort Requested: The command was + * aborted due to an Abort command being + * received that specified the Submission + * Queue Identifier and Command Identifier + * of this command. + * @NVME_SC_ABORT_QUEUE: Command Aborted due to SQ Deletion: The + * command was aborted due to a Delete I/O + * Submission Queue request received for the + * Submission Queue to which the command was + * submitted. + * @NVME_SC_FUSED_FAIL: Command Aborted due to Failed Fused Command: + * The command was aborted due to the other + * command in a fused operation failing. + * @NVME_SC_FUSED_MISSING: Aborted due to Missing Fused Command: The + * fused command was aborted due to the + * adjacent submission queue entry not + * containing a fused command that is the + * other command. + * @NVME_SC_INVALID_NS: Invalid Namespace or Format: The + * namespace or the format of that namespace is invalid. + * @NVME_SC_CMD_SEQ_ERROR: Command Sequence Error: The command was + * aborted due to a protocol violation in a multi-command sequence. + * @NVME_SC_SGL_INVALID_LAST: Invalid SGL Segment Descriptor: The + * command includes an invalid SGL Last Segment or SGL Segment descriptor. + * @NVME_SC_SGL_INVALID_COUNT: Invalid Number of SGL Descriptors: There + * is an SGL Last Segment descriptor or an + * SGL Segment descriptor in a location + * other than the last descriptor of a + * segment based on the length indicated. + * @NVME_SC_SGL_INVALID_DATA: Data SGL Length Invalid: This may occur + * if the length of a Data SGL is too short. + * This may occur if the length of a Data + * SGL is too long and the controller does + * not support SGL transfers longer than the + * amount of data to be transferred as + * indicated in the SGL Support field of the + * Identify Controller data structure. + * @NVME_SC_SGL_INVALID_METADATA: Metadata SGL Length Invalid: This may + * occur if the length of a Metadata SGL is + * too short. This may occur if the length + * of a Metadata SGL is too long and the + * controller does not support SGL transfers + * longer than the amount of data to be + * transferred as indicated in the SGL + * Support field of the Identify Controller + * data structure. + * @NVME_SC_SGL_INVALID_TYPE: SGL Descriptor Type Invalid: The type of + * an SGL Descriptor is a type that is not supported by the controller. + * @NVME_SC_CMB_INVALID_USE: Invalid Use of Controller Memory Buffer: + * The attempted use of the Controller + * Memory Buffer is not supported by the + * controller. + * @NVME_SC_PRP_INVALID_OFFSET: PRP Offset Invalid: The Offset field for + * a PRP entry is invalid. + * @NVME_SC_AWU_EXCEEDED: Atomic Write Unit Exceeded: The length + * specified exceeds the atomic write unit size. + * @NVME_SC_OP_DENIED: Operation Denied: The command was denied + * due to lack of access rights. Refer to + * the appropriate security specification. + * @NVME_SC_SGL_INVALID_OFFSET: SGL Offset Invalid: The offset specified + * in a descriptor is invalid. This may + * occur when using capsules for data + * transfers in NVMe over Fabrics + * implementations and an invalid offset in + * the capsule is specified. + * @NVME_SC_HOSTID_FORMAT: Host Identifier Inconsistent Format: The + * NVM subsystem detected the simultaneous + * use of 64- bit and 128-bit Host + * Identifier values on different + * controllers. + * @NVME_SC_KAT_EXPIRED: Keep Alive Timer Expired: The Keep Alive + * Timer expired. + * @NVME_SC_KAT_INVALID: Keep Alive Timeout Invalid: The Keep + * Alive Timeout value specified is invalid. + * @NVME_SC_CMD_ABORTED_PREMEPT: Command Aborted due to Preempt and Abort: + * The command was aborted due to a Reservation Acquire command. + * @NVME_SC_SANITIZE_FAILED: Sanitize Failed: The most recent sanitize + * operation failed and no recovery action has been successfully completed. + * @NVME_SC_SANITIZE_IN_PROGRESS: Sanitize In Progress: The requested + * function (e.g., command) is prohibited + * while a sanitize operation is in + * progress. + * @NVME_SC_SGL_INVALID_GRANULARITY: SGL Data Block Granularity Invalid: The + * Address alignment or Length granularity + * for an SGL Data Block descriptor is + * invalid. + * @NVME_SC_CMD_IN_CMBQ_NOT_SUPP: Command Not Supported for Queue in CMB: + * The implementation does not support + * submission of the command to a Submission + * Queue in the Controller Memory Buffer or + * command completion to a Completion Queue + * in the Controller Memory Buffer. + * @NVME_SC_NS_WRITE_PROTECTED: Namespace is Write Protected: The command + * is prohibited while the namespace is + * write protected as a result of a change + * in the namespace write protection state + * as defined by the Namespace Write + * Protection State Machine. + * @NVME_SC_CMD_INTERRUPTED: Command Interrupted: Command processing + * was interrupted and the controller is + * unable to successfully complete the + * command. The host should retry the + * command. + * @NVME_SC_TRAN_TPORT_ERROR: Transient Transport Error: A transient + * transport error was detected. If the + * command is retried on the same + * controller, the command is likely to + * succeed. A command that fails with a + * transient transport error four or more + * times should be treated as a persistent + * transport error that is not likely to + * succeed if retried on the same + * controller. + * @NVME_SC_LBA_RANGE: LBA Out of Range: The command references + * an LBA that exceeds the size of the namespace. + * @NVME_SC_CAP_EXCEEDED: Capacity Exceeded: Execution of the + * command has caused the capacity of the + * namespace to be exceeded. + * @NVME_SC_NS_NOT_READY: Namespace Not Ready: The namespace is not + * ready to be accessed as a result of a + * condition other than a condition that is + * reported as an Asymmetric Namespace + * Access condition. + * @NVME_SC_RESERVATION_CONFLICT: Reservation Conflict: The command was + * aborted due to a conflict with a + * reservation held on the accessed + * namespace. + * @NVME_SC_FORMAT_IN_PROGRESS: Format In Progress: A Format NVM command + * is in progress on the namespace. + * @NVME_SC_CQ_INVALID: Completion Queue Invalid: The Completion + * Queue identifier specified in the command + * does not exist. + * @NVME_SC_QID_INVALID: Invalid Queue Identifier: The creation of + * the I/O Completion Queue failed due to an + * invalid queue identifier specified as + * part of the command. An invalid queue + * identifier is one that is currently in + * use or one that is outside the range + * supported by the controller. + * @NVME_SC_QUEUE_SIZE: Invalid Queue Size: The host attempted to + * create an I/O Completion Queue with an + * invalid number of entries. + * @NVME_SC_ABORT_LIMIT: Abort Command Limit Exceeded: The number + * of concurrently outstanding Abort commands has exceeded the limit indicated + * in the Identify Controller data + * structure. + * @NVME_SC_ABORT_MISSING: Abort Command is missing: The abort + * command is missing. + * @NVME_SC_ASYNC_LIMIT: Asynchronous Event Request Limit + * Exceeded: The number of concurrently + * outstanding Asynchronous Event Request + * commands has been exceeded. + * @NVME_SC_FIRMWARE_SLOT: Invalid Firmware Slot: The firmware slot + * indicated is invalid or read only. This + * error is indicated if the firmware slot + * exceeds the number supported. + * @NVME_SC_FIRMWARE_IMAGE: Invalid Firmware Image: The firmware + * image specified for activation is invalid + * and not loaded by the controller. + * @NVME_SC_INVALID_VECTOR: Invalid Interrupt Vector: The creation of + * the I/O Completion Queue failed due to an + * invalid interrupt vector specified as + * part of the command. + * @NVME_SC_INVALID_LOG_PAGE: Invalid Log Page: The log page indicated + * is invalid. This error condition is also + * returned if a reserved log page is + * requested. + * @NVME_SC_INVALID_FORMAT: Invalid Format: The LBA Format specified + * is not supported. + * @NVME_SC_FW_NEEDS_CONV_RESET: Firmware Activation Requires Conventional Reset: + * The firmware commit was successful, + * however, activation of the firmware image + * requires a conventional reset. + * @NVME_SC_INVALID_QUEUE: Invalid Queue Deletion: Invalid I/O + * Completion Queue specified to delete. + * @NVME_SC_FEATURE_NOT_SAVEABLE: Feature Identifier Not Saveable: The + * Feature Identifier specified does not + * support a saveable value. + * @NVME_SC_FEATURE_NOT_CHANGEABLE: Feature Not Changeable: The Feature + * Identifier is not able to be changed. + * @NVME_SC_FEATURE_NOT_PER_NS: Feature Not Namespace Specific: The + * Feature Identifier specified is not + * namespace specific. The Feature + * Identifier settings apply across all + * namespaces. + * @NVME_SC_FW_NEEDS_SUBSYS_RESET: Firmware Activation Requires NVM + * Subsystem Reset: The firmware commit was + * successful, however, activation of the + * firmware image requires an NVM Subsystem. + * @NVME_SC_FW_NEEDS_RESET: Firmware Activation Requires Controller + * Level Reset: The firmware commit was + * successful; however, the image specified + * does not support being activated without + * a reset. + * @NVME_SC_FW_NEEDS_MAX_TIME: Firmware Activation Requires Maximum Time + * Violation: The image specified if + * activated immediately would exceed the + * Maximum Time for Firmware Activation + * (MTFA) value reported in Identify + * Controller. + * @NVME_SC_FW_ACTIVATE_PROHIBITED: Firmware Activation Prohibited: The image + * specified is being prohibited from + * activation by the controller for vendor + * specific reasons. + * @NVME_SC_OVERLAPPING_RANGE: Overlapping Range: The downloaded + * firmware image has overlapping ranges. + * @NVME_SC_NS_INSUFFICIENT_CAP: Namespace Insufficient Capacity: Creating + * the namespace requires more free space + * than is currently available. + * @NVME_SC_NS_ID_UNAVAILABLE: Namespace Identifier Unavailable: The + * number of namespaces supported has been + * exceeded. + * @NVME_SC_NS_ALREADY_ATTACHED: Namespace Already Attached: The + * controller is already attached to the + * namespace specified. + * @NVME_SC_NS_IS_PRIVATE: Namespace Is Private: The namespace is + * private and is already attached to one + * controller. + * @NVME_SC_NS_NOT_ATTACHED: Namespace Not Attached: The request to + * detach the controller could not be completed because the controller is not + * attached to the namespace. + * @NVME_SC_THIN_PROV_NOT_SUPP: Thin Provisioning Not Supported: Thin + * provisioning is not supported by the + * controller. + * @NVME_SC_CTRL_LIST_INVALID: Controller List Invalid: The controller + * list provided contains invalid controller + * ids. + * @NVME_SC_SELF_TEST_IN_PROGRESS: Device Self-test In Progress: + * @NVME_SC_BP_WRITE_PROHIBITED: Boot Partition Write Prohibited: The + * command is trying to modify a locked Boot + * Partition. + * @NVME_SC_INVALID_CTRL_ID: Invalid Controller Identifier: + * @NVME_SC_INVALID_SEC_CTRL_STATE: Invalid Secondary Controller State + * @NVME_SC_INVALID_CTRL_RESOURCES: Invalid Number of Controller Resources + * @NVME_SC_INVALID_RESOURCE_ID: Invalid Resource Identifier + * @NVME_SC_PMR_SAN_PROHIBITED: Sanitize Prohibited While Persistent + * Memory Region is Enabled + * @NVME_SC_ANA_GROUP_ID_INVALID: ANA Group Identifier Invalid + * @NVME_SC_ANA_ATTACH_FAILED: ANA Attach Failed + * @NVME_SC_BAD_ATTRIBUTES: Conflicting Dataset Management Attributes + * @NVME_SC_INVALID_PI: Invalid Protection Information + * @NVME_SC_READ_ONLY: Attempted Write to Read Only Range + * @NVME_SC_CONNECT_FORMAT: Incompatible Format: The NVM subsystem + * does not support the record format + * specified by the host. + * @NVME_SC_CONNECT_CTRL_BUSY: Controller Busy: The controller is + * already associated with a host. + * @NVME_SC_CONNECT_INVALID_PARAM: Connect Invalid Parameters: One or more + * of the command parameters. + * @NVME_SC_CONNECT_RESTART_DISC: Connect Restart Discovery: The NVM + * subsystem requested is not available. + * @NVME_SC_CONNECT_INVALID_HOST: Connect Invalid Host: The host is either + * not allowed to establish an association + * to any controller in the NVM subsystem or + * the host is not allowed to establish an + * association to the specified controller + * @NVME_SC_DISCONNECT_INVALID_QTYPE: Invalid Queue Type: The command was sent + * on the wrong queue type. + * @NVME_SC_DISCOVERY_RESTART: Discover Restart: The snapshot of the + * records is now invalid or out of date. + * @NVME_SC_AUTH_REQUIRED: Authentication Required: NVMe in-band + * authentication is required and the queue + * has not yet been authenticated. + * @NVME_SC_WRITE_FAULT: Write Fault: The write data could not be + * committed to the media. + * @NVME_SC_READ_ERROR: Unrecovered Read Error: The read data + * could not be recovered from the media. + * @NVME_SC_GUARD_CHECK: End-to-end Guard Check Error: The command + * was aborted due to an end-to-end guard + * check failure. + * @NVME_SC_APPTAG_CHECK: End-to-end Application Tag Check Error: + * The command was aborted due to an + * end-to-end application tag check failure. + * @NVME_SC_REFTAG_CHECK: End-to-end Reference Tag Check Error: The + * command was aborted due to an end-to-end + * reference tag check failure. + * @NVME_SC_COMPARE_FAILED: Compare Failure: The command failed due + * to a miscompare during a Compare command. + * @NVME_SC_ACCESS_DENIED: Access Denied: Access to the namespace + * and/or LBA range is denied due to lack of + * access rights. + * @NVME_SC_UNWRITTEN_BLOCK: Deallocated or Unwritten Logical Block: + * The command failed due to an attempt to + * read from or verify an LBA range + * containing a deallocated or unwritten + * logical block. + * @NVME_SC_ANA_INTERNAL_PATH_ERROR: Internal Path Error: The command was not + * completed as the result of a controller + * internal error that is specific to the + * controller processing the command. + * @NVME_SC_ANA_PERSISTENT_LOSS: Asymmetric Access Persistent Loss: The + * requested function (e.g., command) is not + * able to be performed as a result of the + * relationship between the controller and + * the namespace being in the ANA Persistent + * Loss state. + * @NVME_SC_ANA_INACCESSIBLE: Asymmetric Access Inaccessible: The + * requested function (e.g., command) is not + * able to be performed as a result of the + * relationship between the controller and + * the namespace being in the ANA + * Inaccessible state. + * @NVME_SC_ANA_TRANSITION: Asymmetric Access Transition: The + * requested function (e.g., command) is not + * able to be performed as a result of the + * relationship between the controller and + * the namespace transitioning between + * Asymmetric Namespace Access states. + * @NVME_SC_CTRL_PATH_ERROR: Controller Pathing Error: A pathing error + * was detected by the controller. + * @NVME_SC_HOST_PATH_ERROR: Host Pathing Error: A pathing error was + * detected by the host. + * @NVME_SC_CMD_ABORTED_BY_HOST: Command Aborted By Host: The command was + * aborted as a result of host action. + * @NVME_SC_CRD: Mask to get value of Command Retry Delay + * index + * @NVME_SC_MORE: More bit. If set, more status information + * for this command as part of the Error + * Information log that may be retrieved with + * the Get Log Page command. + * @NVME_SC_DNR: Do Not Retry bit. If set, if the same + * command is re-submitted to any controller + * in the NVM subsystem, then that + * re-submitted command is expected to fail. + */ +enum nvme_status_field { /* - * Status code type + * Status Code Type indicators */ + NVME_SCT_MASK = 0x700, NVME_SCT_GENERIC = 0x000, NVME_SCT_CMD_SPECIFIC = 0x100, NVME_SCT_MEDIA = 0x200, NVME_SCT_PATH = 0x300, NVME_SCT_VS = 0x700, - NVME_SCT_MASK = 0x700, /* - * Generic Command Status: + * Status Code inidicators + */ + NVME_SC_MASK = 0xff, + + /* + * Generic Command Status Codes: */ NVME_SC_SUCCESS = 0x0, NVME_SC_INVALID_OPCODE = 0x1, @@ -3353,7 +3735,6 @@ enum { NVME_SC_AWU_EXCEEDED = 0x14, NVME_SC_OP_DENIED = 0x15, NVME_SC_SGL_INVALID_OFFSET = 0x16, - NVME_SC_HOSTID_FORMAT = 0x18, NVME_SC_KAT_EXPIRED = 0x19, NVME_SC_KAT_INVALID = 0x1a, @@ -3365,7 +3746,6 @@ enum { NVME_SC_NS_WRITE_PROTECTED = 0x20, NVME_SC_CMD_INTERRUPTED = 0x21, NVME_SC_TRAN_TPORT_ERROR = 0x22, - NVME_SC_LBA_RANGE = 0x80, NVME_SC_CAP_EXCEEDED = 0x81, NVME_SC_NS_NOT_READY = 0x82, @@ -3373,7 +3753,7 @@ enum { NVME_SC_FORMAT_IN_PROGRESS = 0x84, /* - * Command Specific Status: + * Command Specific Status Codes: */ NVME_SC_CQ_INVALID = 0x00, NVME_SC_QID_INVALID = 0x01, @@ -3429,7 +3809,6 @@ enum { NVME_SC_CONNECT_RESTART_DISC = 0x83, NVME_SC_CONNECT_INVALID_HOST = 0x84, NVME_SC_DISCONNECT_INVALID_QTYPE= 0x85, - NVME_SC_DISCOVERY_RESTART = 0x90, NVME_SC_AUTH_REQUIRED = 0x91, @@ -3452,25 +3831,40 @@ enum { NVME_SC_ANA_PERSISTENT_LOSS = 0x01, NVME_SC_ANA_INACCESSIBLE = 0x02, NVME_SC_ANA_TRANSITION = 0x03, - NVME_SC_CTRL_PATH_ERROR = 0x60, - NVME_SC_HOST_PATH_ERROR = 0x70, NVME_SC_CMD_ABORTED_BY_HOST = 0x71, /* - * Status code mask - */ - NVME_SC_MASK = 0xff, - - /* - * Additional status info + * Additional status field flags */ NVME_SC_CRD = 0x1800, NVME_SC_MORE = 0x2000, NVME_SC_DNR = 0x4000, }; +/** + * nvme_status_code_type() - Returns the NVMe Status Code Type + * @status_field: The NVMe Completion Queue Entry's Status Field + * + * See &enum nvme_status_field + */ +static inline __u16 nvme_status_code_type(__u16 status_field) +{ + return status_field & NVME_SCT_MASK; +} + +/** + * nvme_status_code() - Returns the NVMe Status Code + * @status_field: The NVMe Completion Queue Entry's Status Field + * + * See &enum nvme_status_field + */ +static inline __u16 nvme_status_code(__u16 status_field) +{ + return status_field & NVME_SCT_MASK; +} + #define NVME_MAJOR(ver) ((ver) >> 16) #define NVME_MINOR(ver) (((ver) >> 8) & 0xff) #define NVME_TERTIARY(ver) ((ver) & 0xff) diff --git a/src/nvme/util.c b/src/nvme/util.c index 8acaa6d1..86a2ad0e 100644 --- a/src/nvme/util.c +++ b/src/nvme/util.c @@ -7,7 +7,6 @@ * Chaitanya Kulkarni */ -#include #include #include #include @@ -16,7 +15,6 @@ #include #include -#include #include #include #include @@ -24,7 +22,6 @@ #include #include "filters.h" -#include "ioctl.h" #include "util.h" #include "tree.h" @@ -138,17 +135,15 @@ static inline __u8 nvme_fabrics_status_to_errno(__u16 status) __u8 nvme_status_to_errno(int status, bool fabrics) { - __u16 sc, sct; + __u16 sc; if (!status) return 0; if (status < 0) return errno; - sc = status & NVME_SC_MASK; - sct = status & NVME_SCT_MASK; - - switch (sct) { + sc = nvme_status_code(status); + switch (nvme_status_code_type(status)) { case NVME_SCT_GENERIC: return nvme_generic_status_to_errno(sc); case NVME_SCT_CMD_SPECIFIC: @@ -156,10 +151,6 @@ __u8 nvme_status_to_errno(int status, bool fabrics) return nvme_fabrics_status_to_errno(sc); return nvme_cmd_specific_status_to_errno(sc); default: - /* - * Media, integrity related status, and the others will be - * mapped to EIO. - */ return EIO; } } @@ -282,14 +273,14 @@ int nvme_get_log_page(int fd, __u32 nsid, __u8 log_id, bool rae, } static int nvme_get_telemetry_log(int fd, bool create, bool ctrl, bool rae, - void **buf, __u32 *log_size) + struct nvme_telemetry_log **buf) { - static const __u32 xfer = 512; + static const __u32 xfer = NVME_LOG_TELEM_BLOCK_SIZE; struct nvme_telemetry_log *telem; + enum nvme_cmd_get_log_lid lid; + void *log, *tmp; __u32 size; - __u8 lid; - void *log; int err; log = malloc(xfer); @@ -314,47 +305,47 @@ static int nvme_get_telemetry_log(int fd, bool create, bool ctrl, bool rae, telem = log; if (ctrl && !telem->ctrlavail) { - size = xfer; - goto done; + *buf = log; + return 0; } - size = (le16_to_cpu(telem->dalb3) * xfer) + xfer; - log = realloc(log, size); - if (!log) { + /* dalb3 >= dalb2 >= dalb1 */ + size = (le16_to_cpu(telem->dalb3) + 1) * xfer; + tmp = realloc(log, size); + if (!tmp) { errno = ENOMEM; err = -1; goto free; } + log = tmp; err = nvme_get_log_page(fd, NVME_NSID_NONE, lid, rae, size, (void *)log); - if (err) - goto free; -done: - *log_size = size; - *buf = log; - return 0; + if (!err) { + *buf = log; + return 0; + } free: free(log); return err; } -int nvme_get_ctrl_telemetry(int fd, bool rae, void **buf, __u32 *log_size) +int nvme_get_ctrl_telemetry(int fd, bool rae, struct nvme_telemetry_log **log) { - return nvme_get_telemetry_log(fd, false, true, rae, buf, log_size); + return nvme_get_telemetry_log(fd, false, true, rae, log); } -int nvme_get_host_telemetry(int fd, void **buf, __u32 *log_size) +int nvme_get_host_telemetry(int fd, struct nvme_telemetry_log **log) { - return nvme_get_telemetry_log(fd, false, false, false, buf, log_size); + return nvme_get_telemetry_log(fd, false, false, false, log); } -int nvme_get_new_host_telemetry(int fd, void **buf, __u32 *log_size) +int nvme_get_new_host_telemetry(int fd, struct nvme_telemetry_log **log) { - return nvme_get_telemetry_log(fd, true, false, false, buf, log_size); + return nvme_get_telemetry_log(fd, true, false, false, log); } -void nvme_setup_dsm_range(struct nvme_dsm_range *dsm, __u32 *ctx_attrs, - __u32 *llbas, __u64 *slbas, __u16 nr_ranges) +void nvme_init_dsm_range(struct nvme_dsm_range *dsm, __u32 *ctx_attrs, + __u32 *llbas, __u64 *slbas, __u16 nr_ranges) { int i; @@ -365,7 +356,7 @@ void nvme_setup_dsm_range(struct nvme_dsm_range *dsm, __u32 *ctx_attrs, } } -void nvme_setup_id_ns(struct nvme_id_ns *ns, __u64 nsze, __u64 ncap, __u8 flbas, +void nvme_init_id_ns(struct nvme_id_ns *ns, __u64 nsze, __u64 ncap, __u8 flbas, __u8 dps, __u8 nmic, __u32 anagrpid, __u16 nvmsetid) { memset(ns, 0, sizeof(*ns)); @@ -378,7 +369,7 @@ void nvme_setup_id_ns(struct nvme_id_ns *ns, __u64 nsze, __u64 ncap, __u8 flbas, ns->nvmsetid = cpu_to_le16(nvmsetid); } -void nvme_setup_ctrl_list(struct nvme_ctrl_list *cntlist, __u16 num_ctrls, +void nvme_init_ctrl_list(struct nvme_ctrl_list *cntlist, __u16 num_ctrls, __u16 *ctrlist) { int i; @@ -397,7 +388,7 @@ static int nvme_ns_attachment(int fd, __u32 nsid, __u16 num_ctrls, if (attach) sel = NVME_NS_ATTACH_SEL_CTRL_ATTACH; - nvme_setup_ctrl_list(&cntlist, num_ctrls, ctrlist); + nvme_init_ctrl_list(&cntlist, num_ctrls, ctrlist); return nvme_ns_attach(fd, nsid, sel, &cntlist); } @@ -419,10 +410,8 @@ int nvme_get_ana_log_len(int fd, size_t *analen) int ret; ret = nvme_identify_ctrl(fd, &ctrl); - if (ret) { - errno = nvme_status_to_errno(ret, false); - return -1; - } + if (ret) + return ret; *analen = sizeof(struct nvme_ana_log) + le32_to_cpu(ctrl.nanagrpid) * sizeof(struct nvme_ana_group_desc) + diff --git a/src/nvme/util.h b/src/nvme/util.h index bed6396d..c9803225 100644 --- a/src/nvme/util.h +++ b/src/nvme/util.h @@ -9,138 +9,159 @@ #ifndef _LIBNVME_UTIL_H #define _LIBNVME_UTIL_H -#include -#include - #include "ioctl.h" /** * nvme_status_to_errno() - Converts nvme return status to errno - * @status: Return status from an nvme passthrough commmand - * @fabrics: true if given status is for fabrics - * - * If status < 0, errno is already set. + * @status: Return status from an nvme passthrough commmand + * @fabrics: Set to true if &status is to a fabrics target. * - * Return: Appropriate errno for the given nvme status + * Return: An errno representing the nvme status if it is an nvme status field, + * or unchanged status is < 0 since errno is already set. */ __u8 nvme_status_to_errno(int status, bool fabrics); /** * nvme_fw_download_seq() - - * @fd: - * @size: - * @xfer: - * @offset: - * @buf: + * @fd: File descriptor of nvme device + * @size: Total size of the firmware image to transfer + * @xfer: Maximum size to send with each partial transfer + * @offset: Starting offset to send with this firmware downlaod + * @buf: Address of buffer containing all or part of the firmware image. * - * Return: + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_fw_download_seq(int fd, __u32 size, __u32 xfer, __u32 offset, void *buf); /** * nvme_get_ctrl_telemetry() - - * @fd: - * @rae: - * @buf: - * @log_size: + * @fd: File descriptor of nvme device + * @rae: Retain asynchronous events + * @log: On success, set to the value of the allocated and retreived log. * - * Returns: + * The total size allocated can be calculated as: + * (&struct nvme_telemetry_log.dalb3 + 1) * %NVME_LOG_TELEM_BLOCK_SIZE. + * + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ -int nvme_get_ctrl_telemetry(int fd, bool rae, void **buf, __u32 *log_size); +int nvme_get_ctrl_telemetry(int fd, bool rae, struct nvme_telemetry_log **log); /** * nvme_get_host_telemetry() - - * @fd: - * @buf: - * @log_size: + * @fd: File descriptor of nvme device + * @log: On success, set to the value of the allocated and retreived log. + * + * The total size allocated can be calculated as: + * (&struct nvme_telemetry_log.dalb3 + 1) * %NVME_LOG_TELEM_BLOCK_SIZE. * - * Returns: + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ -int nvme_get_host_telemetry(int fd, void **buf, __u32 *log_size); +int nvme_get_host_telemetry(int fd, struct nvme_telemetry_log **log); /** * nvme_get_new_host_telemetry() - - * @fd: - * @buf: - * @log_size: + * @fd: File descriptor of nvme device + * @log: On success, set to the value of the allocated and retreived log. * - * Returns: + * The total size allocated can be calculated as: + * (&struct nvme_telemetry_log.dalb3 + 1) * %NVME_LOG_TELEM_BLOCK_SIZE. + * + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ -int nvme_get_new_host_telemetry(int fd, void **buf, __u32 *log_size); +int nvme_get_new_host_telemetry(int fd, struct nvme_telemetry_log **log); /** - * nvme_setup_id_ns() - - * @ns: - * @nsze: - * @ncap: - * @flbas: - * @dps: - * @nmic: - * @anagrpid: - * @nvmsetid: + * nvme_init_id_ns() - Initialize an Identify Namepsace structure for creation. + * @ns: Address of the Identify Namespace structure to initialize + * @nsze: Namespace size + * @ncap: namespace capacity + * @flbas: formatted logical block size settings + * @dps: Data protection settings + * @nmic: Namespace sharing capabilities + * @anagrpid: ANA group identifier + * @nvmsetid: NVM Set identifer + * + * This is intended to be used with a namespace management "create", see + * &nvme_ns_mgmt_create(). */ -void nvme_setup_id_ns(struct nvme_id_ns *ns, __u64 nsze, __u64 ncap, __u8 flbas, - __u8 dps, __u8 nmic, __u32 anagrpid, __u16 nvmsetid); +void nvme_init_id_ns(struct nvme_id_ns *ns, __u64 nsze, __u64 ncap, __u8 flbas, + __u8 dps, __u8 nmic, __u32 anagrpid, __u16 nvmsetid); /** - * nvme_setup_ctrl_list() - - * @cntlist: - * @num_ctrls: - * @ctrlist: + * nvme_init_ctrl_list() - Initialize an nvme_ctrl_list structure from an array. + * @cntlist: The controller list structure to initialize + * @num_ctrls: The number of controllers in the array, &ctrlist. + * @ctrlist: An array of controller identifiers in CPU native endian. + * + * This is intended to be used with any command that takes a controller list + * argument. See &nvme_ns_attach_ctrls() and &nvme_ns_detach(). */ -void nvme_setup_ctrl_list(struct nvme_ctrl_list *cntlist, __u16 num_ctrls, - __u16 *ctrlist); +void nvme_init_ctrl_list(struct nvme_ctrl_list *cntlist, __u16 num_ctrls, + __u16 *ctrlist); /** - * nvme_dsm_range() - Constructs a data set range structure + * nvme_init_dsm_range() - Constructs a data set range structure * @dsm: DSM range array * @ctx_attrs: Array of context attributes * @llbas: Array of length in logical blocks * @slbas: Array of starting logical blocks * @nr_ranges: The size of the dsm arrays * - * Each array must be the same size of size 'nr_ranges'. + * Each array must be the same size of size 'nr_ranges'. This is intended to be + * used with constructing a payload for &nvme_dsm(). * * Return: The nvme command status if a response was received or -errno * otherwise. */ -void nvme_setup_dsm_range(struct nvme_dsm_range *dsm, __u32 *ctx_attrs, +void nvme_init_dsm_range(struct nvme_dsm_range *dsm, __u32 *ctx_attrs, __u32 *llbas, __u64 *slbas, __u16 nr_ranges); /** * __nvme_get_log_page() - - * @fd: - * @nsid: - * @log_id: - * @rae: - * @xfer_len: Max partial log transfer size to request while splitting - * @data_len: - * @data: + * @fd: File descriptor of nvme device + * @nsid: Namespace Identifier, if applicable. + * @log_id: Log Identifier, see &enum nvme_cmd_get_log_lid. + * @rae: Retain asynchronous events + * @xfer_len: Max log transfer size per request to split the total. + * @data_len: Total length of the log to transfer. + * @data: User address of at least &data_len to store the log. + * + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int __nvme_get_log_page(int fd, __u32 nsid, __u8 log_id, bool rae, - __u32 xfer_len, __u32 data_len, void *data); + __u32 xfer_len, __u32 data_len, void *data); /** * nvme_get_log_page() - - * @fd: - * @nsid: - * @log_id: - * @rae: - * @data_len: - * @data: + * @fd: File descriptor of nvme device + * @nsid: Namespace Identifier, if applicable. + * @log_id: Log Identifier, see &enum nvme_cmd_get_log_lid. + * @rae: Retain asynchronous events + * @data_len: Total length of the log to transfer. + * @data: User address of at least &data_len to store the log. + * + * Calls __nvme_get_log_page() with a default 4k transfer length, as that is + * guarnateed by the protocol to be a safe transfer size. * - * Calls __nvme_get_log_page() with a default 4k transfer length. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_log_page(int fd, __u32 nsid, __u8 log_id, bool rae, - __u32 data_len, void *data); + __u32 data_len, void *data); /** * nvme_get_ana_log_len() - Retreive size of the current ANA log * @fd: File descriptor of nvme device * @analen: Pointer to where the length will be set on success * - * Return: 0 on success, -1 otherwise with errno set + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_get_ana_log_len(int fd, size_t *analen); @@ -151,8 +172,8 @@ int nvme_get_ana_log_len(int fd, size_t *analen); * @num_ctrls: Number of controllers in ctrlist * @ctrlist: List of controller IDs to perform the attach action * - * Return: The nvme command status if a response was received or -1 - * with errno set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_namespace_attach_ctrls(int fd, __u32 nsid, __u16 num_ctrls, __u16 *ctrlist); @@ -163,37 +184,39 @@ int nvme_namespace_attach_ctrls(int fd, __u32 nsid, __u16 num_ctrls, __u16 *ctrl * @num_ctrls: Number of controllers in ctrlist * @ctrlist: List of controller IDs to perform the detach action * - * Return: The nvme command status if a response was received or -1 - * with errno set otherwise. + * Return: The nvme command status if a response was received (see &enum + * nvme_status_field) or -1 with errno set otherwise. */ int nvme_namespace_detach_ctrls(int fd, __u32 nsid, __u16 num_ctrls, __u16 *ctrlist); /** * nvme_get_feature_length() - Retreive the command payload length for a * specific feature identifier - * @fid: - * @cdw11: - * @len: + * @fid: Feature identifier, see &enum nvme_features_id. + * @cdw11: The cdw11 value may affect the transfer (only known fid is + * %NVME_FEAT_FID_HOST_ID) + * @len: On success, set to this features payload length in bytes. * - * Return: 0 on success, -1 with errno set otherwise + * Return: 0 on success, -1 with errno set to EINVAL if the function did not + * recognize &fid. */ int nvme_get_feature_length(int fid, __u32 cdw11, __u32 *len); /** * nvme_get_directive_receive_length() - - * @dtype: Directive type, see &enum nvme_directive_dtype - * @doper: Directive receive operation, see &enum nvme_directive_receive_doper - * @len: Address to save the payload length of the directive in bytes on - * a successful decode + * @dtype: Directive type, see &enum nvme_directive_dtype + * @doper: Directive receive operation, see &enum nvme_directive_receive_doper + * @len: On success, set to this directives payload length in bytes. * - * Return: 0 on success, -1 with errno set to EINVAL. + * Return: 0 on success, -1 with errno set to EINVAL if the function did not + * recognize &dtype or &doper. */ int nvme_get_directive_receive_length(enum nvme_directive_dtype dtype, enum nvme_directive_receive_doper doper, __u32 *len); /** * nvme_open() - Open an nvme controller or namespace device - * @name: The basename of the device to open + * @name: The basename of the device to open * * This will look for the handle in /dev/ and validate the name and filetype * match linux conventions. @@ -203,14 +226,4 @@ int nvme_get_directive_receive_length(enum nvme_directive_dtype dtype, */ int nvme_open(const char *name); -/** - * nvme_set_attr() - - * @dir: - * @attr: - * @value: - * - * Return - */ -int nvme_set_attr(const char *dir, const char *attr, const char *value); - #endif /* _LIBNVME_UTIL_H */