summaryrefslogtreecommitdiffstats
path: root/src/nvme/util.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:17:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:17:32 +0000
commitb0dc2feab3271dbcb42df6e6d8a37138a90c44a1 (patch)
treeae02f159c125f183b2adae47fdf0e64357bf76a8 /src/nvme/util.h
parentReleasing debian version 1.1-2. (diff)
downloadlibnvme-b0dc2feab3271dbcb42df6e6d8a37138a90c44a1.tar.xz
libnvme-b0dc2feab3271dbcb42df6e6d8a37138a90c44a1.zip
Merging upstream version 1.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/nvme/util.h')
-rw-r--r--src/nvme/util.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/nvme/util.h b/src/nvme/util.h
index 6f1d3e9..e72c156 100644
--- a/src/nvme/util.h
+++ b/src/nvme/util.h
@@ -156,6 +156,23 @@ void nvme_init_copy_range_f1(struct nvme_copy_range_f1 *copy, __u16 *nlbs,
int nvme_get_feature_length(int fid, __u32 cdw11, __u32 *len);
/**
+ * nvme_get_feature_length2() - Retreive the command payload length for a
+ * 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)
+ * @dir: Data transfer direction: false - host to controller, true -
+ * controller to host may affect the transfer (only known fid is
+ * %NVME_FEAT_FID_HOST_MEM_BUF).
+ * @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
+ * recognize &fid.
+ */
+int nvme_get_feature_length2(int fid, __u32 cdw11, enum nvme_data_tfr dir,
+ __u32 *len);
+
+/**
* 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
@@ -575,4 +592,36 @@ enum nvme_version {
*/
const char *nvme_get_version(enum nvme_version type);
+#define NVME_UUID_LEN_STRING 37 /* 1b4e28ba-2fa1-11d2-883f-0016d3cca427 + \0 */
+#define NVME_UUID_LEN 16
+
+/**
+ * nvme_uuid_to_string - Return string represenation of encoded UUID
+ * @uuid: Binary encoded input UUID
+ * @str: Output string represenation of UUID
+ *
+ * Return: Returns error code if type conversion fails.
+ */
+int nvme_uuid_to_string(unsigned char uuid[NVME_UUID_LEN], char *str);
+
+/**
+ * nvme_uuid_from_string - Return encoded UUID represenation of string UUID
+ * @uuid: Binary encoded input UUID
+ * @str: Output string represenation of UUID
+ *
+ * Return: Returns error code if type conversion fails.
+ */
+int nvme_uuid_from_string(const char *str, unsigned char uuid[NVME_UUID_LEN]);
+
+/**
+ * nvme_uuid_random - Generate random UUID
+ * @uuid: Generated random UUID
+ *
+ * Generate random number according
+ * https://www.rfc-editor.org/rfc/rfc4122#section-4.4
+ *
+ * Return: Returns error code if generating of random number fails.
+ */
+int nvme_uuid_random(unsigned char uuid[NVME_UUID_LEN]);
+
#endif /* _LIBNVME_UTIL_H */