diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-07-26 05:25:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-07-26 05:25:24 +0000 |
commit | acf73199fa227b97217238334236af367c8ab2d7 (patch) | |
tree | b6812bd6cbe6b977884ec94def20de59555983d5 /src/nvme/util.h | |
parent | Adding upstream version 1.0. (diff) | |
download | libnvme-upstream/1.1_rc0.tar.xz libnvme-upstream/1.1_rc0.zip |
Adding upstream version 1.1~rc0.upstream/1.1_rc0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/nvme/util.h | 63 |
1 files changed, 53 insertions, 10 deletions
diff --git a/src/nvme/util.h b/src/nvme/util.h index 277b857..6f1d3e9 100644 --- a/src/nvme/util.h +++ b/src/nvme/util.h @@ -4,7 +4,7 @@ * Copyright (c) 2020 Western Digital Corporation or its affiliates. * * Authors: Keith Busch <keith.busch@wdc.com> - * Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> + * Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> */ #ifndef _LIBNVME_UTIL_H #define _LIBNVME_UTIL_H @@ -31,6 +31,11 @@ * @ENVME_CONNECT_INVAL_TR: invalid transport type * @ENVME_CONNECT_LOOKUP_SUBSYS_NAME: failed to lookup subsystem name * @ENVME_CONNECT_LOOKUP_SUBSYS: failed to lookup subsystem + * @ENVME_CONNECT_ALREADY: the connect attempt failed, already connected + * @ENVME_CONNECT_INVAL: invalid arguments/configuration + * @ENVME_CONNECT_ADDRINUSE: hostnqn already in use + * @ENVME_CONNECT_NODEV: invalid interface + * @ENVME_CONNECT_OPNOTSUPP: not supported */ enum nvme_connect_err { ENVME_CONNECT_RESOLVE = 1000, @@ -45,11 +50,16 @@ enum nvme_connect_err { ENVME_CONNECT_INVAL_TR, ENVME_CONNECT_LOOKUP_SUBSYS_NAME, ENVME_CONNECT_LOOKUP_SUBSYS, + ENVME_CONNECT_ALREADY, + ENVME_CONNECT_INVAL, + ENVME_CONNECT_ADDRINUSE, + ENVME_CONNECT_NODEV, + ENVME_CONNECT_OPNOTSUPP, }; /** * nvme_status_to_errno() - Converts nvme return status to errno - * @status: Return status from an nvme passthrough commmand + * @status: Return status from an nvme passthrough command * @fabrics: Set to true if &status is to a fabrics target. * * Return: An errno representing the nvme status if it is an nvme status field, @@ -59,7 +69,7 @@ __u8 nvme_status_to_errno(int status, bool fabrics); /** * nvme_status_to_string() - Returns string describing nvme return status. - * @status: Return status from an nvme passthrough commmand + * @status: Return status from an nvme passthrough command * @fabrics: Set to true if &status is to a fabrics target. * * Return: String representation of the nvme status if it is an nvme status field, @@ -119,11 +129,25 @@ void nvme_init_copy_range(struct nvme_copy_range *copy, __u16 *nlbs, __u32 *elbats, __u16 nr); /** + * nvme_init_copy_range_f1() - Constructs a copy range f1 structure + * @copy: Copy range array + * @nlbs: Number of logical blocks + * @slbas: Starting LBA + * @eilbrts: Expected initial logical block reference tag + * @elbatms: Expected logical block application tag mask + * @elbats: Expected logical block application tag + * @nr: Number of descriptors to construct + */ +void nvme_init_copy_range_f1(struct nvme_copy_range_f1 *copy, __u16 *nlbs, + __u64 *slbas, __u64 *eilbrts, __u32 *elbatms, + __u32 *elbats, __u16 nr); + +/** * nvme_get_feature_length() - Retreive the command payload length for a - * specific feature identifier + * specific feature identifier * @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) + * %NVME_FEAT_FID_HOST_ID) * @len: On success, set to this features payload length in bytes. * * Return: 0 on success, -1 with errno set to EINVAL if the function did not @@ -132,7 +156,7 @@ void nvme_init_copy_range(struct nvme_copy_range *copy, __u16 *nlbs, int nvme_get_feature_length(int fid, __u32 cdw11, __u32 *len); /** - * nvme_get_directive_receive_length() - + * nvme_get_directive_receive_length() - Get directive receive length * @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. @@ -400,8 +424,8 @@ static inline void nvme_feature_decode_namespace_write_protect(__u32 value, static inline void nvme_id_ns_flbas_to_lbaf_inuse(__u8 flbas, __u8 *lbaf_inuse) { - *lbaf_inuse = (((flbas & NVME_NS_FLBAS_HIGHER_MASK) >> 1) \ - | (flbas & NVME_NS_FLBAS_LOWER_MASK)); + *lbaf_inuse = (((flbas & NVME_NS_FLBAS_HIGHER_MASK) >> 1) | + (flbas & NVME_NS_FLBAS_LOWER_MASK)); } struct nvme_root; @@ -473,7 +497,7 @@ char *kv_keymatch(const char *kv, const char *key); * Return: If @s starts with @prefix, then return a pointer within @s at * the first character after the matched @prefix. NULL otherwise. */ -char* startswith(const char *s, const char *prefix); +char *startswith(const char *s, const char *prefix); #define __round_mask(val, mult) ((__typeof__(val))((mult)-1)) @@ -502,7 +526,7 @@ static inline __u16 nvmf_exat_len(size_t val_len) } /** - * nvmf_exat_size - Return min algined size to hold value + * nvmf_exat_size - Return min aligned size to hold value * @val_len: This is the length of the data to be copied to the "exatval" * field of a "struct nvmf_ext_attr". * @@ -532,4 +556,23 @@ static inline __u16 nvmf_exat_size(size_t val_len) */ struct nvmf_ext_attr *nvmf_exat_ptr_next(struct nvmf_ext_attr *p); +/** + * enum nvme_version - Selector for version to be returned by @nvme_get_version + * + * @NVME_VERSION_PROJECT: Project release version + * @NVME_VERSION_GIT: Git reference + */ +enum nvme_version { + NVME_VERSION_PROJECT = 0, + NVME_VERSION_GIT = 1, +}; + +/** + * nvme_get_version - Return version libnvme string + * @type: Selects which version type (see @struct nvme_version) + * + * Return: Returns version string for known types or else "n/a" + */ +const char *nvme_get_version(enum nvme_version type); + #endif /* _LIBNVME_UTIL_H */ |