summaryrefslogtreecommitdiffstats
path: root/src/nvme/util.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:17:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-05 18:17:17 +0000
commit0e75b5495117b9888b7a557fab1db40145a9a705 (patch)
treee294b5156b7a85197e4b3192b6fba291a26dd5c6 /src/nvme/util.h
parentAdding upstream version 1.1. (diff)
downloadlibnvme-0e75b5495117b9888b7a557fab1db40145a9a705.tar.xz
libnvme-0e75b5495117b9888b7a557fab1db40145a9a705.zip
Adding upstream version 1.2.upstream/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 */