summaryrefslogtreecommitdiffstats
path: root/src/nvme/util.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-12-24 07:51:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-12-24 07:51:48 +0000
commit8d843cc9cc0e989d3929f204f77223cd08730c7a (patch)
tree1fcba17d10325d9d7ccb68b2eb48cd9bbba6a534 /src/nvme/util.h
parentReleasing debian version 1.5-3. (diff)
downloadlibnvme-8d843cc9cc0e989d3929f204f77223cd08730c7a.tar.xz
libnvme-8d843cc9cc0e989d3929f204f77223cd08730c7a.zip
Merging upstream version 1.7.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/nvme/util.h')
-rw-r--r--src/nvme/util.h67
1 files changed, 65 insertions, 2 deletions
diff --git a/src/nvme/util.h b/src/nvme/util.h
index 9d6faf3..16d5b9c 100644
--- a/src/nvme/util.h
+++ b/src/nvme/util.h
@@ -9,6 +9,8 @@
#ifndef _LIBNVME_UTIL_H
#define _LIBNVME_UTIL_H
+#include <ifaddrs.h>
+
#include "types.h"
/**
@@ -149,6 +151,40 @@ void nvme_init_copy_range_f1(struct nvme_copy_range_f1 *copy, __u16 *nlbs,
__u32 *elbats, __u16 nr);
/**
+ * nvme_init_copy_range_f2() - Constructs a copy range f2 structure
+ * @copy: Copy range array
+ * @snsids: Source namespace identifier
+ * @nlbs: Number of logical blocks
+ * @slbas: Starting LBA
+ * @sopts: Source options
+ * @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_f2(struct nvme_copy_range_f2 *copy, __u32 *snsids,
+ __u16 *nlbs, __u64 *slbas, __u16 *sopts,
+ __u32 *eilbrts, __u32 *elbatms, __u32 *elbats,
+ __u16 nr);
+
+/**
+ * nvme_init_copy_range_f3() - Constructs a copy range f3 structure
+ * @copy: Copy range array
+ * @snsids: Source namespace identifier
+ * @nlbs: Number of logical blocks
+ * @slbas: Starting LBA
+ * @sopts: Source options
+ * @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_f3(struct nvme_copy_range_f3 *copy, __u32 *snsids,
+ __u16 *nlbs, __u64 *slbas, __u16 *sopts,
+ __u64 *eilbrts, __u32 *elbatms, __u32 *elbats,
+ __u16 nr);
+
+/**
* nvme_get_feature_length() - Retreive the command payload length for a
* specific feature identifier
* @fid: Feature identifier, see &enum nvme_features_id.
@@ -447,8 +483,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 = ((NVME_FLBAS_HIGHER(flbas) >> 1) |
+ NVME_FLBAS_LOWER(flbas));
}
struct nvme_root;
@@ -639,4 +675,31 @@ int nvme_uuid_random(unsigned char uuid[NVME_UUID_LEN]);
*/
bool nvme_ipaddrs_eq(const char *addr1, const char *addr2);
+/**
+ * nvme_iface_matching_addr - Get interface matching @addr
+ * @iface_list: Interface list returned by getifaddrs()
+ * @addr: Address to match
+ *
+ * Parse the interface list pointed to by @iface_list looking
+ * for the interface that has @addr as one of its assigned
+ * addresses.
+ *
+ * Return: The name of the interface that owns @addr or NULL.
+ */
+const char *nvme_iface_matching_addr(const struct ifaddrs *iface_list, const char *addr);
+
+/**
+ * nvme_iface_primary_addr_matches - Check that interface's primary address matches
+ * @iface_list: Interface list returned by getifaddrs()
+ * @iface: Interface to match
+ * @addr: Address to match
+ *
+ * Parse the interface list pointed to by @iface_list and looking for
+ * interface @iface. The get its primary address and check if it matches
+ * @addr.
+ *
+ * Return: true if a match is found, false otherwise.
+ */
+bool nvme_iface_primary_addr_matches(const struct ifaddrs *iface_list, const char *iface, const char *addr);
+
#endif /* _LIBNVME_UTIL_H */