summaryrefslogtreecommitdiffstats
path: root/src/nvme/tree.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/tree.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/tree.h')
-rw-r--r--src/nvme/tree.h127
1 files changed, 126 insertions, 1 deletions
diff --git a/src/nvme/tree.h b/src/nvme/tree.h
index bcf3636..a30e8eb 100644
--- a/src/nvme/tree.h
+++ b/src/nvme/tree.h
@@ -15,6 +15,7 @@
#include <stddef.h>
#include <sys/types.h>
+#include <netinet/in.h>
#include "ioctl.h"
#include "util.h"
@@ -62,6 +63,17 @@ void nvme_root_set_application(nvme_root_t r, const char *a);
const char *nvme_root_get_application(nvme_root_t r);
/**
+ * nvme_root_release_fds - Close all opened file descriptors in the tree
+ * @r: &nvme_root_t object
+ *
+ * Controller and Namespace objects cache the file descriptors
+ * of opened nvme devices. This API can be used to close and
+ * clear all cached fds in the tree.
+ *
+ */
+void nvme_root_release_fds(nvme_root_t r);
+
+/**
* nvme_free_tree() - Free root object
* @r: &nvme_root_t object
*
@@ -295,6 +307,51 @@ nvme_ctrl_t nvme_lookup_ctrl(nvme_subsystem_t s, const char *transport,
const char *host_iface, const char *trsvcid,
nvme_ctrl_t p);
+/**
+ * nvme_ctrl_find() - Locate an existing controller
+ * @s: &nvme_subsystem_t object
+ * @transport: Transport name
+ * @traddr: Transport address
+ * @trsvcid: Transport service identifier
+ * @subsysnqn: Subsystem NQN
+ * @host_traddr: Host transport address
+ * @host_iface: Host interface name
+ *
+ * Lookup a controller in @s based on @transport, @traddr, @trsvcid,
+ * @subsysnqn, @host_traddr, and @host_iface. @transport must be specified,
+ * other fields may be required depending on the transport. Parameters set
+ * to NULL will be ignored.
+ *
+ * Unlike nvme_lookup_ctrl(), this function does not create a new object if
+ * an existing controller cannot be found.
+ *
+ * Return: Controller instance on success, NULL otherwise.
+ */
+nvme_ctrl_t nvme_ctrl_find(nvme_subsystem_t s, const char *transport,
+ const char *traddr, const char *trsvcid,
+ const char *subsysnqn, const char *host_traddr,
+ const char *host_iface);
+
+/**
+ * nvme_ctrl_config_match() - Check if ctrl @c matches config params
+ * @c: An existing controller instance
+ * @transport: Transport name
+ * @traddr: Transport address
+ * @trsvcid: Transport service identifier
+ * @subsysnqn: Subsystem NQN
+ * @host_traddr: Host transport address
+ * @host_iface: Host interface name
+ *
+ * Check that controller @c matches parameters: @transport, @traddr,
+ * @trsvcid, @subsysnqn, @host_traddr, and @host_iface. Parameters set
+ * to NULL will be ignored.
+ *
+ * Return: true if there's a match, false otherwise.
+ */
+bool nvme_ctrl_config_match(struct nvme_ctrl *c, const char *transport,
+ const char *traddr, const char *trsvcid,
+ const char *subsysnqn, const char *host_traddr,
+ const char *host_iface);
/**
* nvme_create_ctrl() - Allocate an unconnected NVMe controller
@@ -484,11 +541,25 @@ nvme_ns_t nvme_subsystem_next_ns(nvme_subsystem_t s, nvme_ns_t n);
* nvme_ns_get_fd() - Get associated file descriptor
* @n: Namespace instance
*
+ * libnvme will open() the file (if not already opened) and keep
+ * an internal copy of the file descriptor. Following calls to
+ * this API retrieve the internal cached copy of the file
+ * descriptor. The file will remain opened and the fd will
+ * remain cached until the ns object is deleted or
+ * nvme_ns_release_fd() is called.
+ *
* Return: File descriptor associated with @n or -1
*/
int nvme_ns_get_fd(nvme_ns_t n);
/**
+ * nvme_ns_release_fd() - Close fd and clear fd from ns object
+ * @n: Namespace instance
+ *
+ */
+void nvme_ns_release_fd(nvme_ns_t n);
+
+/**
* nvme_ns_get_nsid() - NSID of a namespace
* @n: Namespace instance
*
@@ -772,11 +843,25 @@ nvme_ns_t nvme_path_get_ns(nvme_path_t p);
* nvme_ctrl_get_fd() - Get associated file descriptor
* @c: Controller instance
*
+ * libnvme will open() the file (if not already opened) and keep
+ * an internal copy of the file descriptor. Following calls to
+ * this API retrieve the internal cached copy of the file
+ * descriptor. The file will remain opened and the fd will
+ * remain cached until the controller object is deleted or
+ * nvme_ctrl_release_fd() is called.
+ *
* Return: File descriptor associated with @c or -1
*/
int nvme_ctrl_get_fd(nvme_ctrl_t c);
/**
+ * nvme_ctrl_release_fd() - Close fd and clear fd from controller object
+ * @c: Controller instance
+ *
+ */
+void nvme_ctrl_release_fd(nvme_ctrl_t c);
+
+/**
* nvme_ctrl_get_name() - sysfs name of a controller
* @c: Controller instance
*
@@ -802,6 +887,16 @@ const char *nvme_ctrl_get_sysfs_dir(nvme_ctrl_t c);
const char *nvme_ctrl_get_address(nvme_ctrl_t c);
/**
+ * nvme_ctrl_get_src_addr() - Extract src_addr from the c->address string
+ * @c: Controller instance
+ * @src_addr: Where to copy the src_addr. Size must be at least INET6_ADDRSTRLEN.
+ * @src_addr_len: Length of the buffer @src_addr.
+ *
+ * Return: Pointer to @src_addr on success. NULL on failure to extract the src_addr.
+ */
+char *nvme_ctrl_get_src_addr(nvme_ctrl_t c, char *src_addr, size_t src_addr_len);
+
+/**
* nvme_ctrl_get_phy_slot() - PCI physical slot number of a controller
* @c: Controller instance
*
@@ -827,7 +922,7 @@ const char *nvme_ctrl_get_firmware(nvme_ctrl_t c);
const char *nvme_ctrl_get_model(nvme_ctrl_t c);
/**
- * nvme_ctrl_get_state() - Running state of an controller
+ * nvme_ctrl_get_state() - Running state of a controller
* @c: Controller instance
*
* Return: String indicating the running state of @c
@@ -1148,6 +1243,14 @@ const char *nvme_subsystem_get_application(nvme_subsystem_t s);
void nvme_subsystem_set_application(nvme_subsystem_t s, const char *a);
/**
+ * nvme_subsystem_get_iopolicy() - Return the IO policy of subsytem
+ * @s: nvme_subsystem_t object
+ *
+ * Return: IO policy used by current subsystem
+ */
+const char *nvme_subsystem_get_iopolicy(nvme_subsystem_t s);
+
+/**
* nvme_scan_topology() - Scan NVMe topology and apply filter
* @r: nvme_root_t object
* @f: filter to apply
@@ -1177,6 +1280,16 @@ const char *nvme_host_get_hostnqn(nvme_host_t h);
const char *nvme_host_get_hostid(nvme_host_t h);
/**
+ * nvme_host_release_fds() - Close all opened file descriptors under host
+ * @h: nvme_host_t object
+ *
+ * Controller and Namespace objects cache the file descriptors
+ * of opened nvme devices. This API can be used to close and
+ * clear all cached fds under this host.
+ */
+void nvme_host_release_fds(struct nvme_host *h);
+
+/**
* nvme_free_host() - Free nvme_host_t object
* @h: nvme_host_t object
*/
@@ -1293,6 +1406,18 @@ nvme_ns_t nvme_subsystem_lookup_namespace(struct nvme_subsystem *s,
__u32 nsid);
/**
+ * nvme_subsystem_release_fds() - Close all opened fds under subsystem
+ * @s: nvme_subsystem_t object
+ *
+ * Controller and Namespace objects cache the file descriptors
+ * of opened nvme devices. This API can be used to close and
+ * clear all cached fds under this subsystem.
+ *
+ */
+void nvme_subsystem_release_fds(struct nvme_subsystem *s);
+
+
+/**
* nvme_get_path_attr() - Read path sysfs attribute
* @p: nvme_path_t object
* @attr: sysfs attribute name