int main()
{
nvme_root_t r;
+ nvme_host_t h;
nvme_subsystem_t s;
nvme_ctrl_t c;
nvme_path_t p;
printf("%-16s %-96s %-.16s\n", "Subsystem", "Subsystem-NQN", "Controllers");
printf("%-.16s %-.96s %-.16s\n", dash, dash, dash);
- nvme_for_each_subsystem(r, s) {
- bool first = true;
- printf("%-16s %-96s ", nvme_subsystem_get_name(s), nvme_subsystem_get_nqn(s));
+ nvme_for_each_host(r, h) {
+ nvme_for_each_subsystem(h, s) {
+ bool first = true;
+ printf("%-16s %-96s ", nvme_subsystem_get_name(s),
+ nvme_subsystem_get_nqn(s));
- nvme_subsystem_for_each_ctrl(s, c) {
- printf("%s%s", first ? "": ", ", nvme_ctrl_get_name(c));
- first = false;
+ nvme_subsystem_for_each_ctrl(s, c) {
+ printf("%s%s", first ? "": ", ",
+ nvme_ctrl_get_name(c));
+ first = false;
+ }
+ printf("\n");
}
- printf("\n");
}
printf("\n");
printf("%-.8s %-.20s %-.40s %-.8s %-.6s %-.14s %-.12s %-.16s\n", dash, dash,
dash, dash, dash, dash, dash, dash);
- nvme_for_each_subsystem(r, s) {
- nvme_subsystem_for_each_ctrl(s, c) {
- bool first = true;
-
- printf("%-8s %-20s %-40s %-8s %-6s %-14s %-12s ",
- nvme_ctrl_get_name(c), nvme_ctrl_get_serial(c),
- nvme_ctrl_get_model(c), nvme_ctrl_get_firmware(c),
- nvme_ctrl_get_transport(c), nvme_ctrl_get_address(c),
- nvme_subsystem_get_name(s));
-
- nvme_ctrl_for_each_ns(c, n) {
- printf("%s%s", first ? "": ", ",
- nvme_ns_get_name(n));
- first = false;
- }
-
- nvme_ctrl_for_each_path(c, p) {
- printf("%s%s", first ? "": ", ",
- nvme_ns_get_name(nvme_path_get_ns(p)));
- first = false;
+ nvme_for_each_host(r, h) {
+ nvme_for_each_subsystem(h, s) {
+ nvme_subsystem_for_each_ctrl(s, c) {
+ bool first = true;
+
+ printf("%-8s %-20s %-40s %-8s %-6s %-14s %-12s ",
+ nvme_ctrl_get_name(c),
+ nvme_ctrl_get_serial(c),
+ nvme_ctrl_get_model(c),
+ nvme_ctrl_get_firmware(c),
+ nvme_ctrl_get_transport(c),
+ nvme_ctrl_get_address(c),
+ nvme_subsystem_get_name(s));
+
+ nvme_ctrl_for_each_ns(c, n) {
+ printf("%s%s", first ? "": ", ",
+ nvme_ns_get_name(n));
+ first = false;
+ }
+
+ nvme_ctrl_for_each_path(c, p) {
+ printf("%s%s", first ? "": ", ",
+ nvme_ns_get_name(nvme_path_get_ns(p)));
+ first = false;
+ }
+ printf("\n");
}
- printf("\n");
}
}
printf("\n");
printf("%-12s %-8s %-16s %-8s %-16s\n", "Device", "NSID", "Sectors", "Format", "Controllers");
printf("%-.12s %-.8s %-.16s %-.8s %-.16s\n", dash, dash, dash, dash, dash);
- nvme_for_each_subsystem(r, s) {
- nvme_subsystem_for_each_ctrl(s, c)
- nvme_ctrl_for_each_ns(c, n)
- printf("%-12s %-8d %-16lu %-8d %s\n",
- nvme_ns_get_name(n),
- nvme_ns_get_nsid(n),
- nvme_ns_get_lba_count(n),
- nvme_ns_get_lba_size(n),
- nvme_ctrl_get_name(c));
-
- nvme_subsystem_for_each_ns(s, n) {
- bool first = true;
-
- printf("%-12s %-8d %-16lu %-8d ",
- nvme_ns_get_name(n),
- nvme_ns_get_nsid(n),
- nvme_ns_get_lba_count(n),
- nvme_ns_get_lba_size(n));
-
+ nvme_for_each_host(r, h) {
+ nvme_for_each_subsystem(h, s) {
nvme_subsystem_for_each_ctrl(s, c) {
- printf("%s%s", first ? "" : ", ",
- nvme_ctrl_get_name(c));
- first = false;
+ nvme_ctrl_for_each_ns(c, n)
+ printf("%-12s %-8d %-16lu %-8d %s\n",
+ nvme_ns_get_name(n),
+ nvme_ns_get_nsid(n),
+ nvme_ns_get_lba_count(n),
+ nvme_ns_get_lba_size(n),
+ nvme_ctrl_get_name(c));
+ }
+
+ nvme_subsystem_for_each_ns(s, n) {
+ bool first = true;
+
+ printf("%-12s %-8d %-16lu %-8d ",
+ nvme_ns_get_name(n),
+ nvme_ns_get_nsid(n),
+ nvme_ns_get_lba_count(n),
+ nvme_ns_get_lba_size(n));
+ nvme_subsystem_for_each_ctrl(s, c) {
+ printf("%s%s", first ? "" : ", ",
+ nvme_ctrl_get_name(c));
+ first = false;
+ }
+ printf("\n");
}
- printf("\n");
}
}
return 0;
int main()
{
nvme_root_t r;
+ nvme_host_t h;
nvme_subsystem_t s, _s;
nvme_ctrl_t c, _c;
nvme_path_t p, _p;
return -1;
printf(".\n");
- nvme_for_each_subsystem_safe(r, s, _s) {
- printf("%c-- %s - NQN=%s\n", _s ? '|' : '`',
- nvme_subsystem_get_name(s),
- nvme_subsystem_get_nqn(s));
+ nvme_for_each_host(r, h) {
+ nvme_for_each_subsystem_safe(h, s, _s) {
+ printf("%c-- %s - NQN=%s\n", _s ? '|' : '`',
+ nvme_subsystem_get_name(s),
+ nvme_subsystem_get_nqn(s));
- nvme_subsystem_for_each_ns_safe(s, n, _n) {
- printf("%c |-- %s lba size:%d lba max:%lu\n",
- _s ? '|' : ' ',
- nvme_ns_get_name(n), nvme_ns_get_lba_size(n),
- nvme_ns_get_lba_count(n));
- }
+ nvme_subsystem_for_each_ns_safe(s, n, _n) {
+ printf("%c |-- %s lba size:%d lba max:%lu\n",
+ _s ? '|' : ' ',
+ nvme_ns_get_name(n),
+ nvme_ns_get_lba_size(n),
+ nvme_ns_get_lba_count(n));
+ }
- nvme_subsystem_for_each_ctrl_safe(s, c, _c) {
- printf("%c %c-- %s %s %s %s\n",
- _s ? '|' : ' ', _c ? '|' : '`',
- nvme_ctrl_get_name(c),
- nvme_ctrl_get_transport(c),
- nvme_ctrl_get_address(c),
- nvme_ctrl_get_state(c));
+ nvme_subsystem_for_each_ctrl_safe(s, c, _c) {
+ printf("%c %c-- %s %s %s %s\n",
+ _s ? '|' : ' ', _c ? '|' : '`',
+ nvme_ctrl_get_name(c),
+ nvme_ctrl_get_transport(c),
+ nvme_ctrl_get_address(c),
+ nvme_ctrl_get_state(c));
- nvme_ctrl_for_each_ns_safe(c, n, _n)
- printf("%c %c %c-- %s lba size:%d lba max:%lu\n",
- _s ? '|' : ' ', _c ? '|' : ' ',
- _n ? '|' : '`',
- nvme_ns_get_name(n),
- nvme_ns_get_lba_size(n),
- nvme_ns_get_lba_count(n));
+ nvme_ctrl_for_each_ns_safe(c, n, _n)
+ printf("%c %c %c-- %s lba size:%d lba max:%lu\n",
+ _s ? '|' : ' ', _c ? '|' : ' ',
+ _n ? '|' : '`',
+ nvme_ns_get_name(n),
+ nvme_ns_get_lba_size(n),
+ nvme_ns_get_lba_count(n));
- nvme_ctrl_for_each_path_safe(c, p, _p)
- printf("%c %c %c-- %s %s\n",
- _s ? '|' : ' ', _c ? '|' : ' ',
- _p ? '|' : '`',
- nvme_path_get_name(p),
- nvme_path_get_ana_state(p));
+ nvme_ctrl_for_each_path_safe(c, p, _p)
+ printf("%c %c %c-- %s %s\n",
+ _s ? '|' : ' ', _c ? '|' : ' ',
+ _p ? '|' : '`',
+ nvme_path_get_name(p),
+ nvme_path_get_ana_state(p));
+ }
}
}
nvme_free_tree(r);
nvme_subsystem_t s;
nvme_ctrl_t c;
+ nvme_host_t h;
nvme_root_t r;
r = nvme_scan();
if (!r)
return EXIT_FAILURE;
- nvme_for_each_subsystem(r, s)
- nvme_subsystem_for_each_ctrl(s, c)
- i++;
+ nvme_for_each_host(r, h)
+ nvme_for_each_subsystem(h, s)
+ nvme_subsystem_for_each_ctrl(s, c)
+ i++;
e = calloc(i, sizeof(e));
FD_ZERO(&fds);
i = 0;
- nvme_for_each_subsystem(r, s) {
- nvme_subsystem_for_each_ctrl(s, c) {
- int fd = open_uevent(c);
-
- if (fd < 0)
- continue;
- FD_SET(fd, &fds);
- e[i].uevent_fd = fd;
- e[i].c = c;
- i++;
+ nvme_for_each_host(r, h) {
+ nvme_for_each_subsystem(h, s) {
+ nvme_subsystem_for_each_ctrl(s, c) {
+ int fd = open_uevent(c);
+
+ if (fd < 0)
+ continue;
+ FD_SET(fd, &fds);
+ e[i].uevent_fd = fd;
+ e[i].c = c;
+ i++;
+ }
}
}
#include "tree.h"
#include "filters.h"
#include "util.h"
+#include "fabrics.h"
/* XXX: Make a place for private declarations */
extern int nvme_set_attr(const char *dir, const char *attr, const char *value);
+static void nvme_free_host(struct nvme_host *h);
static void nvme_free_subsystem(struct nvme_subsystem *s);
static int nvme_subsystem_scan_namespace(struct nvme_subsystem *s, char *name);
-static int nvme_scan_subsystem(struct nvme_root *r, char *name,
+static int nvme_scan_subsystem(struct nvme_host *h, char *name,
nvme_scan_filter_t f);
static int nvme_subsystem_scan_ctrl(struct nvme_subsystem *s, char *name);
static int nvme_ctrl_scan_namespace(struct nvme_ctrl *c, char *name);
struct list_node entry;
struct list_head ctrls;
struct list_head namespaces;
- struct nvme_root *r;
+ struct nvme_host *h;
char *name;
char *sysfs_dir;
char *subsysnqn;
};
-struct nvme_root {
+struct nvme_host {
+ struct list_node entry;
struct list_head subsystems;
+ struct nvme_root *r;
+
+ char *hostnqn;
+ char *hostid;
+};
+
+struct nvme_root {
+ struct list_head hosts;
};
static inline void nvme_free_dirents(struct dirent **d, int i)
free(d[i]);
free(d);
}
+
+nvme_host_t nvme_default_host(nvme_root_t r)
+{
+ struct nvme_host *h = calloc(1, sizeof(*h));
+
+ if (!h) {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ h->hostnqn = nvmf_hostnqn_from_file();
+ h->hostid = nvmf_hostid_from_file();
+ list_head_init(&h->subsystems);
+ list_add(&r->hosts, &h->entry);
+ h->r = r;
+ return h;
+}
+
static int nvme_scan_topology(struct nvme_root *r, nvme_scan_filter_t f)
{
+ struct nvme_host *h;
struct dirent **subsys;
int i, ret;
+ h = nvme_default_host(r);
+ if (!h) {
+ free(r);
+ errno = ENOMEM;
+ return -1;
+ }
ret = nvme_scan_subsystems(&subsys);
if (ret < 0)
return ret;
for (i = 0; i < ret; i++)
- nvme_scan_subsystem(r, subsys[i]->d_name, f);
+ nvme_scan_subsystem(h, subsys[i]->d_name, f);
nvme_free_dirents(subsys, i);
return 0;
return NULL;
}
- list_head_init(&r->subsystems);
+ list_head_init(&r->hosts);
nvme_scan_topology(r, f);
return r;
}
return nvme_scan_filter(NULL);
}
-nvme_subsystem_t nvme_first_subsystem(nvme_root_t r)
+nvme_host_t nvme_first_host(nvme_root_t r)
+{
+ return list_top(&r->hosts, struct nvme_host, entry);
+}
+
+nvme_host_t nvme_next_host(nvme_root_t r, nvme_host_t h)
+{
+ return h ? list_next(&r->hosts, h, entry) : NULL;
+}
+
+nvme_root_t nvme_host_get_root(nvme_host_t h)
+{
+ return h->r;
+}
+
+const char *nvme_host_get_hostnqn(nvme_host_t h)
+{
+ return h->hostnqn;
+}
+
+const char *nvme_host_get_hostid(nvme_host_t h)
{
- return list_top(&r->subsystems, struct nvme_subsystem, entry);
+ return h->hostid;
}
-nvme_subsystem_t nvme_next_subsystem(nvme_root_t r, nvme_subsystem_t s)
+nvme_subsystem_t nvme_first_subsystem(nvme_host_t h)
{
- return s ? list_next(&r->subsystems, s, entry) : NULL;
+ return list_top(&h->subsystems, struct nvme_subsystem, entry);
+}
+
+nvme_subsystem_t nvme_next_subsystem(nvme_host_t h, nvme_subsystem_t s)
+{
+ return s ? list_next(&h->subsystems, s, entry) : NULL;
}
void nvme_refresh_topology(nvme_root_t r)
{
- struct nvme_subsystem *s, *_s;
+ struct nvme_host *h, *_h;
- nvme_for_each_subsystem_safe(r, s, _s)
- nvme_free_subsystem(s);
+ nvme_for_each_host_safe(r, h, _h)
+ nvme_free_host(h);
nvme_scan_topology(r, NULL);
}
void nvme_reset_topology(nvme_root_t r)
{
- struct nvme_subsystem *s, *_s;
+ struct nvme_host *h, *_h;
- nvme_for_each_subsystem_safe(r, s, _s)
- nvme_free_subsystem(s);
+ nvme_for_each_host_safe(r, h, _h)
+ nvme_free_host(h);
nvme_scan_topology(r, NULL);
}
void nvme_free_tree(nvme_root_t r)
{
- struct nvme_subsystem *s, *_s;
+ struct nvme_host *h, *_h;
- nvme_for_each_subsystem_safe(r, s, _s)
- nvme_free_subsystem(s);
+ nvme_for_each_host_safe(r, h, _h)
+ nvme_free_host(h);
free(r);
}
return c ? list_next(&s->ctrls, c, entry) : NULL;
}
+nvme_host_t nvme_subsystem_get_host(nvme_subsystem_t s)
+{
+ return s->h;
+}
+
nvme_ns_t nvme_subsystem_first_ns(nvme_subsystem_t s)
{
return list_top(&s->namespaces, struct nvme_ns, entry);
free(s);
}
+void nvme_free_host(struct nvme_host *h)
+{
+ struct nvme_subsystem *s, *_s;
+
+ list_del_init(&h->entry);
+ nvme_for_each_subsystem_safe(h, s, _s)
+ nvme_free_subsystem(s);
+ free(h->hostnqn);
+ if (h->hostid)
+ free(h->hostid);
+ free(h);
+}
+
static int nvme_subsystem_scan_namespaces(struct nvme_subsystem *s)
{
struct dirent **namespaces;
return 0;
}
-static int nvme_scan_subsystem(struct nvme_root *r, char *name,
+static int nvme_scan_subsystem(struct nvme_host *h, char *name,
nvme_scan_filter_t f)
{
struct nvme_subsystem *s;
goto free_path;
}
- s->r = r;
- s->name = strdup(name);;
+ s->h = h;
+ s->name = strdup(name);
s->sysfs_dir = path;
s->subsysnqn = nvme_get_subsys_attr(s, "subsysnqn");
list_head_init(&s->ctrls);
list_head_init(&s->namespaces);
+ list_add(&h->subsystems, &s->entry);
nvme_subsystem_scan_namespaces(s);
nvme_subsystem_scan_ctrls(s);
- list_add(&r->subsystems, &s->entry);
if (f && !f(s)) {
nvme_free_subsystem(s);
*/
typedef struct nvme_subsystem *nvme_subsystem_t;
+/**
+ *
+ */
+typedef struct nvme_host *nvme_host_t;
+
/**
*
*/
typedef bool (*nvme_scan_filter_t)(nvme_subsystem_t);
/**
- * nvme_first_subsystem() -
+ * nvme_first_host() -
* @r:
*
* Return:
*/
-nvme_subsystem_t nvme_first_subsystem(nvme_root_t r);
+nvme_host_t nvme_first_host(nvme_root_t r);
/**
- * nvme_next_subsystem() -
+ * nvme_next_host() -
* @r:
+ * @h:
+ *
+ * Return:
+ */
+nvme_host_t nvme_next_host(nvme_root_t r, nvme_host_t h);
+
+/**
+ * nvme_host_get_root() -
+ * @h:
+ *
+ * Return:
+ */
+nvme_root_t nvme_host_get_root(nvme_host_t h);
+
+/**
+ * nvme_host_get_hostnqn() -
+ * @h:
+ *
+ * Return:
+ */
+const char *nvme_host_get_hostnqn(nvme_host_t h);
+
+/**
+ * nvme_host_get_hostid() -
+ * @h:
+ *
+ * Return:
+ */
+const char *nvme_host_get_hostid(nvme_host_t h);
+
+/**
+ * nvme_default_host() -
+ * @r:
+ *
+ * Return:
+ */
+nvme_host_t nvme_default_host(nvme_root_t r);
+
+/**
+ * nvme_first_subsystem() -
+ * @h:
+ *
+ * Return:
+ */
+nvme_subsystem_t nvme_first_subsystem(nvme_host_t h);
+
+/**
+ * nvme_next_subsystem() -
+ * @h:
* @s:
*
* Return:
*/
-nvme_subsystem_t nvme_next_subsystem(nvme_root_t r, nvme_subsystem_t s);
+nvme_subsystem_t nvme_next_subsystem(nvme_host_t h, nvme_subsystem_t s);
+
+/**
+ * nvme_subsystem_get_host() -
+ * @s:
+ *
+ * Return:
+ */
+nvme_host_t nvme_subsystem_get_host(nvme_subsystem_t s);
/**
* nvme_ctrl_first_ns() -
*/
nvme_ns_t nvme_subsystem_next_ns(nvme_subsystem_t s, nvme_ns_t n);
+/**
+ * nvme_for_each_host_safe()
+ */
+#define nvme_for_each_host_safe(r, h, _h) \
+ for (h = nvme_first_host(r), \
+ _h = nvme_next_host(r, h); \
+ h != NULL; \
+ h = _h, _h = nvme_next_host(r, h))
+
+/**
+ * nvme_for_each_host()
+ */
+#define nvme_for_each_host(r, h) \
+ for (h = nvme_first_host(r); h != NULL; \
+ h = nvme_next_host(r, h))
+
/**
* nvme_for_each_subsystem_safe()
*/
-#define nvme_for_each_subsystem_safe(r, s, _s) \
- for (s = nvme_first_subsystem(r), \
- _s = nvme_next_subsystem(r, s); \
+#define nvme_for_each_subsystem_safe(h, s, _s) \
+ for (s = nvme_first_subsystem(h), \
+ _s = nvme_next_subsystem(h, s); \
s != NULL; \
- s = _s, _s = nvme_next_subsystem(r, s))
+ s = _s, _s = nvme_next_subsystem(h, s))
/**
* nvme_for_each_subsystem()
*/
-#define nvme_for_each_subsystem(r, s) \
- for (s = nvme_first_subsystem(r); s != NULL; \
- s = nvme_next_subsystem(r, s))
+#define nvme_for_each_subsystem(h, s) \
+ for (s = nvme_first_subsystem(h); s != NULL; \
+ s = nvme_next_subsystem(h, s))
/**
* nvme_subsystem_for_each_ctrl_safe()
int main()
{
nvme_root_t r;
+ nvme_host_t h;
nvme_subsystem_t s;
nvme_ctrl_t c;
nvme_path_t p;
if (!r)
return -1;
- nvme_for_each_subsystem(r, s) {
- std::cout << nvme_subsystem_get_name(s) << " - NQN=" << nvme_subsystem_get_nqn(s) << "\n";
- nvme_subsystem_for_each_ctrl(s, c) {
- std::cout << " `- " << nvme_ctrl_get_name(c) << " " <<
- nvme_ctrl_get_transport(c) << " " <<
- nvme_ctrl_get_address(c) << " " <<
- nvme_ctrl_get_state(c) << "\n";
- nvme_ctrl_for_each_ns(c, n)
- std::cout << " `- " << nvme_ns_get_name(n) <<
- "lba size:" << nvme_ns_get_lba_size(n) << " lba max:" <<
- nvme_ns_get_lba_count(n) << "\n";
- nvme_ctrl_for_each_path(c, p)
- std::cout << " `- " << nvme_path_get_name(p) << " " <<
- nvme_path_get_ana_state(p) << "\n";
- }
- nvme_subsystem_for_each_ns(s, n) {
- std::cout << " `- " << nvme_ns_get_name(n) <<
- "lba size:" << nvme_ns_get_lba_size(n) << " lba max:" <<
- nvme_ns_get_lba_count(n) << "\n";
+ nvme_for_each_host(r, h) {
+ nvme_for_each_subsystem(h, s) {
+ std::cout << nvme_subsystem_get_name(s)
+ << " - NQN=" << nvme_subsystem_get_nqn(s)
+ << "\n";
+ nvme_subsystem_for_each_ctrl(s, c) {
+ std::cout << " `- " << nvme_ctrl_get_name(c)
+ << " " << nvme_ctrl_get_transport(c)
+ << " " << nvme_ctrl_get_address(c)
+ << " " << nvme_ctrl_get_state(c)
+ << "\n";
+ nvme_ctrl_for_each_ns(c, n) {
+ std::cout << " `- "
+ << nvme_ns_get_name(n)
+ << "lba size:"
+ << nvme_ns_get_lba_size(n)
+ << " lba max:"
+ << nvme_ns_get_lba_count(n)
+ << "\n";
+ }
+ nvme_ctrl_for_each_path(c, p) {
+ std::cout << " `- "
+ << nvme_path_get_name(p)
+ << " "
+ << nvme_path_get_ana_state(p)
+ << "\n";
+ }
+ }
+ nvme_subsystem_for_each_ns(s, n) {
+ std::cout << " `- " << nvme_ns_get_name(n)
+ << "lba size:"
+ << nvme_ns_get_lba_size(n)
+ << " lba max:"
+ << nvme_ns_get_lba_count(n) << "\n";
+ }
}
}
std::cout << "\n";
int main()
{
nvme_root_t r;
+ nvme_host_t h;
nvme_subsystem_t s;
nvme_ctrl_t c;
nvme_path_t p;
printf("Test filter for common loop back target\n");
nqn_match = "testnqn";
r = nvme_scan_filter(nvme_match_subsysnqn_filter);
- nvme_for_each_subsystem(r, s) {
- printf("%s - NQN=%s\n", nvme_subsystem_get_name(s),
- nvme_subsystem_get_nqn(s));
- nvme_subsystem_for_each_ctrl(s, c) {
- printf(" %s %s %s %s\n", nvme_ctrl_get_name(c),
- nvme_ctrl_get_transport(c),
- nvme_ctrl_get_address(c),
- nvme_ctrl_get_state(c));
+ nvme_for_each_host(r, h) {
+ nvme_for_each_subsystem(h, s) {
+ printf("%s - NQN=%s\n", nvme_subsystem_get_name(s),
+ nvme_subsystem_get_nqn(s));
+ nvme_subsystem_for_each_ctrl(s, c) {
+ printf(" %s %s %s %s\n", nvme_ctrl_get_name(c),
+ nvme_ctrl_get_transport(c),
+ nvme_ctrl_get_address(c),
+ nvme_ctrl_get_state(c));
+ }
}
}
printf("\n");
return -1;
printf("Test walking the topology\n");
- nvme_for_each_subsystem(r, s) {
- printf("%s - NQN=%s\n", nvme_subsystem_get_name(s),
- nvme_subsystem_get_nqn(s));
- nvme_subsystem_for_each_ctrl(s, c) {
- printf(" `- %s %s %s %s\n", nvme_ctrl_get_name(c),
- nvme_ctrl_get_transport(c),
- nvme_ctrl_get_address(c),
- nvme_ctrl_get_state(c));
+ nvme_for_each_host(r, h) {
+ nvme_for_each_subsystem(h, s) {
+ printf("%s - NQN=%s\n", nvme_subsystem_get_name(s),
+ nvme_subsystem_get_nqn(s));
+ nvme_subsystem_for_each_ctrl(s, c) {
+ printf(" `- %s %s %s %s\n",
+ nvme_ctrl_get_name(c),
+ nvme_ctrl_get_transport(c),
+ nvme_ctrl_get_address(c),
+ nvme_ctrl_get_state(c));
- nvme_ctrl_for_each_ns(c, n) {
+ nvme_ctrl_for_each_ns(c, n) {
#ifdef CONFIG_LIBUUID
- char uuid_str[40];
- uuid_t uuid;
+ char uuid_str[40];
+ uuid_t uuid;
#endif
- printf(" `- %s lba size:%d lba max:%lu\n",
- nvme_ns_get_name(n), nvme_ns_get_lba_size(n),
- nvme_ns_get_lba_count(n));
- printf(" eui:");
- print_hex(nvme_ns_get_eui64(n), 8);
- printf(" nguid:");
- print_hex(nvme_ns_get_nguid(n), 16);
+ printf(" `- %s lba size:%d lba max:%lu\n",
+ nvme_ns_get_name(n),
+ nvme_ns_get_lba_size(n),
+ nvme_ns_get_lba_count(n));
+ printf(" eui:");
+ print_hex(nvme_ns_get_eui64(n), 8);
+ printf(" nguid:");
+ print_hex(nvme_ns_get_nguid(n), 16);
#ifdef CONFIG_LIBUUID
- nvme_ns_get_uuid(n, uuid);
- uuid_unparse_lower(uuid, uuid_str);
- printf(" uuid:%s csi:%d\n", uuid_str, nvme_ns_get_csi(n));
+ nvme_ns_get_uuid(n, uuid);
+ uuid_unparse_lower(uuid, uuid_str);
+ printf(" uuid:%s csi:%d\n", uuid_str,
+ nvme_ns_get_csi(n));
#endif
- }
+ }
- nvme_ctrl_for_each_path(c, p)
- printf(" `- %s %s\n", nvme_path_get_name(p),
- nvme_path_get_ana_state(p));
- }
+ nvme_ctrl_for_each_path(c, p)
+ printf(" `- %s %s\n",
+ nvme_path_get_name(p),
+ nvme_path_get_ana_state(p));
+ }
- nvme_subsystem_for_each_ns(s, n) {
- printf(" `- %s lba size:%d lba max:%lu\n",
- nvme_ns_get_name(n), nvme_ns_get_lba_size(n),
- nvme_ns_get_lba_count(n));
+ nvme_subsystem_for_each_ns(s, n) {
+ printf(" `- %s lba size:%d lba max:%lu\n",
+ nvme_ns_get_name(n),
+ nvme_ns_get_lba_size(n),
+ nvme_ns_get_lba_count(n));
+ }
}
+ printf("\n");
}
- printf("\n");
printf("Test identification, logs, and features\n");
- nvme_for_each_subsystem(r, s) {
- nvme_subsystem_for_each_ctrl(s, c) {
- test_ctrl(c);
- printf("\n");
- nvme_ctrl_for_each_ns(c, n) {
+ nvme_for_each_host(r, h) {
+ nvme_for_each_subsystem(h, s) {
+ nvme_subsystem_for_each_ctrl(s, c) {
+ test_ctrl(c);
+ printf("\n");
+ nvme_ctrl_for_each_ns(c, n) {
+ test_namespace(n);
+ printf("\n");
+ }
+ }
+ nvme_subsystem_for_each_ns(s, n) {
test_namespace(n);
printf("\n");
}
}
- nvme_subsystem_for_each_ns(s, n) {
- test_namespace(n);
- printf("\n");
- }
}
nvme_free_tree(r);
{
nvme_subsystem_t s;
nvme_root_t r;
+ nvme_host_t h;
nvme_ctrl_t c;
nvme_ns_t n;
if (!r)
return -1;
- nvme_for_each_subsystem(r, s) {
- nvme_subsystem_for_each_ctrl(s, c) {
- nvme_ctrl_for_each_ns(c, n) {
+ nvme_for_each_host(r, h) {
+ nvme_for_each_subsystem(h, s) {
+ nvme_subsystem_for_each_ctrl(s, c) {
+ nvme_ctrl_for_each_ns(c, n) {
+ if (nvme_ns_get_csi(n) == NVME_CSI_ZNS)
+ show_zns_properties(n);
+ }
+ }
+ nvme_subsystem_for_each_ns(s, n) {
if (nvme_ns_get_csi(n) == NVME_CSI_ZNS)
show_zns_properties(n);
}
}
- nvme_subsystem_for_each_ns(s, n) {
- if (nvme_ns_get_csi(n) == NVME_CSI_ZNS)
- show_zns_properties(n);
- }
}
nvme_free_tree(r);
}