diff --git a/fabrics.c b/fabrics.c index 18a0d3982a..287b6c41ee 100644 --- a/fabrics.c +++ b/fabrics.c @@ -153,7 +153,7 @@ static void save_discovery_log(char *raw, struct nvmf_discovery_log *log) fd = open(raw, O_CREAT | O_RDWR | O_TRUNC, 0600); if (fd < 0) { - fprintf(stderr, "failed to open %s: %s\n", raw, nvme_strerror(errno)); + fprintf(stderr, "failed to open %s: %s\n", raw, libnvme_strerror(errno)); return; } @@ -162,7 +162,7 @@ static void save_discovery_log(char *raw, struct nvmf_discovery_log *log) ret = write(fd, log, len); if (ret < 0) fprintf(stderr, "failed to write to %s: %s\n", - raw, nvme_strerror(errno)); + raw, libnvme_strerror(errno)); else printf("Discovery log is saved to %s\n", raw); @@ -184,7 +184,7 @@ static bool cb_decide_retry(struct nvmf_context *fctx, int err, void *user_data) { if (err == -EAGAIN || (err == -EINTR && !nvme_sigint_received)) { - print_debug("nvmf_add_ctrl returned '%s'\n", nvme_strerror(-err)); + print_debug("nvmf_add_ctrl returned '%s'\n", libnvme_strerror(-err)); return true; } @@ -192,12 +192,12 @@ static bool cb_decide_retry(struct nvmf_context *fctx, int err, } static void cb_connected(struct nvmf_context *fctx, - struct nvme_ctrl *c, void *user_data) + struct libnvme_ctrl *c, void *user_data) { struct cb_fabrics_data *cfd = user_data; if (cfd->flags == NORMAL) { - printf("device: %s\n", nvme_ctrl_get_name(c)); + printf("device: %s\n", libnvme_ctrl_get_name(c)); return; } @@ -208,7 +208,7 @@ static void cb_connected(struct nvmf_context *fctx, root = json_create_object(); json_object_add_value_string(root, "device", - nvme_ctrl_get_name(c)); + libnvme_ctrl_get_name(c)); json_print_object(root, NULL); printf("\n"); @@ -218,7 +218,7 @@ static void cb_connected(struct nvmf_context *fctx, } static void cb_already_connected(struct nvmf_context *fctx, - struct nvme_host *host, const char *subsysnqn, + struct libnvme_host *host, const char *subsysnqn, const char *transport, const char *traddr, const char *trsvcid, void *user_data) { @@ -226,7 +226,7 @@ static void cb_already_connected(struct nvmf_context *fctx, return; fprintf(stderr, "already connected to hostnqn=%s,nqn=%s,transport=%s,traddr=%s,trsvcid=%s\n", - nvme_host_get_hostnqn(host), subsysnqn, + libnvme_host_get_hostnqn(host), subsysnqn, transport, traddr, trsvcid); } @@ -449,7 +449,7 @@ static int nvme_read_volatile_config(struct nvme_global_ctx *ctx) break; } - if (nvme_read_config(ctx, filename)) + if (libnvme_read_config(ctx, filename)) ret = 0; free(filename); @@ -465,7 +465,7 @@ static int nvme_read_config_checked(struct nvme_global_ctx *ctx, if (access(filename, F_OK)) return -errno; - return nvme_read_config(ctx, filename); + return libnvme_read_config(ctx, filename); } #define NBFT_SYSFS_PATH "/sys/firmware/acpi/tables" @@ -516,25 +516,25 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect) log_level = map_log_level(nvme_args.verbose, quiet); - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { fprintf(stderr, "Failed to create topology root: %s\n", - nvme_strerror(errno)); + libnvme_strerror(errno)); return -ENOMEM; } if (context) - nvme_set_application(ctx, context); + libnvme_set_application(ctx, context); if (!nvme_read_config_checked(ctx, config_file)) json_config = true; if (!nvme_read_volatile_config(ctx)) json_config = true; - nvme_skip_namespaces(ctx); - ret = nvme_scan_topology(ctx, NULL, NULL); + libnvme_skip_namespaces(ctx); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret < 0) { fprintf(stderr, "Failed to scan topology: %s\n", - nvme_strerror(-ret)); + libnvme_strerror(-ret)); return ret; } @@ -576,7 +576,7 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect) out_free: if (dump_config) - nvme_dump_config(ctx, STDOUT_FILENO); + libnvme_dump_config(ctx, STDOUT_FILENO); return ret; } @@ -589,7 +589,7 @@ int fabrics_connect(const char *desc, int argc, char **argv) char *context = NULL; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_free_ struct nvmf_context *fctx = NULL; - _cleanup_nvme_ctrl_ nvme_ctrl_t c = NULL; + _cleanup_nvme_ctrl_ libnvme_ctrl_t c = NULL; int ret; nvme_print_flags_t flags; struct nvme_fabrics_config cfg = { 0 }; @@ -639,23 +639,23 @@ int fabrics_connect(const char *desc, int argc, char **argv) do_connect: log_level = map_log_level(nvme_args.verbose, quiet); - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { fprintf(stderr, "Failed to create topology root: %s\n", - nvme_strerror(errno)); + libnvme_strerror(errno)); return -ENOMEM; } if (context) - nvme_set_application(ctx, context); + libnvme_set_application(ctx, context); - nvme_read_config(ctx, config_file); + libnvme_read_config(ctx, config_file); nvme_read_volatile_config(ctx); - nvme_skip_namespaces(ctx); - ret = nvme_scan_topology(ctx, NULL, NULL); + libnvme_skip_namespaces(ctx); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret < 0) { fprintf(stderr, "Failed to scan topology: %s\n", - nvme_strerror(-ret)); + libnvme_strerror(-ret)); return ret; } @@ -674,27 +674,27 @@ int fabrics_connect(const char *desc, int argc, char **argv) ret = nvmf_connect(ctx, fctx); if (ret) { fprintf(stderr, "failed to connect: %s\n", - nvme_strerror(-ret)); + libnvme_strerror(-ret)); return ret; } if (dump_config) - nvme_dump_config(ctx, STDERR_FILENO); + libnvme_dump_config(ctx, STDERR_FILENO); return 0; } -static nvme_ctrl_t lookup_nvme_ctrl(struct nvme_global_ctx *ctx, +static libnvme_ctrl_t lookup_nvme_ctrl(struct nvme_global_ctx *ctx, const char *name) { - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; - - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - nvme_subsystem_for_each_ctrl(s, c) { - if (!strcmp(nvme_ctrl_get_name(c), name)) + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; + + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + libnvme_subsystem_for_each_ctrl(s, c) { + if (!strcmp(libnvme_ctrl_get_name(c), name)) return c; } } @@ -707,19 +707,19 @@ static void nvmf_disconnect_nqn(struct nvme_global_ctx *ctx, char *nqn) int i = 0; char *n = nqn; char *p; - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; while ((p = strsep(&n, ",")) != NULL) { if (!strlen(p)) continue; - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - if (strcmp(nvme_subsystem_get_subsysnqn(s), p)) + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + if (strcmp(libnvme_subsystem_get_subsysnqn(s), p)) continue; - nvme_subsystem_for_each_ctrl(s, c) { - if (!nvme_disconnect_ctrl(c)) + libnvme_subsystem_for_each_ctrl(s, c) { + if (!libnvme_disconnect_ctrl(c)) i++; } } @@ -732,7 +732,7 @@ int fabrics_disconnect(const char *desc, int argc, char **argv) { const char *device = "nvme device handle"; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; - nvme_ctrl_t c; + libnvme_ctrl_t c; char *p; int ret; @@ -764,14 +764,14 @@ int fabrics_disconnect(const char *desc, int argc, char **argv) log_level = map_log_level(nvme_args.verbose, false); - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { fprintf(stderr, "Failed to create topology root: %s\n", - nvme_strerror(errno)); + libnvme_strerror(errno)); return -ENOMEM; } - nvme_skip_namespaces(ctx); - ret = nvme_scan_topology(ctx, NULL, NULL); + libnvme_skip_namespaces(ctx); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret < 0) { /* * Do not report an error when the modules are not @@ -782,7 +782,7 @@ int fabrics_disconnect(const char *desc, int argc, char **argv) return 0; fprintf(stderr, "Failed to scan topology: %s\n", - nvme_strerror(-ret)); + libnvme_strerror(-ret)); return ret; } @@ -802,11 +802,11 @@ int fabrics_disconnect(const char *desc, int argc, char **argv) "Did not find device %s\n", p); return -ENODEV; } - ret = nvme_disconnect_ctrl(c); + ret = libnvme_disconnect_ctrl(c); if (ret) fprintf(stderr, "Failed to disconnect %s: %s\n", - p, nvme_strerror(-ret)); + p, libnvme_strerror(-ret)); } } @@ -816,9 +816,9 @@ int fabrics_disconnect(const char *desc, int argc, char **argv) int fabrics_disconnect_all(const char *desc, int argc, char **argv) { _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; int ret; struct config { @@ -836,14 +836,14 @@ int fabrics_disconnect_all(const char *desc, int argc, char **argv) log_level = map_log_level(nvme_args.verbose, false); - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { fprintf(stderr, "Failed to create topology root: %s\n", - nvme_strerror(errno)); + libnvme_strerror(errno)); return -ENOMEM; } - nvme_skip_namespaces(ctx); - ret = nvme_scan_topology(ctx, NULL, NULL); + libnvme_skip_namespaces(ctx); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret < 0) { /* * Do not report an error when the modules are not @@ -854,24 +854,24 @@ int fabrics_disconnect_all(const char *desc, int argc, char **argv) return 0; fprintf(stderr, "Failed to scan topology: %s\n", - nvme_strerror(-ret)); + libnvme_strerror(-ret)); return ret; } - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + libnvme_subsystem_for_each_ctrl(s, c) { if (cfg.transport && strcmp(cfg.transport, - nvme_ctrl_get_transport(c))) + libnvme_ctrl_get_transport(c))) continue; - else if (!strcmp(nvme_ctrl_get_transport(c), + else if (!strcmp(libnvme_ctrl_get_transport(c), "pcie")) continue; - if (nvme_disconnect_ctrl(c)) + if (libnvme_disconnect_ctrl(c)) fprintf(stderr, "failed to disconnect %s\n", - nvme_ctrl_get_name(c)); + libnvme_ctrl_get_name(c)); } } } @@ -906,21 +906,21 @@ int fabrics_config(const char *desc, int argc, char **argv) log_level = map_log_level(nvme_args.verbose, quiet); - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { fprintf(stderr, "Failed to create topology root: %s\n", - nvme_strerror(errno)); + libnvme_strerror(errno)); return -ENOMEM; } - nvme_read_config(ctx, config_file); + libnvme_read_config(ctx, config_file); if (scan_tree) { - nvme_skip_namespaces(ctx); - ret = nvme_scan_topology(ctx, NULL, NULL); + libnvme_skip_namespaces(ctx); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret < 0) { fprintf(stderr, "Failed to scan topology: %s\n", - nvme_strerror(-ret)); + libnvme_strerror(-ret)); return -ret; } } @@ -957,16 +957,16 @@ int fabrics_config(const char *desc, int argc, char **argv) fd = open(config_file, O_RDONLY, 0); if (fd != -1) - nvme_dump_config(ctx, fd); + libnvme_dump_config(ctx, fd); } if (dump_config) - nvme_dump_config(ctx, STDOUT_FILENO); + libnvme_dump_config(ctx, STDOUT_FILENO); return 0; } -static int dim_operation(nvme_ctrl_t c, enum nvmf_dim_tas tas, const char *name) +static int dim_operation(libnvme_ctrl_t c, enum nvmf_dim_tas tas, const char *name) { static const char * const task[] = { [NVMF_DIM_TAS_REGISTER] = "register", @@ -982,20 +982,20 @@ static int dim_operation(nvme_ctrl_t c, enum nvmf_dim_tas tas, const char *name) printf("%s DIM %s command success\n", name, t); } else if (status < NVME_SC_SUCCESS) { fprintf(stderr, "%s DIM %s command error. Status:0x%04x - %s\n", - name, t, status, nvme_status_to_string(status, false)); + name, t, status, libnvme_status_to_string(status, false)); } else { fprintf(stderr, "%s DIM %s command error. Result:0x%04x, Status:0x%04x - %s\n", - name, t, result, status, nvme_status_to_string(status, false)); + name, t, result, status, libnvme_status_to_string(status, false)); } - return nvme_status_to_errno(status, true); + return libnvme_status_to_errno(status, true); } int fabrics_dim(const char *desc, int argc, char **argv) { _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; enum nvmf_dim_tas tas; - nvme_ctrl_t c; + libnvme_ctrl_t c; char *p; int ret; @@ -1038,33 +1038,33 @@ int fabrics_dim(const char *desc, int argc, char **argv) log_level = map_log_level(nvme_args.verbose, false); - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { fprintf(stderr, "Failed to create topology root: %s\n", - nvme_strerror(errno)); + libnvme_strerror(errno)); return -ENODEV; } - nvme_skip_namespaces(ctx); - ret = nvme_scan_topology(ctx, NULL, NULL); + libnvme_skip_namespaces(ctx); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret < 0) { fprintf(stderr, "Failed to scan topology: %s\n", - nvme_strerror(-ret)); + libnvme_strerror(-ret)); return ret; } if (cfg.nqn) { - nvme_host_t h; - nvme_subsystem_t s; + libnvme_host_t h; + libnvme_subsystem_t s; char *n = cfg.nqn; while ((p = strsep(&n, ",")) != NULL) { if (!strlen(p)) continue; - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - if (strcmp(nvme_subsystem_get_subsysnqn(s), p)) + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + if (strcmp(libnvme_subsystem_get_subsysnqn(s), p)) continue; - nvme_subsystem_for_each_ctrl(s, c) + libnvme_subsystem_for_each_ctrl(s, c) ret = dim_operation(c, tas, p); } } @@ -1077,11 +1077,11 @@ int fabrics_dim(const char *desc, int argc, char **argv) while ((p = strsep(&d, ",")) != NULL) { if (!strncmp(p, "/dev/", 5)) p += 5; - ret = nvme_scan_ctrl(ctx, p, &c); + ret = libnvme_scan_ctrl(ctx, p, &c); if (ret) { fprintf(stderr, "Did not find device %s: %s\n", - p, nvme_strerror(ret)); + p, libnvme_strerror(ret)); return ret; } ret = dim_operation(c, tas, p); diff --git a/libnvme/examples/discover-loop.c b/libnvme/examples/discover-loop.c index f1369e8a0d..ffd0ec8c2f 100644 --- a/libnvme/examples/discover-loop.c +++ b/libnvme/examples/discover-loop.c @@ -53,28 +53,28 @@ int main() { struct nvmf_discovery_log *log; struct nvme_global_ctx *ctx; - nvme_host_t h; - nvme_ctrl_t c; + libnvme_host_t h; + libnvme_ctrl_t c; int ret; struct nvme_fabrics_config cfg; nvmf_default_config(&cfg); - ctx = nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); if (!ctx) return 1; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) { - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return 1; } - ret = nvme_get_host(ctx, NULL, NULL, &h); + ret = libnvme_get_host(ctx, NULL, NULL, &h); if (ret) { fprintf(stderr, "Failed to allocated memory\n"); return 1; } - ret = nvme_create_ctrl(ctx, NVME_DISC_SUBSYS_NAME, "loop", + ret = libnvme_create_ctrl(ctx, NVME_DISC_SUBSYS_NAME, "loop", NULL, NULL, NULL, NULL, &c); if (ret) { fprintf(stderr, "Failed to allocate memory\n"); @@ -87,15 +87,15 @@ int main() } ret = nvmf_get_discovery_log(c, &log, 4); - nvme_disconnect_ctrl(c); - nvme_free_ctrl(c); + libnvme_disconnect_ctrl(c); + libnvme_free_ctrl(c); if (ret) fprintf(stderr, "nvmf-discover-log:%x\n", ret); else print_discover_log(log); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); free(log); return 0; } diff --git a/libnvme/examples/display-columnar.c b/libnvme/examples/display-columnar.c index ab6d9e672f..51037fd9a0 100644 --- a/libnvme/examples/display-columnar.c +++ b/libnvme/examples/display-columnar.c @@ -18,35 +18,35 @@ static const char dash[101] = {[0 ... 99] = '-'}; int main() { struct nvme_global_ctx *ctx; - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; - nvme_path_t p; - nvme_ns_t n; + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; + libnvme_path_t p; + libnvme_ns_t n; int err; - ctx = nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); if (!ctx) return 1; - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err) { - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return 1; } printf("%-16s %-96s %-.16s\n", "Subsystem", "Subsystem-NQN", "Controllers"); printf("%-.16s %-.96s %-.16s\n", dash, dash, dash); - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { bool first = true; - printf("%-16s %-96s ", nvme_subsystem_get_name(s), - nvme_subsystem_get_subsysnqn(s)); + printf("%-16s %-96s ", libnvme_subsystem_get_name(s), + libnvme_subsystem_get_subsysnqn(s)); - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_subsystem_for_each_ctrl(s, c) { printf("%s%s", first ? "": ", ", - nvme_ctrl_get_name(c)); + libnvme_ctrl_get_name(c)); first = false; } printf("\n"); @@ -59,29 +59,29 @@ int main() printf("%-.8s %-.20s %-.40s %-.8s %-.6s %-.14s %-.12s %-.16s\n", dash, dash, dash, dash, dash, dash, dash, dash); - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + libnvme_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_traddr(c), - nvme_subsystem_get_name(s)); - - nvme_ctrl_for_each_ns(c, n) { + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_serial(c), + libnvme_ctrl_get_model(c), + libnvme_ctrl_get_firmware(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_subsystem_get_name(s)); + + libnvme_ctrl_for_each_ns(c, n) { printf("%s%s", first ? "": ", ", - nvme_ns_get_name(n)); + libnvme_ns_get_name(n)); first = false; } - nvme_ctrl_for_each_path(c, p) { + libnvme_ctrl_for_each_path(c, p) { printf("%s%s", first ? "": ", ", - nvme_ns_get_name(nvme_path_get_ns(p))); + libnvme_ns_get_name(libnvme_path_get_ns(p))); first = false; } printf("\n"); @@ -93,29 +93,29 @@ int main() 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_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - nvme_subsystem_for_each_ctrl(s, c) { - nvme_ctrl_for_each_ns(c, n) + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + libnvme_subsystem_for_each_ctrl(s, c) { + libnvme_ctrl_for_each_ns(c, n) printf("%-12s %-8d %-16" PRIu64 " %-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)); + libnvme_ns_get_name(n), + libnvme_ns_get_nsid(n), + libnvme_ns_get_lba_count(n), + libnvme_ns_get_lba_size(n), + libnvme_ctrl_get_name(c)); } - nvme_subsystem_for_each_ns(s, n) { + libnvme_subsystem_for_each_ns(s, n) { bool first = true; printf("%-12s %-8d %-16" PRIu64 " %-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) { + libnvme_ns_get_name(n), + libnvme_ns_get_nsid(n), + libnvme_ns_get_lba_count(n), + libnvme_ns_get_lba_size(n)); + libnvme_subsystem_for_each_ctrl(s, c) { printf("%s%s", first ? "" : ", ", - nvme_ctrl_get_name(c)); + libnvme_ctrl_get_name(c)); first = false; } printf("\n"); diff --git a/libnvme/examples/display-tree.c b/libnvme/examples/display-tree.c index 91f67676d8..2a92a6f7a1 100644 --- a/libnvme/examples/display-tree.c +++ b/libnvme/examples/display-tree.c @@ -17,63 +17,63 @@ int main() { struct nvme_global_ctx *ctx; - nvme_host_t h; - nvme_subsystem_t s, _s; - nvme_ctrl_t c, _c; - nvme_path_t p, _p; - nvme_ns_t n, _n; + libnvme_host_t h; + libnvme_subsystem_t s, _s; + libnvme_ctrl_t c, _c; + libnvme_path_t p, _p; + libnvme_ns_t n, _n; int err; - ctx = nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); if (!ctx) return 1; - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err) { - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return 1; } printf(".\n"); - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem_safe(h, s, _s) { + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem_safe(h, s, _s) { printf("%c-- %s - NQN=%s\n", _s ? '|' : '`', - nvme_subsystem_get_name(s), - nvme_subsystem_get_subsysnqn(s)); + libnvme_subsystem_get_name(s), + libnvme_subsystem_get_subsysnqn(s)); - nvme_subsystem_for_each_ns_safe(s, n, _n) { + libnvme_subsystem_for_each_ns_safe(s, n, _n) { printf("%c |-- %s lba size:%d lba max:%" PRIu64 "\n", _s ? '|' : ' ', - nvme_ns_get_name(n), - nvme_ns_get_lba_size(n), - nvme_ns_get_lba_count(n)); + libnvme_ns_get_name(n), + libnvme_ns_get_lba_size(n), + libnvme_ns_get_lba_count(n)); } - nvme_subsystem_for_each_ctrl_safe(s, c, _c) { + libnvme_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_traddr(c), - nvme_ctrl_get_state(c)); + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_state(c)); - nvme_ctrl_for_each_ns_safe(c, n, _n) + libnvme_ctrl_for_each_ns_safe(c, n, _n) printf("%c %c %c-- %s lba size:%d lba max:%" PRIu64 "\n", _s ? '|' : ' ', _c ? '|' : ' ', _n ? '|' : '`', - nvme_ns_get_name(n), - nvme_ns_get_lba_size(n), - nvme_ns_get_lba_count(n)); + libnvme_ns_get_name(n), + libnvme_ns_get_lba_size(n), + libnvme_ns_get_lba_count(n)); - nvme_ctrl_for_each_path_safe(c, p, _p) + libnvme_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)); + libnvme_path_get_name(p), + libnvme_path_get_ana_state(p)); } } } - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return 0; } diff --git a/libnvme/examples/mi-conf.c b/libnvme/examples/mi-conf.c index 03b74639d7..6408720e67 100644 --- a/libnvme/examples/mi-conf.c +++ b/libnvme/examples/mi-conf.c @@ -49,7 +49,7 @@ int find_port(nvme_mi_ep_t ep, uint8_t *portp, uint16_t *mtup) int rc; /* query number of ports */ - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); if (rc) { warn("Failed reading subsystem info"); return -1; @@ -57,7 +57,7 @@ int find_port(nvme_mi_ep_t ep, uint8_t *portp, uint16_t *mtup) found = false; for (port = 0; port <= ss_info.nump; port++) { - rc = nvme_mi_mi_read_mi_data_port(ep, port, &port_info); + rc = libnvme_mi_mi_read_mi_data_port(ep, port, &port_info); if (rc) { warn("Failed reading port info for port %ud", port); return -1; @@ -157,11 +157,11 @@ int main(int argc, char **argv) if (rc) errx(EXIT_FAILURE, "can't parse MI device string '%s'", devstr); - ctx = nvme_create_global_ctx(stderr, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stderr, DEFAULT_LOGLEVEL); if (!ctx) err(EXIT_FAILURE, "can't create global context"); - ep = nvme_mi_open_mctp(ctx, net, eid); + ep = libnvme_mi_open_mctp(ctx, net, eid); if (!ep) { warnx("can't open MCTP endpoint %d:%d", net, eid); goto out_free_ctx; @@ -182,7 +182,7 @@ int main(int argc, char **argv) goto out_close_bus; } - rc = nvme_mi_mi_config_get_mctp_mtu(ep, port, &cur_mtu); + rc = libnvme_mi_mi_config_get_mctp_mtu(ep, port, &cur_mtu); if (rc) { cur_mtu = 0; warn("Can't query current MTU; no way to revert on failure"); @@ -193,7 +193,7 @@ int main(int argc, char **argv) goto out_close_bus; } - rc = nvme_mi_mi_config_set_mctp_mtu(ep, port, mtu); + rc = libnvme_mi_mi_config_set_mctp_mtu(ep, port, mtu); if (rc) { warn("Can't set MCTP MTU"); goto out_close_bus; @@ -203,7 +203,7 @@ int main(int argc, char **argv) if (rc) { /* revert if we have an old setting */ if (cur_mtu) { - rc = nvme_mi_mi_config_set_mctp_mtu(ep, port, cur_mtu); + rc = libnvme_mi_mi_config_set_mctp_mtu(ep, port, cur_mtu); if (rc) warn("Failed to restore previous MTU!"); rc = -1; @@ -217,9 +217,9 @@ int main(int argc, char **argv) dbus_connection_unref(bus); out_close_ep: dbus_error_free(&berr); - nvme_mi_close(ep); + libnvme_mi_close(ep); out_free_ctx: - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return rc ? EXIT_FAILURE : EXIT_SUCCESS; } diff --git a/libnvme/examples/mi-mctp-ae.c b/libnvme/examples/mi-mctp-ae.c index e35ffebc75..a90a4249a4 100644 --- a/libnvme/examples/mi-mctp-ae.c +++ b/libnvme/examples/mi-mctp-ae.c @@ -55,7 +55,7 @@ static void print_event_info(struct nvme_mi_event *event) } } -enum nvme_mi_aem_handler_next_action aem_handler(nvme_mi_ep_t ep, size_t num_events, void *userdata) +enum libnvme_mi_aem_handler_next_action aem_handler(nvme_mi_ep_t ep, size_t num_events, void *userdata) { struct app_userdata *data = (struct app_userdata *) userdata; @@ -63,7 +63,7 @@ enum nvme_mi_aem_handler_next_action aem_handler(nvme_mi_ep_t ep, size_t num_eve printf("Received notification #%d with %zu events:\n", data->count, num_events); for (int i = 0; i < num_events; i++) { - struct nvme_mi_event *event = nvme_mi_aem_get_next_event(ep); + struct nvme_mi_event *event = libnvme_mi_aem_get_next_event(ep); if (event == NULL) printf("Unexpected NULL event\n"); @@ -110,11 +110,11 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - ctx = nvme_create_global_ctx(stderr, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stderr, DEFAULT_LOGLEVEL); if (!ctx) err(EXIT_FAILURE, "can't create NVMe root"); - ep = nvme_mi_open_mctp(ctx, net, eid); + ep = libnvme_mi_open_mctp(ctx, net, eid); if (!ep) err(EXIT_FAILURE, "can't open MCTP endpoint %d:%d", net, eid); @@ -122,7 +122,7 @@ int main(int argc, char **argv) aem_config.aemd = 1; aem_config.aerd = 100; - rc = nvme_mi_aem_get_enabled(ep, &enabled_map); + rc = libnvme_mi_aem_get_enabled(ep, &enabled_map); if (rc) err(EXIT_FAILURE, "Can't query enabled aems:%d", rc); printf("The following events were previously enabled:\n"); @@ -131,19 +131,19 @@ int main(int argc, char **argv) printf("Event: %d\n", i); } - rc = nvme_mi_aem_enable(ep, &aem_config, &data); + rc = libnvme_mi_aem_enable(ep, &aem_config, &data); if (rc == EOPNOTSUPP) errx(EXIT_FAILURE, "MCTP Peer-Bind is required for AEM"); else if (rc) err(EXIT_FAILURE, "Can't enable aem:%d", rc); - rc = nvme_mi_aem_get_enabled(ep, &enabled_map); + rc = libnvme_mi_aem_get_enabled(ep, &enabled_map); if (rc) err(EXIT_FAILURE, "Can't query enabled aems:%d", rc); struct pollfd fds[2]; - fds[AEM_FD_INDEX].fd = nvme_mi_aem_get_fd(ep); + fds[AEM_FD_INDEX].fd = libnvme_mi_aem_get_fd(ep); if (fds[AEM_FD_INDEX].fd < 0) errx(EXIT_FAILURE, "Can't get aem fd"); @@ -162,19 +162,19 @@ int main(int argc, char **argv) } //Time to do the work if (fds[AEM_FD_INDEX].revents & POLLIN) { - rc = nvme_mi_aem_process(ep, &data); + rc = libnvme_mi_aem_process(ep, &data); if (rc) err(EXIT_FAILURE, - "nvme_mi_aem_process failed with:%d", rc); + "libnvme_mi_aem_process failed with:%d", rc); } if (fds[STD_IN_FD_INDEX].revents & POLLIN) break;//we are done } //Cleanup - nvme_mi_aem_disable(ep); - nvme_mi_close(ep); - nvme_free_global_ctx(ctx); + libnvme_mi_aem_disable(ep); + libnvme_mi_close(ep); + libnvme_free_global_ctx(ctx); return rc ? EXIT_FAILURE : EXIT_SUCCESS; } diff --git a/libnvme/examples/mi-mctp-csi-test.c b/libnvme/examples/mi-mctp-csi-test.c index 57602fe049..302363b45b 100644 --- a/libnvme/examples/mi-mctp-csi-test.c +++ b/libnvme/examples/mi-mctp-csi-test.c @@ -83,7 +83,7 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv) lid = 0x1; } - hdl = nvme_mi_init_transport_handle(ep, ctrl_id); + hdl = libnvme_mi_init_transport_handle(ep, ctrl_id); if (!hdl) { warn("can't create controller"); return -1; @@ -128,17 +128,17 @@ int do_csi_test(struct nvme_global_ctx *ctx, int net, __u8 eid, int rc = 0; nvme_mi_ep_t ep1, ep2; - ep1 = nvme_mi_open_mctp(ctx, net, eid); + ep1 = libnvme_mi_open_mctp(ctx, net, eid); if (!ep1) errx(EXIT_FAILURE, "can't open MCTP endpoint %d:%d", net, eid); - ep2 = nvme_mi_open_mctp(ctx, net, eid); + ep2 = libnvme_mi_open_mctp(ctx, net, eid); if (!ep2) errx(EXIT_FAILURE, "can't open MCTP endpoint %d:%d", net, eid); pthread_t thread; - nvme_mi_set_csi(ep1, 0);//Not necessary, but to be explicit - nvme_mi_set_csi(ep2, 1); + libnvme_mi_set_csi(ep1, 0);//Not necessary, but to be explicit + libnvme_mi_set_csi(ep2, 1); struct thread_struct s; s.ep = ep2; @@ -164,8 +164,8 @@ int do_csi_test(struct nvme_global_ctx *ctx, int net, __u8 eid, printf("Second thread finished with rc=%d\n", s.rc); - nvme_mi_close(ep1); - nvme_mi_close(ep2); + libnvme_mi_close(ep1); + libnvme_mi_close(ep2); if (rc) return rc; @@ -237,12 +237,12 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - ctx = nvme_create_global_ctx(stderr, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stderr, DEFAULT_LOGLEVEL); if (!ctx) err(EXIT_FAILURE, "can't create NVMe root"); rc = do_action_endpoint(action, ctx, net, eid, argc, argv); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return rc ? EXIT_FAILURE : EXIT_SUCCESS; } diff --git a/libnvme/examples/mi-mctp.c b/libnvme/examples/mi-mctp.c index 5aa4831095..674690942e 100644 --- a/libnvme/examples/mi-mctp.c +++ b/libnvme/examples/mi-mctp.c @@ -60,7 +60,7 @@ static int show_port(nvme_mi_ep_t ep, int portid) const char *typestr; int rc; - rc = nvme_mi_mi_read_mi_data_port(ep, portid, &port); + rc = libnvme_mi_mi_read_mi_data_port(ep, portid, &port); if (rc) return rc; @@ -89,7 +89,7 @@ int do_info(nvme_mi_ep_t ep) struct nvme_mi_read_nvm_ss_info ss_info; int i, rc; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); if (rc) { warn("can't perform Read MI Data operation"); return -1; @@ -104,7 +104,7 @@ int do_info(nvme_mi_ep_t ep) for (i = 0; i <= ss_info.nump; i++) show_port(ep, i); - rc = nvme_mi_mi_subsystem_health_status_poll(ep, true, &ss_health); + rc = libnvme_mi_mi_subsystem_health_status_poll(ep, true, &ss_health); if (rc) err(EXIT_FAILURE, "can't perform Health Status Poll operation"); @@ -123,7 +123,7 @@ static int show_ctrl(nvme_mi_ep_t ep, uint16_t ctrl_id) struct nvme_mi_read_ctrl_info ctrl; int rc; - rc = nvme_mi_mi_read_mi_data_ctrl(ep, ctrl_id, &ctrl); + rc = libnvme_mi_mi_read_mi_data_ctrl(ep, ctrl_id, &ctrl); if (rc) return rc; @@ -151,7 +151,7 @@ static int do_controllers(nvme_mi_ep_t ep) struct nvme_ctrl_list ctrl_list; int rc, i; - rc = nvme_mi_mi_read_mi_data_ctrl_list(ep, 0, &ctrl_list); + rc = libnvme_mi_mi_read_mi_data_ctrl_list(ep, 0, &ctrl_list); if (rc) { warnx("Can't perform Controller List operation"); return rc; @@ -201,7 +201,7 @@ int do_identify(nvme_mi_ep_t ep, int argc, char **argv) partial = argc > 2 && !strcmp(argv[2], "--partial"); - hdl = nvme_mi_init_transport_handle(ep, ctrl_id); + hdl = libnvme_mi_init_transport_handle(ep, ctrl_id); if (!hdl) { warn("can't create controller"); return -1; @@ -216,7 +216,7 @@ int do_identify(nvme_mi_ep_t ep, int argc, char **argv) if (partial) cmd.data_len = offsetof(struct nvme_id_ctrl, rab); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); if (rc) { warn("can't perform Admin Identify command"); return -1; @@ -283,7 +283,7 @@ int do_control_primitive(nvme_mi_ep_t ep, int argc, char **argv) return -1; } - rc = nvme_mi_control(ep, opcode, 0, &cpsr); /* cpsp reserved in example */ + rc = libnvme_mi_control(ep, opcode, 0, &cpsr); /* cpsp reserved in example */ if (rc) { warn("can't perform primitive control command"); return -1; @@ -391,7 +391,7 @@ int do_get_log_page(nvme_mi_ep_t ep, int argc, char **argv) lid = 0x1; } - hdl = nvme_mi_init_transport_handle(ep, ctrl_id); + hdl = libnvme_mi_init_transport_handle(ep, ctrl_id); if (!hdl) { warn("can't create controller"); return -1; @@ -478,7 +478,7 @@ int do_admin_raw(nvme_mi_ep_t ep, int argc, char **argv) memset(buf, 0, sizeof(buf)); resp = (void *)buf; - hdl = nvme_mi_init_transport_handle(ep, ctrl_id); + hdl = libnvme_mi_init_transport_handle(ep, ctrl_id); if (!hdl) { warn("can't create controller"); return -1; @@ -486,7 +486,7 @@ int do_admin_raw(nvme_mi_ep_t ep, int argc, char **argv) resp_data_len = sizeof(buf) - sizeof(*resp); - rc = nvme_mi_admin_xfer(hdl, &req, 0, resp, 0, &resp_data_len); + rc = libnvme_mi_admin_xfer(hdl, &req, 0, resp, 0, &resp_data_len); if (rc) { warn("nvme_admin_xfer failed: %d", rc); return -1; @@ -559,14 +559,14 @@ int do_security_info(nvme_mi_ep_t ep, int argc, char **argv) ctrl_id = tmp & 0xffff; - hdl = nvme_mi_init_transport_handle(ep, ctrl_id); + hdl = libnvme_mi_init_transport_handle(ep, ctrl_id); if (!hdl) { warn("can't create controller"); return -1; } nvme_init_security_receive(&cmd, 0, 0, 0, 0, 0, data, data_len); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); if (rc) { warnx("can't perform Security Receive command: rc %d", rc); return -1; @@ -635,7 +635,7 @@ int do_config_get(nvme_mi_ep_t ep, int argc, char **argv) else port = 0; - rc = nvme_mi_mi_config_get_smbus_freq(ep, port, &freq); + rc = libnvme_mi_mi_config_get_smbus_freq(ep, port, &freq); if (rc) { warn("can't query SMBus freq for port %d\n", port); } else { @@ -644,7 +644,7 @@ int do_config_get(nvme_mi_ep_t ep, int argc, char **argv) fstr ?: "unknown", freq); } - rc = nvme_mi_mi_config_get_mctp_mtu(ep, port, &mtu); + rc = libnvme_mi_mi_config_get_mctp_mtu(ep, port, &mtu); if (rc) warn("can't query MCTP MTU for port %d\n", port); else @@ -676,7 +676,7 @@ int do_config_set(nvme_mi_ep_t ep, int argc, char **argv) "Try 100k, 400k or 1M\n", val); return -1; } - rc = nvme_mi_mi_config_set_smbus_freq(ep, port, freq); + rc = libnvme_mi_mi_config_set_smbus_freq(ep, port, freq); } else if (!strcmp(name, "mtu")) { uint16_t mtu; @@ -688,7 +688,7 @@ int do_config_set(nvme_mi_ep_t ep, int argc, char **argv) fprintf(stderr, "MTU value too small\n"); return -1; } - rc = nvme_mi_mi_config_set_mctp_mtu(ep, port, mtu); + rc = libnvme_mi_mi_config_set_mctp_mtu(ep, port, mtu); } else { fprintf(stderr, "Invalid configuration '%s', " @@ -833,31 +833,31 @@ int main(int argc, char **argv) struct nvme_global_ctx *ctx; int i = 0; - ctx = nvme_mi_scan_mctp(); + ctx = libnvme_mi_scan_mctp(); if (!ctx) errx(EXIT_FAILURE, "can't scan D-Bus entries"); - nvme_mi_for_each_endpoint(ctx, ep) i++; + libnvme_mi_for_each_endpoint(ctx, ep) i++; printf("Found %d endpoints in D-Bus:\n", i); - nvme_mi_for_each_endpoint(ctx, ep) { - char *desc = nvme_mi_endpoint_desc(ep); + libnvme_mi_for_each_endpoint(ctx, ep) { + char *desc = libnvme_mi_endpoint_desc(ep); printf("%s\n", desc); rc = do_action_endpoint(action, ep, argc, argv); printf("---\n"); free(desc); } - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); } else { - ctx = nvme_create_global_ctx(stderr, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stderr, DEFAULT_LOGLEVEL); if (!ctx) err(EXIT_FAILURE, "can't create NVMe root"); - ep = nvme_mi_open_mctp(ctx, net, eid); + ep = libnvme_mi_open_mctp(ctx, net, eid); if (!ep) errx(EXIT_FAILURE, "can't open MCTP endpoint %d:%d", net, eid); rc = do_action_endpoint(action, ep, argc, argv); - nvme_mi_close(ep); - nvme_free_global_ctx(ctx); + libnvme_mi_close(ep); + libnvme_free_global_ctx(ctx); } return rc ? EXIT_FAILURE : EXIT_SUCCESS; diff --git a/libnvme/examples/telemetry-listen.c b/libnvme/examples/telemetry-listen.c index 931d95d99d..94f6561dbb 100644 --- a/libnvme/examples/telemetry-listen.c +++ b/libnvme/examples/telemetry-listen.c @@ -28,19 +28,19 @@ #include "nvme/tree.h" struct events { - nvme_ctrl_t c; + libnvme_ctrl_t c; int uevent_fd; }; -static int open_uevent(nvme_ctrl_t c) +static int open_uevent(libnvme_ctrl_t c) { char buf[0x1000]; - if (snprintf(buf, sizeof(buf), "%s/uevent", nvme_ctrl_get_sysfs_dir(c)) < 0) + if (snprintf(buf, sizeof(buf), "%s/uevent", libnvme_ctrl_get_sysfs_dir(c)) < 0) return -1; return open(buf, O_RDONLY); } -static void save_telemetry(nvme_ctrl_t c) +static void save_telemetry(libnvme_ctrl_t c) { char buf[0x1000]; size_t log_size; @@ -49,14 +49,14 @@ static void save_telemetry(nvme_ctrl_t c) time_t s; /* Clear the log (rae == false) at the end to see new telemetry events later */ - ret = nvme_get_ctrl_telemetry(nvme_ctrl_get_transport_handle(c), false, &log, + ret = nvme_get_ctrl_telemetry(libnvme_ctrl_get_transport_handle(c), false, &log, NVME_TELEMETRY_DA_3, &log_size); if (ret) return; s = time(NULL); ret = snprintf(buf, sizeof(buf), "/var/log/%s-telemetry-%llu", - nvme_ctrl_get_subsysnqn(c), (unsigned long long)s); + libnvme_ctrl_get_subsysnqn(c), (unsigned long long)s); if (ret < 0) { free(log); return; @@ -78,7 +78,7 @@ static void save_telemetry(nvme_ctrl_t c) free(log); } -static void check_telemetry(nvme_ctrl_t c, int ufd) +static void check_telemetry(libnvme_ctrl_t c, int ufd) { char buf[0x1000] = { 0 }; char *p, *ptr; @@ -100,7 +100,7 @@ static void check_telemetry(nvme_ctrl_t c, int ufd) lid = (aen >> 16) & 0xff; printf("%s: aen type:%x info:%x lid:%d\n", - nvme_ctrl_get_name(c), type, info, lid); + libnvme_ctrl_get_name(c), type, info, lid); if (type == NVME_AER_NOTICE && info == NVME_AER_NOTICE_TELEMETRY) save_telemetry(c); @@ -134,31 +134,31 @@ int main() int i = 0; struct nvme_global_ctx *ctx; - nvme_subsystem_t s; - nvme_ctrl_t c; - nvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; + libnvme_host_t h; - ctx = nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); if (!ctx) return 1; - if (nvme_scan_topology(ctx, NULL, NULL)) { - nvme_free_global_ctx(ctx); + if (libnvme_scan_topology(ctx, NULL, NULL)) { + libnvme_free_global_ctx(ctx); return EXIT_FAILURE; } - nvme_for_each_host(ctx, h) - nvme_for_each_subsystem(h, s) - nvme_subsystem_for_each_ctrl(s, c) + libnvme_for_each_host(ctx, h) + libnvme_for_each_subsystem(h, s) + libnvme_subsystem_for_each_ctrl(s, c) i++; e = calloc(i, sizeof(struct events)); FD_ZERO(&fds); i = 0; - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + libnvme_subsystem_for_each_ctrl(s, c) { int fd = open_uevent(c); if (fd < 0) @@ -172,7 +172,7 @@ int main() } wait_events(&fds, e, i); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); free(e); return EXIT_SUCCESS; diff --git a/libnvme/libnvme/nvme.i b/libnvme/libnvme/nvme.i index f9fd65dc7c..0c783c42e6 100644 --- a/libnvme/libnvme/nvme.i +++ b/libnvme/libnvme/nvme.i @@ -20,10 +20,10 @@ %allowexception; %rename(global_ctx) nvme_global_ctx; -%rename(host) nvme_host; -%rename(ctrl) nvme_ctrl; -%rename(subsystem) nvme_subsystem; -%rename(ns) nvme_ns; +%rename(host) libnvme_host; +%rename(ctrl) libnvme_ctrl; +%rename(subsystem) libnvme_subsystem; +%rename(ns) libnvme_ns; %{ #include @@ -39,13 +39,13 @@ Py_XDECREF(val); /* .. therefore decrement ref. count. */ } PyObject *read_hostnqn() { - char * val = nvme_read_hostnqn(); + char * val = libnvme_read_hostnqn(); PyObject * obj = PyUnicode_FromString(val); free(val); return obj; } PyObject *read_hostid() { - char * val = nvme_read_hostid(); + char * val = libnvme_read_hostid(); PyObject * obj = PyUnicode_FromString(val); free(val); return obj; @@ -54,11 +54,11 @@ PyObject *read_hostnqn(); PyObject *read_hostid(); -%exception nvme_ctrl::connect { +%exception libnvme_ctrl::connect { connect_err = 0; $action /* $action sets connect_err to non-zero value on failure */ if (connect_err) { - const char *errstr = nvme_errno_to_string(-connect_err); + const char *errstr = libnvme_errno_to_string(-connect_err); if (errstr) { SWIG_exception(SWIG_RuntimeError, errstr); } else { @@ -67,14 +67,14 @@ PyObject *read_hostid(); } } -%exception nvme_ctrl::disconnect { +%exception libnvme_ctrl::disconnect { connect_err = 0; errno = 0; $action /* $action sets connect_err to non-zero value on failure */ if (connect_err == 1) { SWIG_exception(SWIG_AttributeError, "No controller connection"); } else if (connect_err) { - const char *errstr = nvme_errno_to_string(-connect_err); + const char *errstr = libnvme_errno_to_string(-connect_err); if (errstr) { SWIG_exception(SWIG_RuntimeError, errstr); } else { @@ -83,13 +83,13 @@ PyObject *read_hostid(); } } -%exception nvme_ctrl::discover { +%exception libnvme_ctrl::discover { discover_err = 0; $action /* $action sets discover_err to non-zero value on failure */ if (discover_err == 1) { SWIG_exception(SWIG_AttributeError, "No controller connection"); } else if (discover_err) { - const char *errstr = nvme_errno_to_string(-discover_err); + const char *errstr = libnvme_errno_to_string(-discover_err); if (errstr) { SWIG_exception(SWIG_RuntimeError, errstr); } else { @@ -343,16 +343,16 @@ PyObject *read_hostid(); #include "fabrics.h" #define STR_OR_NONE(str) (!(str) ? "None" : str) -struct nvme_host * nvme_first_host(struct nvme_global_ctx * ctx); -struct nvme_host * nvme_next_host(struct nvme_global_ctx *ctx, struct nvme_host * h); -struct nvme_subsystem * nvme_first_subsystem(struct nvme_host * h); -struct nvme_subsystem * nvme_next_subsystem(struct nvme_host * h, struct nvme_subsystem * s); -struct nvme_ctrl * nvme_subsystem_first_ctrl(struct nvme_subsystem * s); -struct nvme_ctrl * nvme_subsystem_next_ctrl(struct nvme_subsystem * s, struct nvme_ctrl * c); -struct nvme_ns * nvme_subsystem_first_ns(struct nvme_subsystem * s); -struct nvme_ns * nvme_subsystem_next_ns(struct nvme_subsystem * s, struct nvme_ns * n); -struct nvme_ns * nvme_ctrl_first_ns(struct nvme_ctrl * c); -struct nvme_ns * nvme_ctrl_next_ns(struct nvme_ctrl * c, struct nvme_ns * n); +struct libnvme_host * libnvme_first_host(struct nvme_global_ctx * ctx); +struct libnvme_host * libnvme_next_host(struct nvme_global_ctx *ctx, struct libnvme_host * h); +struct libnvme_subsystem * libnvme_first_subsystem(struct libnvme_host * h); +struct libnvme_subsystem * libnvme_next_subsystem(struct libnvme_host * h, struct libnvme_subsystem * s); +struct libnvme_ctrl * libnvme_subsystem_first_ctrl(struct libnvme_subsystem * s); +struct libnvme_ctrl * libnvme_subsystem_next_ctrl(struct libnvme_subsystem * s, struct libnvme_ctrl * c); +struct libnvme_ns * libnvme_subsystem_first_ns(struct libnvme_subsystem * s); +struct libnvme_ns * libnvme_subsystem_next_ns(struct libnvme_subsystem * s, struct libnvme_ns * n); +struct libnvme_ns * libnvme_ctrl_first_ns(struct libnvme_ctrl * c); +struct libnvme_ns * libnvme_ctrl_next_ns(struct libnvme_ctrl * c, struct libnvme_ns * n); struct nvme_global_ctx { %immutable config_file; @@ -361,7 +361,7 @@ struct nvme_global_ctx { char *application; }; -struct nvme_host { +struct libnvme_host { %immutable hostnqn; %immutable hostid; %immutable hostsymname; @@ -373,7 +373,7 @@ struct nvme_host { } }; -struct nvme_subsystem { +struct libnvme_subsystem { %immutable sysfs_dir; %immutable subsysnqn; %immutable model; @@ -394,7 +394,7 @@ struct nvme_subsystem { } }; -struct nvme_ctrl { +struct libnvme_ctrl { %immutable name; %immutable subsystem; %immutable state; @@ -427,7 +427,7 @@ struct nvme_ctrl { * accessing the members directly. * * For example, SWIG will generate code like this: - * name = nvme_ctrl_name_get(ctrl) + * name = libnvme_ctrl_name_get(ctrl) * * instead of that: * name = ctrl->name @@ -462,17 +462,17 @@ struct nvme_ctrl { /** * We are remapping the following members of the C code's - * nvme_ctrl_t to different names in Python. Here's the mapping: + * libnvme_ctrl_t to different names in Python. Here's the mapping: * * C code Python (SWIG) * ===================== ===================== * ctrl->s ctrl->subsystem */ - struct nvme_subsystem *subsystem; // Maps to "s" in the C code + struct libnvme_subsystem *subsystem; // Maps to "s" in the C code } }; -struct nvme_ns { +struct libnvme_ns { %immutable nsid; %immutable eui64; %immutable nguid; @@ -487,17 +487,17 @@ struct nvme_ns { nvme_global_ctx(const char *config_file = NULL) { struct nvme_global_ctx *ctx; - ctx = nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); if (!ctx) return NULL; - nvme_scan_topology(ctx, NULL, NULL); - nvme_read_config(ctx, config_file); + libnvme_scan_topology(ctx, NULL, NULL); + libnvme_read_config(ctx, config_file); return ctx; } ~nvme_global_ctx() { - nvme_free_global_ctx($self); + libnvme_free_global_ctx($self); } struct nvme_global_ctx* __enter__() { return $self; @@ -515,21 +515,21 @@ struct nvme_ns { else if (!strcmp(level, "crit")) log_level = LOG_CRIT; else if (!strcmp(level, "alert")) log_level = LOG_ALERT; else if (!strcmp(level, "emerg")) log_level = LOG_EMERG; - nvme_set_logging_level($self, log_level, false, false); + libnvme_set_logging_level($self, log_level, false, false); } %pythoncode %{ def hosts(self): """Iterator over all host objects""" - h = nvme_first_host(self) + h = libnvme_first_host(self) while h: yield h - h = nvme_next_host(self, h) + h = libnvme_next_host(self, h) %} void refresh_topology() { - nvme_refresh_topology($self); + libnvme_refresh_topology($self); } void dump_config() { - nvme_dump_config($self, STDERR_FILENO); + libnvme_dump_config($self, STDERR_FILENO); } } @@ -543,39 +543,39 @@ struct nvme_ns { @return: None" %enddef -%pythonappend nvme_host::nvme_host(struct nvme_global_ctx *ctx, +%pythonappend libnvme_host::libnvme_host(struct nvme_global_ctx *ctx, const char *hostnqn, const char *hostid, const char *hostkey, const char *hostsymname) { self.__parent = ctx # Keep a reference to parent to ensure garbage collection happens in the right order} -%extend nvme_host { - nvme_host(struct nvme_global_ctx *ctx, +%extend libnvme_host { + libnvme_host(struct nvme_global_ctx *ctx, const char *hostnqn = NULL, const char *hostid = NULL, const char *hostkey = NULL, const char *hostsymname = NULL) { - nvme_host_t h; - if (nvme_get_host(ctx, hostnqn, hostid, &h)) + libnvme_host_t h; + if (libnvme_get_host(ctx, hostnqn, hostid, &h)) return NULL; if (hostsymname) - nvme_host_set_hostsymname(h, hostsymname); + libnvme_host_set_hostsymname(h, hostsymname); if (hostkey) - nvme_host_set_dhchap_host_key(h, hostkey); + libnvme_host_set_dhchap_host_key(h, hostkey); return h; } - ~nvme_host() { - nvme_free_host($self); + ~libnvme_host() { + libnvme_free_host($self); } - struct nvme_host* __enter__() { + struct libnvme_host* __enter__() { return $self; } - struct nvme_host* __exit__(PyObject *type, PyObject *value, PyObject *traceback) { + struct libnvme_host* __exit__(PyObject *type, PyObject *value, PyObject *traceback) { return $self; } %feature("autodoc", SET_SYMNAME_DOCSTRING) set_symname; void set_symname(const char *hostsymname) { - nvme_host_set_hostsymname($self, hostsymname); + libnvme_host_set_hostsymname($self, hostsymname); } PyObject* __str__() { @@ -584,46 +584,46 @@ struct nvme_ns { %pythoncode %{ def subsystems(self): """Iterator over all subsystem objects""" - s = nvme_first_subsystem(self) + s = libnvme_first_subsystem(self) while s: yield s - s = nvme_next_subsystem(self, s) + s = libnvme_next_subsystem(self, s) %} } %{ - const char *nvme_host_dhchap_host_key_get(struct nvme_host *h) { - return nvme_host_get_dhchap_host_key(h); + const char *libnvme_host_dhchap_host_key_get(struct libnvme_host *h) { + return libnvme_host_get_dhchap_host_key(h); } - void nvme_host_dhchap_host_key_set(struct nvme_host *h, char *key) { - nvme_host_set_dhchap_host_key(h, key); + void libnvme_host_dhchap_host_key_set(struct libnvme_host *h, char *key) { + libnvme_host_set_dhchap_host_key(h, key); } %}; -%pythonappend nvme_subsystem::nvme_subsystem(struct nvme_global_ctx *ctx, - struct nvme_host *host, +%pythonappend libnvme_subsystem::libnvme_subsystem(struct nvme_global_ctx *ctx, + struct libnvme_host *host, const char *subsysnqn, const char *name) { self.__parent = host # Keep a reference to parent to ensure garbage collection happens in the right order} -%extend nvme_subsystem { - nvme_subsystem(struct nvme_global_ctx *ctx, - struct nvme_host *host, +%extend libnvme_subsystem { + libnvme_subsystem(struct nvme_global_ctx *ctx, + struct libnvme_host *host, const char *subsysnqn, const char *name = NULL) { - struct nvme_subsystem *s; + struct libnvme_subsystem *s; - if (nvme_get_subsystem(ctx, host, name, subsysnqn, &s)) + if (libnvme_get_subsystem(ctx, host, name, subsysnqn, &s)) return NULL; return s; } - ~nvme_subsystem() { - nvme_free_subsystem($self); + ~libnvme_subsystem() { + libnvme_free_subsystem($self); } - struct nvme_subsystem* __enter__() { + struct libnvme_subsystem* __enter__() { return $self; } - struct nvme_subsystem* __exit__(PyObject *type, PyObject *value, PyObject *traceback) { + struct libnvme_subsystem* __exit__(PyObject *type, PyObject *value, PyObject *traceback) { return $self; } PyObject *__str__() { @@ -632,74 +632,74 @@ struct nvme_ns { %pythoncode %{ def controllers(self): """Iterator over all controller objects""" - c = nvme_subsystem_first_ctrl(self) + c = libnvme_subsystem_first_ctrl(self) while c: yield c - c = nvme_subsystem_next_ctrl(self, c) + c = libnvme_subsystem_next_ctrl(self, c) %} %pythoncode %{ def namespaces(self): """Iterator over all namespace objects""" - ns = nvme_subsystem_first_ns(self) + ns = libnvme_subsystem_first_ns(self) while ns: yield ns - ns = nvme_subsystem_next_ns(self, ns) + ns = libnvme_subsystem_next_ns(self, ns) %} %immutable name; const char *name; %immutable host; - struct nvme_host *host; + struct libnvme_host *host; } %{ - const char *nvme_subsystem_name_get(struct nvme_subsystem *s) { - return nvme_subsystem_get_name(s); + const char *libnvme_subsystem_name_get(struct libnvme_subsystem *s) { + return libnvme_subsystem_get_name(s); } - struct nvme_host *nvme_subsystem_host_get(struct nvme_subsystem *s) { - return nvme_subsystem_get_host(s); + struct libnvme_host *libnvme_subsystem_host_get(struct libnvme_subsystem *s) { + return libnvme_subsystem_get_host(s); } - const char *nvme_subsystem_sysfs_dir_get(struct nvme_subsystem *s) { - return nvme_subsystem_get_sysfs_dir(s); + const char *libnvme_subsystem_sysfs_dir_get(struct libnvme_subsystem *s) { + return libnvme_subsystem_get_sysfs_dir(s); } - const char *nvme_subsystem_iopolicy_get(struct nvme_subsystem *s) { - return nvme_subsystem_get_iopolicy(s); + const char *libnvme_subsystem_iopolicy_get(struct libnvme_subsystem *s) { + return libnvme_subsystem_get_iopolicy(s); } - const char *nvme_subsystem_application_get(struct nvme_subsystem *s) { - return nvme_subsystem_get_application(s); + const char *libnvme_subsystem_application_get(struct libnvme_subsystem *s) { + return libnvme_subsystem_get_application(s); } - void nvme_subsystem_application_set(struct nvme_subsystem *s, const char *a) { - nvme_subsystem_set_application(s, a); + void libnvme_subsystem_application_set(struct libnvme_subsystem *s, const char *a) { + libnvme_subsystem_set_application(s, a); } %}; -%pythonappend nvme_ctrl::connect(struct nvme_host *h, +%pythonappend libnvme_ctrl::connect(struct libnvme_host *h, struct nvme_fabrics_config *cfg) { self.__host = h # Keep a reference to parent to ensure ctrl obj gets GCed before host} -%pythonappend nvme_ctrl::init(struct nvme_host *h, int instance) { +%pythonappend libnvme_ctrl::init(struct libnvme_host *h, int instance) { self.__host = h # Keep a reference to parent to ensure ctrl obj gets GCed before host} -%extend nvme_ctrl { - nvme_ctrl(struct nvme_global_ctx *ctx, +%extend libnvme_ctrl { + libnvme_ctrl(struct nvme_global_ctx *ctx, const char *subsysnqn, const char *transport, const char *traddr = NULL, const char *host_traddr = NULL, const char *host_iface = NULL, const char *trsvcid = NULL) { - struct nvme_ctrl *c; - if (nvme_create_ctrl(ctx, subsysnqn, transport, traddr, + struct libnvme_ctrl *c; + if (libnvme_create_ctrl(ctx, subsysnqn, transport, traddr, host_traddr, host_iface, trsvcid, &c)) return NULL; return c; } - ~nvme_ctrl() { - nvme_free_ctrl($self); + ~libnvme_ctrl() { + libnvme_free_ctrl($self); } - struct nvme_ctrl* __enter__() { + struct libnvme_ctrl* __enter__() { return $self; } - struct nvme_ctrl* __exit__(PyObject *type, PyObject *value, PyObject *traceback) { - if (nvme_ctrl_get_name($self)) - nvme_disconnect_ctrl($self); + struct libnvme_ctrl* __exit__(PyObject *type, PyObject *value, PyObject *traceback) { + if (libnvme_ctrl_get_name($self)) + libnvme_disconnect_ctrl($self); return $self; } @@ -711,16 +711,16 @@ struct nvme_ns { return _nvme.ctrl_discovery_ctrl_set(self, discovery) %} - bool init(struct nvme_host *h, int instance) { - return nvme_init_ctrl(h, $self, instance) == 0; + bool init(struct libnvme_host *h, int instance) { + return libnvme_init_ctrl(h, $self, instance) == 0; } - void connect(struct nvme_host *h, + void connect(struct libnvme_host *h, struct nvme_fabrics_config *cfg = NULL) { int ret; const char *dev; - dev = nvme_ctrl_get_name($self); + dev = libnvme_ctrl_get_name($self); if (dev && !cfg->duplicate_connect) { connect_err = -ENVME_CONNECT_ALREADY; return; @@ -736,7 +736,7 @@ struct nvme_ns { } } bool connected() { - return nvme_ctrl_get_name($self) != NULL; + return libnvme_ctrl_get_name($self) != NULL; } %pythoncode %{ def persistent_set(self, persistent: bool): @@ -746,19 +746,19 @@ struct nvme_ns { return _nvme.ctrl_persistent_set(self, persistent) %} void rescan() { - nvme_rescan_ctrl($self); + libnvme_rescan_ctrl($self); } void disconnect() { int ret; const char *dev; - dev = nvme_ctrl_get_name($self); + dev = libnvme_ctrl_get_name($self); if (!dev) { connect_err = 1; return; } Py_BEGIN_ALLOW_THREADS /* Release Python GIL */ - ret = nvme_disconnect_ctrl($self); + ret = libnvme_disconnect_ctrl($self); Py_END_ALLOW_THREADS /* Reacquire Python GIL */ if (ret < 0) connect_err = 2; @@ -781,8 +781,8 @@ struct nvme_ns { if (status != NVME_SC_SUCCESS) { /* On error, return an error message */ return (status < 0) ? - PyUnicode_FromFormat("Status:0x%04x - %s", status, nvme_status_to_string(status, false)) : - PyUnicode_FromFormat("Result:0x%04x, Status:0x%04x - %s", result, status, nvme_status_to_string(status, false)); + PyUnicode_FromFormat("Status:0x%04x - %s", status, libnvme_status_to_string(status, false)) : + PyUnicode_FromFormat("Result:0x%04x, Status:0x%04x - %s", result, status, libnvme_status_to_string(status, false)); } /* On success, return None */ @@ -802,7 +802,7 @@ struct nvme_ns { .lsp = lsp, }; - dev = nvme_ctrl_get_name($self); + dev = libnvme_ctrl_get_name($self); if (!dev) { discover_err = 1; return NULL; @@ -824,7 +824,7 @@ struct nvme_ns { Py_BEGIN_ALLOW_THREADS /* Release Python GIL */ nvme_init_get_log_supported_log_pages(&cmd, NVME_CSI_NVM, &log); - ret = nvme_get_log(nvme_ctrl_get_transport_handle($self), &cmd, rae, NVME_LOG_PAGE_PDU_SIZE); + ret = nvme_get_log(libnvme_ctrl_get_transport_handle($self), &cmd, rae, NVME_LOG_PAGE_PDU_SIZE); Py_END_ALLOW_THREADS /* Reacquire Python GIL */ if (ret) { @@ -842,17 +842,17 @@ struct nvme_ns { PyObject* __str__() { return $self->address ? - PyUnicode_FromFormat("nvme_ctrl(transport=%s,%s)", STR_OR_NONE($self->transport), STR_OR_NONE($self->address)) : - PyUnicode_FromFormat("nvme_ctrl(transport=%s)", STR_OR_NONE($self->transport)); + PyUnicode_FromFormat("libnvme_ctrl(transport=%s,%s)", STR_OR_NONE($self->transport), STR_OR_NONE($self->address)) : + PyUnicode_FromFormat("libnvme_ctrl(transport=%s)", STR_OR_NONE($self->transport)); } %pythoncode %{ def namespaces(self): """Iterator over all namespace objects""" - ns = nvme_ctrl_first_ns(self) + ns = libnvme_ctrl_first_ns(self) while ns: yield ns - ns = nvme_ctrl_next_ns(self, ns) + ns = libnvme_ctrl_next_ns(self, ns) %} } @@ -870,142 +870,142 @@ struct nvme_ns { * */ - const char *nvme_ctrl_name_get(struct nvme_ctrl *c) { - return nvme_ctrl_get_name(c); + const char *libnvme_ctrl_name_get(struct libnvme_ctrl *c) { + return libnvme_ctrl_get_name(c); } - struct nvme_subsystem *nvme_ctrl_subsystem_get(struct nvme_ctrl *c) { - return nvme_ctrl_get_subsystem(c); + struct libnvme_subsystem *libnvme_ctrl_subsystem_get(struct libnvme_ctrl *c) { + return libnvme_ctrl_get_subsystem(c); } - const char *nvme_ctrl_state_get(struct nvme_ctrl *c) { - return nvme_ctrl_get_state(c); + const char *libnvme_ctrl_state_get(struct libnvme_ctrl *c) { + return libnvme_ctrl_get_state(c); } - const char *nvme_ctrl_dhchap_ctrl_key_get(struct nvme_ctrl *c) { - return nvme_ctrl_get_dhchap_ctrl_key(c); + const char *libnvme_ctrl_dhchap_ctrl_key_get(struct libnvme_ctrl *c) { + return libnvme_ctrl_get_dhchap_ctrl_key(c); } - void nvme_ctrl_dhchap_ctrl_key_set(struct nvme_ctrl *c, const char *key) { - nvme_ctrl_set_dhchap_ctrl_key(c, key); + void libnvme_ctrl_dhchap_ctrl_key_set(struct libnvme_ctrl *c, const char *key) { + libnvme_ctrl_set_dhchap_ctrl_key(c, key); } - const char *nvme_ctrl_dhchap_host_key_get(struct nvme_ctrl *c) { - return nvme_ctrl_get_dhchap_host_key(c); + const char *libnvme_ctrl_dhchap_host_key_get(struct libnvme_ctrl *c) { + return libnvme_ctrl_get_dhchap_host_key(c); } - void nvme_ctrl_dhchap_host_key_set(struct nvme_ctrl *c, const char *key) { - nvme_ctrl_set_dhchap_host_key(c, key); + void libnvme_ctrl_dhchap_host_key_set(struct libnvme_ctrl *c, const char *key) { + libnvme_ctrl_set_dhchap_host_key(c, key); } - const char *nvme_ctrl_cntlid_get(nvme_ctrl_t c) { - return nvme_ctrl_get_cntlid(c); + const char *libnvme_ctrl_cntlid_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_cntlid(c); } - bool nvme_ctrl_persistent_get(struct nvme_ctrl *c) { - return nvme_ctrl_get_persistent(c); + bool libnvme_ctrl_persistent_get(struct libnvme_ctrl *c) { + return libnvme_ctrl_get_persistent(c); } - void nvme_ctrl_persistent_set(struct nvme_ctrl *c, bool persistent) { - nvme_ctrl_set_persistent(c, persistent); + void libnvme_ctrl_persistent_set(struct libnvme_ctrl *c, bool persistent) { + libnvme_ctrl_set_persistent(c, persistent); } - const char *nvme_ctrl_phy_slot_get(nvme_ctrl_t c) { - return nvme_ctrl_get_phy_slot(c); + const char *libnvme_ctrl_phy_slot_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_phy_slot(c); } - const char *nvme_ctrl_trsvcid_get(nvme_ctrl_t c) { - return nvme_ctrl_get_trsvcid(c); + const char *libnvme_ctrl_trsvcid_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_trsvcid(c); } - const char *nvme_ctrl_traddr_get(nvme_ctrl_t c) { - return nvme_ctrl_get_traddr(c); + const char *libnvme_ctrl_traddr_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_traddr(c); } - const char *nvme_ctrl_subsysnqn_get(nvme_ctrl_t c) { - return nvme_ctrl_get_subsysnqn(c); + const char *libnvme_ctrl_subsysnqn_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_subsysnqn(c); } - const char *nvme_ctrl_transport_get(nvme_ctrl_t c) { - return nvme_ctrl_get_transport(c); + const char *libnvme_ctrl_transport_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_transport(c); } - const char *nvme_ctrl_sqsize_get(nvme_ctrl_t c) { - return nvme_ctrl_get_sqsize(c); + const char *libnvme_ctrl_sqsize_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_sqsize(c); } - const char *nvme_ctrl_serial_get(nvme_ctrl_t c) { - return nvme_ctrl_get_serial(c); + const char *libnvme_ctrl_serial_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_serial(c); } - const char *nvme_ctrl_queue_count_get(nvme_ctrl_t c) { - return nvme_ctrl_get_queue_count(c); + const char *libnvme_ctrl_queue_count_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_queue_count(c); } - const char *nvme_ctrl_numa_node_get(nvme_ctrl_t c) { - return nvme_ctrl_get_numa_node(c); + const char *libnvme_ctrl_numa_node_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_numa_node(c); } - const char *nvme_ctrl_model_get(nvme_ctrl_t c) { - return nvme_ctrl_get_model(c); + const char *libnvme_ctrl_model_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_model(c); } - const char *nvme_ctrl_firmware_get(nvme_ctrl_t c) { - return nvme_ctrl_get_firmware(c); + const char *libnvme_ctrl_firmware_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_firmware(c); } - const char *nvme_ctrl_address_get(nvme_ctrl_t c) { - return nvme_ctrl_get_traddr(c); + const char *libnvme_ctrl_address_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_traddr(c); } - const char *nvme_ctrl_sysfs_dir_get(nvme_ctrl_t c) { - return nvme_ctrl_get_sysfs_dir(c); + const char *libnvme_ctrl_sysfs_dir_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_sysfs_dir(c); } - bool nvme_ctrl_discovery_ctrl_get(struct nvme_ctrl *c) { - return nvme_ctrl_get_discovery_ctrl(c); + bool libnvme_ctrl_discovery_ctrl_get(struct libnvme_ctrl *c) { + return libnvme_ctrl_get_discovery_ctrl(c); } - void nvme_ctrl_discovery_ctrl_set(struct nvme_ctrl *c, bool discovery) { - nvme_ctrl_set_discovery_ctrl(c, discovery); + void libnvme_ctrl_discovery_ctrl_set(struct libnvme_ctrl *c, bool discovery) { + libnvme_ctrl_set_discovery_ctrl(c, discovery); } - bool nvme_ctrl_unique_discovery_ctrl_get(nvme_ctrl_t c) { - return nvme_ctrl_get_unique_discovery_ctrl(c); + bool libnvme_ctrl_unique_discovery_ctrl_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_unique_discovery_ctrl(c); } - void nvme_ctrl_unique_discovery_ctrl_set(nvme_ctrl_t c, bool unique) { - nvme_ctrl_set_unique_discovery_ctrl(c, unique); + void libnvme_ctrl_unique_discovery_ctrl_set(libnvme_ctrl_t c, bool unique) { + libnvme_ctrl_set_unique_discovery_ctrl(c, unique); } - const char *nvme_ctrl_keyring_get(nvme_ctrl_t c) { - return nvme_ctrl_get_keyring(c); + const char *libnvme_ctrl_keyring_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_keyring(c); } - void nvme_ctrl_keyring_set(nvme_ctrl_t c, const char *keyring) { - nvme_ctrl_set_keyring(c, keyring); + void libnvme_ctrl_keyring_set(libnvme_ctrl_t c, const char *keyring) { + libnvme_ctrl_set_keyring(c, keyring); } - const char *nvme_ctrl_tls_key_identity_get(nvme_ctrl_t c) { - return nvme_ctrl_get_tls_key_identity(c); + const char *libnvme_ctrl_tls_key_identity_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_tls_key_identity(c); } - void nvme_ctrl_tls_key_identity_set(nvme_ctrl_t c, const char *identity) { - nvme_ctrl_set_tls_key_identity(c, identity); + void libnvme_ctrl_tls_key_identity_set(libnvme_ctrl_t c, const char *identity) { + libnvme_ctrl_set_tls_key_identity(c, identity); } - const char *nvme_ctrl_tls_key_get(nvme_ctrl_t c) { - return nvme_ctrl_get_tls_key(c); + const char *libnvme_ctrl_tls_key_get(libnvme_ctrl_t c) { + return libnvme_ctrl_get_tls_key(c); } - void nvme_ctrl_tls_key_set(nvme_ctrl_t c, const char *key) { - nvme_ctrl_set_tls_key(c, key); + void libnvme_ctrl_tls_key_set(libnvme_ctrl_t c, const char *key) { + libnvme_ctrl_set_tls_key(c, key); } %} -%pythonappend nvme_ns::nvme_ns(struct nvme_subsystem *s, +%pythonappend libnvme_ns::libnvme_ns(struct libnvme_subsystem *s, unsigned int nsid) { self.__parent = s # Keep a reference to parent to ensure garbage collection happens in the right order} -%extend nvme_ns { - nvme_ns(struct nvme_subsystem *s, +%extend libnvme_ns { + libnvme_ns(struct libnvme_subsystem *s, unsigned int nsid) { - return nvme_subsystem_lookup_namespace(s, nsid); + return libnvme_subsystem_lookup_namespace(s, nsid); } - ~nvme_ns() { - nvme_free_ns($self); + ~libnvme_ns() { + libnvme_free_ns($self); } - struct nvme_ns* __enter__() { + struct libnvme_ns* __enter__() { return $self; } - struct nvme_ns* __exit__(PyObject *type, PyObject *value, PyObject *traceback) { + struct libnvme_ns* __exit__(PyObject *type, PyObject *value, PyObject *traceback) { return $self; } PyObject *__str__() { @@ -1016,8 +1016,8 @@ struct nvme_ns { } %{ - const char *nvme_ns_name_get(struct nvme_ns *n) { - return nvme_ns_get_name(n); + const char *libnvme_ns_name_get(struct libnvme_ns *n) { + return libnvme_ns_get_name(n); } %}; @@ -1065,7 +1065,7 @@ struct nvme_ns { { char uuid_str[NVME_UUID_LEN_STRING]; PyDict_SetItemStringDecRef(output, "nid_type", PyUnicode_FromString("uuid")); - nvme_uuid_to_string(ss->nid, uuid_str); + libnvme_uuid_to_string(ss->nid, uuid_str); nid = PyUnicode_FromString(uuid_str); break; } @@ -1164,7 +1164,7 @@ struct nvme_ns { PyDict_SetItemStringDecRef(host, "nqn", PyUnicode_FromString(nbft->host.nqn)); if (nbft->host.id) { char uuid_str[NVME_UUID_LEN_STRING]; - nvme_uuid_to_string((unsigned char *)nbft->host.id, uuid_str); + libnvme_uuid_to_string((unsigned char *)nbft->host.id, uuid_str); PyDict_SetItemStringDecRef(host, "id", PyUnicode_FromString(uuid_str)); } @@ -1244,13 +1244,13 @@ struct nvme_ns { PyObject *output; int ret; - ret = nvme_read_nbft(ctx, &nbft, filename); + ret = libnvme_read_nbft(ctx, &nbft, filename); if (ret) { Py_RETURN_NONE; } output = nbft_to_pydict(nbft); - nvme_free_nbft(ctx, nbft); + libnvme_free_nbft(ctx, nbft); return output; } %}; diff --git a/libnvme/src/accessors.ld b/libnvme/src/accessors.ld index 3cd26f8f7d..58aa702356 100644 --- a/libnvme/src/accessors.ld +++ b/libnvme/src/accessors.ld @@ -10,145 +10,145 @@ LIBNVME_ACCESSORS_3 { global: - nvme_path_get_name; - nvme_path_set_name; - nvme_path_get_sysfs_dir; - nvme_path_set_sysfs_dir; - nvme_path_get_ana_state; - nvme_path_set_ana_state; - nvme_path_get_numa_nodes; - nvme_path_set_numa_nodes; - nvme_path_get_grpid; - nvme_path_set_grpid; - nvme_ns_get_nsid; - nvme_ns_set_nsid; - nvme_ns_get_name; - nvme_ns_set_name; - nvme_ns_get_sysfs_dir; - nvme_ns_set_sysfs_dir; - nvme_ns_get_lba_shift; - nvme_ns_set_lba_shift; - nvme_ns_get_lba_size; - nvme_ns_set_lba_size; - nvme_ns_get_meta_size; - nvme_ns_set_meta_size; - nvme_ns_get_lba_count; - nvme_ns_set_lba_count; - nvme_ns_get_lba_util; - nvme_ns_set_lba_util; - nvme_ctrl_get_name; - nvme_ctrl_get_sysfs_dir; - nvme_ctrl_get_firmware; - nvme_ctrl_get_model; - nvme_ctrl_get_numa_node; - nvme_ctrl_get_queue_count; - nvme_ctrl_get_serial; - nvme_ctrl_get_sqsize; - nvme_ctrl_get_transport; - nvme_ctrl_get_subsysnqn; - nvme_ctrl_get_traddr; - nvme_ctrl_get_trsvcid; - nvme_ctrl_get_dhchap_host_key; - nvme_ctrl_set_dhchap_host_key; - nvme_ctrl_get_dhchap_ctrl_key; - nvme_ctrl_set_dhchap_ctrl_key; - nvme_ctrl_get_keyring; - nvme_ctrl_set_keyring; - nvme_ctrl_get_tls_key_identity; - nvme_ctrl_set_tls_key_identity; - nvme_ctrl_get_tls_key; - nvme_ctrl_set_tls_key; - nvme_ctrl_get_cntrltype; - nvme_ctrl_get_cntlid; - nvme_ctrl_get_dctype; - nvme_ctrl_get_host_traddr; - nvme_ctrl_get_host_iface; - nvme_ctrl_get_discovery_ctrl; - nvme_ctrl_set_discovery_ctrl; - nvme_ctrl_get_unique_discovery_ctrl; - nvme_ctrl_set_unique_discovery_ctrl; - nvme_ctrl_get_discovered; - nvme_ctrl_set_discovered; - nvme_ctrl_get_persistent; - nvme_ctrl_set_persistent; - nvme_ctrl_get_phy_slot; - nvme_subsystem_get_name; - nvme_subsystem_get_sysfs_dir; - nvme_subsystem_get_subsysnqn; - nvme_subsystem_get_model; - nvme_subsystem_get_serial; - nvme_subsystem_get_firmware; - nvme_subsystem_get_subsystype; - nvme_subsystem_get_application; - nvme_subsystem_set_application; - nvme_subsystem_get_iopolicy; - nvme_subsystem_set_iopolicy; - nvme_host_get_hostnqn; - nvme_host_get_hostid; - nvme_host_get_dhchap_host_key; - nvme_host_set_dhchap_host_key; - nvme_host_get_hostsymname; - nvme_host_set_hostsymname; - nvme_host_get_pdc_enabled_valid; - nvme_host_set_pdc_enabled_valid; - nvme_fabric_options_get_cntlid; - nvme_fabric_options_set_cntlid; - nvme_fabric_options_get_concat; - nvme_fabric_options_set_concat; - nvme_fabric_options_get_ctrl_loss_tmo; - nvme_fabric_options_set_ctrl_loss_tmo; - nvme_fabric_options_get_data_digest; - nvme_fabric_options_set_data_digest; - nvme_fabric_options_get_dhchap_ctrl_secret; - nvme_fabric_options_set_dhchap_ctrl_secret; - nvme_fabric_options_get_dhchap_secret; - nvme_fabric_options_set_dhchap_secret; - nvme_fabric_options_get_disable_sqflow; - nvme_fabric_options_set_disable_sqflow; - nvme_fabric_options_get_discovery; - nvme_fabric_options_set_discovery; - nvme_fabric_options_get_duplicate_connect; - nvme_fabric_options_set_duplicate_connect; - nvme_fabric_options_get_fast_io_fail_tmo; - nvme_fabric_options_set_fast_io_fail_tmo; - nvme_fabric_options_get_hdr_digest; - nvme_fabric_options_set_hdr_digest; - nvme_fabric_options_get_host_iface; - nvme_fabric_options_set_host_iface; - nvme_fabric_options_get_host_traddr; - nvme_fabric_options_set_host_traddr; - nvme_fabric_options_get_hostid; - nvme_fabric_options_set_hostid; - nvme_fabric_options_get_hostnqn; - nvme_fabric_options_set_hostnqn; - nvme_fabric_options_get_instance; - nvme_fabric_options_set_instance; - nvme_fabric_options_get_keep_alive_tmo; - nvme_fabric_options_set_keep_alive_tmo; - nvme_fabric_options_get_keyring; - nvme_fabric_options_set_keyring; - nvme_fabric_options_get_nqn; - nvme_fabric_options_set_nqn; - nvme_fabric_options_get_nr_io_queues; - nvme_fabric_options_set_nr_io_queues; - nvme_fabric_options_get_nr_poll_queues; - nvme_fabric_options_set_nr_poll_queues; - nvme_fabric_options_get_nr_write_queues; - nvme_fabric_options_set_nr_write_queues; - nvme_fabric_options_get_queue_size; - nvme_fabric_options_set_queue_size; - nvme_fabric_options_get_reconnect_delay; - nvme_fabric_options_set_reconnect_delay; - nvme_fabric_options_get_tls; - nvme_fabric_options_set_tls; - nvme_fabric_options_get_tls_key; - nvme_fabric_options_set_tls_key; - nvme_fabric_options_get_tos; - nvme_fabric_options_set_tos; - nvme_fabric_options_get_traddr; - nvme_fabric_options_set_traddr; - nvme_fabric_options_get_transport; - nvme_fabric_options_set_transport; - nvme_fabric_options_get_trsvcid; - nvme_fabric_options_set_trsvcid; + libnvme_path_get_name; + libnvme_path_set_name; + libnvme_path_get_sysfs_dir; + libnvme_path_set_sysfs_dir; + libnvme_path_get_ana_state; + libnvme_path_set_ana_state; + libnvme_path_get_numa_nodes; + libnvme_path_set_numa_nodes; + libnvme_path_get_grpid; + libnvme_path_set_grpid; + libnvme_ns_get_nsid; + libnvme_ns_set_nsid; + libnvme_ns_get_name; + libnvme_ns_set_name; + libnvme_ns_get_sysfs_dir; + libnvme_ns_set_sysfs_dir; + libnvme_ns_get_lba_shift; + libnvme_ns_set_lba_shift; + libnvme_ns_get_lba_size; + libnvme_ns_set_lba_size; + libnvme_ns_get_meta_size; + libnvme_ns_set_meta_size; + libnvme_ns_get_lba_count; + libnvme_ns_set_lba_count; + libnvme_ns_get_lba_util; + libnvme_ns_set_lba_util; + libnvme_ctrl_get_name; + libnvme_ctrl_get_sysfs_dir; + libnvme_ctrl_get_firmware; + libnvme_ctrl_get_model; + libnvme_ctrl_get_numa_node; + libnvme_ctrl_get_queue_count; + libnvme_ctrl_get_serial; + libnvme_ctrl_get_sqsize; + libnvme_ctrl_get_transport; + libnvme_ctrl_get_subsysnqn; + libnvme_ctrl_get_traddr; + libnvme_ctrl_get_trsvcid; + libnvme_ctrl_get_dhchap_host_key; + libnvme_ctrl_set_dhchap_host_key; + libnvme_ctrl_get_dhchap_ctrl_key; + libnvme_ctrl_set_dhchap_ctrl_key; + libnvme_ctrl_get_keyring; + libnvme_ctrl_set_keyring; + libnvme_ctrl_get_tls_key_identity; + libnvme_ctrl_set_tls_key_identity; + libnvme_ctrl_get_tls_key; + libnvme_ctrl_set_tls_key; + libnvme_ctrl_get_cntrltype; + libnvme_ctrl_get_cntlid; + libnvme_ctrl_get_dctype; + libnvme_ctrl_get_host_traddr; + libnvme_ctrl_get_host_iface; + libnvme_ctrl_get_discovery_ctrl; + libnvme_ctrl_set_discovery_ctrl; + libnvme_ctrl_get_unique_discovery_ctrl; + libnvme_ctrl_set_unique_discovery_ctrl; + libnvme_ctrl_get_discovered; + libnvme_ctrl_set_discovered; + libnvme_ctrl_get_persistent; + libnvme_ctrl_set_persistent; + libnvme_ctrl_get_phy_slot; + libnvme_subsystem_get_name; + libnvme_subsystem_get_sysfs_dir; + libnvme_subsystem_get_subsysnqn; + libnvme_subsystem_get_model; + libnvme_subsystem_get_serial; + libnvme_subsystem_get_firmware; + libnvme_subsystem_get_subsystype; + libnvme_subsystem_get_application; + libnvme_subsystem_set_application; + libnvme_subsystem_get_iopolicy; + libnvme_subsystem_set_iopolicy; + libnvme_host_get_hostnqn; + libnvme_host_get_hostid; + libnvme_host_get_dhchap_host_key; + libnvme_host_set_dhchap_host_key; + libnvme_host_get_hostsymname; + libnvme_host_set_hostsymname; + libnvme_host_get_pdc_enabled_valid; + libnvme_host_set_pdc_enabled_valid; + libnvme_fabric_options_get_cntlid; + libnvme_fabric_options_set_cntlid; + libnvme_fabric_options_get_concat; + libnvme_fabric_options_set_concat; + libnvme_fabric_options_get_ctrl_loss_tmo; + libnvme_fabric_options_set_ctrl_loss_tmo; + libnvme_fabric_options_get_data_digest; + libnvme_fabric_options_set_data_digest; + libnvme_fabric_options_get_dhchap_ctrl_secret; + libnvme_fabric_options_set_dhchap_ctrl_secret; + libnvme_fabric_options_get_dhchap_secret; + libnvme_fabric_options_set_dhchap_secret; + libnvme_fabric_options_get_disable_sqflow; + libnvme_fabric_options_set_disable_sqflow; + libnvme_fabric_options_get_discovery; + libnvme_fabric_options_set_discovery; + libnvme_fabric_options_get_duplicate_connect; + libnvme_fabric_options_set_duplicate_connect; + libnvme_fabric_options_get_fast_io_fail_tmo; + libnvme_fabric_options_set_fast_io_fail_tmo; + libnvme_fabric_options_get_hdr_digest; + libnvme_fabric_options_set_hdr_digest; + libnvme_fabric_options_get_host_iface; + libnvme_fabric_options_set_host_iface; + libnvme_fabric_options_get_host_traddr; + libnvme_fabric_options_set_host_traddr; + libnvme_fabric_options_get_hostid; + libnvme_fabric_options_set_hostid; + libnvme_fabric_options_get_hostnqn; + libnvme_fabric_options_set_hostnqn; + libnvme_fabric_options_get_instance; + libnvme_fabric_options_set_instance; + libnvme_fabric_options_get_keep_alive_tmo; + libnvme_fabric_options_set_keep_alive_tmo; + libnvme_fabric_options_get_keyring; + libnvme_fabric_options_set_keyring; + libnvme_fabric_options_get_nqn; + libnvme_fabric_options_set_nqn; + libnvme_fabric_options_get_nr_io_queues; + libnvme_fabric_options_set_nr_io_queues; + libnvme_fabric_options_get_nr_poll_queues; + libnvme_fabric_options_set_nr_poll_queues; + libnvme_fabric_options_get_nr_write_queues; + libnvme_fabric_options_set_nr_write_queues; + libnvme_fabric_options_get_queue_size; + libnvme_fabric_options_set_queue_size; + libnvme_fabric_options_get_reconnect_delay; + libnvme_fabric_options_set_reconnect_delay; + libnvme_fabric_options_get_tls; + libnvme_fabric_options_set_tls; + libnvme_fabric_options_get_tls_key; + libnvme_fabric_options_set_tls_key; + libnvme_fabric_options_get_tos; + libnvme_fabric_options_set_tos; + libnvme_fabric_options_get_traddr; + libnvme_fabric_options_set_traddr; + libnvme_fabric_options_get_transport; + libnvme_fabric_options_set_transport; + libnvme_fabric_options_get_trsvcid; + libnvme_fabric_options_set_trsvcid; }; diff --git a/libnvme/src/libnvme.ld b/libnvme/src/libnvme.ld index 6d5d7a0f9b..5016d8ddd8 100644 --- a/libnvme/src/libnvme.ld +++ b/libnvme/src/libnvme.ld @@ -3,197 +3,197 @@ LIBNVME_3 { global: nvme_clear_etdas; - nvme_close; - nvme_create_ctrl; - nvme_create_global_ctx; - nvme_ctrl_match_config; - nvme_ctrl_first_ns; - nvme_ctrl_first_path; - nvme_ctrl_get_config; - nvme_ctrl_get_phy_slot; - nvme_ctrl_get_src_addr; - nvme_ctrl_get_state; - nvme_ctrl_get_subsysnqn; - nvme_ctrl_get_subsystem; - nvme_ctrl_get_transport_handle; - nvme_ctrl_identify; - nvme_ctrl_next_ns; - nvme_ctrl_next_path; - nvme_ctrl_release_transport_handle; - nvme_reset_ctrl; - nvme_filter_ctrls; - nvme_describe_key_serial; - nvme_disconnect_ctrl; - nvme_dump_config; - nvme_dump_tree; - nvme_errno_to_string; - nvme_export_tls_key; - nvme_export_tls_key_versioned; - nvme_first_host; - nvme_first_subsystem; - nvme_free_ctrl; - nvme_free_global_ctx; - nvme_free_host; - nvme_free_ns; - nvme_free_subsystem; - nvme_gen_dhchap_key; - nvme_generate_tls_key_identity; - nvme_generate_tls_key_identity_compat; + libnvme_close; + libnvme_create_ctrl; + libnvme_create_global_ctx; + libnvme_ctrl_match_config; + libnvme_ctrl_first_ns; + libnvme_ctrl_first_path; + libnvme_ctrl_get_config; + libnvme_ctrl_get_phy_slot; + libnvme_ctrl_get_src_addr; + libnvme_ctrl_get_state; + libnvme_ctrl_get_subsysnqn; + libnvme_ctrl_get_subsystem; + libnvme_ctrl_get_transport_handle; + libnvme_ctrl_identify; + libnvme_ctrl_next_ns; + libnvme_ctrl_next_path; + libnvme_ctrl_release_transport_handle; + libnvme_reset_ctrl; + libnvme_filter_ctrls; + libnvme_describe_key_serial; + libnvme_disconnect_ctrl; + libnvme_dump_config; + libnvme_dump_tree; + libnvme_errno_to_string; + libnvme_export_tls_key; + libnvme_export_tls_key_versioned; + libnvme_first_host; + libnvme_first_subsystem; + libnvme_free_ctrl; + libnvme_free_global_ctx; + libnvme_free_host; + libnvme_free_ns; + libnvme_free_subsystem; + libnvme_gen_dhchap_key; + libnvme_generate_tls_key_identity; + libnvme_generate_tls_key_identity_compat; nvme_get_ana_log_atomic; nvme_get_ana_log_len; nvme_get_ana_log_len_from_id_ctrl; - nvme_get_application; - nvme_get_attr; - nvme_get_ctrl_attr; + libnvme_get_application; + libnvme_get_attr; + libnvme_get_ctrl_attr; nvme_get_ctrl_telemetry; nvme_get_directive_receive_length; nvme_get_feature_length; nvme_get_host_telemetry; nvme_get_log; - nvme_get_logging_level; + libnvme_get_logging_level; nvme_get_logical_block_size; nvme_get_new_host_telemetry; - nvme_get_ns_attr; - nvme_get_nsid; - nvme_get_path_attr; - nvme_get_subsys_attr; + libnvme_get_ns_attr; + libnvme_get_nsid; + libnvme_get_path_attr; + libnvme_get_subsys_attr; nvme_get_telemetry_log; nvme_get_telemetry_max; nvme_get_uuid_list; - nvme_get_version; - nvme_get_host; - nvme_host_get_global_ctx; - nvme_host_get_ids; - nvme_host_is_pdc_enabled; - nvme_host_release_fds; - nvme_host_set_pdc_enabled; - nvme_read_hostid; - nvme_generate_hostid; - nvme_read_hostnqn; - nvme_generate_hostnqn; - nvme_generate_hostnqn_from_hostid; - nvme_import_tls_key; - nvme_import_tls_key_versioned; - nvme_init_ctrl; - nvme_insert_tls_key; - nvme_insert_tls_key_compat; - nvme_insert_tls_key_versioned; - nvme_lookup_key; - nvme_lookup_keyring; - nvme_mi_admin_xfer; - nvme_mi_aem_disable; - nvme_mi_aem_enable; - nvme_mi_aem_get_enabled; - nvme_mi_aem_get_fd; - nvme_mi_aem_get_next_event; - nvme_mi_aem_process; - nvme_mi_close; - nvme_mi_control; - nvme_mi_ctrl_id; - nvme_mi_endpoint_desc; - nvme_mi_ep_get_timeout; - nvme_mi_ep_set_timeout; - nvme_mi_first_endpoint; - nvme_mi_init_transport_handle; - nvme_mi_mi_config_get; - nvme_mi_mi_config_set; - nvme_mi_mi_read_mi_data_ctrl; - nvme_mi_mi_read_mi_data_ctrl_list; - nvme_mi_mi_read_mi_data_port; - nvme_mi_mi_read_mi_data_subsys; - nvme_mi_mi_subsystem_health_status_poll; - nvme_mi_mi_xfer; - nvme_mi_next_endpoint; - nvme_mi_open_mctp; - nvme_mi_scan_ep; - nvme_mi_scan_mctp; - nvme_mi_set_csi; - nvme_mi_status_to_string; + libnvme_get_version; + libnvme_get_host; + libnvme_host_get_global_ctx; + libnvme_host_get_ids; + libnvme_host_is_pdc_enabled; + libnvme_host_release_fds; + libnvme_host_set_pdc_enabled; + libnvme_read_hostid; + libnvme_generate_hostid; + libnvme_read_hostnqn; + libnvme_generate_hostnqn; + libnvme_generate_hostnqn_from_hostid; + libnvme_import_tls_key; + libnvme_import_tls_key_versioned; + libnvme_init_ctrl; + libnvme_insert_tls_key; + libnvme_insert_tls_key_compat; + libnvme_insert_tls_key_versioned; + libnvme_lookup_key; + libnvme_lookup_keyring; + libnvme_mi_admin_xfer; + libnvme_mi_aem_disable; + libnvme_mi_aem_enable; + libnvme_mi_aem_get_enabled; + libnvme_mi_aem_get_fd; + libnvme_mi_aem_get_next_event; + libnvme_mi_aem_process; + libnvme_mi_close; + libnvme_mi_control; + libnvme_mi_ctrl_id; + libnvme_mi_endpoint_desc; + libnvme_mi_ep_get_timeout; + libnvme_mi_ep_set_timeout; + libnvme_mi_first_endpoint; + libnvme_mi_init_transport_handle; + libnvme_mi_mi_config_get; + libnvme_mi_mi_config_set; + libnvme_mi_mi_read_mi_data_ctrl; + libnvme_mi_mi_read_mi_data_ctrl_list; + libnvme_mi_mi_read_mi_data_port; + libnvme_mi_mi_read_mi_data_subsys; + libnvme_mi_mi_subsystem_health_status_poll; + libnvme_mi_mi_xfer; + libnvme_mi_next_endpoint; + libnvme_mi_open_mctp; + libnvme_mi_scan_ep; + libnvme_mi_scan_mctp; + libnvme_mi_set_csi; + libnvme_mi_status_to_string; nvme_mi_submit_entry; nvme_mi_submit_exit; - nvme_filter_namespace; - nvme_namespace_first_path; - nvme_namespace_next_path; - nvme_free_nbft; - nvme_read_nbft; - nvme_next_host; - nvme_next_subsystem; - nvme_ns_compare; - nvme_ns_flush; - nvme_ns_get_csi; - nvme_ns_get_ctrl; - nvme_ns_get_eui64; - nvme_ns_get_firmware; - nvme_ns_get_generic_name; - nvme_ns_get_model; - nvme_ns_get_nguid; - nvme_ns_get_serial; - nvme_ns_get_subsystem; - nvme_ns_get_uuid; - nvme_ns_identify; - nvme_ns_read; - nvme_rescan_ns; - nvme_ns_verify; - nvme_ns_write; - nvme_ns_write_uncorrectable; - nvme_ns_write_zeros; - nvme_open; - nvme_parse_uri; - nvme_path_get_ctrl; - nvme_path_get_ns; - nvme_path_get_queue_depth; - nvme_filter_paths; - nvme_read_config; - nvme_read_key; - nvme_refresh_topology; - nvme_rescan_ctrl; - nvme_revoke_tls_key; - nvme_scan_ctrl; - nvme_scan_ctrl_namespace_paths; - nvme_scan_ctrl_namespaces; - nvme_scan_ctrls; - nvme_scan_namespace; - nvme_scan_subsystem_namespaces; - nvme_scan_subsystems; - nvme_scan_tls_keys; - nvme_scan_topology; - nvme_set_application; - nvme_set_dry_run; + libnvme_filter_namespace; + libnvme_namespace_first_path; + libnvme_namespace_next_path; + libnvme_free_nbft; + libnvme_read_nbft; + libnvme_next_host; + libnvme_next_subsystem; + libnvme_ns_compare; + libnvme_ns_flush; + libnvme_ns_get_csi; + libnvme_ns_get_ctrl; + libnvme_ns_get_eui64; + libnvme_ns_get_firmware; + libnvme_ns_get_generic_name; + libnvme_ns_get_model; + libnvme_ns_get_nguid; + libnvme_ns_get_serial; + libnvme_ns_get_subsystem; + libnvme_ns_get_uuid; + libnvme_ns_identify; + libnvme_ns_read; + libnvme_rescan_ns; + libnvme_ns_verify; + libnvme_ns_write; + libnvme_ns_write_uncorrectable; + libnvme_ns_write_zeros; + libnvme_open; + libnvme_parse_uri; + libnvme_path_get_ctrl; + libnvme_path_get_ns; + libnvme_path_get_queue_depth; + libnvme_filter_paths; + libnvme_read_config; + libnvme_read_key; + libnvme_refresh_topology; + libnvme_rescan_ctrl; + libnvme_revoke_tls_key; + libnvme_scan_ctrl; + libnvme_scan_ctrl_namespace_paths; + libnvme_scan_ctrl_namespaces; + libnvme_scan_ctrls; + libnvme_scan_namespace; + libnvme_scan_subsystem_namespaces; + libnvme_scan_subsystems; + libnvme_scan_tls_keys; + libnvme_scan_topology; + libnvme_set_application; + libnvme_set_dry_run; nvme_set_etdas; - nvme_set_ioctl_probing; - nvme_set_keyring; - nvme_set_logging_level; - nvme_skip_namespaces; - nvme_status_to_errno; - nvme_status_to_string; - nvme_strerror; - nvme_submit_admin_passthru; - nvme_submit_io_passthru; - nvme_filter_subsys; - nvme_subsystem_first_ctrl; - nvme_subsystem_first_ns; - nvme_get_subsystem; - nvme_subsystem_get_host; - nvme_subsystem_lookup_namespace; - nvme_subsystem_next_ctrl; - nvme_subsystem_next_ns; - nvme_subsystem_release_fds; - nvme_reset_subsystem; - nvme_transport_handle_get_fd; - nvme_transport_handle_get_name; - nvme_transport_handle_is_blkdev; - nvme_transport_handle_is_chardev; - nvme_transport_handle_is_direct; - nvme_transport_handle_is_mi; - nvme_transport_handle_set_decide_retry; - nvme_transport_handle_set_submit_entry; - nvme_transport_handle_set_submit_exit; - nvme_unlink_ctrl; - nvme_update_key; - nvme_find_uuid; - nvme_uuid_from_string; - nvme_random_uuid; - nvme_uuid_to_string; + libnvme_set_ioctl_probing; + libnvme_set_keyring; + libnvme_set_logging_level; + libnvme_skip_namespaces; + libnvme_status_to_errno; + libnvme_status_to_string; + libnvme_strerror; + libnvme_submit_admin_passthru; + libnvme_submit_io_passthru; + libnvme_filter_subsys; + libnvme_subsystem_first_ctrl; + libnvme_subsystem_first_ns; + libnvme_get_subsystem; + libnvme_subsystem_get_host; + libnvme_subsystem_lookup_namespace; + libnvme_subsystem_next_ctrl; + libnvme_subsystem_next_ns; + libnvme_subsystem_release_fds; + libnvme_reset_subsystem; + libnvme_transport_handle_get_fd; + libnvme_transport_handle_get_name; + libnvme_transport_handle_is_blkdev; + libnvme_transport_handle_is_chardev; + libnvme_transport_handle_is_direct; + libnvme_transport_handle_is_mi; + libnvme_transport_handle_set_decide_retry; + libnvme_transport_handle_set_submit_entry; + libnvme_transport_handle_set_submit_exit; + libnvme_unlink_ctrl; + libnvme_update_key; + libnvme_find_uuid; + libnvme_uuid_from_string; + libnvme_random_uuid; + libnvme_uuid_to_string; local: *; }; diff --git a/libnvme/src/nvme/accessors.c b/libnvme/src/nvme/accessors.c index d3c507d7ed..d844e72b4a 100644 --- a/libnvme/src/nvme/accessors.c +++ b/libnvme/src/nvme/accessors.c @@ -25,258 +25,264 @@ #include "compiler_attributes.h" /**************************************************************************** - * Accessors for: struct nvme_path + * Accessors for: struct libnvme_path ****************************************************************************/ -__public void nvme_path_set_name(struct nvme_path *p, const char *name) +__public void libnvme_path_set_name(struct libnvme_path *p, const char *name) { free(p->name); p->name = name ? strdup(name) : NULL; } -__public const char *nvme_path_get_name(const struct nvme_path *p) +__public const char *libnvme_path_get_name(const struct libnvme_path *p) { return p->name; } -__public void nvme_path_set_sysfs_dir( - struct nvme_path *p, +__public void libnvme_path_set_sysfs_dir( + struct libnvme_path *p, const char *sysfs_dir) { free(p->sysfs_dir); p->sysfs_dir = sysfs_dir ? strdup(sysfs_dir) : NULL; } -__public const char *nvme_path_get_sysfs_dir(const struct nvme_path *p) +__public const char *libnvme_path_get_sysfs_dir(const struct libnvme_path *p) { return p->sysfs_dir; } -__public void nvme_path_set_ana_state( - struct nvme_path *p, +__public void libnvme_path_set_ana_state( + struct libnvme_path *p, const char *ana_state) { free(p->ana_state); p->ana_state = ana_state ? strdup(ana_state) : NULL; } -__public const char *nvme_path_get_ana_state(const struct nvme_path *p) +__public const char *libnvme_path_get_ana_state(const struct libnvme_path *p) { return p->ana_state; } -__public void nvme_path_set_numa_nodes( - struct nvme_path *p, +__public void libnvme_path_set_numa_nodes( + struct libnvme_path *p, const char *numa_nodes) { free(p->numa_nodes); p->numa_nodes = numa_nodes ? strdup(numa_nodes) : NULL; } -__public const char *nvme_path_get_numa_nodes(const struct nvme_path *p) +__public const char *libnvme_path_get_numa_nodes(const struct libnvme_path *p) { return p->numa_nodes; } -__public void nvme_path_set_grpid(struct nvme_path *p, int grpid) +__public void libnvme_path_set_grpid(struct libnvme_path *p, int grpid) { p->grpid = grpid; } -__public int nvme_path_get_grpid(const struct nvme_path *p) +__public int libnvme_path_get_grpid(const struct libnvme_path *p) { return p->grpid; } /**************************************************************************** - * Accessors for: struct nvme_ns + * Accessors for: struct libnvme_ns ****************************************************************************/ -__public void nvme_ns_set_nsid(struct nvme_ns *p, __u32 nsid) +__public void libnvme_ns_set_nsid(struct libnvme_ns *p, __u32 nsid) { p->nsid = nsid; } -__public __u32 nvme_ns_get_nsid(const struct nvme_ns *p) +__public __u32 libnvme_ns_get_nsid(const struct libnvme_ns *p) { return p->nsid; } -__public void nvme_ns_set_name(struct nvme_ns *p, const char *name) +__public void libnvme_ns_set_name(struct libnvme_ns *p, const char *name) { free(p->name); p->name = name ? strdup(name) : NULL; } -__public const char *nvme_ns_get_name(const struct nvme_ns *p) +__public const char *libnvme_ns_get_name(const struct libnvme_ns *p) { return p->name; } -__public void nvme_ns_set_sysfs_dir(struct nvme_ns *p, const char *sysfs_dir) +__public void libnvme_ns_set_sysfs_dir( + struct libnvme_ns *p, + const char *sysfs_dir) { free(p->sysfs_dir); p->sysfs_dir = sysfs_dir ? strdup(sysfs_dir) : NULL; } -__public const char *nvme_ns_get_sysfs_dir(const struct nvme_ns *p) +__public const char *libnvme_ns_get_sysfs_dir(const struct libnvme_ns *p) { return p->sysfs_dir; } -__public void nvme_ns_set_lba_shift(struct nvme_ns *p, int lba_shift) +__public void libnvme_ns_set_lba_shift(struct libnvme_ns *p, int lba_shift) { p->lba_shift = lba_shift; } -__public int nvme_ns_get_lba_shift(const struct nvme_ns *p) +__public int libnvme_ns_get_lba_shift(const struct libnvme_ns *p) { return p->lba_shift; } -__public void nvme_ns_set_lba_size(struct nvme_ns *p, int lba_size) +__public void libnvme_ns_set_lba_size(struct libnvme_ns *p, int lba_size) { p->lba_size = lba_size; } -__public int nvme_ns_get_lba_size(const struct nvme_ns *p) +__public int libnvme_ns_get_lba_size(const struct libnvme_ns *p) { return p->lba_size; } -__public void nvme_ns_set_meta_size(struct nvme_ns *p, int meta_size) +__public void libnvme_ns_set_meta_size(struct libnvme_ns *p, int meta_size) { p->meta_size = meta_size; } -__public int nvme_ns_get_meta_size(const struct nvme_ns *p) +__public int libnvme_ns_get_meta_size(const struct libnvme_ns *p) { return p->meta_size; } -__public void nvme_ns_set_lba_count(struct nvme_ns *p, uint64_t lba_count) +__public void libnvme_ns_set_lba_count(struct libnvme_ns *p, uint64_t lba_count) { p->lba_count = lba_count; } -__public uint64_t nvme_ns_get_lba_count(const struct nvme_ns *p) +__public uint64_t libnvme_ns_get_lba_count(const struct libnvme_ns *p) { return p->lba_count; } -__public void nvme_ns_set_lba_util(struct nvme_ns *p, uint64_t lba_util) +__public void libnvme_ns_set_lba_util(struct libnvme_ns *p, uint64_t lba_util) { p->lba_util = lba_util; } -__public uint64_t nvme_ns_get_lba_util(const struct nvme_ns *p) +__public uint64_t libnvme_ns_get_lba_util(const struct libnvme_ns *p) { return p->lba_util; } /**************************************************************************** - * Accessors for: struct nvme_ctrl + * Accessors for: struct libnvme_ctrl ****************************************************************************/ -__public const char *nvme_ctrl_get_name(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_name(const struct libnvme_ctrl *p) { return p->name; } -__public const char *nvme_ctrl_get_sysfs_dir(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_sysfs_dir(const struct libnvme_ctrl *p) { return p->sysfs_dir; } -__public const char *nvme_ctrl_get_firmware(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_firmware(const struct libnvme_ctrl *p) { return p->firmware; } -__public const char *nvme_ctrl_get_model(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_model(const struct libnvme_ctrl *p) { return p->model; } -__public const char *nvme_ctrl_get_numa_node(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_numa_node(const struct libnvme_ctrl *p) { return p->numa_node; } -__public const char *nvme_ctrl_get_queue_count(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_queue_count(const struct libnvme_ctrl *p) { return p->queue_count; } -__public const char *nvme_ctrl_get_serial(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_serial(const struct libnvme_ctrl *p) { return p->serial; } -__public const char *nvme_ctrl_get_sqsize(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_sqsize(const struct libnvme_ctrl *p) { return p->sqsize; } -__public const char *nvme_ctrl_get_transport(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_transport(const struct libnvme_ctrl *p) { return p->transport; } -__public const char *nvme_ctrl_get_subsysnqn(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_subsysnqn(const struct libnvme_ctrl *p) { return p->subsysnqn; } -__public const char *nvme_ctrl_get_traddr(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_traddr(const struct libnvme_ctrl *p) { return p->traddr; } -__public const char *nvme_ctrl_get_trsvcid(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_trsvcid(const struct libnvme_ctrl *p) { return p->trsvcid; } -__public void nvme_ctrl_set_dhchap_host_key( - struct nvme_ctrl *p, +__public void libnvme_ctrl_set_dhchap_host_key( + struct libnvme_ctrl *p, const char *dhchap_host_key) { free(p->dhchap_host_key); p->dhchap_host_key = dhchap_host_key ? strdup(dhchap_host_key) : NULL; } -__public const char *nvme_ctrl_get_dhchap_host_key(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_dhchap_host_key( + const struct libnvme_ctrl *p) { return p->dhchap_host_key; } -__public void nvme_ctrl_set_dhchap_ctrl_key( - struct nvme_ctrl *p, +__public void libnvme_ctrl_set_dhchap_ctrl_key( + struct libnvme_ctrl *p, const char *dhchap_ctrl_key) { free(p->dhchap_ctrl_key); p->dhchap_ctrl_key = dhchap_ctrl_key ? strdup(dhchap_ctrl_key) : NULL; } -__public const char *nvme_ctrl_get_dhchap_ctrl_key(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_dhchap_ctrl_key( + const struct libnvme_ctrl *p) { return p->dhchap_ctrl_key; } -__public void nvme_ctrl_set_keyring(struct nvme_ctrl *p, const char *keyring) +__public void libnvme_ctrl_set_keyring( + struct libnvme_ctrl *p, + const char *keyring) { free(p->keyring); p->keyring = keyring ? strdup(keyring) : NULL; } -__public const char *nvme_ctrl_get_keyring(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_keyring(const struct libnvme_ctrl *p) { return p->keyring; } -__public void nvme_ctrl_set_tls_key_identity( - struct nvme_ctrl *p, +__public void libnvme_ctrl_set_tls_key_identity( + struct libnvme_ctrl *p, const char *tls_key_identity) { free(p->tls_key_identity); @@ -284,604 +290,621 @@ __public void nvme_ctrl_set_tls_key_identity( tls_key_identity ? strdup(tls_key_identity) : NULL; } -__public const char *nvme_ctrl_get_tls_key_identity(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_tls_key_identity( + const struct libnvme_ctrl *p) { return p->tls_key_identity; } -__public void nvme_ctrl_set_tls_key(struct nvme_ctrl *p, const char *tls_key) +__public void libnvme_ctrl_set_tls_key( + struct libnvme_ctrl *p, + const char *tls_key) { free(p->tls_key); p->tls_key = tls_key ? strdup(tls_key) : NULL; } -__public const char *nvme_ctrl_get_tls_key(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_tls_key(const struct libnvme_ctrl *p) { return p->tls_key; } -__public const char *nvme_ctrl_get_cntrltype(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_cntrltype(const struct libnvme_ctrl *p) { return p->cntrltype; } -__public const char *nvme_ctrl_get_cntlid(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_cntlid(const struct libnvme_ctrl *p) { return p->cntlid; } -__public const char *nvme_ctrl_get_dctype(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_dctype(const struct libnvme_ctrl *p) { return p->dctype; } -__public const char *nvme_ctrl_get_phy_slot(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_phy_slot(const struct libnvme_ctrl *p) { return p->phy_slot; } -__public const char *nvme_ctrl_get_host_traddr(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_host_traddr(const struct libnvme_ctrl *p) { return p->host_traddr; } -__public const char *nvme_ctrl_get_host_iface(const struct nvme_ctrl *p) +__public const char *libnvme_ctrl_get_host_iface(const struct libnvme_ctrl *p) { return p->host_iface; } -__public void nvme_ctrl_set_discovery_ctrl( - struct nvme_ctrl *p, +__public void libnvme_ctrl_set_discovery_ctrl( + struct libnvme_ctrl *p, bool discovery_ctrl) { p->discovery_ctrl = discovery_ctrl; } -__public bool nvme_ctrl_get_discovery_ctrl(const struct nvme_ctrl *p) +__public bool libnvme_ctrl_get_discovery_ctrl(const struct libnvme_ctrl *p) { return p->discovery_ctrl; } -__public void nvme_ctrl_set_unique_discovery_ctrl( - struct nvme_ctrl *p, +__public void libnvme_ctrl_set_unique_discovery_ctrl( + struct libnvme_ctrl *p, bool unique_discovery_ctrl) { p->unique_discovery_ctrl = unique_discovery_ctrl; } -__public bool nvme_ctrl_get_unique_discovery_ctrl(const struct nvme_ctrl *p) +__public bool libnvme_ctrl_get_unique_discovery_ctrl( + const struct libnvme_ctrl *p) { return p->unique_discovery_ctrl; } -__public void nvme_ctrl_set_discovered(struct nvme_ctrl *p, bool discovered) +__public void libnvme_ctrl_set_discovered( + struct libnvme_ctrl *p, + bool discovered) { p->discovered = discovered; } -__public bool nvme_ctrl_get_discovered(const struct nvme_ctrl *p) +__public bool libnvme_ctrl_get_discovered(const struct libnvme_ctrl *p) { return p->discovered; } -__public void nvme_ctrl_set_persistent(struct nvme_ctrl *p, bool persistent) +__public void libnvme_ctrl_set_persistent( + struct libnvme_ctrl *p, + bool persistent) { p->persistent = persistent; } -__public bool nvme_ctrl_get_persistent(const struct nvme_ctrl *p) +__public bool libnvme_ctrl_get_persistent(const struct libnvme_ctrl *p) { return p->persistent; } /**************************************************************************** - * Accessors for: struct nvme_subsystem + * Accessors for: struct libnvme_subsystem ****************************************************************************/ -__public const char *nvme_subsystem_get_name(const struct nvme_subsystem *p) +__public const char *libnvme_subsystem_get_name( + const struct libnvme_subsystem *p) { return p->name; } -__public const char *nvme_subsystem_get_sysfs_dir( - const struct nvme_subsystem *p) +__public const char *libnvme_subsystem_get_sysfs_dir( + const struct libnvme_subsystem *p) { return p->sysfs_dir; } -__public const char *nvme_subsystem_get_subsysnqn( - const struct nvme_subsystem *p) +__public const char *libnvme_subsystem_get_subsysnqn( + const struct libnvme_subsystem *p) { return p->subsysnqn; } -__public const char *nvme_subsystem_get_model(const struct nvme_subsystem *p) +__public const char *libnvme_subsystem_get_model( + const struct libnvme_subsystem *p) { return p->model; } -__public const char *nvme_subsystem_get_serial(const struct nvme_subsystem *p) +__public const char *libnvme_subsystem_get_serial( + const struct libnvme_subsystem *p) { return p->serial; } -__public const char *nvme_subsystem_get_firmware(const struct nvme_subsystem *p) +__public const char *libnvme_subsystem_get_firmware( + const struct libnvme_subsystem *p) { return p->firmware; } -__public const char *nvme_subsystem_get_subsystype( - const struct nvme_subsystem *p) +__public const char *libnvme_subsystem_get_subsystype( + const struct libnvme_subsystem *p) { return p->subsystype; } -__public void nvme_subsystem_set_application( - struct nvme_subsystem *p, +__public void libnvme_subsystem_set_application( + struct libnvme_subsystem *p, const char *application) { free(p->application); p->application = application ? strdup(application) : NULL; } -__public const char *nvme_subsystem_get_application( - const struct nvme_subsystem *p) +__public const char *libnvme_subsystem_get_application( + const struct libnvme_subsystem *p) { return p->application; } -__public void nvme_subsystem_set_iopolicy( - struct nvme_subsystem *p, +__public void libnvme_subsystem_set_iopolicy( + struct libnvme_subsystem *p, const char *iopolicy) { free(p->iopolicy); p->iopolicy = iopolicy ? strdup(iopolicy) : NULL; } -__public const char *nvme_subsystem_get_iopolicy(const struct nvme_subsystem *p) +__public const char *libnvme_subsystem_get_iopolicy( + const struct libnvme_subsystem *p) { return p->iopolicy; } /**************************************************************************** - * Accessors for: struct nvme_host + * Accessors for: struct libnvme_host ****************************************************************************/ -__public const char *nvme_host_get_hostnqn(const struct nvme_host *p) +__public const char *libnvme_host_get_hostnqn(const struct libnvme_host *p) { return p->hostnqn; } -__public const char *nvme_host_get_hostid(const struct nvme_host *p) +__public const char *libnvme_host_get_hostid(const struct libnvme_host *p) { return p->hostid; } -__public void nvme_host_set_dhchap_host_key( - struct nvme_host *p, +__public void libnvme_host_set_dhchap_host_key( + struct libnvme_host *p, const char *dhchap_host_key) { free(p->dhchap_host_key); p->dhchap_host_key = dhchap_host_key ? strdup(dhchap_host_key) : NULL; } -__public const char *nvme_host_get_dhchap_host_key(const struct nvme_host *p) +__public const char *libnvme_host_get_dhchap_host_key( + const struct libnvme_host *p) { return p->dhchap_host_key; } -__public void nvme_host_set_hostsymname( - struct nvme_host *p, +__public void libnvme_host_set_hostsymname( + struct libnvme_host *p, const char *hostsymname) { free(p->hostsymname); p->hostsymname = hostsymname ? strdup(hostsymname) : NULL; } -__public const char *nvme_host_get_hostsymname(const struct nvme_host *p) +__public const char *libnvme_host_get_hostsymname(const struct libnvme_host *p) { return p->hostsymname; } -__public void nvme_host_set_pdc_enabled_valid( - struct nvme_host *p, +__public void libnvme_host_set_pdc_enabled_valid( + struct libnvme_host *p, bool pdc_enabled_valid) { p->pdc_enabled_valid = pdc_enabled_valid; } -__public bool nvme_host_get_pdc_enabled_valid(const struct nvme_host *p) +__public bool libnvme_host_get_pdc_enabled_valid(const struct libnvme_host *p) { return p->pdc_enabled_valid; } /**************************************************************************** - * Accessors for: struct nvme_fabric_options + * Accessors for: struct libnvme_fabric_options ****************************************************************************/ -__public void nvme_fabric_options_set_cntlid( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_cntlid( + struct libnvme_fabric_options *p, bool cntlid) { p->cntlid = cntlid; } -__public bool nvme_fabric_options_get_cntlid( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_cntlid( + const struct libnvme_fabric_options *p) { return p->cntlid; } -__public void nvme_fabric_options_set_concat( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_concat( + struct libnvme_fabric_options *p, bool concat) { p->concat = concat; } -__public bool nvme_fabric_options_get_concat( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_concat( + const struct libnvme_fabric_options *p) { return p->concat; } -__public void nvme_fabric_options_set_ctrl_loss_tmo( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_ctrl_loss_tmo( + struct libnvme_fabric_options *p, bool ctrl_loss_tmo) { p->ctrl_loss_tmo = ctrl_loss_tmo; } -__public bool nvme_fabric_options_get_ctrl_loss_tmo( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_ctrl_loss_tmo( + const struct libnvme_fabric_options *p) { return p->ctrl_loss_tmo; } -__public void nvme_fabric_options_set_data_digest( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_data_digest( + struct libnvme_fabric_options *p, bool data_digest) { p->data_digest = data_digest; } -__public bool nvme_fabric_options_get_data_digest( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_data_digest( + const struct libnvme_fabric_options *p) { return p->data_digest; } -__public void nvme_fabric_options_set_dhchap_ctrl_secret( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_dhchap_ctrl_secret( + struct libnvme_fabric_options *p, bool dhchap_ctrl_secret) { p->dhchap_ctrl_secret = dhchap_ctrl_secret; } -__public bool nvme_fabric_options_get_dhchap_ctrl_secret( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_dhchap_ctrl_secret( + const struct libnvme_fabric_options *p) { return p->dhchap_ctrl_secret; } -__public void nvme_fabric_options_set_dhchap_secret( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_dhchap_secret( + struct libnvme_fabric_options *p, bool dhchap_secret) { p->dhchap_secret = dhchap_secret; } -__public bool nvme_fabric_options_get_dhchap_secret( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_dhchap_secret( + const struct libnvme_fabric_options *p) { return p->dhchap_secret; } -__public void nvme_fabric_options_set_disable_sqflow( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_disable_sqflow( + struct libnvme_fabric_options *p, bool disable_sqflow) { p->disable_sqflow = disable_sqflow; } -__public bool nvme_fabric_options_get_disable_sqflow( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_disable_sqflow( + const struct libnvme_fabric_options *p) { return p->disable_sqflow; } -__public void nvme_fabric_options_set_discovery( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_discovery( + struct libnvme_fabric_options *p, bool discovery) { p->discovery = discovery; } -__public bool nvme_fabric_options_get_discovery( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_discovery( + const struct libnvme_fabric_options *p) { return p->discovery; } -__public void nvme_fabric_options_set_duplicate_connect( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_duplicate_connect( + struct libnvme_fabric_options *p, bool duplicate_connect) { p->duplicate_connect = duplicate_connect; } -__public bool nvme_fabric_options_get_duplicate_connect( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_duplicate_connect( + const struct libnvme_fabric_options *p) { return p->duplicate_connect; } -__public void nvme_fabric_options_set_fast_io_fail_tmo( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_fast_io_fail_tmo( + struct libnvme_fabric_options *p, bool fast_io_fail_tmo) { p->fast_io_fail_tmo = fast_io_fail_tmo; } -__public bool nvme_fabric_options_get_fast_io_fail_tmo( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_fast_io_fail_tmo( + const struct libnvme_fabric_options *p) { return p->fast_io_fail_tmo; } -__public void nvme_fabric_options_set_hdr_digest( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_hdr_digest( + struct libnvme_fabric_options *p, bool hdr_digest) { p->hdr_digest = hdr_digest; } -__public bool nvme_fabric_options_get_hdr_digest( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_hdr_digest( + const struct libnvme_fabric_options *p) { return p->hdr_digest; } -__public void nvme_fabric_options_set_host_iface( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_host_iface( + struct libnvme_fabric_options *p, bool host_iface) { p->host_iface = host_iface; } -__public bool nvme_fabric_options_get_host_iface( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_host_iface( + const struct libnvme_fabric_options *p) { return p->host_iface; } -__public void nvme_fabric_options_set_host_traddr( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_host_traddr( + struct libnvme_fabric_options *p, bool host_traddr) { p->host_traddr = host_traddr; } -__public bool nvme_fabric_options_get_host_traddr( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_host_traddr( + const struct libnvme_fabric_options *p) { return p->host_traddr; } -__public void nvme_fabric_options_set_hostid( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_hostid( + struct libnvme_fabric_options *p, bool hostid) { p->hostid = hostid; } -__public bool nvme_fabric_options_get_hostid( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_hostid( + const struct libnvme_fabric_options *p) { return p->hostid; } -__public void nvme_fabric_options_set_hostnqn( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_hostnqn( + struct libnvme_fabric_options *p, bool hostnqn) { p->hostnqn = hostnqn; } -__public bool nvme_fabric_options_get_hostnqn( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_hostnqn( + const struct libnvme_fabric_options *p) { return p->hostnqn; } -__public void nvme_fabric_options_set_instance( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_instance( + struct libnvme_fabric_options *p, bool instance) { p->instance = instance; } -__public bool nvme_fabric_options_get_instance( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_instance( + const struct libnvme_fabric_options *p) { return p->instance; } -__public void nvme_fabric_options_set_keep_alive_tmo( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_keep_alive_tmo( + struct libnvme_fabric_options *p, bool keep_alive_tmo) { p->keep_alive_tmo = keep_alive_tmo; } -__public bool nvme_fabric_options_get_keep_alive_tmo( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_keep_alive_tmo( + const struct libnvme_fabric_options *p) { return p->keep_alive_tmo; } -__public void nvme_fabric_options_set_keyring( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_keyring( + struct libnvme_fabric_options *p, bool keyring) { p->keyring = keyring; } -__public bool nvme_fabric_options_get_keyring( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_keyring( + const struct libnvme_fabric_options *p) { return p->keyring; } -__public void nvme_fabric_options_set_nqn( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_nqn( + struct libnvme_fabric_options *p, bool nqn) { p->nqn = nqn; } -__public bool nvme_fabric_options_get_nqn(const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_nqn( + const struct libnvme_fabric_options *p) { return p->nqn; } -__public void nvme_fabric_options_set_nr_io_queues( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_nr_io_queues( + struct libnvme_fabric_options *p, bool nr_io_queues) { p->nr_io_queues = nr_io_queues; } -__public bool nvme_fabric_options_get_nr_io_queues( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_nr_io_queues( + const struct libnvme_fabric_options *p) { return p->nr_io_queues; } -__public void nvme_fabric_options_set_nr_poll_queues( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_nr_poll_queues( + struct libnvme_fabric_options *p, bool nr_poll_queues) { p->nr_poll_queues = nr_poll_queues; } -__public bool nvme_fabric_options_get_nr_poll_queues( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_nr_poll_queues( + const struct libnvme_fabric_options *p) { return p->nr_poll_queues; } -__public void nvme_fabric_options_set_nr_write_queues( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_nr_write_queues( + struct libnvme_fabric_options *p, bool nr_write_queues) { p->nr_write_queues = nr_write_queues; } -__public bool nvme_fabric_options_get_nr_write_queues( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_nr_write_queues( + const struct libnvme_fabric_options *p) { return p->nr_write_queues; } -__public void nvme_fabric_options_set_queue_size( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_queue_size( + struct libnvme_fabric_options *p, bool queue_size) { p->queue_size = queue_size; } -__public bool nvme_fabric_options_get_queue_size( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_queue_size( + const struct libnvme_fabric_options *p) { return p->queue_size; } -__public void nvme_fabric_options_set_reconnect_delay( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_reconnect_delay( + struct libnvme_fabric_options *p, bool reconnect_delay) { p->reconnect_delay = reconnect_delay; } -__public bool nvme_fabric_options_get_reconnect_delay( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_reconnect_delay( + const struct libnvme_fabric_options *p) { return p->reconnect_delay; } -__public void nvme_fabric_options_set_tls( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_tls( + struct libnvme_fabric_options *p, bool tls) { p->tls = tls; } -__public bool nvme_fabric_options_get_tls(const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_tls( + const struct libnvme_fabric_options *p) { return p->tls; } -__public void nvme_fabric_options_set_tls_key( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_tls_key( + struct libnvme_fabric_options *p, bool tls_key) { p->tls_key = tls_key; } -__public bool nvme_fabric_options_get_tls_key( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_tls_key( + const struct libnvme_fabric_options *p) { return p->tls_key; } -__public void nvme_fabric_options_set_tos( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_tos( + struct libnvme_fabric_options *p, bool tos) { p->tos = tos; } -__public bool nvme_fabric_options_get_tos(const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_tos( + const struct libnvme_fabric_options *p) { return p->tos; } -__public void nvme_fabric_options_set_traddr( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_traddr( + struct libnvme_fabric_options *p, bool traddr) { p->traddr = traddr; } -__public bool nvme_fabric_options_get_traddr( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_traddr( + const struct libnvme_fabric_options *p) { return p->traddr; } -__public void nvme_fabric_options_set_transport( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_transport( + struct libnvme_fabric_options *p, bool transport) { p->transport = transport; } -__public bool nvme_fabric_options_get_transport( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_transport( + const struct libnvme_fabric_options *p) { return p->transport; } -__public void nvme_fabric_options_set_trsvcid( - struct nvme_fabric_options *p, +__public void libnvme_fabric_options_set_trsvcid( + struct libnvme_fabric_options *p, bool trsvcid) { p->trsvcid = trsvcid; } -__public bool nvme_fabric_options_get_trsvcid( - const struct nvme_fabric_options *p) +__public bool libnvme_fabric_options_get_trsvcid( + const struct libnvme_fabric_options *p) { return p->trsvcid; } diff --git a/libnvme/src/nvme/accessors.h b/libnvme/src/nvme/accessors.h index 5c594dd127..e15e450825 100644 --- a/libnvme/src/nvme/accessors.h +++ b/libnvme/src/nvme/accessors.h @@ -27,1176 +27,1202 @@ #include /* __u32, __u64, etc. */ /* Forward declarations. These are internal (opaque) structs. */ -struct nvme_path; -struct nvme_ns; -struct nvme_ctrl; -struct nvme_subsystem; -struct nvme_host; -struct nvme_fabric_options; +struct libnvme_path; +struct libnvme_ns; +struct libnvme_ctrl; +struct libnvme_subsystem; +struct libnvme_host; +struct libnvme_fabric_options; /**************************************************************************** - * Accessors for: struct nvme_path + * Accessors for: struct libnvme_path ****************************************************************************/ /** - * nvme_path_set_name() - Set name. - * @p: The &struct nvme_path instance to update. + * libnvme_path_set_name() - Set name. + * @p: The &struct libnvme_path instance to update. * @name: New string; a copy is stored. Pass NULL to clear. */ -void nvme_path_set_name(struct nvme_path *p, const char *name); +void libnvme_path_set_name(struct libnvme_path *p, const char *name); /** - * nvme_path_get_name() - Get name. - * @p: The &struct nvme_path instance to query. + * libnvme_path_get_name() - Get name. + * @p: The &struct libnvme_path instance to query. * * Return: The value of the name field, or NULL if not set. */ -const char *nvme_path_get_name(const struct nvme_path *p); +const char *libnvme_path_get_name(const struct libnvme_path *p); /** - * nvme_path_set_sysfs_dir() - Set sysfs_dir. - * @p: The &struct nvme_path instance to update. + * libnvme_path_set_sysfs_dir() - Set sysfs_dir. + * @p: The &struct libnvme_path instance to update. * @sysfs_dir: New string; a copy is stored. Pass NULL to clear. */ -void nvme_path_set_sysfs_dir(struct nvme_path *p, const char *sysfs_dir); +void libnvme_path_set_sysfs_dir(struct libnvme_path *p, const char *sysfs_dir); /** - * nvme_path_get_sysfs_dir() - Get sysfs_dir. - * @p: The &struct nvme_path instance to query. + * libnvme_path_get_sysfs_dir() - Get sysfs_dir. + * @p: The &struct libnvme_path instance to query. * * Return: The value of the sysfs_dir field, or NULL if not set. */ -const char *nvme_path_get_sysfs_dir(const struct nvme_path *p); +const char *libnvme_path_get_sysfs_dir(const struct libnvme_path *p); /** - * nvme_path_set_ana_state() - Set ana_state. - * @p: The &struct nvme_path instance to update. + * libnvme_path_set_ana_state() - Set ana_state. + * @p: The &struct libnvme_path instance to update. * @ana_state: New string; a copy is stored. Pass NULL to clear. */ -void nvme_path_set_ana_state(struct nvme_path *p, const char *ana_state); +void libnvme_path_set_ana_state(struct libnvme_path *p, const char *ana_state); /** - * nvme_path_get_ana_state() - Get ana_state. - * @p: The &struct nvme_path instance to query. + * libnvme_path_get_ana_state() - Get ana_state. + * @p: The &struct libnvme_path instance to query. * * Return: The value of the ana_state field, or NULL if not set. */ -const char *nvme_path_get_ana_state(const struct nvme_path *p); +const char *libnvme_path_get_ana_state(const struct libnvme_path *p); /** - * nvme_path_set_numa_nodes() - Set numa_nodes. - * @p: The &struct nvme_path instance to update. + * libnvme_path_set_numa_nodes() - Set numa_nodes. + * @p: The &struct libnvme_path instance to update. * @numa_nodes: New string; a copy is stored. Pass NULL to clear. */ -void nvme_path_set_numa_nodes(struct nvme_path *p, const char *numa_nodes); +void libnvme_path_set_numa_nodes( + struct libnvme_path *p, + const char *numa_nodes); /** - * nvme_path_get_numa_nodes() - Get numa_nodes. - * @p: The &struct nvme_path instance to query. + * libnvme_path_get_numa_nodes() - Get numa_nodes. + * @p: The &struct libnvme_path instance to query. * * Return: The value of the numa_nodes field, or NULL if not set. */ -const char *nvme_path_get_numa_nodes(const struct nvme_path *p); +const char *libnvme_path_get_numa_nodes(const struct libnvme_path *p); /** - * nvme_path_set_grpid() - Set grpid. - * @p: The &struct nvme_path instance to update. + * libnvme_path_set_grpid() - Set grpid. + * @p: The &struct libnvme_path instance to update. * @grpid: Value to assign to the grpid field. */ -void nvme_path_set_grpid(struct nvme_path *p, int grpid); +void libnvme_path_set_grpid(struct libnvme_path *p, int grpid); /** - * nvme_path_get_grpid() - Get grpid. - * @p: The &struct nvme_path instance to query. + * libnvme_path_get_grpid() - Get grpid. + * @p: The &struct libnvme_path instance to query. * * Return: The value of the grpid field. */ -int nvme_path_get_grpid(const struct nvme_path *p); +int libnvme_path_get_grpid(const struct libnvme_path *p); /**************************************************************************** - * Accessors for: struct nvme_ns + * Accessors for: struct libnvme_ns ****************************************************************************/ /** - * nvme_ns_set_nsid() - Set nsid. - * @p: The &struct nvme_ns instance to update. + * libnvme_ns_set_nsid() - Set nsid. + * @p: The &struct libnvme_ns instance to update. * @nsid: Value to assign to the nsid field. */ -void nvme_ns_set_nsid(struct nvme_ns *p, __u32 nsid); +void libnvme_ns_set_nsid(struct libnvme_ns *p, __u32 nsid); /** - * nvme_ns_get_nsid() - Get nsid. - * @p: The &struct nvme_ns instance to query. + * libnvme_ns_get_nsid() - Get nsid. + * @p: The &struct libnvme_ns instance to query. * * Return: The value of the nsid field. */ -__u32 nvme_ns_get_nsid(const struct nvme_ns *p); +__u32 libnvme_ns_get_nsid(const struct libnvme_ns *p); /** - * nvme_ns_set_name() - Set name. - * @p: The &struct nvme_ns instance to update. + * libnvme_ns_set_name() - Set name. + * @p: The &struct libnvme_ns instance to update. * @name: New string; a copy is stored. Pass NULL to clear. */ -void nvme_ns_set_name(struct nvme_ns *p, const char *name); +void libnvme_ns_set_name(struct libnvme_ns *p, const char *name); /** - * nvme_ns_get_name() - Get name. - * @p: The &struct nvme_ns instance to query. + * libnvme_ns_get_name() - Get name. + * @p: The &struct libnvme_ns instance to query. * * Return: The value of the name field, or NULL if not set. */ -const char *nvme_ns_get_name(const struct nvme_ns *p); +const char *libnvme_ns_get_name(const struct libnvme_ns *p); /** - * nvme_ns_set_sysfs_dir() - Set sysfs_dir. - * @p: The &struct nvme_ns instance to update. + * libnvme_ns_set_sysfs_dir() - Set sysfs_dir. + * @p: The &struct libnvme_ns instance to update. * @sysfs_dir: New string; a copy is stored. Pass NULL to clear. */ -void nvme_ns_set_sysfs_dir(struct nvme_ns *p, const char *sysfs_dir); +void libnvme_ns_set_sysfs_dir(struct libnvme_ns *p, const char *sysfs_dir); /** - * nvme_ns_get_sysfs_dir() - Get sysfs_dir. - * @p: The &struct nvme_ns instance to query. + * libnvme_ns_get_sysfs_dir() - Get sysfs_dir. + * @p: The &struct libnvme_ns instance to query. * * Return: The value of the sysfs_dir field, or NULL if not set. */ -const char *nvme_ns_get_sysfs_dir(const struct nvme_ns *p); +const char *libnvme_ns_get_sysfs_dir(const struct libnvme_ns *p); /** - * nvme_ns_set_lba_shift() - Set lba_shift. - * @p: The &struct nvme_ns instance to update. + * libnvme_ns_set_lba_shift() - Set lba_shift. + * @p: The &struct libnvme_ns instance to update. * @lba_shift: Value to assign to the lba_shift field. */ -void nvme_ns_set_lba_shift(struct nvme_ns *p, int lba_shift); +void libnvme_ns_set_lba_shift(struct libnvme_ns *p, int lba_shift); /** - * nvme_ns_get_lba_shift() - Get lba_shift. - * @p: The &struct nvme_ns instance to query. + * libnvme_ns_get_lba_shift() - Get lba_shift. + * @p: The &struct libnvme_ns instance to query. * * Return: The value of the lba_shift field. */ -int nvme_ns_get_lba_shift(const struct nvme_ns *p); +int libnvme_ns_get_lba_shift(const struct libnvme_ns *p); /** - * nvme_ns_set_lba_size() - Set lba_size. - * @p: The &struct nvme_ns instance to update. + * libnvme_ns_set_lba_size() - Set lba_size. + * @p: The &struct libnvme_ns instance to update. * @lba_size: Value to assign to the lba_size field. */ -void nvme_ns_set_lba_size(struct nvme_ns *p, int lba_size); +void libnvme_ns_set_lba_size(struct libnvme_ns *p, int lba_size); /** - * nvme_ns_get_lba_size() - Get lba_size. - * @p: The &struct nvme_ns instance to query. + * libnvme_ns_get_lba_size() - Get lba_size. + * @p: The &struct libnvme_ns instance to query. * * Return: The value of the lba_size field. */ -int nvme_ns_get_lba_size(const struct nvme_ns *p); +int libnvme_ns_get_lba_size(const struct libnvme_ns *p); /** - * nvme_ns_set_meta_size() - Set meta_size. - * @p: The &struct nvme_ns instance to update. + * libnvme_ns_set_meta_size() - Set meta_size. + * @p: The &struct libnvme_ns instance to update. * @meta_size: Value to assign to the meta_size field. */ -void nvme_ns_set_meta_size(struct nvme_ns *p, int meta_size); +void libnvme_ns_set_meta_size(struct libnvme_ns *p, int meta_size); /** - * nvme_ns_get_meta_size() - Get meta_size. - * @p: The &struct nvme_ns instance to query. + * libnvme_ns_get_meta_size() - Get meta_size. + * @p: The &struct libnvme_ns instance to query. * * Return: The value of the meta_size field. */ -int nvme_ns_get_meta_size(const struct nvme_ns *p); +int libnvme_ns_get_meta_size(const struct libnvme_ns *p); /** - * nvme_ns_set_lba_count() - Set lba_count. - * @p: The &struct nvme_ns instance to update. + * libnvme_ns_set_lba_count() - Set lba_count. + * @p: The &struct libnvme_ns instance to update. * @lba_count: Value to assign to the lba_count field. */ -void nvme_ns_set_lba_count(struct nvme_ns *p, uint64_t lba_count); +void libnvme_ns_set_lba_count(struct libnvme_ns *p, uint64_t lba_count); /** - * nvme_ns_get_lba_count() - Get lba_count. - * @p: The &struct nvme_ns instance to query. + * libnvme_ns_get_lba_count() - Get lba_count. + * @p: The &struct libnvme_ns instance to query. * * Return: The value of the lba_count field. */ -uint64_t nvme_ns_get_lba_count(const struct nvme_ns *p); +uint64_t libnvme_ns_get_lba_count(const struct libnvme_ns *p); /** - * nvme_ns_set_lba_util() - Set lba_util. - * @p: The &struct nvme_ns instance to update. + * libnvme_ns_set_lba_util() - Set lba_util. + * @p: The &struct libnvme_ns instance to update. * @lba_util: Value to assign to the lba_util field. */ -void nvme_ns_set_lba_util(struct nvme_ns *p, uint64_t lba_util); +void libnvme_ns_set_lba_util(struct libnvme_ns *p, uint64_t lba_util); /** - * nvme_ns_get_lba_util() - Get lba_util. - * @p: The &struct nvme_ns instance to query. + * libnvme_ns_get_lba_util() - Get lba_util. + * @p: The &struct libnvme_ns instance to query. * * Return: The value of the lba_util field. */ -uint64_t nvme_ns_get_lba_util(const struct nvme_ns *p); +uint64_t libnvme_ns_get_lba_util(const struct libnvme_ns *p); /**************************************************************************** - * Accessors for: struct nvme_ctrl + * Accessors for: struct libnvme_ctrl ****************************************************************************/ /** - * nvme_ctrl_get_name() - Get name. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_name() - Get name. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the name field, or NULL if not set. */ -const char *nvme_ctrl_get_name(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_name(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_sysfs_dir() - Get sysfs_dir. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_sysfs_dir() - Get sysfs_dir. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the sysfs_dir field, or NULL if not set. */ -const char *nvme_ctrl_get_sysfs_dir(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_sysfs_dir(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_firmware() - Get firmware. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_firmware() - Get firmware. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the firmware field, or NULL if not set. */ -const char *nvme_ctrl_get_firmware(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_firmware(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_model() - Get model. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_model() - Get model. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the model field, or NULL if not set. */ -const char *nvme_ctrl_get_model(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_model(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_numa_node() - Get numa_node. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_numa_node() - Get numa_node. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the numa_node field, or NULL if not set. */ -const char *nvme_ctrl_get_numa_node(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_numa_node(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_queue_count() - Get queue_count. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_queue_count() - Get queue_count. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the queue_count field, or NULL if not set. */ -const char *nvme_ctrl_get_queue_count(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_queue_count(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_serial() - Get serial. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_serial() - Get serial. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the serial field, or NULL if not set. */ -const char *nvme_ctrl_get_serial(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_serial(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_sqsize() - Get sqsize. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_sqsize() - Get sqsize. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the sqsize field, or NULL if not set. */ -const char *nvme_ctrl_get_sqsize(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_sqsize(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_transport() - Get transport. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_transport() - Get transport. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the transport field, or NULL if not set. */ -const char *nvme_ctrl_get_transport(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_transport(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_subsysnqn() - Get subsysnqn. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_subsysnqn() - Get subsysnqn. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the subsysnqn field, or NULL if not set. */ -const char *nvme_ctrl_get_subsysnqn(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_subsysnqn(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_traddr() - Get traddr. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_traddr() - Get traddr. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the traddr field, or NULL if not set. */ -const char *nvme_ctrl_get_traddr(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_traddr(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_trsvcid() - Get trsvcid. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_trsvcid() - Get trsvcid. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the trsvcid field, or NULL if not set. */ -const char *nvme_ctrl_get_trsvcid(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_trsvcid(const struct libnvme_ctrl *p); /** - * nvme_ctrl_set_dhchap_host_key() - Set dhchap_host_key. - * @p: The &struct nvme_ctrl instance to update. + * libnvme_ctrl_set_dhchap_host_key() - Set dhchap_host_key. + * @p: The &struct libnvme_ctrl instance to update. * @dhchap_host_key: New string; a copy is stored. Pass NULL to clear. */ -void nvme_ctrl_set_dhchap_host_key( - struct nvme_ctrl *p, +void libnvme_ctrl_set_dhchap_host_key( + struct libnvme_ctrl *p, const char *dhchap_host_key); /** - * nvme_ctrl_get_dhchap_host_key() - Get dhchap_host_key. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_dhchap_host_key() - Get dhchap_host_key. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the dhchap_host_key field, or NULL if not set. */ -const char *nvme_ctrl_get_dhchap_host_key(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_dhchap_host_key(const struct libnvme_ctrl *p); /** - * nvme_ctrl_set_dhchap_ctrl_key() - Set dhchap_ctrl_key. - * @p: The &struct nvme_ctrl instance to update. + * libnvme_ctrl_set_dhchap_ctrl_key() - Set dhchap_ctrl_key. + * @p: The &struct libnvme_ctrl instance to update. * @dhchap_ctrl_key: New string; a copy is stored. Pass NULL to clear. */ -void nvme_ctrl_set_dhchap_ctrl_key( - struct nvme_ctrl *p, +void libnvme_ctrl_set_dhchap_ctrl_key( + struct libnvme_ctrl *p, const char *dhchap_ctrl_key); /** - * nvme_ctrl_get_dhchap_ctrl_key() - Get dhchap_ctrl_key. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_dhchap_ctrl_key() - Get dhchap_ctrl_key. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the dhchap_ctrl_key field, or NULL if not set. */ -const char *nvme_ctrl_get_dhchap_ctrl_key(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_dhchap_ctrl_key(const struct libnvme_ctrl *p); /** - * nvme_ctrl_set_keyring() - Set keyring. - * @p: The &struct nvme_ctrl instance to update. + * libnvme_ctrl_set_keyring() - Set keyring. + * @p: The &struct libnvme_ctrl instance to update. * @keyring: New string; a copy is stored. Pass NULL to clear. */ -void nvme_ctrl_set_keyring(struct nvme_ctrl *p, const char *keyring); +void libnvme_ctrl_set_keyring(struct libnvme_ctrl *p, const char *keyring); /** - * nvme_ctrl_get_keyring() - Get keyring. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_keyring() - Get keyring. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the keyring field, or NULL if not set. */ -const char *nvme_ctrl_get_keyring(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_keyring(const struct libnvme_ctrl *p); /** - * nvme_ctrl_set_tls_key_identity() - Set tls_key_identity. - * @p: The &struct nvme_ctrl instance to update. + * libnvme_ctrl_set_tls_key_identity() - Set tls_key_identity. + * @p: The &struct libnvme_ctrl instance to update. * @tls_key_identity: New string; a copy is stored. Pass NULL to clear. */ -void nvme_ctrl_set_tls_key_identity( - struct nvme_ctrl *p, +void libnvme_ctrl_set_tls_key_identity( + struct libnvme_ctrl *p, const char *tls_key_identity); /** - * nvme_ctrl_get_tls_key_identity() - Get tls_key_identity. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_tls_key_identity() - Get tls_key_identity. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the tls_key_identity field, or NULL if not set. */ -const char *nvme_ctrl_get_tls_key_identity(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_tls_key_identity(const struct libnvme_ctrl *p); /** - * nvme_ctrl_set_tls_key() - Set tls_key. - * @p: The &struct nvme_ctrl instance to update. + * libnvme_ctrl_set_tls_key() - Set tls_key. + * @p: The &struct libnvme_ctrl instance to update. * @tls_key: New string; a copy is stored. Pass NULL to clear. */ -void nvme_ctrl_set_tls_key(struct nvme_ctrl *p, const char *tls_key); +void libnvme_ctrl_set_tls_key(struct libnvme_ctrl *p, const char *tls_key); /** - * nvme_ctrl_get_tls_key() - Get tls_key. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_tls_key() - Get tls_key. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the tls_key field, or NULL if not set. */ -const char *nvme_ctrl_get_tls_key(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_tls_key(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_cntrltype() - Get cntrltype. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_cntrltype() - Get cntrltype. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the cntrltype field, or NULL if not set. */ -const char *nvme_ctrl_get_cntrltype(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_cntrltype(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_cntlid() - Get cntlid. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_cntlid() - Get cntlid. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the cntlid field, or NULL if not set. */ -const char *nvme_ctrl_get_cntlid(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_cntlid(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_dctype() - Get dctype. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_dctype() - Get dctype. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the dctype field, or NULL if not set. */ -const char *nvme_ctrl_get_dctype(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_dctype(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_phy_slot() - Get phy_slot. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_phy_slot() - Get phy_slot. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the phy_slot field, or NULL if not set. */ -const char *nvme_ctrl_get_phy_slot(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_phy_slot(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_host_traddr() - Get host_traddr. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_host_traddr() - Get host_traddr. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the host_traddr field, or NULL if not set. */ -const char *nvme_ctrl_get_host_traddr(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_host_traddr(const struct libnvme_ctrl *p); /** - * nvme_ctrl_get_host_iface() - Get host_iface. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_host_iface() - Get host_iface. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the host_iface field, or NULL if not set. */ -const char *nvme_ctrl_get_host_iface(const struct nvme_ctrl *p); +const char *libnvme_ctrl_get_host_iface(const struct libnvme_ctrl *p); /** - * nvme_ctrl_set_discovery_ctrl() - Set discovery_ctrl. - * @p: The &struct nvme_ctrl instance to update. + * libnvme_ctrl_set_discovery_ctrl() - Set discovery_ctrl. + * @p: The &struct libnvme_ctrl instance to update. * @discovery_ctrl: Value to assign to the discovery_ctrl field. */ -void nvme_ctrl_set_discovery_ctrl(struct nvme_ctrl *p, bool discovery_ctrl); +void libnvme_ctrl_set_discovery_ctrl( + struct libnvme_ctrl *p, + bool discovery_ctrl); /** - * nvme_ctrl_get_discovery_ctrl() - Get discovery_ctrl. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_discovery_ctrl() - Get discovery_ctrl. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the discovery_ctrl field. */ -bool nvme_ctrl_get_discovery_ctrl(const struct nvme_ctrl *p); +bool libnvme_ctrl_get_discovery_ctrl(const struct libnvme_ctrl *p); /** - * nvme_ctrl_set_unique_discovery_ctrl() - Set unique_discovery_ctrl. - * @p: The &struct nvme_ctrl instance to update. + * libnvme_ctrl_set_unique_discovery_ctrl() - Set unique_discovery_ctrl. + * @p: The &struct libnvme_ctrl instance to update. * @unique_discovery_ctrl: Value to assign to the unique_discovery_ctrl field. */ -void nvme_ctrl_set_unique_discovery_ctrl( - struct nvme_ctrl *p, +void libnvme_ctrl_set_unique_discovery_ctrl( + struct libnvme_ctrl *p, bool unique_discovery_ctrl); /** - * nvme_ctrl_get_unique_discovery_ctrl() - Get unique_discovery_ctrl. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_unique_discovery_ctrl() - Get unique_discovery_ctrl. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the unique_discovery_ctrl field. */ -bool nvme_ctrl_get_unique_discovery_ctrl(const struct nvme_ctrl *p); +bool libnvme_ctrl_get_unique_discovery_ctrl(const struct libnvme_ctrl *p); /** - * nvme_ctrl_set_discovered() - Set discovered. - * @p: The &struct nvme_ctrl instance to update. + * libnvme_ctrl_set_discovered() - Set discovered. + * @p: The &struct libnvme_ctrl instance to update. * @discovered: Value to assign to the discovered field. */ -void nvme_ctrl_set_discovered(struct nvme_ctrl *p, bool discovered); +void libnvme_ctrl_set_discovered(struct libnvme_ctrl *p, bool discovered); /** - * nvme_ctrl_get_discovered() - Get discovered. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_discovered() - Get discovered. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the discovered field. */ -bool nvme_ctrl_get_discovered(const struct nvme_ctrl *p); +bool libnvme_ctrl_get_discovered(const struct libnvme_ctrl *p); /** - * nvme_ctrl_set_persistent() - Set persistent. - * @p: The &struct nvme_ctrl instance to update. + * libnvme_ctrl_set_persistent() - Set persistent. + * @p: The &struct libnvme_ctrl instance to update. * @persistent: Value to assign to the persistent field. */ -void nvme_ctrl_set_persistent(struct nvme_ctrl *p, bool persistent); +void libnvme_ctrl_set_persistent(struct libnvme_ctrl *p, bool persistent); /** - * nvme_ctrl_get_persistent() - Get persistent. - * @p: The &struct nvme_ctrl instance to query. + * libnvme_ctrl_get_persistent() - Get persistent. + * @p: The &struct libnvme_ctrl instance to query. * * Return: The value of the persistent field. */ -bool nvme_ctrl_get_persistent(const struct nvme_ctrl *p); +bool libnvme_ctrl_get_persistent(const struct libnvme_ctrl *p); /**************************************************************************** - * Accessors for: struct nvme_subsystem + * Accessors for: struct libnvme_subsystem ****************************************************************************/ /** - * nvme_subsystem_get_name() - Get name. - * @p: The &struct nvme_subsystem instance to query. + * libnvme_subsystem_get_name() - Get name. + * @p: The &struct libnvme_subsystem instance to query. * * Return: The value of the name field, or NULL if not set. */ -const char *nvme_subsystem_get_name(const struct nvme_subsystem *p); +const char *libnvme_subsystem_get_name(const struct libnvme_subsystem *p); /** - * nvme_subsystem_get_sysfs_dir() - Get sysfs_dir. - * @p: The &struct nvme_subsystem instance to query. + * libnvme_subsystem_get_sysfs_dir() - Get sysfs_dir. + * @p: The &struct libnvme_subsystem instance to query. * * Return: The value of the sysfs_dir field, or NULL if not set. */ -const char *nvme_subsystem_get_sysfs_dir(const struct nvme_subsystem *p); +const char *libnvme_subsystem_get_sysfs_dir(const struct libnvme_subsystem *p); /** - * nvme_subsystem_get_subsysnqn() - Get subsysnqn. - * @p: The &struct nvme_subsystem instance to query. + * libnvme_subsystem_get_subsysnqn() - Get subsysnqn. + * @p: The &struct libnvme_subsystem instance to query. * * Return: The value of the subsysnqn field, or NULL if not set. */ -const char *nvme_subsystem_get_subsysnqn(const struct nvme_subsystem *p); +const char *libnvme_subsystem_get_subsysnqn(const struct libnvme_subsystem *p); /** - * nvme_subsystem_get_model() - Get model. - * @p: The &struct nvme_subsystem instance to query. + * libnvme_subsystem_get_model() - Get model. + * @p: The &struct libnvme_subsystem instance to query. * * Return: The value of the model field, or NULL if not set. */ -const char *nvme_subsystem_get_model(const struct nvme_subsystem *p); +const char *libnvme_subsystem_get_model(const struct libnvme_subsystem *p); /** - * nvme_subsystem_get_serial() - Get serial. - * @p: The &struct nvme_subsystem instance to query. + * libnvme_subsystem_get_serial() - Get serial. + * @p: The &struct libnvme_subsystem instance to query. * * Return: The value of the serial field, or NULL if not set. */ -const char *nvme_subsystem_get_serial(const struct nvme_subsystem *p); +const char *libnvme_subsystem_get_serial(const struct libnvme_subsystem *p); /** - * nvme_subsystem_get_firmware() - Get firmware. - * @p: The &struct nvme_subsystem instance to query. + * libnvme_subsystem_get_firmware() - Get firmware. + * @p: The &struct libnvme_subsystem instance to query. * * Return: The value of the firmware field, or NULL if not set. */ -const char *nvme_subsystem_get_firmware(const struct nvme_subsystem *p); +const char *libnvme_subsystem_get_firmware(const struct libnvme_subsystem *p); /** - * nvme_subsystem_get_subsystype() - Get subsystype. - * @p: The &struct nvme_subsystem instance to query. + * libnvme_subsystem_get_subsystype() - Get subsystype. + * @p: The &struct libnvme_subsystem instance to query. * * Return: The value of the subsystype field, or NULL if not set. */ -const char *nvme_subsystem_get_subsystype(const struct nvme_subsystem *p); +const char *libnvme_subsystem_get_subsystype(const struct libnvme_subsystem *p); /** - * nvme_subsystem_set_application() - Set application. - * @p: The &struct nvme_subsystem instance to update. + * libnvme_subsystem_set_application() - Set application. + * @p: The &struct libnvme_subsystem instance to update. * @application: New string; a copy is stored. Pass NULL to clear. */ -void nvme_subsystem_set_application( - struct nvme_subsystem *p, +void libnvme_subsystem_set_application( + struct libnvme_subsystem *p, const char *application); /** - * nvme_subsystem_get_application() - Get application. - * @p: The &struct nvme_subsystem instance to query. + * libnvme_subsystem_get_application() - Get application. + * @p: The &struct libnvme_subsystem instance to query. * * Return: The value of the application field, or NULL if not set. */ -const char *nvme_subsystem_get_application(const struct nvme_subsystem *p); +const char *libnvme_subsystem_get_application( + const struct libnvme_subsystem *p); /** - * nvme_subsystem_set_iopolicy() - Set iopolicy. - * @p: The &struct nvme_subsystem instance to update. + * libnvme_subsystem_set_iopolicy() - Set iopolicy. + * @p: The &struct libnvme_subsystem instance to update. * @iopolicy: New string; a copy is stored. Pass NULL to clear. */ -void nvme_subsystem_set_iopolicy( - struct nvme_subsystem *p, +void libnvme_subsystem_set_iopolicy( + struct libnvme_subsystem *p, const char *iopolicy); /** - * nvme_subsystem_get_iopolicy() - Get iopolicy. - * @p: The &struct nvme_subsystem instance to query. + * libnvme_subsystem_get_iopolicy() - Get iopolicy. + * @p: The &struct libnvme_subsystem instance to query. * * Return: The value of the iopolicy field, or NULL if not set. */ -const char *nvme_subsystem_get_iopolicy(const struct nvme_subsystem *p); +const char *libnvme_subsystem_get_iopolicy(const struct libnvme_subsystem *p); /**************************************************************************** - * Accessors for: struct nvme_host + * Accessors for: struct libnvme_host ****************************************************************************/ /** - * nvme_host_get_hostnqn() - Get hostnqn. - * @p: The &struct nvme_host instance to query. + * libnvme_host_get_hostnqn() - Get hostnqn. + * @p: The &struct libnvme_host instance to query. * * Return: The value of the hostnqn field, or NULL if not set. */ -const char *nvme_host_get_hostnqn(const struct nvme_host *p); +const char *libnvme_host_get_hostnqn(const struct libnvme_host *p); /** - * nvme_host_get_hostid() - Get hostid. - * @p: The &struct nvme_host instance to query. + * libnvme_host_get_hostid() - Get hostid. + * @p: The &struct libnvme_host instance to query. * * Return: The value of the hostid field, or NULL if not set. */ -const char *nvme_host_get_hostid(const struct nvme_host *p); +const char *libnvme_host_get_hostid(const struct libnvme_host *p); /** - * nvme_host_set_dhchap_host_key() - Set dhchap_host_key. - * @p: The &struct nvme_host instance to update. + * libnvme_host_set_dhchap_host_key() - Set dhchap_host_key. + * @p: The &struct libnvme_host instance to update. * @dhchap_host_key: New string; a copy is stored. Pass NULL to clear. */ -void nvme_host_set_dhchap_host_key( - struct nvme_host *p, +void libnvme_host_set_dhchap_host_key( + struct libnvme_host *p, const char *dhchap_host_key); /** - * nvme_host_get_dhchap_host_key() - Get dhchap_host_key. - * @p: The &struct nvme_host instance to query. + * libnvme_host_get_dhchap_host_key() - Get dhchap_host_key. + * @p: The &struct libnvme_host instance to query. * * Return: The value of the dhchap_host_key field, or NULL if not set. */ -const char *nvme_host_get_dhchap_host_key(const struct nvme_host *p); +const char *libnvme_host_get_dhchap_host_key(const struct libnvme_host *p); /** - * nvme_host_set_hostsymname() - Set hostsymname. - * @p: The &struct nvme_host instance to update. + * libnvme_host_set_hostsymname() - Set hostsymname. + * @p: The &struct libnvme_host instance to update. * @hostsymname: New string; a copy is stored. Pass NULL to clear. */ -void nvme_host_set_hostsymname(struct nvme_host *p, const char *hostsymname); +void libnvme_host_set_hostsymname( + struct libnvme_host *p, + const char *hostsymname); /** - * nvme_host_get_hostsymname() - Get hostsymname. - * @p: The &struct nvme_host instance to query. + * libnvme_host_get_hostsymname() - Get hostsymname. + * @p: The &struct libnvme_host instance to query. * * Return: The value of the hostsymname field, or NULL if not set. */ -const char *nvme_host_get_hostsymname(const struct nvme_host *p); +const char *libnvme_host_get_hostsymname(const struct libnvme_host *p); /** - * nvme_host_set_pdc_enabled_valid() - Set pdc_enabled_valid. - * @p: The &struct nvme_host instance to update. + * libnvme_host_set_pdc_enabled_valid() - Set pdc_enabled_valid. + * @p: The &struct libnvme_host instance to update. * @pdc_enabled_valid: Value to assign to the pdc_enabled_valid field. */ -void nvme_host_set_pdc_enabled_valid( - struct nvme_host *p, +void libnvme_host_set_pdc_enabled_valid( + struct libnvme_host *p, bool pdc_enabled_valid); /** - * nvme_host_get_pdc_enabled_valid() - Get pdc_enabled_valid. - * @p: The &struct nvme_host instance to query. + * libnvme_host_get_pdc_enabled_valid() - Get pdc_enabled_valid. + * @p: The &struct libnvme_host instance to query. * * Return: The value of the pdc_enabled_valid field. */ -bool nvme_host_get_pdc_enabled_valid(const struct nvme_host *p); +bool libnvme_host_get_pdc_enabled_valid(const struct libnvme_host *p); /**************************************************************************** - * Accessors for: struct nvme_fabric_options + * Accessors for: struct libnvme_fabric_options ****************************************************************************/ /** - * nvme_fabric_options_set_cntlid() - Set cntlid. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_cntlid() - Set cntlid. + * @p: The &struct libnvme_fabric_options instance to update. * @cntlid: Value to assign to the cntlid field. */ -void nvme_fabric_options_set_cntlid(struct nvme_fabric_options *p, bool cntlid); +void libnvme_fabric_options_set_cntlid( + struct libnvme_fabric_options *p, + bool cntlid); /** - * nvme_fabric_options_get_cntlid() - Get cntlid. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_cntlid() - Get cntlid. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the cntlid field. */ -bool nvme_fabric_options_get_cntlid(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_cntlid(const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_concat() - Set concat. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_concat() - Set concat. + * @p: The &struct libnvme_fabric_options instance to update. * @concat: Value to assign to the concat field. */ -void nvme_fabric_options_set_concat(struct nvme_fabric_options *p, bool concat); +void libnvme_fabric_options_set_concat( + struct libnvme_fabric_options *p, + bool concat); /** - * nvme_fabric_options_get_concat() - Get concat. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_concat() - Get concat. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the concat field. */ -bool nvme_fabric_options_get_concat(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_concat(const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_ctrl_loss_tmo() - Set ctrl_loss_tmo. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_ctrl_loss_tmo() - Set ctrl_loss_tmo. + * @p: The &struct libnvme_fabric_options instance to update. * @ctrl_loss_tmo: Value to assign to the ctrl_loss_tmo field. */ -void nvme_fabric_options_set_ctrl_loss_tmo( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_ctrl_loss_tmo( + struct libnvme_fabric_options *p, bool ctrl_loss_tmo); /** - * nvme_fabric_options_get_ctrl_loss_tmo() - Get ctrl_loss_tmo. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_ctrl_loss_tmo() - Get ctrl_loss_tmo. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the ctrl_loss_tmo field. */ -bool nvme_fabric_options_get_ctrl_loss_tmo(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_ctrl_loss_tmo( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_data_digest() - Set data_digest. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_data_digest() - Set data_digest. + * @p: The &struct libnvme_fabric_options instance to update. * @data_digest: Value to assign to the data_digest field. */ -void nvme_fabric_options_set_data_digest( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_data_digest( + struct libnvme_fabric_options *p, bool data_digest); /** - * nvme_fabric_options_get_data_digest() - Get data_digest. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_data_digest() - Get data_digest. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the data_digest field. */ -bool nvme_fabric_options_get_data_digest(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_data_digest( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_dhchap_ctrl_secret() - Set dhchap_ctrl_secret. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_dhchap_ctrl_secret() - Set dhchap_ctrl_secret. + * @p: The &struct libnvme_fabric_options instance to update. * @dhchap_ctrl_secret: Value to assign to the dhchap_ctrl_secret field. */ -void nvme_fabric_options_set_dhchap_ctrl_secret( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_dhchap_ctrl_secret( + struct libnvme_fabric_options *p, bool dhchap_ctrl_secret); /** - * nvme_fabric_options_get_dhchap_ctrl_secret() - Get dhchap_ctrl_secret. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_dhchap_ctrl_secret() - Get dhchap_ctrl_secret. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the dhchap_ctrl_secret field. */ -bool nvme_fabric_options_get_dhchap_ctrl_secret( - const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_dhchap_ctrl_secret( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_dhchap_secret() - Set dhchap_secret. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_dhchap_secret() - Set dhchap_secret. + * @p: The &struct libnvme_fabric_options instance to update. * @dhchap_secret: Value to assign to the dhchap_secret field. */ -void nvme_fabric_options_set_dhchap_secret( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_dhchap_secret( + struct libnvme_fabric_options *p, bool dhchap_secret); /** - * nvme_fabric_options_get_dhchap_secret() - Get dhchap_secret. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_dhchap_secret() - Get dhchap_secret. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the dhchap_secret field. */ -bool nvme_fabric_options_get_dhchap_secret(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_dhchap_secret( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_disable_sqflow() - Set disable_sqflow. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_disable_sqflow() - Set disable_sqflow. + * @p: The &struct libnvme_fabric_options instance to update. * @disable_sqflow: Value to assign to the disable_sqflow field. */ -void nvme_fabric_options_set_disable_sqflow( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_disable_sqflow( + struct libnvme_fabric_options *p, bool disable_sqflow); /** - * nvme_fabric_options_get_disable_sqflow() - Get disable_sqflow. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_disable_sqflow() - Get disable_sqflow. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the disable_sqflow field. */ -bool nvme_fabric_options_get_disable_sqflow( - const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_disable_sqflow( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_discovery() - Set discovery. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_discovery() - Set discovery. + * @p: The &struct libnvme_fabric_options instance to update. * @discovery: Value to assign to the discovery field. */ -void nvme_fabric_options_set_discovery( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_discovery( + struct libnvme_fabric_options *p, bool discovery); /** - * nvme_fabric_options_get_discovery() - Get discovery. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_discovery() - Get discovery. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the discovery field. */ -bool nvme_fabric_options_get_discovery(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_discovery( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_duplicate_connect() - Set duplicate_connect. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_duplicate_connect() - Set duplicate_connect. + * @p: The &struct libnvme_fabric_options instance to update. * @duplicate_connect: Value to assign to the duplicate_connect field. */ -void nvme_fabric_options_set_duplicate_connect( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_duplicate_connect( + struct libnvme_fabric_options *p, bool duplicate_connect); /** - * nvme_fabric_options_get_duplicate_connect() - Get duplicate_connect. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_duplicate_connect() - Get duplicate_connect. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the duplicate_connect field. */ -bool nvme_fabric_options_get_duplicate_connect( - const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_duplicate_connect( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_fast_io_fail_tmo() - Set fast_io_fail_tmo. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_fast_io_fail_tmo() - Set fast_io_fail_tmo. + * @p: The &struct libnvme_fabric_options instance to update. * @fast_io_fail_tmo: Value to assign to the fast_io_fail_tmo field. */ -void nvme_fabric_options_set_fast_io_fail_tmo( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_fast_io_fail_tmo( + struct libnvme_fabric_options *p, bool fast_io_fail_tmo); /** - * nvme_fabric_options_get_fast_io_fail_tmo() - Get fast_io_fail_tmo. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_fast_io_fail_tmo() - Get fast_io_fail_tmo. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the fast_io_fail_tmo field. */ -bool nvme_fabric_options_get_fast_io_fail_tmo( - const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_fast_io_fail_tmo( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_hdr_digest() - Set hdr_digest. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_hdr_digest() - Set hdr_digest. + * @p: The &struct libnvme_fabric_options instance to update. * @hdr_digest: Value to assign to the hdr_digest field. */ -void nvme_fabric_options_set_hdr_digest( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_hdr_digest( + struct libnvme_fabric_options *p, bool hdr_digest); /** - * nvme_fabric_options_get_hdr_digest() - Get hdr_digest. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_hdr_digest() - Get hdr_digest. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the hdr_digest field. */ -bool nvme_fabric_options_get_hdr_digest(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_hdr_digest( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_host_iface() - Set host_iface. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_host_iface() - Set host_iface. + * @p: The &struct libnvme_fabric_options instance to update. * @host_iface: Value to assign to the host_iface field. */ -void nvme_fabric_options_set_host_iface( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_host_iface( + struct libnvme_fabric_options *p, bool host_iface); /** - * nvme_fabric_options_get_host_iface() - Get host_iface. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_host_iface() - Get host_iface. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the host_iface field. */ -bool nvme_fabric_options_get_host_iface(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_host_iface( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_host_traddr() - Set host_traddr. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_host_traddr() - Set host_traddr. + * @p: The &struct libnvme_fabric_options instance to update. * @host_traddr: Value to assign to the host_traddr field. */ -void nvme_fabric_options_set_host_traddr( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_host_traddr( + struct libnvme_fabric_options *p, bool host_traddr); /** - * nvme_fabric_options_get_host_traddr() - Get host_traddr. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_host_traddr() - Get host_traddr. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the host_traddr field. */ -bool nvme_fabric_options_get_host_traddr(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_host_traddr( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_hostid() - Set hostid. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_hostid() - Set hostid. + * @p: The &struct libnvme_fabric_options instance to update. * @hostid: Value to assign to the hostid field. */ -void nvme_fabric_options_set_hostid(struct nvme_fabric_options *p, bool hostid); +void libnvme_fabric_options_set_hostid( + struct libnvme_fabric_options *p, + bool hostid); /** - * nvme_fabric_options_get_hostid() - Get hostid. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_hostid() - Get hostid. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the hostid field. */ -bool nvme_fabric_options_get_hostid(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_hostid(const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_hostnqn() - Set hostnqn. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_hostnqn() - Set hostnqn. + * @p: The &struct libnvme_fabric_options instance to update. * @hostnqn: Value to assign to the hostnqn field. */ -void nvme_fabric_options_set_hostnqn( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_hostnqn( + struct libnvme_fabric_options *p, bool hostnqn); /** - * nvme_fabric_options_get_hostnqn() - Get hostnqn. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_hostnqn() - Get hostnqn. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the hostnqn field. */ -bool nvme_fabric_options_get_hostnqn(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_hostnqn(const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_instance() - Set instance. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_instance() - Set instance. + * @p: The &struct libnvme_fabric_options instance to update. * @instance: Value to assign to the instance field. */ -void nvme_fabric_options_set_instance( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_instance( + struct libnvme_fabric_options *p, bool instance); /** - * nvme_fabric_options_get_instance() - Get instance. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_instance() - Get instance. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the instance field. */ -bool nvme_fabric_options_get_instance(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_instance( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_keep_alive_tmo() - Set keep_alive_tmo. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_keep_alive_tmo() - Set keep_alive_tmo. + * @p: The &struct libnvme_fabric_options instance to update. * @keep_alive_tmo: Value to assign to the keep_alive_tmo field. */ -void nvme_fabric_options_set_keep_alive_tmo( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_keep_alive_tmo( + struct libnvme_fabric_options *p, bool keep_alive_tmo); /** - * nvme_fabric_options_get_keep_alive_tmo() - Get keep_alive_tmo. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_keep_alive_tmo() - Get keep_alive_tmo. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the keep_alive_tmo field. */ -bool nvme_fabric_options_get_keep_alive_tmo( - const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_keep_alive_tmo( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_keyring() - Set keyring. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_keyring() - Set keyring. + * @p: The &struct libnvme_fabric_options instance to update. * @keyring: Value to assign to the keyring field. */ -void nvme_fabric_options_set_keyring( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_keyring( + struct libnvme_fabric_options *p, bool keyring); /** - * nvme_fabric_options_get_keyring() - Get keyring. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_keyring() - Get keyring. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the keyring field. */ -bool nvme_fabric_options_get_keyring(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_keyring(const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_nqn() - Set nqn. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_nqn() - Set nqn. + * @p: The &struct libnvme_fabric_options instance to update. * @nqn: Value to assign to the nqn field. */ -void nvme_fabric_options_set_nqn(struct nvme_fabric_options *p, bool nqn); +void libnvme_fabric_options_set_nqn(struct libnvme_fabric_options *p, bool nqn); /** - * nvme_fabric_options_get_nqn() - Get nqn. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_nqn() - Get nqn. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the nqn field. */ -bool nvme_fabric_options_get_nqn(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_nqn(const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_nr_io_queues() - Set nr_io_queues. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_nr_io_queues() - Set nr_io_queues. + * @p: The &struct libnvme_fabric_options instance to update. * @nr_io_queues: Value to assign to the nr_io_queues field. */ -void nvme_fabric_options_set_nr_io_queues( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_nr_io_queues( + struct libnvme_fabric_options *p, bool nr_io_queues); /** - * nvme_fabric_options_get_nr_io_queues() - Get nr_io_queues. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_nr_io_queues() - Get nr_io_queues. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the nr_io_queues field. */ -bool nvme_fabric_options_get_nr_io_queues(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_nr_io_queues( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_nr_poll_queues() - Set nr_poll_queues. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_nr_poll_queues() - Set nr_poll_queues. + * @p: The &struct libnvme_fabric_options instance to update. * @nr_poll_queues: Value to assign to the nr_poll_queues field. */ -void nvme_fabric_options_set_nr_poll_queues( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_nr_poll_queues( + struct libnvme_fabric_options *p, bool nr_poll_queues); /** - * nvme_fabric_options_get_nr_poll_queues() - Get nr_poll_queues. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_nr_poll_queues() - Get nr_poll_queues. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the nr_poll_queues field. */ -bool nvme_fabric_options_get_nr_poll_queues( - const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_nr_poll_queues( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_nr_write_queues() - Set nr_write_queues. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_nr_write_queues() - Set nr_write_queues. + * @p: The &struct libnvme_fabric_options instance to update. * @nr_write_queues: Value to assign to the nr_write_queues field. */ -void nvme_fabric_options_set_nr_write_queues( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_nr_write_queues( + struct libnvme_fabric_options *p, bool nr_write_queues); /** - * nvme_fabric_options_get_nr_write_queues() - Get nr_write_queues. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_nr_write_queues() - Get nr_write_queues. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the nr_write_queues field. */ -bool nvme_fabric_options_get_nr_write_queues( - const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_nr_write_queues( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_queue_size() - Set queue_size. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_queue_size() - Set queue_size. + * @p: The &struct libnvme_fabric_options instance to update. * @queue_size: Value to assign to the queue_size field. */ -void nvme_fabric_options_set_queue_size( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_queue_size( + struct libnvme_fabric_options *p, bool queue_size); /** - * nvme_fabric_options_get_queue_size() - Get queue_size. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_queue_size() - Get queue_size. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the queue_size field. */ -bool nvme_fabric_options_get_queue_size(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_queue_size( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_reconnect_delay() - Set reconnect_delay. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_reconnect_delay() - Set reconnect_delay. + * @p: The &struct libnvme_fabric_options instance to update. * @reconnect_delay: Value to assign to the reconnect_delay field. */ -void nvme_fabric_options_set_reconnect_delay( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_reconnect_delay( + struct libnvme_fabric_options *p, bool reconnect_delay); /** - * nvme_fabric_options_get_reconnect_delay() - Get reconnect_delay. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_reconnect_delay() - Get reconnect_delay. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the reconnect_delay field. */ -bool nvme_fabric_options_get_reconnect_delay( - const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_reconnect_delay( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_tls() - Set tls. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_tls() - Set tls. + * @p: The &struct libnvme_fabric_options instance to update. * @tls: Value to assign to the tls field. */ -void nvme_fabric_options_set_tls(struct nvme_fabric_options *p, bool tls); +void libnvme_fabric_options_set_tls(struct libnvme_fabric_options *p, bool tls); /** - * nvme_fabric_options_get_tls() - Get tls. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_tls() - Get tls. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the tls field. */ -bool nvme_fabric_options_get_tls(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_tls(const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_tls_key() - Set tls_key. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_tls_key() - Set tls_key. + * @p: The &struct libnvme_fabric_options instance to update. * @tls_key: Value to assign to the tls_key field. */ -void nvme_fabric_options_set_tls_key( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_tls_key( + struct libnvme_fabric_options *p, bool tls_key); /** - * nvme_fabric_options_get_tls_key() - Get tls_key. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_tls_key() - Get tls_key. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the tls_key field. */ -bool nvme_fabric_options_get_tls_key(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_tls_key(const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_tos() - Set tos. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_tos() - Set tos. + * @p: The &struct libnvme_fabric_options instance to update. * @tos: Value to assign to the tos field. */ -void nvme_fabric_options_set_tos(struct nvme_fabric_options *p, bool tos); +void libnvme_fabric_options_set_tos(struct libnvme_fabric_options *p, bool tos); /** - * nvme_fabric_options_get_tos() - Get tos. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_tos() - Get tos. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the tos field. */ -bool nvme_fabric_options_get_tos(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_tos(const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_traddr() - Set traddr. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_traddr() - Set traddr. + * @p: The &struct libnvme_fabric_options instance to update. * @traddr: Value to assign to the traddr field. */ -void nvme_fabric_options_set_traddr(struct nvme_fabric_options *p, bool traddr); +void libnvme_fabric_options_set_traddr( + struct libnvme_fabric_options *p, + bool traddr); /** - * nvme_fabric_options_get_traddr() - Get traddr. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_traddr() - Get traddr. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the traddr field. */ -bool nvme_fabric_options_get_traddr(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_traddr(const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_transport() - Set transport. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_transport() - Set transport. + * @p: The &struct libnvme_fabric_options instance to update. * @transport: Value to assign to the transport field. */ -void nvme_fabric_options_set_transport( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_transport( + struct libnvme_fabric_options *p, bool transport); /** - * nvme_fabric_options_get_transport() - Get transport. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_transport() - Get transport. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the transport field. */ -bool nvme_fabric_options_get_transport(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_transport( + const struct libnvme_fabric_options *p); /** - * nvme_fabric_options_set_trsvcid() - Set trsvcid. - * @p: The &struct nvme_fabric_options instance to update. + * libnvme_fabric_options_set_trsvcid() - Set trsvcid. + * @p: The &struct libnvme_fabric_options instance to update. * @trsvcid: Value to assign to the trsvcid field. */ -void nvme_fabric_options_set_trsvcid( - struct nvme_fabric_options *p, +void libnvme_fabric_options_set_trsvcid( + struct libnvme_fabric_options *p, bool trsvcid); /** - * nvme_fabric_options_get_trsvcid() - Get trsvcid. - * @p: The &struct nvme_fabric_options instance to query. + * libnvme_fabric_options_get_trsvcid() - Get trsvcid. + * @p: The &struct libnvme_fabric_options instance to query. * * Return: The value of the trsvcid field. */ -bool nvme_fabric_options_get_trsvcid(const struct nvme_fabric_options *p); +bool libnvme_fabric_options_get_trsvcid(const struct libnvme_fabric_options *p); #endif /* _ACCESSORS_H_ */ diff --git a/libnvme/src/nvme/cmds.c b/libnvme/src/nvme/cmds.c index d5de75ca5d..c185d6a1a1 100644 --- a/libnvme/src/nvme/cmds.c +++ b/libnvme/src/nvme/cmds.c @@ -88,7 +88,7 @@ __public int nvme_get_log(struct nvme_transport_handle *hdl, if (hdl->uring_enabled) ret = nvme_submit_admin_passthru_async(hdl, cmd); else - ret = nvme_submit_admin_passthru(hdl, cmd); + ret = libnvme_submit_admin_passthru(hdl, cmd); if (ret) return ret; @@ -239,7 +239,7 @@ __public int nvme_set_etdas(struct nvme_transport_handle *hdl, bool *changed) int err; nvme_init_get_features_host_behavior(&cmd, 0, &da4); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) return err; @@ -251,7 +251,7 @@ __public int nvme_set_etdas(struct nvme_transport_handle *hdl, bool *changed) da4.etdas = 1; nvme_init_set_features_host_behavior(&cmd, false, &da4); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) return err; @@ -266,7 +266,7 @@ __public int nvme_clear_etdas(struct nvme_transport_handle *hdl, bool *changed) int err; nvme_init_get_features_host_behavior(&cmd, 0, &da4); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) return err; @@ -277,7 +277,7 @@ __public int nvme_clear_etdas(struct nvme_transport_handle *hdl, bool *changed) da4.etdas = 0; nvme_init_set_features_host_behavior(&cmd, false, &da4); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) return err; @@ -294,7 +294,7 @@ __public int nvme_get_uuid_list(struct nvme_transport_handle *hdl, memset(&ctrl, 0, sizeof(struct nvme_id_ctrl)); nvme_init_identify_ctrl(&cmd, &ctrl); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_msg(hdl->ctx, LOG_ERR, "ERROR: nvme_identify_ctrl() failed 0x%x\n", err); @@ -304,7 +304,7 @@ __public int nvme_get_uuid_list(struct nvme_transport_handle *hdl, if ((ctrl.ctratt & NVME_CTRL_CTRATT_UUID_LIST) == NVME_CTRL_CTRATT_UUID_LIST) { nvme_init_identify_uuid_list(&cmd, uuid_list); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); } return err; @@ -322,7 +322,7 @@ __public int nvme_get_telemetry_max(struct nvme_transport_handle *hdl, return -ENOMEM; nvme_init_identify_ctrl(&cmd, id_ctrl); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) return err; @@ -541,7 +541,7 @@ __public int nvme_get_ana_log_len(struct nvme_transport_handle *hdl, size_t *ana return -ENOMEM; nvme_init_identify_ctrl(&cmd, ctrl); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (ret) return ret; @@ -562,7 +562,7 @@ __public int nvme_get_logical_block_size(struct nvme_transport_handle *hdl, return -ENOMEM; nvme_init_identify_ns(&cmd, nsid, ns); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (ret) return ret; diff --git a/libnvme/src/nvme/fabrics.c b/libnvme/src/nvme/fabrics.c index 129aa134d3..25cc739ea3 100644 --- a/libnvme/src/nvme/fabrics.c +++ b/libnvme/src/nvme/fabrics.c @@ -191,9 +191,9 @@ __public int nvmf_context_create(struct nvme_global_ctx *ctx, bool (*decide_retry)(struct nvmf_context *fctx, int err, void *user_data), void (*connected)(struct nvmf_context *fctx, - struct nvme_ctrl *c, void *user_data), + struct libnvme_ctrl *c, void *user_data), void (*already_connected)(struct nvmf_context *fctx, - struct nvme_host *host, const char *subsysnqn, + struct libnvme_host *host, const char *subsysnqn, const char *transport, const char *traddr, const char *trsvcid, void *user_data), void *user_data, struct nvmf_context **fctxp) @@ -309,7 +309,7 @@ __public int nvmf_context_set_device(struct nvmf_context *fctx, const char *devi * Not all of these options may actually be supported, * but we retain the old behavior of passing all that might be. */ -static const struct nvme_fabric_options default_supported_options = { +static const struct libnvme_fabric_options default_supported_options = { .ctrl_loss_tmo = true, .data_digest = true, .disable_sqflow = true, @@ -336,10 +336,10 @@ static const struct nvme_fabric_options default_supported_options = { #define MERGE_CFG_OPTION(c, n, o, d) \ if ((c)->o == d) (c)->o = (n)->o -static struct nvme_fabrics_config *merge_config(nvme_ctrl_t c, +static struct nvme_fabrics_config *merge_config(libnvme_ctrl_t c, const struct nvme_fabrics_config *cfg) { - struct nvme_fabrics_config *ctrl_cfg = nvme_ctrl_get_config(c); + struct nvme_fabrics_config *ctrl_cfg = libnvme_ctrl_get_config(c); MERGE_CFG_OPTION(ctrl_cfg, cfg, nr_io_queues, 0); MERGE_CFG_OPTION(ctrl_cfg, cfg, nr_write_queues, 0); @@ -365,9 +365,9 @@ static struct nvme_fabrics_config *merge_config(nvme_ctrl_t c, #define UPDATE_CFG_OPTION(c, n, o, d) \ if ((n)->o != d) (c)->o = (n)->o -__public void nvmf_update_config(nvme_ctrl_t c, const struct nvme_fabrics_config *cfg) +__public void nvmf_update_config(libnvme_ctrl_t c, const struct nvme_fabrics_config *cfg) { - struct nvme_fabrics_config *ctrl_cfg = nvme_ctrl_get_config(c); + struct nvme_fabrics_config *ctrl_cfg = libnvme_ctrl_get_config(c); UPDATE_CFG_OPTION(ctrl_cfg, cfg, nr_io_queues, 0); UPDATE_CFG_OPTION(ctrl_cfg, cfg, nr_write_queues, 0); @@ -656,7 +656,7 @@ static int inet_pton_with_scope(struct nvme_global_ctx *ctx, int af, return ret; } -static bool traddr_is_hostname(struct nvme_global_ctx *ctx, nvme_ctrl_t c) +static bool traddr_is_hostname(struct nvme_global_ctx *ctx, libnvme_ctrl_t c) { struct sockaddr_storage addr; @@ -669,10 +669,10 @@ static bool traddr_is_hostname(struct nvme_global_ctx *ctx, nvme_ctrl_t c) return true; } -static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr) +static int build_options(libnvme_host_t h, libnvme_ctrl_t c, char **argstr) { - struct nvme_fabrics_config *cfg = nvme_ctrl_get_config(c); - const char *transport = nvme_ctrl_get_transport(c); + struct nvme_fabrics_config *cfg = libnvme_ctrl_get_config(c); + const char *transport = libnvme_ctrl_get_transport(c); const char *hostnqn, *hostid, *hostkey, *ctrlkey = NULL; bool discover = false, discovery_nqn = false; struct nvme_global_ctx *ctx = h->ctx; @@ -686,7 +686,7 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr) } if (strncmp(transport, "loop", 4)) { - if (!nvme_ctrl_get_traddr(c)) { + if (!libnvme_ctrl_get_traddr(c)) { nvme_msg(h->ctx, LOG_ERR, "need a address (-a) argument\n"); return -ENVME_CONNECT_AARG; } @@ -694,27 +694,27 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr) /* always specify nqn as first arg - this will init the string */ if (asprintf(argstr, "nqn=%s", - nvme_ctrl_get_subsysnqn(c)) < 0) { + libnvme_ctrl_get_subsysnqn(c)) < 0) { return -ENOMEM; } - if (!strcmp(nvme_ctrl_get_subsysnqn(c), NVME_DISC_SUBSYS_NAME)) { - nvme_ctrl_set_discovery_ctrl(c, true); - nvme_ctrl_set_unique_discovery_ctrl(c, false); + if (!strcmp(libnvme_ctrl_get_subsysnqn(c), NVME_DISC_SUBSYS_NAME)) { + libnvme_ctrl_set_discovery_ctrl(c, true); + libnvme_ctrl_set_unique_discovery_ctrl(c, false); discovery_nqn = true; } - if (nvme_ctrl_get_discovery_ctrl(c)) + if (libnvme_ctrl_get_discovery_ctrl(c)) discover = true; - hostnqn = nvme_host_get_hostnqn(h); - hostid = nvme_host_get_hostid(h); - hostkey = nvme_host_get_dhchap_host_key(h); + hostnqn = libnvme_host_get_hostnqn(h); + hostid = libnvme_host_get_hostid(h); + hostkey = libnvme_host_get_dhchap_host_key(h); if (!hostkey) - hostkey = nvme_ctrl_get_dhchap_host_key(c); + hostkey = libnvme_ctrl_get_dhchap_host_key(c); if (hostkey) - ctrlkey = nvme_ctrl_get_dhchap_ctrl_key(c); + ctrlkey = libnvme_ctrl_get_dhchap_ctrl_key(c); if (cfg->tls && cfg->concat) { nvme_msg(h->ctx, LOG_ERR, "cannot specify --tls and --concat together\n"); @@ -742,13 +742,13 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr) if (add_argument(ctx, argstr, transport, transport) || add_argument(ctx, argstr, traddr, - nvme_ctrl_get_traddr(c)) || + libnvme_ctrl_get_traddr(c)) || add_argument(ctx, argstr, host_traddr, - nvme_ctrl_get_host_traddr(c)) || + libnvme_ctrl_get_host_traddr(c)) || add_argument(ctx, argstr, host_iface, - nvme_ctrl_get_host_iface(c)) || + libnvme_ctrl_get_host_iface(c)) || add_argument(ctx, argstr, trsvcid, - nvme_ctrl_get_trsvcid(c)) || + libnvme_ctrl_get_trsvcid(c)) || (hostnqn && add_argument(ctx, argstr, hostnqn, hostnqn)) || (hostid && add_argument(ctx, argstr, hostid, hostid)) || (discover && !discovery_nqn && @@ -825,7 +825,7 @@ static int __nvmf_supported_options(struct nvme_global_ctx *ctx) fd = open(nvmf_dev, O_RDONLY); if (fd < 0) { nvme_msg(ctx, LOG_ERR, "Failed to open %s: %s\n", - nvmf_dev, nvme_strerror(errno)); + nvmf_dev, libnvme_strerror(errno)); return -ENVME_CONNECT_OPEN; } @@ -845,7 +845,7 @@ static int __nvmf_supported_options(struct nvme_global_ctx *ctx) } nvme_msg(ctx, LOG_ERR, "Failed to read from %s: %s\n", - nvmf_dev, nvme_strerror(errno)); + nvmf_dev, libnvme_strerror(errno)); return -ENVME_CONNECT_READ; } @@ -906,7 +906,7 @@ static int __nvmf_add_ctrl(struct nvme_global_ctx *ctx, const char *argstr) fd = open(nvmf_dev, O_RDWR); if (fd < 0) { nvme_msg(ctx, LOG_ERR, "Failed to open %s: %s\n", - nvmf_dev, nvme_strerror(errno)); + nvmf_dev, libnvme_strerror(errno)); return -ENVME_CONNECT_OPEN; } @@ -915,7 +915,7 @@ static int __nvmf_add_ctrl(struct nvme_global_ctx *ctx, const char *argstr) ret = write(fd, argstr, len); if (ret != len) { nvme_msg(ctx, LOG_INFO, "Failed to write to %s: %s\n", - nvmf_dev, nvme_strerror(errno)); + nvmf_dev, libnvme_strerror(errno)); switch (errno) { case EALREADY: return -ENVME_CONNECT_ALREADY; @@ -942,7 +942,7 @@ static int __nvmf_add_ctrl(struct nvme_global_ctx *ctx, const char *argstr) len = read(fd, buf, sizeof(buf) - 1); if (len < 0) { nvme_msg(ctx, LOG_ERR, "Failed to read from %s: %s\n", - nvmf_dev, nvme_strerror(errno)); + nvmf_dev, libnvme_strerror(errno)); return -ENVME_CONNECT_READ; } nvme_msg(ctx, LOG_DEBUG, "connect ctrl, response '%.*s'\n", @@ -960,34 +960,34 @@ static int __nvmf_add_ctrl(struct nvme_global_ctx *ctx, const char *argstr) return -ENVME_CONNECT_PARSE; } -static const char *lookup_context(struct nvme_global_ctx *ctx, nvme_ctrl_t c) +static const char *lookup_context(struct nvme_global_ctx *ctx, libnvme_ctrl_t c) { - nvme_host_t h; - nvme_subsystem_t s; + libnvme_host_t h; + libnvme_subsystem_t s; - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { struct nvmf_context fctx = { - .transport = nvme_ctrl_get_transport(c), - .traddr = nvme_ctrl_get_traddr(c), + .transport = libnvme_ctrl_get_transport(c), + .traddr = libnvme_ctrl_get_traddr(c), .host_traddr = NULL, .host_iface = NULL, - .trsvcid = nvme_ctrl_get_trsvcid(c), + .trsvcid = libnvme_ctrl_get_trsvcid(c), .subsysnqn = NULL, }; if (nvme_ctrl_find(s, &fctx)) - return nvme_subsystem_get_application(s); + return libnvme_subsystem_get_application(s); } } return NULL; } -__public int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, +__public int nvmf_add_ctrl(libnvme_host_t h, libnvme_ctrl_t c, const struct nvme_fabrics_config *cfg) { - nvme_subsystem_t s; + libnvme_subsystem_t s; const char *root_app, *app; _cleanup_free_ char *argstr = NULL; int ret; @@ -996,15 +996,15 @@ __public int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, cfg = merge_config(c, cfg); /* apply configuration from config file (JSON) */ - s = nvme_lookup_subsystem(h, NULL, nvme_ctrl_get_subsysnqn(c)); + s = nvme_lookup_subsystem(h, NULL, libnvme_ctrl_get_subsysnqn(c)); if (s) { - nvme_ctrl_t fc; + libnvme_ctrl_t fc; struct nvmf_context fctx = { - .transport = nvme_ctrl_get_transport(c), - .traddr = nvme_ctrl_get_traddr(c), - .host_traddr = nvme_ctrl_get_host_traddr(c), - .host_iface = nvme_ctrl_get_trsvcid(c), - .trsvcid = nvme_ctrl_get_trsvcid(c), + .transport = libnvme_ctrl_get_transport(c), + .traddr = libnvme_ctrl_get_traddr(c), + .host_traddr = libnvme_ctrl_get_host_traddr(c), + .host_iface = libnvme_ctrl_get_trsvcid(c), + .trsvcid = libnvme_ctrl_get_trsvcid(c), .subsysnqn = NULL, }; @@ -1012,35 +1012,35 @@ __public int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, if (fc) { const char *key; - cfg = merge_config(c, nvme_ctrl_get_config(fc)); + cfg = merge_config(c, libnvme_ctrl_get_config(fc)); /* * An authentication key might already been set * in @cfg, so ensure to update @c with the correct * controller key. */ - key = nvme_ctrl_get_dhchap_host_key(fc); + key = libnvme_ctrl_get_dhchap_host_key(fc); if (key) - nvme_ctrl_set_dhchap_host_key(c, key); - key = nvme_ctrl_get_dhchap_ctrl_key(fc); + libnvme_ctrl_set_dhchap_host_key(c, key); + key = libnvme_ctrl_get_dhchap_ctrl_key(fc); if (key) - nvme_ctrl_set_dhchap_ctrl_key(c, key); - key = nvme_ctrl_get_keyring(fc); + libnvme_ctrl_set_dhchap_ctrl_key(c, key); + key = libnvme_ctrl_get_keyring(fc); if (key) - nvme_ctrl_set_keyring(c, key); - key = nvme_ctrl_get_tls_key_identity(fc); + libnvme_ctrl_set_keyring(c, key); + key = libnvme_ctrl_get_tls_key_identity(fc); if (key) - nvme_ctrl_set_tls_key_identity(c, key); - key = nvme_ctrl_get_tls_key(fc); + libnvme_ctrl_set_tls_key_identity(c, key); + key = libnvme_ctrl_get_tls_key(fc); if (key) - nvme_ctrl_set_tls_key(c, key); + libnvme_ctrl_set_tls_key(c, key); } } - root_app = nvme_get_application(h->ctx); + root_app = libnvme_get_application(h->ctx); if (root_app) { - app = nvme_subsystem_get_application(s); - if (!app && nvme_ctrl_get_discovery_ctrl(c)) + app = libnvme_subsystem_get_application(s); + if (!app && libnvme_ctrl_get_discovery_ctrl(c)) app = lookup_context(h->ctx, c); /* @@ -1051,12 +1051,12 @@ __public int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, */ if (app && strcmp(app, root_app)) { nvme_msg(h->ctx, LOG_INFO, "skip %s, not managed by %s\n", - nvme_subsystem_get_subsysnqn(s), root_app); + libnvme_subsystem_get_subsysnqn(s), root_app); return -ENVME_CONNECT_IGNORED; } } - nvme_ctrl_set_discovered(c, true); + libnvme_ctrl_set_discovered(c, true); if (traddr_is_hostname(h->ctx, c)) { char *traddr = c->traddr; @@ -1076,11 +1076,11 @@ __public int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, return ret; nvme_msg(h->ctx, LOG_INFO, "nvme%d: %s connected\n", ret, - nvme_ctrl_get_subsysnqn(c)); - return nvme_init_ctrl(h, c, ret); + libnvme_ctrl_get_subsysnqn(c)); + return libnvme_init_ctrl(h, c, ret); } -__public int nvmf_connect_ctrl(nvme_ctrl_t c) +__public int nvmf_connect_ctrl(libnvme_ctrl_t c) { _cleanup_free_ char *argstr = NULL; int ret; @@ -1096,13 +1096,13 @@ __public int nvmf_connect_ctrl(nvme_ctrl_t c) return 0; } -static int nvmf_connect_disc_entry(nvme_host_t h, +static int nvmf_connect_disc_entry(libnvme_host_t h, struct nvmf_disc_log_entry *e, struct nvmf_context *fctx, const struct nvme_fabrics_config *cfg, - bool *discover, nvme_ctrl_t *cp) + bool *discover, libnvme_ctrl_t *cp) { - nvme_ctrl_t c; + libnvme_ctrl_t c; int ret; switch (e->trtype) { @@ -1159,15 +1159,15 @@ static int nvmf_connect_disc_entry(nvme_host_t h, switch (e->subtype) { case NVME_NQN_CURR: - nvme_ctrl_set_discovered(c, true); - nvme_ctrl_set_unique_discovery_ctrl(c, + libnvme_ctrl_set_discovered(c, true); + libnvme_ctrl_set_unique_discovery_ctrl(c, strcmp(e->subnqn, NVME_DISC_SUBSYS_NAME)); break; case NVME_NQN_DISC: if (discover) *discover = true; - nvme_ctrl_set_discovery_ctrl(c, true); - nvme_ctrl_set_unique_discovery_ctrl(c, + libnvme_ctrl_set_discovery_ctrl(c, true); + libnvme_ctrl_set_unique_discovery_ctrl(c, strcmp(e->subnqn, NVME_DISC_SUBSYS_NAME)); break; default: @@ -1175,13 +1175,13 @@ static int nvmf_connect_disc_entry(nvme_host_t h, e->subtype); fallthrough; case NVME_NQN_NVME: - nvme_ctrl_set_discovery_ctrl(c, false); - nvme_ctrl_set_unique_discovery_ctrl(c, false); + libnvme_ctrl_set_discovery_ctrl(c, false); + libnvme_ctrl_set_unique_discovery_ctrl(c, false); break; } - if (nvme_ctrl_get_discovered(c)) { - nvme_free_ctrl(c); + if (libnvme_ctrl_get_discovered(c)) { + libnvme_free_ctrl(c); return -EAGAIN; } @@ -1219,7 +1219,7 @@ static int nvmf_connect_disc_entry(nvme_host_t h, return 0; } } - nvme_free_ctrl(c); + libnvme_free_ctrl(c); return -ENOENT; } @@ -1237,9 +1237,9 @@ static int nvme_discovery_log(const struct nvme_get_discovery_args *args, struct nvmf_discovery_log *log; int retries = 0; int err; - const char *name = nvme_ctrl_get_name(args->c); + const char *name = libnvme_ctrl_get_name(args->c); uint64_t genctr, numrec; - struct nvme_transport_handle *hdl = nvme_ctrl_get_transport_handle(args->c); + struct nvme_transport_handle *hdl = libnvme_ctrl_get_transport_handle(args->c); struct nvme_passthru_cmd cmd; log = __nvme_alloc(sizeof(*log)); @@ -1347,7 +1347,7 @@ static void sanitize_discovery_log_entry(struct nvmf_disc_log_entry *e) } } -__public int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp, +__public int nvmf_get_discovery_log(libnvme_ctrl_t c, struct nvmf_discovery_log **logp, int max_retries) { struct nvme_get_discovery_args args = { @@ -1416,7 +1416,7 @@ static __u32 nvmf_get_tel(const char *hostsymname) * @tsas: Transport Specific Address Subtype for the address being * registered. */ -static void nvmf_fill_die(struct nvmf_ext_die *die, struct nvme_host *h, +static void nvmf_fill_die(struct nvmf_ext_die *die, struct libnvme_host *h, __u32 tel, __u8 trtype, __u8 adrfam, const char *reg_addr, union nvmf_tsas *tsas) { @@ -1439,7 +1439,7 @@ static void nvmf_fill_die(struct nvmf_ext_die *die, struct nvme_host *h, exat = die->exat; exat->exattype = cpu_to_le16(NVMF_EXATTYPE_HOSTID); exat->exatlen = cpu_to_le16(nvmf_exat_len(NVME_UUID_LEN)); - nvme_uuid_from_string(h->hostid, exat->exatval); + libnvme_uuid_from_string(h->hostid, exat->exatval); /* Extended Attribute for the Symbolic Name (optional) */ symname_len = h->hostsymname ? strlen(h->hostsymname) : 0; @@ -1480,13 +1480,13 @@ static void nvmf_fill_die(struct nvmf_ext_die *die, struct nvme_host *h, * * Return: 0 on success; on failure -1 is returned and errno is set */ -static int nvmf_dim(nvme_ctrl_t c, enum nvmf_dim_tas tas, __u8 trtype, +static int nvmf_dim(libnvme_ctrl_t c, enum nvmf_dim_tas tas, __u8 trtype, __u8 adrfam, const char *reg_addr, union nvmf_tsas *tsas, __u32 *result) { struct nvme_global_ctx *ctx = c->s && c->s->h ? c->s->h->ctx : NULL; _cleanup_free_ struct nvmf_dim_data *dim = NULL; - struct nvme_transport_handle *hdl = nvme_ctrl_get_transport_handle(c); + struct nvme_transport_handle *hdl = libnvme_ctrl_get_transport_handle(c); struct nvme_passthru_cmd cmd; struct nvmf_ext_die *die; __u32 tdl; @@ -1549,7 +1549,7 @@ static int nvmf_dim(nvme_ctrl_t c, enum nvmf_dim_tas tas, __u8 trtype, ret = get_entity_name(dim->ename, sizeof(dim->ename)); if (ret < 0) nvme_msg(ctx, LOG_INFO, "%s: Failed to retrieve ENAME. %s.\n", - c->name, nvme_strerror(-ret)); + c->name, libnvme_strerror(-ret)); else if (ret == 0) nvme_msg(ctx, LOG_INFO, "%s: Failed to retrieve ENAME.\n", c->name); @@ -1562,7 +1562,7 @@ static int nvmf_dim(nvme_ctrl_t c, enum nvmf_dim_tas tas, __u8 trtype, nvmf_fill_die(die, c->s->h, tel, trtype, adrfam, reg_addr, tsas); nvme_init_dim_send(&cmd, tas, dim, tdl); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /** @@ -1579,7 +1579,7 @@ static int nvmf_dim(nvme_ctrl_t c, enum nvmf_dim_tas tas, __u8 trtype, * Return: The address family of the source address associated with the * socket connected to the DC. */ -static __u8 nvme_get_adrfam(nvme_ctrl_t c) +static __u8 nvme_get_adrfam(libnvme_ctrl_t c) { struct sockaddr_storage addr; __u8 adrfam = NVMF_ADDR_FAMILY_IP4; @@ -1614,7 +1614,7 @@ static const char *dctype_str[] = { * sysfs. We must get them directly from the controller by performing an * identify command. */ -static int nvme_fetch_cntrltype_dctype_from_id(nvme_ctrl_t c) +static int nvme_fetch_cntrltype_dctype_from_id(libnvme_ctrl_t c) { _cleanup_free_ struct nvme_id_ctrl *id = NULL; int ret; @@ -1623,7 +1623,7 @@ static int nvme_fetch_cntrltype_dctype_from_id(nvme_ctrl_t c) if (!id) return -ENOMEM; - ret = nvme_ctrl_identify(c, id); + ret = libnvme_ctrl_identify(c, id); if (ret) return ret; @@ -1643,7 +1643,7 @@ static int nvme_fetch_cntrltype_dctype_from_id(nvme_ctrl_t c) return 0; } -__public bool nvmf_is_registration_supported(nvme_ctrl_t c) +__public bool nvmf_is_registration_supported(libnvme_ctrl_t c) { if (!c->cntrltype || !c->dctype) if (nvme_fetch_cntrltype_dctype_from_id(c)) @@ -1652,7 +1652,7 @@ __public bool nvmf_is_registration_supported(nvme_ctrl_t c) return !strcmp(c->dctype, "ddc") || !strcmp(c->dctype, "cdc"); } -__public int nvmf_register_ctrl(nvme_ctrl_t c, enum nvmf_dim_tas tas, __u32 *result) +__public int nvmf_register_ctrl(libnvme_ctrl_t c, enum nvmf_dim_tas tas, __u32 *result) { if (!nvmf_is_registration_supported(c)) return -ENOTSUP; @@ -1693,7 +1693,7 @@ static char *unescape_uri(const char *str, int len) return dst; } -__public int nvme_parse_uri(const char *str, struct nvme_fabrics_uri **urip) +__public int libnvme_parse_uri(const char *str, struct nvme_fabrics_uri **urip) { struct nvme_fabrics_uri *uri; _cleanup_free_ char *scheme = NULL; @@ -1808,12 +1808,12 @@ __public void nvmf_free_uri(struct nvme_fabrics_uri *uri) free(uri); } -static nvme_ctrl_t lookup_ctrl(nvme_host_t h, struct nvmf_context *fctx) +static libnvme_ctrl_t lookup_ctrl(libnvme_host_t h, struct nvmf_context *fctx) { - nvme_subsystem_t s; - nvme_ctrl_t c; + libnvme_subsystem_t s; + libnvme_ctrl_t c; - nvme_for_each_subsystem(h, s) { + libnvme_for_each_subsystem(h, s) { c = nvme_ctrl_find(s, fctx); if (c) return c; @@ -1823,14 +1823,14 @@ static nvme_ctrl_t lookup_ctrl(nvme_host_t h, struct nvmf_context *fctx) } static int lookup_host(struct nvme_global_ctx *ctx, - struct nvmf_context *fctx, struct nvme_host **host) + struct nvmf_context *fctx, struct libnvme_host **host) { _cleanup_free_ char *hnqn = NULL; _cleanup_free_ char *hid = NULL; - struct nvme_host *h; + struct libnvme_host *h; int err; - err = nvme_host_get_ids(ctx, fctx->hostnqn, fctx->hostid, &hnqn, &hid); + err = libnvme_host_get_ids(ctx, fctx->hostnqn, fctx->hostid, &hnqn, &hid); if (err < 0) return err; @@ -1843,11 +1843,11 @@ static int lookup_host(struct nvme_global_ctx *ctx, return 0; } -static int setup_connection(struct nvmf_context *fctx, struct nvme_host *h, +static int setup_connection(struct nvmf_context *fctx, struct libnvme_host *h, bool discovery) { if (fctx->hostkey) - nvme_host_set_dhchap_host_key(h, fctx->hostkey); + libnvme_host_set_dhchap_host_key(h, fctx->hostkey); if (!fctx->trsvcid) fctx->trsvcid = nvmf_get_default_trsvcid(fctx->transport, @@ -1874,7 +1874,7 @@ static int set_discovery_kato(struct nvmf_context *fctx, static void nvme_parse_tls_args(const char *keyring, const char *tls_key, const char *tls_key_identity, - struct nvme_fabrics_config *cfg, nvme_ctrl_t c) + struct nvme_fabrics_config *cfg, libnvme_ctrl_t c) { if (keyring) { char *endptr; @@ -1883,11 +1883,11 @@ static void nvme_parse_tls_args(const char *keyring, const char *tls_key, if (endptr != keyring) cfg->keyring = id; else - nvme_ctrl_set_keyring(c, keyring); + libnvme_ctrl_set_keyring(c, keyring); } if (tls_key_identity) - nvme_ctrl_set_tls_key_identity(c, tls_key_identity); + libnvme_ctrl_set_tls_key_identity(c, tls_key_identity); if (tls_key) { char *endptr; @@ -1896,18 +1896,18 @@ static void nvme_parse_tls_args(const char *keyring, const char *tls_key, if (endptr != tls_key) cfg->tls_key = id; else - nvme_ctrl_set_tls_key(c, tls_key); + libnvme_ctrl_set_tls_key(c, tls_key); } } static int _nvmf_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fctx, bool connect, - struct nvme_ctrl *c) + struct libnvme_ctrl *c) { _cleanup_free_ struct nvmf_discovery_log *log = NULL; - nvme_subsystem_t s = nvme_ctrl_get_subsystem(c); - nvme_host_t h = nvme_subsystem_get_host(s); + libnvme_subsystem_t s = libnvme_ctrl_get_subsystem(c); + libnvme_host_t h = libnvme_subsystem_get_host(s); uint64_t numrec; int err; @@ -1922,7 +1922,7 @@ static int _nvmf_discovery(struct nvme_global_ctx *ctx, err = nvmf_get_discovery_wargs(&args, &log); if (err) { nvme_msg(ctx, LOG_ERR, "failed to get discovery log: %s\n", - nvme_strerror(err)); + libnvme_strerror(err)); return err; } @@ -1936,10 +1936,10 @@ static int _nvmf_discovery(struct nvme_global_ctx *ctx, for (int i = 0; i < numrec; i++) { struct nvmf_disc_log_entry *e = &log->entries[i]; - nvme_ctrl_t cl; + libnvme_ctrl_t cl; bool discover = false; bool disconnect; - nvme_ctrl_t child = { 0 }; + libnvme_ctrl_t child = { 0 }; int tmo = fctx->cfg->keep_alive_tmo; struct nvmf_context nfctx = *fctx; @@ -1951,11 +1951,11 @@ static int _nvmf_discovery(struct nvme_global_ctx *ctx, /* Already connected ? */ cl = lookup_ctrl(h, &nfctx); - if (cl && nvme_ctrl_get_name(cl)) + if (cl && libnvme_ctrl_get_name(cl)) continue; /* Skip connect if the transport types don't match */ - if (strcmp(nvme_ctrl_get_transport(c), + if (strcmp(libnvme_ctrl_get_transport(c), nfctx.transport)) continue; @@ -2002,8 +2002,8 @@ static int _nvmf_discovery(struct nvme_global_ctx *ctx, _nvmf_discovery(ctx, &nfctx, true, child); if (child && disconnect) { - nvme_disconnect_ctrl(child); - nvme_free_ctrl(child); + libnvme_disconnect_ctrl(child); + libnvme_free_ctrl(child); } } else if (err == -ENVME_CONNECT_ALREADY) { struct nvmf_disc_log_entry *e = &log->entries[i]; @@ -2036,16 +2036,16 @@ __public const char *nvmf_get_default_trsvcid(const char *transport, return NULL; } -static bool is_persistent_discovery_ctrl(nvme_host_t h, nvme_ctrl_t c) +static bool is_persistent_discovery_ctrl(libnvme_host_t h, libnvme_ctrl_t c) { - if (nvme_host_is_pdc_enabled(h, DEFAULT_PDC_ENABLED)) - return nvme_ctrl_get_unique_discovery_ctrl(c); + if (libnvme_host_is_pdc_enabled(h, DEFAULT_PDC_ENABLED)) + return libnvme_ctrl_get_unique_discovery_ctrl(c); return false; } -static int nvme_add_ctrl(struct nvmf_context *fctx, - struct nvme_host *h, struct nvme_ctrl *c, +static int libnvme_add_ctrl(struct nvmf_context *fctx, + struct libnvme_host *h, struct libnvme_ctrl *c, struct nvme_fabrics_config *cfg) { int err; @@ -2061,31 +2061,31 @@ static int nvme_add_ctrl(struct nvmf_context *fctx, } static int __create_discovery_ctrl(struct nvme_global_ctx *ctx, - struct nvmf_context *fctx, nvme_host_t h, - struct nvme_fabrics_config *cfg, struct nvme_ctrl **ctrl) + struct nvmf_context *fctx, libnvme_host_t h, + struct nvme_fabrics_config *cfg, struct libnvme_ctrl **ctrl) { - nvme_ctrl_t c; + libnvme_ctrl_t c; int tmo, ret; ret = _nvme_create_ctrl(ctx, fctx, &c); if (ret) return ret; - nvme_ctrl_set_discovery_ctrl(c, true); - nvme_ctrl_set_unique_discovery_ctrl(c, + libnvme_ctrl_set_discovery_ctrl(c, true); + libnvme_ctrl_set_unique_discovery_ctrl(c, strcmp(fctx->subsysnqn, NVME_DISC_SUBSYS_NAME)); tmo = set_discovery_kato(fctx, cfg); - if (nvme_ctrl_get_unique_discovery_ctrl(c) && fctx->hostkey) { - nvme_ctrl_set_dhchap_host_key(c, fctx->hostkey); + if (libnvme_ctrl_get_unique_discovery_ctrl(c) && fctx->hostkey) { + libnvme_ctrl_set_dhchap_host_key(c, fctx->hostkey); if (fctx->ctrlkey) - nvme_ctrl_set_dhchap_ctrl_key(c, fctx->ctrlkey); + libnvme_ctrl_set_dhchap_ctrl_key(c, fctx->ctrlkey); } - ret = nvme_add_ctrl(fctx, h, c, cfg); + ret = libnvme_add_ctrl(fctx, h, c, cfg); cfg->keep_alive_tmo = tmo; if (ret) { - nvme_free_ctrl(c); + libnvme_free_ctrl(c); return ret; } @@ -2094,43 +2094,43 @@ static int __create_discovery_ctrl(struct nvme_global_ctx *ctx, } static int nvmf_create_discovery_ctrl(struct nvme_global_ctx *ctx, - struct nvmf_context *fctx, nvme_host_t h, + struct nvmf_context *fctx, libnvme_host_t h, struct nvme_fabrics_config *cfg, - struct nvme_ctrl **ctrl) + struct libnvme_ctrl **ctrl) { _cleanup_free_ struct nvme_id_ctrl *id = NULL; - struct nvme_ctrl *c; + struct libnvme_ctrl *c; int ret; ret = __create_discovery_ctrl(ctx, fctx, h, cfg, &c); if (ret) return ret; - if (nvme_ctrl_get_unique_discovery_ctrl(c)) { + if (libnvme_ctrl_get_unique_discovery_ctrl(c)) { *ctrl = c; return 0; } id = __nvme_alloc(sizeof(*id)); if (!id) { - nvme_free_ctrl(c); + libnvme_free_ctrl(c); return -ENOMEM; } - ret = nvme_open(ctx, c->name, &c->hdl); + ret = libnvme_open(ctx, c->name, &c->hdl); if (ret) { nvme_msg(ctx, LOG_ERR, "failed to open %s\n", c->name); return ret; } /* Find out the name of discovery controller */ - ret = nvme_ctrl_identify(c, id); + ret = libnvme_ctrl_identify(c, id); if (ret) { nvme_msg(ctx, LOG_ERR, "failed to identify controller, error %s\n", - nvme_strerror(-ret)); - nvme_disconnect_ctrl(c); - nvme_free_ctrl(c); + libnvme_strerror(-ret)); + libnvme_disconnect_ctrl(c); + libnvme_free_ctrl(c); return ret; } @@ -2143,8 +2143,8 @@ static int nvmf_create_discovery_ctrl(struct nvme_global_ctx *ctx, * The subsysnqn is not the well-known name. Prefer the unique * subsysnqn over the well-known one. */ - nvme_disconnect_ctrl(c); - nvme_free_ctrl(c); + libnvme_disconnect_ctrl(c); + libnvme_free_ctrl(c); fctx->subsysnqn = id->subnqn; ret = __create_discovery_ctrl(ctx, fctx, h, cfg, &c); @@ -2156,18 +2156,18 @@ static int nvmf_create_discovery_ctrl(struct nvme_global_ctx *ctx, } int _discovery_config_json(struct nvme_global_ctx *ctx, - struct nvmf_context *fctx, nvme_host_t h, nvme_ctrl_t c, + struct nvmf_context *fctx, libnvme_host_t h, libnvme_ctrl_t c, bool connect, bool force) { struct nvmf_context nfctx = *fctx; struct nvme_fabrics_config cfg; - nvme_ctrl_t cn; + libnvme_ctrl_t cn; int ret = 0; - nfctx.transport = nvme_ctrl_get_transport(c); - nfctx.traddr = nvme_ctrl_get_traddr(c); - nfctx.host_traddr = nvme_ctrl_get_host_traddr(c); - nfctx.host_iface = nvme_ctrl_get_host_iface(c); + nfctx.transport = libnvme_ctrl_get_transport(c); + nfctx.traddr = libnvme_ctrl_get_traddr(c); + nfctx.host_traddr = libnvme_ctrl_get_host_traddr(c); + nfctx.host_iface = libnvme_ctrl_get_host_iface(c); if (!nfctx.transport && !nfctx.traddr) return 0; @@ -2197,17 +2197,17 @@ int _discovery_config_json(struct nvme_global_ctx *ctx, } } - nfctx.trsvcid = nvme_ctrl_get_trsvcid(c); + nfctx.trsvcid = libnvme_ctrl_get_trsvcid(c); if (!nfctx.trsvcid || !strcmp(nfctx.trsvcid, "")) nfctx.trsvcid = nvmf_get_default_trsvcid(nfctx.transport, true); if (force) - nfctx.subsysnqn = nvme_ctrl_get_subsysnqn(c); + nfctx.subsysnqn = libnvme_ctrl_get_subsysnqn(c); else nfctx.subsysnqn = NVME_DISC_SUBSYS_NAME; - if (nvme_ctrl_get_persistent(c)) + if (libnvme_ctrl_get_persistent(c)) nfctx.persistent = true; memcpy(&cfg, fctx->cfg, sizeof(cfg)); @@ -2227,8 +2227,8 @@ int _discovery_config_json(struct nvme_global_ctx *ctx, _nvmf_discovery(ctx, &nfctx, connect, cn); if (!(fctx->persistent || is_persistent_discovery_ctrl(h, cn))) - ret = nvme_disconnect_ctrl(cn); - nvme_free_ctrl(cn); + ret = libnvme_disconnect_ctrl(cn); + libnvme_free_ctrl(cn); return ret; } @@ -2237,9 +2237,9 @@ __public int nvmf_discovery_config_json(struct nvme_global_ctx *ctx, struct nvmf_context *fctx, bool connect, bool force) { const char *hnqn, *hid; - struct nvme_subsystem *s; - struct nvme_host *h; - struct nvme_ctrl *c; + struct libnvme_subsystem *s; + struct libnvme_host *h; + struct libnvme_ctrl *c; int ret = 0, err; err = lookup_host(ctx, fctx, &h); @@ -2250,26 +2250,26 @@ __public int nvmf_discovery_config_json(struct nvme_global_ctx *ctx, if (err) return err; - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - hnqn = nvme_host_get_hostnqn(h); + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + hnqn = libnvme_host_get_hostnqn(h); if (fctx->hostnqn && hnqn && strcmp(fctx->hostnqn, hnqn)) continue; - hid = nvme_host_get_hostid(h); + hid = libnvme_host_get_hostid(h); if (fctx->hostid && hid && strcmp(fctx->hostid, hid)) continue; - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_subsystem_for_each_ctrl(s, c) { err = _discovery_config_json(ctx, fctx, h, c, connect, force); if (err) { nvme_msg(ctx, LOG_ERR, "failed to connect to hostnqn=%s,nqn=%s,%s\n", - nvme_host_get_hostnqn(h), - nvme_subsystem_get_name(s), - nvme_ctrl_get_traddr(c)); + libnvme_host_get_hostnqn(h), + libnvme_subsystem_get_name(s), + libnvme_ctrl_get_traddr(c)); if (!ret) ret = err; @@ -2286,9 +2286,9 @@ __public int nvmf_connect_config_json(struct nvme_global_ctx *ctx, { const char *hnqn, *hid; const char *transport; - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c, _c; + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c, _c; int ret = 0, err; err = lookup_host(ctx, fctx, &h); @@ -2299,19 +2299,19 @@ __public int nvmf_connect_config_json(struct nvme_global_ctx *ctx, if (err) return err; - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - hnqn = nvme_host_get_hostnqn(h); + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + hnqn = libnvme_host_get_hostnqn(h); if (fctx->hostnqn && hnqn && strcmp(fctx->hostnqn, hnqn)) continue; - hid = nvme_host_get_hostid(h); + hid = libnvme_host_get_hostid(h); if (fctx->hostid && hid && strcmp(fctx->hostid, hid)) continue; - nvme_subsystem_for_each_ctrl_safe(s, c, _c) { - transport = nvme_ctrl_get_transport(c); + libnvme_subsystem_for_each_ctrl_safe(s, c, _c) { + transport = libnvme_ctrl_get_transport(c); /* ignore none fabric transports */ if (strcmp(transport, "tcp") && @@ -2326,9 +2326,9 @@ __public int nvmf_connect_config_json(struct nvme_global_ctx *ctx, nvme_msg(ctx, LOG_ERR, "failed to connect to hostnqn=%s,nqn=%s,%s\n", - nvme_host_get_hostnqn(h), - nvme_subsystem_get_name(s), - nvme_ctrl_get_traddr(c)); + libnvme_host_get_hostnqn(h), + libnvme_subsystem_get_name(s), + libnvme_ctrl_get_traddr(c)); if (!ret) ret = err; @@ -2343,8 +2343,8 @@ __public int nvmf_connect_config_json(struct nvme_global_ctx *ctx, __public int nvmf_discovery_config_file(struct nvme_global_ctx *ctx, struct nvmf_context *fctx, bool connect, bool force) { - struct nvme_host *h; - struct nvme_ctrl *c; + struct libnvme_host *h; + struct libnvme_ctrl *c; int err; err = lookup_host(ctx, fctx, &h); @@ -2382,8 +2382,8 @@ __public int nvmf_discovery_config_file(struct nvme_global_ctx *ctx, _nvmf_discovery(ctx, &nfctx, connect, c); if (!(nfctx.persistent || is_persistent_discovery_ctrl(h, c))) - err = nvme_disconnect_ctrl(c); - nvme_free_ctrl(c); + err = libnvme_disconnect_ctrl(c); + libnvme_free_ctrl(c); } while (!err); fctx->parser_cleanup(fctx, fctx->user_data); @@ -2399,14 +2399,14 @@ __public int nvmf_config_modify(struct nvme_global_ctx *ctx, { _cleanup_free_ char *hnqn = NULL; _cleanup_free_ char *hid = NULL; - struct nvme_host *h; - struct nvme_subsystem *s; - struct nvme_ctrl *c; + struct libnvme_host *h; + struct libnvme_subsystem *s; + struct libnvme_ctrl *c; if (!fctx->hostnqn) - fctx->hostnqn = hnqn = nvme_read_hostnqn(); + fctx->hostnqn = hnqn = libnvme_read_hostnqn(); if (!fctx->hostid && hnqn) - fctx->hostid = hid = nvme_read_hostid(); + fctx->hostid = hid = libnvme_read_hostid(); h = nvme_lookup_host(ctx, fctx->hostnqn, fctx->hostid); if (!h) { @@ -2416,7 +2416,7 @@ __public int nvmf_config_modify(struct nvme_global_ctx *ctx, } if (fctx->hostkey) - nvme_host_set_dhchap_host_key(h, fctx->hostkey); + libnvme_host_set_dhchap_host_key(h, fctx->hostkey); s = nvme_lookup_subsystem(h, NULL, fctx->subsysnqn); if (!s) { @@ -2431,7 +2431,7 @@ __public int nvmf_config_modify(struct nvme_global_ctx *ctx, return -ENODEV; } if (fctx->ctrlkey) - nvme_ctrl_set_dhchap_ctrl_key(c, fctx->ctrlkey); + libnvme_ctrl_set_dhchap_ctrl_key(c, fctx->ctrlkey); nvme_parse_tls_args(fctx->keyring, fctx->tls_key, fctx->tls_key_identity, fctx->cfg, c); @@ -2465,7 +2465,7 @@ __public int nvmf_nbft_read_files(struct nvme_global_ctx *ctx, char *path, snprintf(filename, sizeof(filename), "%s/%s", path, dent[i]->d_name); - ret = nvme_read_nbft(ctx, &nbft, filename); + ret = libnvme_read_nbft(ctx, &nbft, filename); if (!ret) { struct nbft_file_entry *new; @@ -2492,7 +2492,7 @@ __public void nvmf_nbft_free(struct nvme_global_ctx *ctx, struct nbft_file_entry while (head) { struct nbft_file_entry *next = head->next; - nvme_free_nbft(ctx, head->nbft); + libnvme_free_nbft(ctx, head->nbft); free(head); head = next; @@ -2526,22 +2526,22 @@ static bool validate_uri(struct nvme_global_ctx *ctx, } static int nbft_connect(struct nvme_global_ctx *ctx, - struct nvmf_context *fctx, struct nvme_host *h, + struct nvmf_context *fctx, struct libnvme_host *h, struct nvmf_disc_log_entry *e, struct nbft_info_subsystem_ns *ss, struct nvme_fabrics_config *cfg) { - nvme_ctrl_t c; + libnvme_ctrl_t c; int saved_log_level; bool saved_log_tstamp; bool saved_log_pid; int ret; - saved_log_level = nvme_get_logging_level(ctx, &saved_log_tstamp, + saved_log_level = libnvme_get_logging_level(ctx, &saved_log_tstamp, &saved_log_pid); c = lookup_ctrl(h, fctx); - if (c && nvme_ctrl_get_name(c)) + if (c && libnvme_ctrl_get_name(c)) return 0; ret = _nvme_create_ctrl(ctx, fctx, &c); @@ -2550,7 +2550,7 @@ static int nbft_connect(struct nvme_global_ctx *ctx, /* Pause logging for unavailable SSNSs */ if (ss && ss->unavailable && saved_log_level < 1) - nvme_set_logging_level(ctx, -1, false, false); + libnvme_set_logging_level(ctx, -1, false, false); if (e) { if (e->trtype == NVMF_TRTYPE_TCP && @@ -2562,13 +2562,13 @@ static int nbft_connect(struct nvme_global_ctx *ctx, /* Resume logging */ if (ss && ss->unavailable && saved_log_level < 1) - nvme_set_logging_level(ctx, + libnvme_set_logging_level(ctx, saved_log_level, saved_log_pid, saved_log_tstamp); if (ret) { - nvme_free_ctrl(c); + libnvme_free_ctrl(c); /* * In case this SSNS was marked as 'unavailable' and * our connection attempt has failed, ignore it. @@ -2590,7 +2590,7 @@ static int nbft_connect(struct nvme_global_ctx *ctx, static int nbft_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fctx, struct nbft_info_discovery *dd, - struct nvme_host *h, struct nvme_ctrl *c, + struct libnvme_host *h, struct libnvme_ctrl *c, struct nvme_fabrics_config *defcfg) { struct nvmf_discovery_log *log = NULL; @@ -2610,14 +2610,14 @@ static int nbft_discovery(struct nvme_global_ctx *ctx, if (ret) { nvme_msg(ctx, LOG_ERR, "Discovery Descriptor %d: failed to get discovery log: %s\n", - dd->index, nvme_strerror(ret)); + dd->index, libnvme_strerror(ret)); return ret; } for (i = 0; i < le64_to_cpu(log->numrec); i++) { struct nvmf_disc_log_entry *e = &log->entries[i]; struct nvmf_context nfctx = *fctx; - nvme_ctrl_t cl; + libnvme_ctrl_t cl; int tmo = defcfg->keep_alive_tmo; nfctx.subsysnqn = e->subnqn; @@ -2630,24 +2630,24 @@ static int nbft_discovery(struct nvme_global_ctx *ctx, /* Already connected ? */ cl = lookup_ctrl(h, &nfctx); - if (cl && nvme_ctrl_get_name(cl)) + if (cl && libnvme_ctrl_get_name(cl)) continue; /* Skip connect if the transport types don't match */ - if (strcmp(nvme_ctrl_get_transport(c), + if (strcmp(libnvme_ctrl_get_transport(c), nfctx.transport)) continue; if (e->subtype == NVME_NQN_DISC) { - nvme_ctrl_t child; + libnvme_ctrl_t child; ret = nvmf_connect_disc_entry(h, e, &nfctx, defcfg, NULL, &child); if (ret) continue; nbft_discovery(ctx, &nfctx, dd, h, child, defcfg); - nvme_disconnect_ctrl(child); - nvme_free_ctrl(child); + libnvme_disconnect_ctrl(child); + libnvme_free_ctrl(child); } else { ret = nbft_connect(ctx, &nfctx, h, e, NULL, defcfg); @@ -2697,7 +2697,7 @@ __public int nvmf_discovery_nbft(struct nvme_global_ctx *ctx, struct nbft_info_subsystem_ns **ss; struct nbft_info_hfi *hfi; struct nbft_info_discovery **dd; - struct nvme_host *h; + struct libnvme_host *h; int ret, rr, i; ret = lookup_host(ctx, fctx, &h); @@ -2734,7 +2734,7 @@ __public int nvmf_discovery_nbft(struct nvme_global_ctx *ctx, if (fctx->hostid) hostid = fctx->hostid; else if (*entry->nbft->host.id) { - ret = nvme_uuid_to_string(entry->nbft->host.id, uuid); + ret = libnvme_uuid_to_string(entry->nbft->host.id, uuid); if (!ret) hostid = uuid; else @@ -2817,7 +2817,7 @@ __public int nvmf_discovery_nbft(struct nvme_global_ctx *ctx, struct nvmf_context nfctx = *fctx; bool persistent = false; bool linked = false; - nvme_ctrl_t c; + libnvme_ctrl_t c; /* only perform discovery when no SSNS record references it */ for (ss = entry->nbft->subsystem_ns_list; @@ -2837,7 +2837,7 @@ __public int nvmf_discovery_nbft(struct nvme_global_ctx *ctx, continue; hfi = (*dd)->hfi; - ret = nvme_parse_uri((*dd)->uri, &uri); + ret = libnvme_parse_uri((*dd)->uri, &uri); if (ret) continue; if (!validate_uri(ctx, *dd, uri)) @@ -2866,7 +2866,7 @@ __public int nvmf_discovery_nbft(struct nvme_global_ctx *ctx, /* Lookup existing discovery controller */ c = lookup_ctrl(h, &nfctx); - if (c && nvme_ctrl_get_name(c)) + if (c && libnvme_ctrl_get_name(c)) persistent = true; if (!c) { @@ -2885,14 +2885,14 @@ __public int nvmf_discovery_nbft(struct nvme_global_ctx *ctx, if (ret) { nvme_msg(ctx, LOG_ERR, "Discovery Descriptor %d: failed to add discovery controller: %s\n", - (*dd)->index, nvme_strerror(-ret)); + (*dd)->index, libnvme_strerror(-ret)); goto out_free; } rr = nbft_discovery(ctx, &nfctx, *dd, h, c, fctx->cfg); if (!persistent) - nvme_disconnect_ctrl(c); - nvme_free_ctrl(c); + libnvme_disconnect_ctrl(c); + libnvme_free_ctrl(c); if (rr == -ENOMEM) { ret = rr; goto out_free; @@ -2907,8 +2907,8 @@ __public int nvmf_discovery_nbft(struct nvme_global_ctx *ctx, __public int nvmf_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fctx, bool connect, bool force) { - struct nvme_ctrl *c = NULL; - struct nvme_host *h; + struct libnvme_ctrl *c = NULL; + struct libnvme_host *h; int ret; ret = lookup_host(ctx, fctx, &h); @@ -2920,7 +2920,7 @@ __public int nvmf_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fc return ret; if (fctx->device && !force) { - ret = nvme_scan_ctrl(ctx, fctx->device, &c); + ret = libnvme_scan_ctrl(ctx, fctx->device, &c); if (!ret) { /* Check if device matches command-line options */ if (!_nvme_ctrl_match_config(c, fctx)) { @@ -2929,13 +2929,13 @@ __public int nvmf_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fc fctx->device); } - if (!nvme_ctrl_get_discovery_ctrl(c)) { + if (!libnvme_ctrl_get_discovery_ctrl(c)) { nvme_msg( ctx, LOG_ERR, "ctrl device %s found, ignoring non discovery controller\n", fctx->device); - nvme_free_ctrl(c); + libnvme_free_ctrl(c); c = NULL; fctx->persistent = false; } else { @@ -2957,10 +2957,10 @@ __public int nvmf_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fc */ if (!fctx->host_traddr) fctx->host_traddr = (char *) - nvme_ctrl_get_host_traddr(c); + libnvme_ctrl_get_host_traddr(c); if (!fctx->host_iface) fctx->host_iface = (char *) - nvme_ctrl_get_host_iface(c); + libnvme_ctrl_get_host_iface(c); } } else { /* @@ -2986,23 +2986,23 @@ __public int nvmf_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fc if (ret != -ENVME_CONNECT_IGNORED) nvme_msg(ctx, LOG_ERR, "failed to add controller, error %s\n", - nvme_strerror(-ret)); + libnvme_strerror(-ret)); return ret; } } ret = _nvmf_discovery(ctx, fctx, connect, c); if (!(fctx->persistent || is_persistent_discovery_ctrl(h, c))) - nvme_disconnect_ctrl(c); - nvme_free_ctrl(c); + libnvme_disconnect_ctrl(c); + libnvme_free_ctrl(c); return ret; } __public int nvmf_connect(struct nvme_global_ctx *ctx, struct nvmf_context *fctx) { - struct nvme_host *h; - struct nvme_ctrl *c; + struct libnvme_host *h; + struct libnvme_ctrl *c; int err; err = lookup_host(ctx, fctx, &h); @@ -3014,10 +3014,10 @@ __public int nvmf_connect(struct nvme_global_ctx *ctx, struct nvmf_context *fctx return err; c = lookup_ctrl(h, fctx); - if (c && nvme_ctrl_get_name(c) && !fctx->cfg->duplicate_connect) { - fctx->already_connected(fctx, h, nvme_ctrl_get_subsysnqn(c), - nvme_ctrl_get_transport(c), nvme_ctrl_get_traddr(c), - nvme_ctrl_get_trsvcid(c), fctx->user_data); + if (c && libnvme_ctrl_get_name(c) && !fctx->cfg->duplicate_connect) { + fctx->already_connected(fctx, h, libnvme_ctrl_get_subsysnqn(c), + libnvme_ctrl_get_transport(c), libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_trsvcid(c), fctx->user_data); return -EALREADY; } @@ -3026,9 +3026,9 @@ __public int nvmf_connect(struct nvme_global_ctx *ctx, struct nvmf_context *fctx return err; if (fctx->hostkey) { - nvme_ctrl_set_dhchap_host_key(c, fctx->hostkey); + libnvme_ctrl_set_dhchap_host_key(c, fctx->hostkey); if (fctx->ctrlkey) - nvme_ctrl_set_dhchap_ctrl_key(c, fctx->ctrlkey); + libnvme_ctrl_set_dhchap_ctrl_key(c, fctx->ctrlkey); } nvme_parse_tls_args(fctx->keyring, fctx->tls_key, @@ -3044,11 +3044,11 @@ __public int nvmf_connect(struct nvme_global_ctx *ctx, struct nvmf_context *fctx set_discovery_kato(fctx, fctx->cfg); } - err = nvme_add_ctrl(fctx, h, c, fctx->cfg); + err = libnvme_add_ctrl(fctx, h, c, fctx->cfg); if (err) { nvme_msg(ctx, LOG_ERR, "could not add new controller: %s\n", - nvme_strerror(-err)); - nvme_free_ctrl(c); + libnvme_strerror(-err)); + libnvme_free_ctrl(c); return err; } diff --git a/libnvme/src/nvme/fabrics.h b/libnvme/src/nvme/fabrics.h index 5a441ec2a0..fbcf6faf52 100644 --- a/libnvme/src/nvme/fabrics.h +++ b/libnvme/src/nvme/fabrics.h @@ -203,7 +203,7 @@ void nvmf_default_config(struct nvme_fabrics_config *cfg); * Updates the values from @c with the configuration values from @cfg; * all non-default values from @cfg will overwrite the values in @c. */ -void nvmf_update_config(nvme_ctrl_t c, const struct nvme_fabrics_config *cfg); +void nvmf_update_config(libnvme_ctrl_t c, const struct nvme_fabrics_config *cfg); /** * nvmf_add_ctrl() - Connect a controller and update topology @@ -217,7 +217,7 @@ void nvmf_update_config(nvme_ctrl_t c, const struct nvme_fabrics_config *cfg); * * Return: 0 on success, or an error code on failure. */ -int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, +int nvmf_add_ctrl(libnvme_host_t h, libnvme_ctrl_t c, const struct nvme_fabrics_config *cfg); /** @@ -229,7 +229,7 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, * * Return: 0 on success, or an error code on failure. */ -int nvmf_connect_ctrl(nvme_ctrl_t c); +int nvmf_connect_ctrl(libnvme_ctrl_t c); /** * nvmf_get_discovery_log() - Return the discovery log page @@ -244,7 +244,7 @@ int nvmf_connect_ctrl(nvme_ctrl_t c); * * Return: 0 on success, or an error code on failure. */ -int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp, +int nvmf_get_discovery_log(libnvme_ctrl_t c, struct nvmf_discovery_log **logp, int max_retries); /** @@ -257,7 +257,7 @@ int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp, * @lsp: Log specific field (See enum nvmf_log_discovery_lsp) */ struct nvme_get_discovery_args { - nvme_ctrl_t c; + libnvme_ctrl_t c; int args_size; int max_retries; __u32 *result; @@ -296,7 +296,7 @@ int nvmf_get_discovery_wargs(struct nvme_get_discovery_args *args, * Return: true if controller supports explicit registration. false * otherwise. */ -bool nvmf_is_registration_supported(nvme_ctrl_t c); +bool nvmf_is_registration_supported(libnvme_ctrl_t c); /** * nvmf_register_ctrl() - Perform registration task with a DC @@ -311,10 +311,10 @@ bool nvmf_is_registration_supported(nvme_ctrl_t c); * * Return: 0 on success, or an error code on failure. */ -int nvmf_register_ctrl(nvme_ctrl_t c, enum nvmf_dim_tas tas, __u32 *result); +int nvmf_register_ctrl(libnvme_ctrl_t c, enum nvmf_dim_tas tas, __u32 *result); /** - * nvme_parse_uri() - Parse the URI string + * libnvme_parse_uri() - Parse the URI string * @str: URI string * @uri: URI object to return * @@ -326,7 +326,7 @@ int nvmf_register_ctrl(nvme_ctrl_t c, enum nvmf_dim_tas tas, __u32 *result); * Return: &nvme_fabrics_uri structure on success; NULL on failure with errno * set. */ -int nvme_parse_uri(const char *str, struct nvme_fabrics_uri **uri); +int libnvme_parse_uri(const char *str, struct nvme_fabrics_uri **uri); /** * nvmf_free_uri() - Free the URI structure @@ -374,9 +374,9 @@ int nvmf_context_create(struct nvme_global_ctx *ctx, bool (*decide_retry)(struct nvmf_context *fctx, int err, void *user_data), void (*connected)(struct nvmf_context *fctx, - struct nvme_ctrl *c, void *user_data), + struct libnvme_ctrl *c, void *user_data), void (*already_connected)(struct nvmf_context *fctx, - struct nvme_host *host, const char *subsysnqn, + struct libnvme_host *host, const char *subsysnqn, const char *transport, const char *traddr, const char *trsvcid, void *user_data), void *user_data, struct nvmf_context **fctxp); diff --git a/libnvme/src/nvme/filters.c b/libnvme/src/nvme/filters.c index e960420821..a8cadb4841 100644 --- a/libnvme/src/nvme/filters.c +++ b/libnvme/src/nvme/filters.c @@ -15,7 +15,7 @@ #include "private.h" #include "compiler_attributes.h" -__public int nvme_filter_namespace(const struct dirent *d) +__public int libnvme_filter_namespace(const struct dirent *d) { int i, n; @@ -29,7 +29,7 @@ __public int nvme_filter_namespace(const struct dirent *d) return 0; } -__public int nvme_filter_paths(const struct dirent *d) +__public int libnvme_filter_paths(const struct dirent *d) { int i, c, n; @@ -43,7 +43,7 @@ __public int nvme_filter_paths(const struct dirent *d) return 0; } -__public int nvme_filter_ctrls(const struct dirent *d) +__public int libnvme_filter_ctrls(const struct dirent *d) { int i, c, n; @@ -62,7 +62,7 @@ __public int nvme_filter_ctrls(const struct dirent *d) return 0; } -__public int nvme_filter_subsys(const struct dirent *d) +__public int libnvme_filter_subsys(const struct dirent *d) { int i; @@ -76,72 +76,72 @@ __public int nvme_filter_subsys(const struct dirent *d) return 0; } -__public int nvme_scan_subsystems(struct dirent ***subsys) +__public int libnvme_scan_subsystems(struct dirent ***subsys) { const char *dir = nvme_subsys_sysfs_dir(); int ret; - ret = scandir(dir, subsys, nvme_filter_subsys, alphasort); + ret = scandir(dir, subsys, libnvme_filter_subsys, alphasort); if (ret < 0) return -errno; return ret; } -__public int nvme_scan_subsystem_namespaces(nvme_subsystem_t s, struct dirent ***ns) +__public int libnvme_scan_subsystem_namespaces(libnvme_subsystem_t s, struct dirent ***ns) { int ret; - ret = scandir(nvme_subsystem_get_sysfs_dir(s), ns, - nvme_filter_namespace, alphasort); + ret = scandir(libnvme_subsystem_get_sysfs_dir(s), ns, + libnvme_filter_namespace, alphasort); if (ret < 0) return -errno; return ret; } -__public int nvme_scan_ctrls(struct dirent ***ctrls) +__public int libnvme_scan_ctrls(struct dirent ***ctrls) { const char *dir = nvme_ctrl_sysfs_dir(); int ret; - ret = scandir(dir, ctrls, nvme_filter_ctrls, alphasort); + ret = scandir(dir, ctrls, libnvme_filter_ctrls, alphasort); if (ret < 0) return -errno; return ret; } -__public int nvme_scan_ctrl_namespace_paths(nvme_ctrl_t c, struct dirent ***paths) +__public int libnvme_scan_ctrl_namespace_paths(libnvme_ctrl_t c, struct dirent ***paths) { int ret; - ret = scandir(nvme_ctrl_get_sysfs_dir(c), paths, - nvme_filter_paths, alphasort); + ret = scandir(libnvme_ctrl_get_sysfs_dir(c), paths, + libnvme_filter_paths, alphasort); if (ret < 0) return -errno; return ret; } -__public int nvme_scan_ctrl_namespaces(nvme_ctrl_t c, struct dirent ***ns) +__public int libnvme_scan_ctrl_namespaces(libnvme_ctrl_t c, struct dirent ***ns) { int ret; - ret = scandir(nvme_ctrl_get_sysfs_dir(c), ns, - nvme_filter_namespace, alphasort); + ret = scandir(libnvme_ctrl_get_sysfs_dir(c), ns, + libnvme_filter_namespace, alphasort); if (ret < 0) return -errno; return ret; } -int nvme_scan_ns_head_paths(nvme_ns_head_t head, struct dirent ***paths) +int libnvme_scan_ns_head_paths(libnvme_ns_head_t head, struct dirent ***paths) { int ret; - ret = scandir(nvme_ns_head_get_sysfs_dir(head), paths, - nvme_filter_paths, alphasort); + ret = scandir(libnvme_ns_head_get_sysfs_dir(head), paths, + libnvme_filter_paths, alphasort); if (ret < 0) return -errno; diff --git a/libnvme/src/nvme/filters.h b/libnvme/src/nvme/filters.h index 05fd02a6f6..69f3bb2b31 100644 --- a/libnvme/src/nvme/filters.h +++ b/libnvme/src/nvme/filters.h @@ -20,87 +20,87 @@ */ /** - * nvme_filter_namespace() - Filter for namespaces + * libnvme_filter_namespace() - Filter for namespaces * @d: dirent to check * * Return: 1 if @d matches, 0 otherwise */ -int nvme_filter_namespace(const struct dirent *d); +int libnvme_filter_namespace(const struct dirent *d); /** - * nvme_filter_paths() - Filter for paths + * libnvme_filter_paths() - Filter for paths * @d: dirent to check * * Return: 1 if @d matches, 0 otherwise */ -int nvme_filter_paths(const struct dirent *d); +int libnvme_filter_paths(const struct dirent *d); /** - * nvme_filter_ctrls() - Filter for controllers + * libnvme_filter_ctrls() - Filter for controllers * @d: dirent to check * * Return: 1 if @d matches, 0 otherwise */ -int nvme_filter_ctrls(const struct dirent *d); +int libnvme_filter_ctrls(const struct dirent *d); /** - * nvme_filter_subsys() - Filter for subsystems + * libnvme_filter_subsys() - Filter for subsystems * @d: dirent to check * * Return: 1 if @d matches, 0 otherwise */ -int nvme_filter_subsys(const struct dirent *d); +int libnvme_filter_subsys(const struct dirent *d); /** - * nvme_scan_subsystems() - Scan for subsystems + * libnvme_scan_subsystems() - Scan for subsystems * @subsys: Pointer to array of dirents * * Return: number of entries in @subsys or a negative error code */ -int nvme_scan_subsystems(struct dirent ***subsys); +int libnvme_scan_subsystems(struct dirent ***subsys); /** - * nvme_scan_subsystem_namespaces() - Scan for namespaces in a subsystem + * libnvme_scan_subsystem_namespaces() - Scan for namespaces in a subsystem * @s: Subsystem to scan * @ns: Pointer to array of dirents * * Return: number of entries in @ns or a negative error code */ -int nvme_scan_subsystem_namespaces(nvme_subsystem_t s, struct dirent ***ns); +int libnvme_scan_subsystem_namespaces(libnvme_subsystem_t s, struct dirent ***ns); /** - * nvme_scan_ctrls() - Scan for controllers + * libnvme_scan_ctrls() - Scan for controllers * @ctrls: Pointer to array of dirents * * Return: number of entries in @ctrls or a negative error code */ -int nvme_scan_ctrls(struct dirent ***ctrls); +int libnvme_scan_ctrls(struct dirent ***ctrls); /** - * nvme_scan_ctrl_namespace_paths() - Scan for namespace paths in a controller + * libnvme_scan_ctrl_namespace_paths() - Scan for namespace paths in a controller * @c: Controller to scan * @paths: Pointer to array of dirents * * Return: number of entries in @paths or a negative error code */ -int nvme_scan_ctrl_namespace_paths(nvme_ctrl_t c, struct dirent ***paths); +int libnvme_scan_ctrl_namespace_paths(libnvme_ctrl_t c, struct dirent ***paths); /** - * nvme_scan_ctrl_namespaces() - Scan for namespaces in a controller + * libnvme_scan_ctrl_namespaces() - Scan for namespaces in a controller * @c: Controller to scan * @ns: Pointer to array of dirents * * Return: number of entries in @ns or a negative error code */ -int nvme_scan_ctrl_namespaces(nvme_ctrl_t c, struct dirent ***ns); +int libnvme_scan_ctrl_namespaces(libnvme_ctrl_t c, struct dirent ***ns); /** - * nvme_scan_ns_head_paths() - Scan for namespace paths + * libnvme_scan_ns_head_paths() - Scan for namespace paths * @head: Namespace head node to scan * @paths : Pointer to array of dirents * * Return: number of entries in @ents or a negative error code */ -int nvme_scan_ns_head_paths(nvme_ns_head_t head, struct dirent ***paths); +int libnvme_scan_ns_head_paths(libnvme_ns_head_t head, struct dirent ***paths); #endif /* _LIBNVME_FILTERS_H */ diff --git a/libnvme/src/nvme/ioctl.c b/libnvme/src/nvme/ioctl.c index 85f401b940..d9f019bf41 100644 --- a/libnvme/src/nvme/ioctl.c +++ b/libnvme/src/nvme/ioctl.c @@ -38,7 +38,7 @@ static int nvme_verify_chr(struct nvme_transport_handle *hdl) return 0; } -__public int nvme_reset_subsystem(struct nvme_transport_handle *hdl) +__public int libnvme_reset_subsystem(struct nvme_transport_handle *hdl) { int ret; @@ -52,7 +52,7 @@ __public int nvme_reset_subsystem(struct nvme_transport_handle *hdl) return ret; } -__public int nvme_reset_ctrl(struct nvme_transport_handle *hdl) +__public int libnvme_reset_ctrl(struct nvme_transport_handle *hdl) { int ret; @@ -66,7 +66,7 @@ __public int nvme_reset_ctrl(struct nvme_transport_handle *hdl) return ret; } -__public int nvme_rescan_ns(struct nvme_transport_handle *hdl) +__public int libnvme_rescan_ns(struct nvme_transport_handle *hdl) { int ret; @@ -80,7 +80,7 @@ __public int nvme_rescan_ns(struct nvme_transport_handle *hdl) return ret; } -__public int nvme_get_nsid(struct nvme_transport_handle *hdl, __u32 *nsid) +__public int libnvme_get_nsid(struct nvme_transport_handle *hdl, __u32 *nsid) { __u32 tmp; @@ -171,7 +171,7 @@ static int nvme_submit_passthru64(struct nvme_transport_handle *hdl, return err; } -__public int nvme_submit_io_passthru(struct nvme_transport_handle *hdl, +__public int libnvme_submit_io_passthru(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd) { if (hdl->ioctl_io64) @@ -179,7 +179,7 @@ __public int nvme_submit_io_passthru(struct nvme_transport_handle *hdl, return nvme_submit_passthru32(hdl, NVME_IOCTL_IO_CMD, cmd); } -__public int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl, +__public int libnvme_submit_admin_passthru(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd) { switch (hdl->type) { diff --git a/libnvme/src/nvme/ioctl.h b/libnvme/src/nvme/ioctl.h index 197c94cd4b..047270ead8 100644 --- a/libnvme/src/nvme/ioctl.h +++ b/libnvme/src/nvme/ioctl.h @@ -27,7 +27,7 @@ #define NVME_LOG_PAGE_PDU_SIZE 4096 /** - * nvme_submit_admin_passthru() - Submit an nvme passthrough admin command + * libnvme_submit_admin_passthru() - Submit an nvme passthrough admin command * @hdl: Transport handle * @cmd: The nvme admin command to send * @@ -36,11 +36,11 @@ * Return: 0 on success, the nvme command status if a response was * received (see &enum nvme_status_field) or a negative error otherwise. */ -int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl, +int libnvme_submit_admin_passthru(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd); /** - * nvme_submit_io_passthru() - Submit an nvme passthrough command + * libnvme_submit_io_passthru() - Submit an nvme passthrough command * @hdl: Transport handle * @cmd: The nvme io command to send * @@ -49,11 +49,11 @@ int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl, * Return: 0 on success, the nvme command status if a response was * received (see &enum nvme_status_field) or a negative error otherwise. */ -int nvme_submit_io_passthru(struct nvme_transport_handle *hdl, +int libnvme_submit_io_passthru(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd); /** - * nvme_reset_subsystem() - Initiate a subsystem reset + * libnvme_reset_subsystem() - Initiate a subsystem reset * @hdl: Transport handle * * This should only be sent to controller handles, not to namespaces. @@ -61,30 +61,30 @@ int nvme_submit_io_passthru(struct nvme_transport_handle *hdl, * Return: Zero if a subsystem reset was initiated or -1 with errno set * otherwise. */ -int nvme_reset_subsystem(struct nvme_transport_handle *hdl); +int libnvme_reset_subsystem(struct nvme_transport_handle *hdl); /** - * nvme_reset_ctrl() - Initiate a controller reset + * libnvme_reset_ctrl() - Initiate a controller reset * @hdl: Transport handle * * This should only be sent to controller handles, not to namespaces. * * Return: 0 if a reset was initiated or -1 with errno set otherwise. */ -int nvme_reset_ctrl(struct nvme_transport_handle *hdl); +int libnvme_reset_ctrl(struct nvme_transport_handle *hdl); /** - * nvme_rescan_ns() - Initiate a controller rescan + * libnvme_rescan_ns() - Initiate a controller rescan * @hdl: Transport handle * * This should only be sent to controller handles, not to namespaces. * * Return: 0 if a rescan was initiated or -1 with errno set otherwise. */ -int nvme_rescan_ns(struct nvme_transport_handle *hdl); +int libnvme_rescan_ns(struct nvme_transport_handle *hdl); /** - * nvme_get_nsid() - Retrieve the NSID from a namespace file descriptor + * libnvme_get_nsid() - Retrieve the NSID from a namespace file descriptor * @hdl: Transport handle * @nsid: User pointer to namespace id * @@ -95,4 +95,4 @@ int nvme_rescan_ns(struct nvme_transport_handle *hdl); * * Return: 0 if @nsid was set successfully or -1 with errno set otherwise. */ -int nvme_get_nsid(struct nvme_transport_handle *hdl, __u32 *nsid); +int libnvme_get_nsid(struct nvme_transport_handle *hdl, __u32 *nsid); diff --git a/libnvme/src/nvme/json.c b/libnvme/src/nvme/json.c index f42f3a26e2..b4cfe0aded 100644 --- a/libnvme/src/nvme/json.c +++ b/libnvme/src/nvme/json.c @@ -22,10 +22,10 @@ #define JSON_UPDATE_BOOL_OPTION(c, k, a, o) \ if (!strcmp(# a, k ) && !c->a) c->a = json_object_get_boolean(o); -static void json_update_attributes(nvme_ctrl_t c, +static void json_update_attributes(libnvme_ctrl_t c, struct json_object *ctrl_obj) { - struct nvme_fabrics_config *cfg = nvme_ctrl_get_config(c); + struct nvme_fabrics_config *cfg = libnvme_ctrl_get_config(c); json_object_object_foreach(ctrl_obj, key_str, val_obj) { JSON_UPDATE_INT_OPTION(cfg, key_str, @@ -60,28 +60,28 @@ static void json_update_attributes(nvme_ctrl_t c, JSON_UPDATE_BOOL_OPTION(cfg, key_str, concat, val_obj); if (!strcmp("persistent", key_str) && - !nvme_ctrl_get_persistent(c)) - nvme_ctrl_set_persistent(c, true); + !libnvme_ctrl_get_persistent(c)) + libnvme_ctrl_set_persistent(c, true); if (!strcmp("discovery", key_str) && - !nvme_ctrl_get_discovery_ctrl(c)) - nvme_ctrl_set_discovery_ctrl(c, true); + !libnvme_ctrl_get_discovery_ctrl(c)) + libnvme_ctrl_set_discovery_ctrl(c, true); if (!strcmp("keyring", key_str)) - nvme_ctrl_set_keyring(c, + libnvme_ctrl_set_keyring(c, json_object_get_string(val_obj)); if (!strcmp("tls_key_identity", key_str)) { - nvme_ctrl_set_tls_key_identity(c, + libnvme_ctrl_set_tls_key_identity(c, json_object_get_string(val_obj)); } if (!strcmp("tls_key", key_str)) { - nvme_ctrl_set_tls_key(c, + libnvme_ctrl_set_tls_key(c, json_object_get_string(val_obj)); } } } -static void json_parse_port(nvme_subsystem_t s, struct json_object *port_obj) +static void json_parse_port(libnvme_subsystem_t s, struct json_object *port_obj) { - nvme_ctrl_t c; + libnvme_ctrl_t c; struct json_object *attr_obj; struct nvmf_context fctx = {}; @@ -107,29 +107,29 @@ static void json_parse_port(nvme_subsystem_t s, struct json_object *port_obj) json_update_attributes(c, port_obj); attr_obj = json_object_object_get(port_obj, "dhchap_key"); if (attr_obj) - nvme_ctrl_set_dhchap_host_key(c, json_object_get_string(attr_obj)); + libnvme_ctrl_set_dhchap_host_key(c, json_object_get_string(attr_obj)); attr_obj = json_object_object_get(port_obj, "dhchap_ctrl_key"); if (attr_obj) - nvme_ctrl_set_dhchap_ctrl_key(c, json_object_get_string(attr_obj)); + libnvme_ctrl_set_dhchap_ctrl_key(c, json_object_get_string(attr_obj)); attr_obj = json_object_object_get(port_obj, "keyring"); if (attr_obj) - nvme_ctrl_set_keyring(c, json_object_get_string(attr_obj)); + libnvme_ctrl_set_keyring(c, json_object_get_string(attr_obj)); attr_obj = json_object_object_get(port_obj, "tls_key_identity"); if (attr_obj) { - nvme_ctrl_set_tls_key_identity(c, + libnvme_ctrl_set_tls_key_identity(c, json_object_get_string(attr_obj)); } attr_obj = json_object_object_get(port_obj, "tls_key"); if (attr_obj) { - nvme_ctrl_set_tls_key(c, + libnvme_ctrl_set_tls_key(c, json_object_get_string(attr_obj)); } } -static void json_parse_subsys(nvme_host_t h, struct json_object *subsys_obj) +static void json_parse_subsys(libnvme_host_t h, struct json_object *subsys_obj) { struct json_object *nqn_obj, *app_obj, *port_array; - nvme_subsystem_t s; + libnvme_subsystem_t s; const char *nqn; int p; @@ -142,7 +142,7 @@ static void json_parse_subsys(nvme_host_t h, struct json_object *subsys_obj) return; app_obj = json_object_object_get(subsys_obj, "application"); if (app_obj) - nvme_subsystem_set_application(s, json_object_get_string(app_obj)); + libnvme_subsystem_set_application(s, json_object_get_string(app_obj)); port_array = json_object_object_get(subsys_obj, "ports"); if (!port_array) @@ -159,7 +159,7 @@ static void json_parse_subsys(nvme_host_t h, struct json_object *subsys_obj) static void json_parse_host(struct nvme_global_ctx *ctx, struct json_object *host_obj) { struct json_object *attr_obj, *subsys_array, *subsys_obj; - nvme_host_t h; + libnvme_host_t h; const char *hostnqn, *hostid = NULL; int s; @@ -173,13 +173,13 @@ static void json_parse_host(struct nvme_global_ctx *ctx, struct json_object *hos h = nvme_lookup_host(ctx, hostnqn, hostid); attr_obj = json_object_object_get(host_obj, "dhchap_key"); if (attr_obj) - nvme_host_set_dhchap_host_key(h, json_object_get_string(attr_obj)); + libnvme_host_set_dhchap_host_key(h, json_object_get_string(attr_obj)); attr_obj = json_object_object_get(host_obj, "hostsymname"); if (attr_obj) - nvme_host_set_hostsymname(h, json_object_get_string(attr_obj)); + libnvme_host_set_hostsymname(h, json_object_get_string(attr_obj)); attr_obj = json_object_object_get(host_obj, "persistent_discovery_ctrl"); if (attr_obj) - nvme_host_set_pdc_enabled(h, json_object_get_boolean(attr_obj)); + libnvme_host_set_pdc_enabled(h, json_object_get_boolean(attr_obj)); subsys_array = json_object_object_get(host_obj, "subsystems"); if (!subsys_array) return; @@ -238,7 +238,7 @@ int json_read_config(struct nvme_global_ctx *ctx, const char *config_file) fd = open(config_file, O_RDONLY); if (fd < 0) { nvme_msg(ctx, LOG_DEBUG, "Error opening %s, %s\n", - config_file, nvme_strerror(errno)); + config_file, libnvme_strerror(errno)); return fd; } json_root = parse_json(ctx, fd); @@ -272,13 +272,13 @@ int json_read_config(struct nvme_global_ctx *ctx, const char *config_file) json_object_object_add((p), # o , \ json_object_new_boolean((c)->o)) -static void json_update_port(struct json_object *ctrl_array, nvme_ctrl_t c) +static void json_update_port(struct json_object *ctrl_array, libnvme_ctrl_t c) { - struct nvme_fabrics_config *cfg = nvme_ctrl_get_config(c); + struct nvme_fabrics_config *cfg = libnvme_ctrl_get_config(c); struct json_object *port_obj = json_object_new_object(); const char *transport, *value; - transport = nvme_ctrl_get_transport(c); + transport = libnvme_ctrl_get_transport(c); if (!strcmp(transport, "pcie")) { json_object_put(port_obj); return; @@ -286,40 +286,40 @@ static void json_update_port(struct json_object *ctrl_array, nvme_ctrl_t c) json_object_object_add(port_obj, "transport", json_object_new_string(transport)); - value = nvme_ctrl_get_traddr(c); + value = libnvme_ctrl_get_traddr(c); if (value) json_object_object_add(port_obj, "traddr", json_object_new_string(value)); - value = nvme_ctrl_get_host_traddr(c); + value = libnvme_ctrl_get_host_traddr(c); if (value) json_object_object_add(port_obj, "host_traddr", json_object_new_string(value)); - value = nvme_ctrl_get_host_iface(c); + value = libnvme_ctrl_get_host_iface(c); if (value) json_object_object_add(port_obj, "host_iface", json_object_new_string(value)); - value = nvme_ctrl_get_trsvcid(c); + value = libnvme_ctrl_get_trsvcid(c); if (value) json_object_object_add(port_obj, "trsvcid", json_object_new_string(value)); - value = nvme_ctrl_get_dhchap_host_key(c); + value = libnvme_ctrl_get_dhchap_host_key(c); if (value) json_object_object_add(port_obj, "dhchap_key", json_object_new_string(value)); - value = nvme_ctrl_get_dhchap_ctrl_key(c); + value = libnvme_ctrl_get_dhchap_ctrl_key(c); if (value) json_object_object_add(port_obj, "dhchap_ctrl_key", json_object_new_string(value)); JSON_BOOL_OPTION(cfg, port_obj, tls); - value = nvme_ctrl_get_keyring(c); + value = libnvme_ctrl_get_keyring(c); if (value) json_object_object_add(port_obj, "keyring", json_object_new_string(value)); - value = nvme_ctrl_get_tls_key_identity(c); + value = libnvme_ctrl_get_tls_key_identity(c); if (value) json_object_object_add(port_obj, "tls_key_identity", json_object_new_string(value)); - value = nvme_ctrl_get_tls_key(c); + value = libnvme_ctrl_get_tls_key(c); if (value) json_object_object_add(port_obj, "tls_key", json_object_new_string(value)); @@ -340,10 +340,10 @@ static void json_update_port(struct json_object *ctrl_array, nvme_ctrl_t c) JSON_BOOL_OPTION(cfg, port_obj, hdr_digest); JSON_BOOL_OPTION(cfg, port_obj, data_digest); JSON_BOOL_OPTION(cfg, port_obj, concat); - if (nvme_ctrl_get_persistent(c)) + if (libnvme_ctrl_get_persistent(c)) json_object_object_add(port_obj, "persistent", json_object_new_boolean(true)); - if (nvme_ctrl_get_discovery_ctrl(c)) + if (libnvme_ctrl_get_discovery_ctrl(c)) json_object_object_add(port_obj, "discovery", json_object_new_boolean(true)); @@ -351,10 +351,10 @@ static void json_update_port(struct json_object *ctrl_array, nvme_ctrl_t c) } static void json_update_subsys(struct json_object *subsys_array, - nvme_subsystem_t s) + libnvme_subsystem_t s) { - nvme_ctrl_t c; - const char *subsysnqn = nvme_subsystem_get_subsysnqn(s), *app; + libnvme_ctrl_t c; + const char *subsysnqn = libnvme_subsystem_get_subsysnqn(s), *app; struct json_object *subsys_obj = json_object_new_object(); struct json_object *port_array; @@ -364,12 +364,12 @@ static void json_update_subsys(struct json_object *subsys_array, json_object_object_add(subsys_obj, "nqn", json_object_new_string(subsysnqn)); - app = nvme_subsystem_get_application(s); + app = libnvme_subsystem_get_application(s); if (app) json_object_object_add(subsys_obj, "application", json_object_new_string(app)); port_array = json_object_new_array(); - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_subsystem_for_each_ctrl(s, c) { json_update_port(port_array, c); } if (json_object_array_length(port_array)) { @@ -383,31 +383,31 @@ static void json_update_subsys(struct json_object *subsys_array, int json_update_config(struct nvme_global_ctx *ctx, int fd) { - nvme_host_t h; + libnvme_host_t h; struct json_object *json_root, *host_obj; struct json_object *subsys_array; int ret = 0; json_root = json_object_new_array(); - nvme_for_each_host(ctx, h) { - nvme_subsystem_t s; + libnvme_for_each_host(ctx, h) { + libnvme_subsystem_t s; const char *hostnqn, *hostid, *dhchap_key, *hostsymname; host_obj = json_object_new_object(); if (!host_obj) continue; - hostnqn = nvme_host_get_hostnqn(h); + hostnqn = libnvme_host_get_hostnqn(h); json_object_object_add(host_obj, "hostnqn", json_object_new_string(hostnqn)); - hostid = nvme_host_get_hostid(h); + hostid = libnvme_host_get_hostid(h); if (hostid) json_object_object_add(host_obj, "hostid", json_object_new_string(hostid)); - dhchap_key = nvme_host_get_dhchap_host_key(h); + dhchap_key = libnvme_host_get_dhchap_host_key(h); if (dhchap_key) json_object_object_add(host_obj, "dhchap_key", json_object_new_string(dhchap_key)); - hostsymname = nvme_host_get_hostsymname(h); + hostsymname = libnvme_host_get_hostsymname(h); if (hostsymname) json_object_object_add(host_obj, "hostsymname", json_object_new_string(hostsymname)); @@ -415,7 +415,7 @@ int json_update_config(struct nvme_global_ctx *ctx, int fd) json_object_object_add(host_obj, "persistent_discovery_ctrl", json_object_new_boolean(h->pdc_enabled)); subsys_array = json_object_new_array(); - nvme_for_each_subsystem(h, s) { + libnvme_for_each_subsystem(h, s) { json_update_subsys(subsys_array, s); } if (json_object_array_length(subsys_array)) { @@ -440,40 +440,40 @@ int json_update_config(struct nvme_global_ctx *ctx, int fd) return ret; } -static void json_dump_ctrl(struct json_object *ctrl_array, nvme_ctrl_t c) +static void json_dump_ctrl(struct json_object *ctrl_array, libnvme_ctrl_t c) { - struct nvme_fabrics_config *cfg = nvme_ctrl_get_config(c); + struct nvme_fabrics_config *cfg = libnvme_ctrl_get_config(c); struct json_object *ctrl_obj = json_object_new_object(); const char *name, *transport, *value; - name = nvme_ctrl_get_name(c); + name = libnvme_ctrl_get_name(c); if (name && strlen(name)) json_object_object_add(ctrl_obj, "name", json_object_new_string(name)); - transport = nvme_ctrl_get_transport(c); + transport = libnvme_ctrl_get_transport(c); json_object_object_add(ctrl_obj, "transport", json_object_new_string(transport)); - value = nvme_ctrl_get_traddr(c); + value = libnvme_ctrl_get_traddr(c); if (value) json_object_object_add(ctrl_obj, "traddr", json_object_new_string(value)); - value = nvme_ctrl_get_host_traddr(c); + value = libnvme_ctrl_get_host_traddr(c); if (value) json_object_object_add(ctrl_obj, "host_traddr", json_object_new_string(value)); - value = nvme_ctrl_get_host_iface(c); + value = libnvme_ctrl_get_host_iface(c); if (value) json_object_object_add(ctrl_obj, "host_iface", json_object_new_string(value)); - value = nvme_ctrl_get_trsvcid(c); + value = libnvme_ctrl_get_trsvcid(c); if (value) json_object_object_add(ctrl_obj, "trsvcid", json_object_new_string(value)); - value = nvme_ctrl_get_dhchap_host_key(c); + value = libnvme_ctrl_get_dhchap_host_key(c); if (value) json_object_object_add(ctrl_obj, "dhchap_key", json_object_new_string(value)); - value = nvme_ctrl_get_dhchap_ctrl_key(c); + value = libnvme_ctrl_get_dhchap_ctrl_key(c); if (value) json_object_object_add(ctrl_obj, "dhchap_ctrl_key", json_object_new_string(value)); @@ -496,63 +496,63 @@ static void json_dump_ctrl(struct json_object *ctrl_array, nvme_ctrl_t c) if (!strcmp(transport, "tcp")) { JSON_BOOL_OPTION(cfg, ctrl_obj, tls); - value = nvme_ctrl_get_keyring(c); + value = libnvme_ctrl_get_keyring(c); if (value) json_object_object_add(ctrl_obj, "keyring", json_object_new_string(value)); - value = nvme_ctrl_get_tls_key_identity(c); + value = libnvme_ctrl_get_tls_key_identity(c); if (value) json_object_object_add(ctrl_obj, "tls_key_identity", json_object_new_string(value)); - value = nvme_ctrl_get_tls_key(c); + value = libnvme_ctrl_get_tls_key(c); if (value) json_object_object_add(ctrl_obj, "tls_key", json_object_new_string(value)); } JSON_BOOL_OPTION(cfg, ctrl_obj, concat); - if (nvme_ctrl_get_persistent(c)) + if (libnvme_ctrl_get_persistent(c)) json_object_object_add(ctrl_obj, "persistent", json_object_new_boolean(true)); - if (nvme_ctrl_get_discovery_ctrl(c)) + if (libnvme_ctrl_get_discovery_ctrl(c)) json_object_object_add(ctrl_obj, "discovery", json_object_new_boolean(true)); json_object_array_add(ctrl_array, ctrl_obj); } -static unsigned int json_dump_subsys_multipath(nvme_subsystem_t s, +static unsigned int json_dump_subsys_multipath(libnvme_subsystem_t s, struct json_object *ns_array) { - nvme_ns_t n; - nvme_path_t p; + libnvme_ns_t n; + libnvme_path_t p; unsigned int i = 0; - nvme_subsystem_for_each_ns(s, n) { + libnvme_subsystem_for_each_ns(s, n) { struct json_object *ns_obj; struct json_object *path_array; ns_obj = json_object_new_object(); json_object_object_add(ns_obj, "nsid", - json_object_new_int(nvme_ns_get_nsid(n))); + json_object_new_int(libnvme_ns_get_nsid(n))); json_object_object_add(ns_obj, "name", - json_object_new_string(nvme_ns_get_name(n))); + json_object_new_string(libnvme_ns_get_name(n))); path_array = json_object_new_array(); - nvme_namespace_for_each_path(n, p) { + libnvme_namespace_for_each_path(n, p) { struct json_object *path_obj; struct json_object *ctrl_array; - nvme_ctrl_t c; + libnvme_ctrl_t c; path_obj = json_object_new_object(); json_object_object_add(path_obj, "path", - json_object_new_string(nvme_path_get_name(p))); + json_object_new_string(libnvme_path_get_name(p))); json_object_object_add(path_obj, "ANAState", - json_object_new_string(nvme_path_get_ana_state(p))); + json_object_new_string(libnvme_path_get_ana_state(p))); json_object_object_add(path_obj, "NUMANodes", - json_object_new_string(nvme_path_get_numa_nodes(p))); + json_object_new_string(libnvme_path_get_numa_nodes(p))); json_object_object_add(path_obj, "qdepth", - json_object_new_int(nvme_path_get_queue_depth(p))); + json_object_new_int(libnvme_path_get_queue_depth(p))); - c = nvme_path_get_ctrl(p); + c = libnvme_path_get_ctrl(p); ctrl_array = json_object_new_array(); json_dump_ctrl(ctrl_array, c); json_object_object_add(path_obj, "controller", ctrl_array); @@ -565,22 +565,22 @@ static unsigned int json_dump_subsys_multipath(nvme_subsystem_t s, return i; } -static void json_dump_subsys_non_multipath(nvme_subsystem_t s, +static void json_dump_subsys_non_multipath(libnvme_subsystem_t s, struct json_object *ns_array) { - nvme_ctrl_t c; - nvme_ns_t n; + libnvme_ctrl_t c; + libnvme_ns_t n; - nvme_subsystem_for_each_ctrl(s, c) { - nvme_ctrl_for_each_ns(c, n) { + libnvme_subsystem_for_each_ctrl(s, c) { + libnvme_ctrl_for_each_ns(c, n) { struct json_object *ctrl_array; struct json_object *ns_obj; ns_obj = json_object_new_object(); json_object_object_add(ns_obj, "nsid", - json_object_new_int(nvme_ns_get_nsid(n))); + json_object_new_int(libnvme_ns_get_nsid(n))); json_object_object_add(ns_obj, "name", - json_object_new_string(nvme_ns_get_name(n))); + json_object_new_string(libnvme_ns_get_name(n))); ctrl_array = json_object_new_array(); json_dump_ctrl(ctrl_array, c); @@ -592,15 +592,15 @@ static void json_dump_subsys_non_multipath(nvme_subsystem_t s, } static void json_dump_subsys(struct json_object *subsys_array, - nvme_subsystem_t s) + libnvme_subsystem_t s) { struct json_object *subsys_obj = json_object_new_object(); struct json_object *ns_array; json_object_object_add(subsys_obj, "name", - json_object_new_string(nvme_subsystem_get_name(s))); + json_object_new_string(libnvme_subsystem_get_name(s))); json_object_object_add(subsys_obj, "nqn", - json_object_new_string(nvme_subsystem_get_subsysnqn(s))); + json_object_new_string(libnvme_subsystem_get_subsysnqn(s))); ns_array = json_object_new_array(); if (!json_dump_subsys_multipath(s, ns_array)) @@ -615,25 +615,25 @@ static void json_dump_subsys(struct json_object *subsys_array, int json_dump_tree(struct nvme_global_ctx *ctx) { - nvme_host_t h; + libnvme_host_t h; struct json_object *json_root, *host_obj; struct json_object *host_array, *subsys_array; int ret = 0; json_root = json_object_new_object(); host_array = json_object_new_array(); - nvme_for_each_host(ctx, h) { - nvme_subsystem_t s; + libnvme_for_each_host(ctx, h) { + libnvme_subsystem_t s; const char *hostid, *dhchap_key; host_obj = json_object_new_object(); json_object_object_add(host_obj, "hostnqn", - json_object_new_string(nvme_host_get_hostnqn(h))); - hostid = nvme_host_get_hostid(h); + json_object_new_string(libnvme_host_get_hostnqn(h))); + hostid = libnvme_host_get_hostid(h); if (hostid) json_object_object_add(host_obj, "hostid", json_object_new_string(hostid)); - dhchap_key = nvme_host_get_dhchap_host_key(h); + dhchap_key = libnvme_host_get_dhchap_host_key(h); if (dhchap_key) json_object_object_add(host_obj, "dhchap_key", json_object_new_string(dhchap_key)); @@ -641,7 +641,7 @@ int json_dump_tree(struct nvme_global_ctx *ctx) json_object_object_add(host_obj, "persistent_discovery_ctrl", json_object_new_boolean(h->pdc_enabled)); subsys_array = json_object_new_array(); - nvme_for_each_subsystem(h, s) { + libnvme_for_each_subsystem(h, s) { json_dump_subsys(subsys_array, s); } if (json_object_array_length(subsys_array)) diff --git a/libnvme/src/nvme/lib.c b/libnvme/src/nvme/lib.c index 2dd8a26452..dd46aa355e 100644 --- a/libnvme/src/nvme/lib.c +++ b/libnvme/src/nvme/lib.c @@ -33,7 +33,7 @@ static bool nvme_mi_probe_enabled_default(void) } -__public struct nvme_global_ctx *nvme_create_global_ctx(FILE *fp, int log_level) +__public struct nvme_global_ctx *libnvme_create_global_ctx(FILE *fp, int log_level) { struct nvme_global_ctx *ctx; int fd; @@ -63,9 +63,9 @@ __public struct nvme_global_ctx *nvme_create_global_ctx(FILE *fp, int log_level) return ctx; } -__public void nvme_free_global_ctx(struct nvme_global_ctx *ctx) +__public void libnvme_free_global_ctx(struct nvme_global_ctx *ctx) { - struct nvme_host *h, *_h; + struct libnvme_host *h, *_h; nvme_mi_ep_t ep, tmp; if (!ctx) @@ -75,27 +75,27 @@ __public void nvme_free_global_ctx(struct nvme_global_ctx *ctx) ctx->ifaddrs_cache = NULL; free(ctx->options); - nvme_for_each_host_safe(ctx, h, _h) + libnvme_for_each_host_safe(ctx, h, _h) __nvme_free_host(h); - nvme_mi_for_each_endpoint_safe(ctx, ep, tmp) - nvme_mi_close(ep); + libnvme_mi_for_each_endpoint_safe(ctx, ep, tmp) + libnvme_mi_close(ep); free(ctx->config_file); free(ctx->application); nvme_close_uring(ctx); free(ctx); } -__public void nvme_set_dry_run(struct nvme_global_ctx *ctx, bool enable) +__public void libnvme_set_dry_run(struct nvme_global_ctx *ctx, bool enable) { ctx->dry_run = enable; } -__public void nvme_set_ioctl_probing(struct nvme_global_ctx *ctx, bool enable) +__public void libnvme_set_ioctl_probing(struct nvme_global_ctx *ctx, bool enable) { ctx->ioctl_probing = enable; } -__public void nvme_transport_handle_set_submit_entry(struct nvme_transport_handle *hdl, +__public void libnvme_transport_handle_set_submit_entry(struct nvme_transport_handle *hdl, void *(*submit_entry)(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd)) { @@ -104,7 +104,7 @@ __public void nvme_transport_handle_set_submit_entry(struct nvme_transport_handl hdl->submit_exit = __nvme_submit_exit; } -__public void nvme_transport_handle_set_submit_exit(struct nvme_transport_handle *hdl, +__public void libnvme_transport_handle_set_submit_exit(struct nvme_transport_handle *hdl, void (*submit_exit)(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd, int err, void *user_data)) @@ -114,7 +114,7 @@ __public void nvme_transport_handle_set_submit_exit(struct nvme_transport_handle hdl->submit_exit = __nvme_submit_exit; } -__public void nvme_transport_handle_set_decide_retry(struct nvme_transport_handle *hdl, +__public void libnvme_transport_handle_set_decide_retry(struct nvme_transport_handle *hdl, bool (*decide_retry)(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd, int err)) { @@ -132,7 +132,7 @@ static int __nvme_transport_handle_open_direct( int ret, id, ns; bool c = true; - name = nvme_basename(devname); + name = libnvme_basename(devname); hdl->type = NVME_TRANSPORT_HANDLE_TYPE_DIRECT; @@ -202,7 +202,7 @@ struct nvme_transport_handle *__nvme_create_transport_handle( return hdl; } -__public int nvme_open(struct nvme_global_ctx *ctx, const char *name, +__public int libnvme_open(struct nvme_global_ctx *ctx, const char *name, struct nvme_transport_handle **hdlp) { struct nvme_transport_handle *hdl; @@ -235,7 +235,7 @@ __public int nvme_open(struct nvme_global_ctx *ctx, const char *name, ret = __nvme_transport_handle_open_direct(hdl, name); if (ret) { - nvme_close(hdl); + libnvme_close(hdl); return ret; } @@ -244,7 +244,7 @@ __public int nvme_open(struct nvme_global_ctx *ctx, const char *name, return 0; } -__public void nvme_close(struct nvme_transport_handle *hdl) +__public void libnvme_close(struct nvme_transport_handle *hdl) { if (!hdl) return; @@ -264,32 +264,32 @@ __public void nvme_close(struct nvme_transport_handle *hdl) } } -__public int nvme_transport_handle_get_fd(struct nvme_transport_handle *hdl) +__public int libnvme_transport_handle_get_fd(struct nvme_transport_handle *hdl) { return hdl->fd; } -__public const char *nvme_transport_handle_get_name(struct nvme_transport_handle *hdl) +__public const char *libnvme_transport_handle_get_name(struct nvme_transport_handle *hdl) { return basename(hdl->name); } -__public bool nvme_transport_handle_is_blkdev(struct nvme_transport_handle *hdl) +__public bool libnvme_transport_handle_is_blkdev(struct nvme_transport_handle *hdl) { return S_ISBLK(hdl->stat.st_mode); } -__public bool nvme_transport_handle_is_chardev(struct nvme_transport_handle *hdl) +__public bool libnvme_transport_handle_is_chardev(struct nvme_transport_handle *hdl) { return S_ISCHR(hdl->stat.st_mode); } -__public bool nvme_transport_handle_is_direct(struct nvme_transport_handle *hdl) +__public bool libnvme_transport_handle_is_direct(struct nvme_transport_handle *hdl) { return hdl->type == NVME_TRANSPORT_HANDLE_TYPE_DIRECT; } -__public bool nvme_transport_handle_is_mi(struct nvme_transport_handle *hdl) +__public bool libnvme_transport_handle_is_mi(struct nvme_transport_handle *hdl) { return hdl->type == NVME_TRANSPORT_HANDLE_TYPE_MI; } diff --git a/libnvme/src/nvme/lib.h b/libnvme/src/nvme/lib.h index 6efc245d9b..a28fcf8540 100644 --- a/libnvme/src/nvme/lib.h +++ b/libnvme/src/nvme/lib.h @@ -22,24 +22,24 @@ #endif /** - * nvme_create_global_ctx() - Initialize global context object + * libnvme_create_global_ctx() - Initialize global context object * @fp: File descriptor for logging messages * @log_level: Logging level to use * * Return: Initialized &struct nvme_global_ctx object */ -struct nvme_global_ctx *nvme_create_global_ctx(FILE *fp, int log_level); +struct nvme_global_ctx *libnvme_create_global_ctx(FILE *fp, int log_level); /** - * nvme_free_global_ctx() - Free global context object + * libnvme_free_global_ctx() - Free global context object * @ctx: &struct nvme_global_ctx object * * Free an &struct nvme_global_ctx object and all attached objects */ -void nvme_free_global_ctx(struct nvme_global_ctx *ctx); +void libnvme_free_global_ctx(struct nvme_global_ctx *ctx); /** - * nvme_set_logging_level() - Set current logging level + * libnvme_set_logging_level() - Set current logging level * @ctx: struct nvme_global_ctx object * @log_level: Logging level to set * @log_pid: Boolean to enable logging of the PID @@ -47,11 +47,11 @@ void nvme_free_global_ctx(struct nvme_global_ctx *ctx); * * Sets the current logging level for the global context. */ -void nvme_set_logging_level(struct nvme_global_ctx *ctx, int log_level, +void libnvme_set_logging_level(struct nvme_global_ctx *ctx, int log_level, bool log_pid, bool log_tstamp); /** - * nvme_get_logging_level() - Get current logging level + * libnvme_get_logging_level() - Get current logging level * @ctx: struct nvme_global_ctx object * @log_pid: Pointer to store a current value of logging of * the PID flag at (optional). @@ -62,11 +62,11 @@ void nvme_set_logging_level(struct nvme_global_ctx *ctx, int log_level, * * Return: current log level value or DEFAULT_LOGLEVEL if not initialized. */ -int nvme_get_logging_level(struct nvme_global_ctx *ctx, bool *log_pid, +int libnvme_get_logging_level(struct nvme_global_ctx *ctx, bool *log_pid, bool *log_tstamp); /** - * nvme_open() - Open an nvme controller or namespace device + * libnvme_open() - Open an nvme controller or namespace device * @ctx: struct nvme_global_ctx object * @name: The basename of the device to open * @hdl: Transport handle to return @@ -76,72 +76,72 @@ int nvme_get_logging_level(struct nvme_global_ctx *ctx, bool *log_pid, * * Return: 0 on success or negative error code otherwise */ -int nvme_open(struct nvme_global_ctx *ctx, const char *name, +int libnvme_open(struct nvme_global_ctx *ctx, const char *name, struct nvme_transport_handle **hdl); /** - * nvme_close() - Close transport handle + * libnvme_close() - Close transport handle * @hdl: Transport handle */ -void nvme_close(struct nvme_transport_handle *hdl); +void libnvme_close(struct nvme_transport_handle *hdl); /** - * nvme_transport_handle_get_fd - Return file descriptor from transport handle + * libnvme_transport_handle_get_fd - Return file descriptor from transport handle * @hdl: Transport handle * * If the device handle is for a ioctl based device, - * nvme_transport_handle_get_fd will return a valid file descriptor. + * libnvme_transport_handle_get_fd will return a valid file descriptor. * * Return: File descriptor for an IOCTL based transport handle, otherwise -1. */ -int nvme_transport_handle_get_fd(struct nvme_transport_handle *hdl); +int libnvme_transport_handle_get_fd(struct nvme_transport_handle *hdl); /** - * nvme_transport_handle_get_name - Return name of the device transport handle + * libnvme_transport_handle_get_name - Return name of the device transport handle * @hdl: Transport handle * * Return: Device file name, otherwise -1. */ -const char *nvme_transport_handle_get_name(struct nvme_transport_handle *hdl); +const char *libnvme_transport_handle_get_name(struct nvme_transport_handle *hdl); /** - * nvme_transport_handle_is_blkdev - Check if transport handle is a block device + * libnvme_transport_handle_is_blkdev - Check if transport handle is a block device * @hdl: Transport handle * * Return: Return true if transport handle is a block device, otherwise false. */ -bool nvme_transport_handle_is_blkdev(struct nvme_transport_handle *hdl); +bool libnvme_transport_handle_is_blkdev(struct nvme_transport_handle *hdl); /** - * nvme_transport_handle_is_chardev - Check if transport handle is a char device + * libnvme_transport_handle_is_chardev - Check if transport handle is a char device * @hdl: Transport handle * * Return: Return true if transport handle is a char device, otherwise false. */ -bool nvme_transport_handle_is_chardev(struct nvme_transport_handle *hdl); +bool libnvme_transport_handle_is_chardev(struct nvme_transport_handle *hdl); /** - * nvme_transport_handle_is_direct - Check if transport handle is using IOCTL + * libnvme_transport_handle_is_direct - Check if transport handle is using IOCTL * interface * @hdl: Transport handle * * Return: Return true if transport handle is using IOCTL itnerface, * otherwise false. */ -bool nvme_transport_handle_is_direct(struct nvme_transport_handle *hdl); +bool libnvme_transport_handle_is_direct(struct nvme_transport_handle *hdl); /** - * nvme_transport_handle_is_mi - Check if transport handle is a using MI + * libnvme_transport_handle_is_mi - Check if transport handle is a using MI * interface * @hdl: Transport handle * * Return: Return true if transport handle is using MI interface, * otherwise false. */ -bool nvme_transport_handle_is_mi(struct nvme_transport_handle *hdl); +bool libnvme_transport_handle_is_mi(struct nvme_transport_handle *hdl); /** - * nvme_transport_handle_set_submit_entry() - Install a submit-entry callback + * libnvme_transport_handle_set_submit_entry() - Install a submit-entry callback * @hdl: Transport handle to configure * @submit_entry: Callback invoked immediately before a passthrough command is * submitted. The function receives the command about to be issued @@ -156,12 +156,12 @@ bool nvme_transport_handle_is_mi(struct nvme_transport_handle *hdl); * * Return: None. */ -void nvme_transport_handle_set_submit_entry(struct nvme_transport_handle *hdl, +void libnvme_transport_handle_set_submit_entry(struct nvme_transport_handle *hdl, void *(*submit_entry)(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd)); /** - * nvme_transport_handle_set_submit_exit() - Install a submit-exit callback + * libnvme_transport_handle_set_submit_exit() - Install a submit-exit callback * @hdl: Transport handle to configure * @submit_exit: Callback invoked after a passthrough command completes. The * function receives the command, the completion status @err @@ -175,13 +175,13 @@ void nvme_transport_handle_set_submit_entry(struct nvme_transport_handle *hdl, * * Return: None. */ -void nvme_transport_handle_set_submit_exit(struct nvme_transport_handle *hdl, +void libnvme_transport_handle_set_submit_exit(struct nvme_transport_handle *hdl, void (*submit_exit)(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd, int err, void *user_data)); /** - * nvme_transport_handle_set_decide_retry() - Install a retry-decision callback + * libnvme_transport_handle_set_decide_retry() - Install a retry-decision callback * @hdl: Transport handle to configure * @decide_retry: Callback used to determine whether a passthrough command * should be retried after an error. The function is called with @@ -200,12 +200,12 @@ void nvme_transport_handle_set_submit_exit(struct nvme_transport_handle *hdl, * * Return: None. */ -void nvme_transport_handle_set_decide_retry(struct nvme_transport_handle *hdl, +void libnvme_transport_handle_set_decide_retry(struct nvme_transport_handle *hdl, bool (*decide_retry)(struct nvme_transport_handle *hdl, struct nvme_passthru_cmd *cmd, int err)); /** - * nvme_set_probe_enabled() - enable/disable the probe for new MI endpoints + * libnvme_set_probe_enabled() - enable/disable the probe for new MI endpoints * @ctx: &struct nvme_global_ctx object * @enabled: whether to probe new endpoints * @@ -213,20 +213,20 @@ void nvme_transport_handle_set_decide_retry(struct nvme_transport_handle *hdl, * Defaults to enabled, which results in some initial messaging with the * endpoint to determine model-specific details. */ -void nvme_set_probe_enabled(struct nvme_global_ctx *ctx, bool enabled); +void libnvme_set_probe_enabled(struct nvme_global_ctx *ctx, bool enabled); /** - * nvme_set_dry_run() - Set global dry run state + * libnvme_set_dry_run() - Set global dry run state * @ctx: struct nvme_global_ctx object * @enable: Enable/disable dry run state * * When dry_run is enabled, any IOCTL commands send via the passthru * interface won't be executed. */ -void nvme_set_dry_run(struct nvme_global_ctx *ctx, bool enable); +void libnvme_set_dry_run(struct nvme_global_ctx *ctx, bool enable); /** - * nvme_set_ioctl_probing() - Enable/disable 64-bit IOCTL probing + * libnvme_set_ioctl_probing() - Enable/disable 64-bit IOCTL probing * @ctx: struct nvme_global_ctx object * @enable: Enable/disable 64-bit IOCTL probing * @@ -235,4 +235,4 @@ void nvme_set_dry_run(struct nvme_global_ctx *ctx, bool enable); * * IOCTL probing is enabled per default. */ -void nvme_set_ioctl_probing(struct nvme_global_ctx *ctx, bool enable); +void libnvme_set_ioctl_probing(struct nvme_global_ctx *ctx, bool enable); diff --git a/libnvme/src/nvme/linux.c b/libnvme/src/nvme/linux.c index f8913e7ea8..0cc1f7672b 100644 --- a/libnvme/src/nvme/linux.c +++ b/libnvme/src/nvme/linux.c @@ -110,7 +110,7 @@ static char *__nvme_get_attr(const char *path) return strlen(value) ? strdup(value) : NULL; } -__public char *nvme_get_attr(const char *dir, const char *attr) +__public char *libnvme_get_attr(const char *dir, const char *attr) { _cleanup_free_ char *path = NULL; int ret; @@ -122,24 +122,24 @@ __public char *nvme_get_attr(const char *dir, const char *attr) return __nvme_get_attr(path); } -__public char *nvme_get_subsys_attr(nvme_subsystem_t s, const char *attr) +__public char *libnvme_get_subsys_attr(libnvme_subsystem_t s, const char *attr) { - return nvme_get_attr(nvme_subsystem_get_sysfs_dir(s), attr); + return libnvme_get_attr(libnvme_subsystem_get_sysfs_dir(s), attr); } -__public char *nvme_get_ctrl_attr(nvme_ctrl_t c, const char *attr) +__public char *libnvme_get_ctrl_attr(libnvme_ctrl_t c, const char *attr) { - return nvme_get_attr(nvme_ctrl_get_sysfs_dir(c), attr); + return libnvme_get_attr(libnvme_ctrl_get_sysfs_dir(c), attr); } -__public char *nvme_get_ns_attr(nvme_ns_t n, const char *attr) +__public char *libnvme_get_ns_attr(libnvme_ns_t n, const char *attr) { - return nvme_get_attr(nvme_ns_get_sysfs_dir(n), attr); + return libnvme_get_attr(libnvme_ns_get_sysfs_dir(n), attr); } -__public char *nvme_get_path_attr(nvme_path_t p, const char *attr) +__public char *libnvme_get_path_attr(libnvme_path_t p, const char *attr) { - return nvme_get_attr(nvme_path_get_sysfs_dir(p), attr); + return libnvme_get_attr(libnvme_path_get_sysfs_dir(p), attr); } #ifndef CONFIG_OPENSSL @@ -148,7 +148,7 @@ static unsigned char default_hmac(size_t key_len) return NVME_HMAC_ALG_NONE; } -__public int nvme_gen_dhchap_key(struct nvme_global_ctx *ctx, +__public int libnvme_gen_dhchap_key(struct nvme_global_ctx *ctx, char *hostnqn, enum nvme_hmac_alg hmac, unsigned int key_len, unsigned char *secret, unsigned char *key) @@ -593,7 +593,7 @@ static DEFINE_CLEANUP_FUNC(cleanup_evp_mac_ctx, EVP_MAC_CTX *, EVP_MAC_CTX_free) static DEFINE_CLEANUP_FUNC(cleanup_evp_mac, EVP_MAC *, EVP_MAC_free) #define _cleanup_evp_mac_ __cleanup__(cleanup_evp_mac) -__public int nvme_gen_dhchap_key(struct nvme_global_ctx *ctx, +__public int libnvme_gen_dhchap_key(struct nvme_global_ctx *ctx, char *hostnqn, enum nvme_hmac_alg hmac, unsigned int key_len, unsigned char *secret, unsigned char *key) @@ -841,7 +841,7 @@ static ssize_t nvme_identity_len(int hmac, int version, const char *hostnqn, return len; } -__public int nvme_generate_tls_key_identity(struct nvme_global_ctx *ctx, +__public int libnvme_generate_tls_key_identity(struct nvme_global_ctx *ctx, const char *hostnqn, const char *subsysnqn, int version, int hmac, unsigned char *configured_key, int key_len, @@ -879,7 +879,7 @@ __public int nvme_generate_tls_key_identity(struct nvme_global_ctx *ctx, return 0; } -__public int nvme_generate_tls_key_identity_compat(struct nvme_global_ctx *ctx, +__public int libnvme_generate_tls_key_identity_compat(struct nvme_global_ctx *ctx, const char *hostnqn, const char *subsysnqn, int version, int hmac, unsigned char *configured_key, int key_len, char **ident) @@ -917,7 +917,7 @@ __public int nvme_generate_tls_key_identity_compat(struct nvme_global_ctx *ctx, } #ifdef CONFIG_KEYUTILS -__public int nvme_lookup_keyring(struct nvme_global_ctx *ctx, const char *keyring, +__public int libnvme_lookup_keyring(struct nvme_global_ctx *ctx, const char *keyring, long *key) { key_serial_t keyring_id; @@ -932,7 +932,7 @@ __public int nvme_lookup_keyring(struct nvme_global_ctx *ctx, const char *keyrin return 0; } -__public char *nvme_describe_key_serial(struct nvme_global_ctx *ctx, long key_id) +__public char *libnvme_describe_key_serial(struct nvme_global_ctx *ctx, long key_id) { _cleanup_free_ char *str = NULL; char *last; @@ -951,7 +951,7 @@ __public char *nvme_describe_key_serial(struct nvme_global_ctx *ctx, long key_id return strdup(last); } -__public int nvme_lookup_key(struct nvme_global_ctx *ctx, const char *type, +__public int libnvme_lookup_key(struct nvme_global_ctx *ctx, const char *type, const char *identity, long *keyp) { key_serial_t key; @@ -962,12 +962,12 @@ __public int nvme_lookup_key(struct nvme_global_ctx *ctx, const char *type, return key; } -__public int nvme_set_keyring(struct nvme_global_ctx *ctx, long key_id) +__public int libnvme_set_keyring(struct nvme_global_ctx *ctx, long key_id) { long err; if (key_id == 0) { - if (nvme_lookup_keyring(ctx, NULL, &key_id)) + if (libnvme_lookup_keyring(ctx, NULL, &key_id)) return -ENOKEY; } @@ -977,13 +977,13 @@ __public int nvme_set_keyring(struct nvme_global_ctx *ctx, long key_id) return 0; } -__public int nvme_read_key(struct nvme_global_ctx *ctx, long keyring_id, +__public int libnvme_read_key(struct nvme_global_ctx *ctx, long keyring_id, long key_id, int *len, unsigned char **key) { void *buffer; int ret; - ret = nvme_set_keyring(ctx, keyring_id); + ret = libnvme_set_keyring(ctx, keyring_id); if (ret < 0) return ret; @@ -996,7 +996,7 @@ __public int nvme_read_key(struct nvme_global_ctx *ctx, long keyring_id, return 0; } -__public int nvme_update_key(struct nvme_global_ctx *ctx, long keyring_id, +__public int libnvme_update_key(struct nvme_global_ctx *ctx, long keyring_id, const char *key_type, const char *identity, unsigned char *key_data, int key_len, long *keyp) { @@ -1056,21 +1056,21 @@ int __scan_keys_cb(key_serial_t parent, key_serial_t key, char *desc, return 1; } -__public int nvme_scan_tls_keys(struct nvme_global_ctx *ctx, const char *keyring, +__public int libnvme_scan_tls_keys(struct nvme_global_ctx *ctx, const char *keyring, nvme_scan_tls_keys_cb_t cb, void *data) { struct __scan_keys_data d; long keyring_id; int ret; - ret = nvme_lookup_keyring(ctx, keyring, &keyring_id); + ret = libnvme_lookup_keyring(ctx, keyring, &keyring_id); if (ret) return ret; if (!keyring_id) return -EINVAL; - ret = nvme_set_keyring(ctx, keyring_id); + ret = libnvme_set_keyring(ctx, keyring_id); if (ret < 0) return ret; @@ -1115,7 +1115,7 @@ static int __nvme_insert_tls_key(struct nvme_global_ctx *ctx, return -ENOKEY; } - ret = nvme_update_key(ctx, keyring_id, key_type, identity, + ret = libnvme_update_key(ctx, keyring_id, key_type, identity, psk, key_len, &key); if (ret) return ret; @@ -1124,7 +1124,7 @@ static int __nvme_insert_tls_key(struct nvme_global_ctx *ctx, return 0; } -__public int nvme_insert_tls_key_versioned(struct nvme_global_ctx *ctx, +__public int libnvme_insert_tls_key_versioned(struct nvme_global_ctx *ctx, const char *keyring, const char *key_type, const char *hostnqn, const char *subsysnqn, int version, int hmac, @@ -1134,11 +1134,11 @@ __public int nvme_insert_tls_key_versioned(struct nvme_global_ctx *ctx, long keyring_id; int ret; - ret = nvme_lookup_keyring(ctx, keyring, &keyring_id); + ret = libnvme_lookup_keyring(ctx, keyring, &keyring_id); if (ret) return ret; - ret = nvme_set_keyring(ctx, keyring_id); + ret = libnvme_set_keyring(ctx, keyring_id); if (ret < 0) return 0; @@ -1147,7 +1147,7 @@ __public int nvme_insert_tls_key_versioned(struct nvme_global_ctx *ctx, configured_key, key_len, false, key); } -__public int nvme_insert_tls_key_compat(struct nvme_global_ctx *ctx, +__public int libnvme_insert_tls_key_compat(struct nvme_global_ctx *ctx, const char *keyring, const char *key_type, const char *hostnqn, const char *subsysnqn, int version, int hmac, @@ -1157,11 +1157,11 @@ __public int nvme_insert_tls_key_compat(struct nvme_global_ctx *ctx, long keyring_id; int ret; - ret = nvme_lookup_keyring(ctx, keyring, &keyring_id); + ret = libnvme_lookup_keyring(ctx, keyring, &keyring_id); if (ret) return ret; - ret = nvme_set_keyring(ctx, keyring_id); + ret = libnvme_set_keyring(ctx, keyring_id); if (ret < 0) return 0; @@ -1170,14 +1170,14 @@ __public int nvme_insert_tls_key_compat(struct nvme_global_ctx *ctx, configured_key, key_len, true, key); } -__public int nvme_revoke_tls_key(struct nvme_global_ctx *ctx, +__public int libnvme_revoke_tls_key(struct nvme_global_ctx *ctx, const char *keyring, const char *key_type, const char *identity) { long keyring_id, key; int ret; - ret = nvme_lookup_keyring(ctx, keyring, &keyring_id); + ret = libnvme_lookup_keyring(ctx, keyring, &keyring_id); if (ret) return ret; @@ -1203,7 +1203,7 @@ static int __nvme_import_tls_key(struct nvme_global_ctx *ctx, long keyring_id, size_t key_len; int ret; - ret = nvme_import_tls_key_versioned(ctx, key, &version, + ret = libnvme_import_tls_key_versioned(ctx, key, &version, &hmac, &key_len, &key_data); if (ret) return ret; @@ -1220,15 +1220,15 @@ static int __nvme_import_tls_key(struct nvme_global_ctx *ctx, long keyring_id, key_data, key_len, false, keyp); } - return nvme_update_key(ctx, keyring_id, "psk", identity, + return libnvme_update_key(ctx, keyring_id, "psk", identity, key_data, key_len, keyp); } -int __nvme_import_keys_from_config(nvme_host_t h, nvme_ctrl_t c, +int __nvme_import_keys_from_config(libnvme_host_t h, libnvme_ctrl_t c, long *keyring_id, long *key_id) { - const char *hostnqn = nvme_host_get_hostnqn(h); - const char *subsysnqn = nvme_ctrl_get_subsysnqn(c); + const char *hostnqn = libnvme_host_get_hostnqn(h); + const char *subsysnqn = libnvme_ctrl_get_subsysnqn(c); const char *keyring, *key, *identity; long kr_id = 0, id = 0; int ret; @@ -1240,13 +1240,13 @@ int __nvme_import_keys_from_config(nvme_host_t h, nvme_ctrl_t c, } /* If we don't have a key avoid all keyring operations */ - key = nvme_ctrl_get_tls_key(c); + key = libnvme_ctrl_get_tls_key(c); if (!key) goto out; - keyring = nvme_ctrl_get_keyring(c); + keyring = libnvme_ctrl_get_keyring(c); if (keyring) { - ret = nvme_lookup_keyring(h->ctx, keyring, &kr_id); + ret = libnvme_lookup_keyring(h->ctx, keyring, &kr_id); if (ret) return ret; } else @@ -1258,19 +1258,19 @@ int __nvme_import_keys_from_config(nvme_host_t h, nvme_ctrl_t c, * That means we are explicitly selecting the keyring. */ if (!kr_id) { - ret = nvme_lookup_keyring(h->ctx, ".nvme", &kr_id); + ret = libnvme_lookup_keyring(h->ctx, ".nvme", &kr_id); if (ret) return ret; } - if (nvme_set_keyring(h->ctx, kr_id) < 0) { + if (libnvme_set_keyring(h->ctx, kr_id) < 0) { nvme_msg(h->ctx, LOG_ERR, "Failed to set keyring\n"); return -errno; } - identity = nvme_ctrl_get_tls_key_identity(c); + identity = libnvme_ctrl_get_tls_key_identity(c); if (identity) { - ret = nvme_lookup_key(h->ctx, "psk", identity, &id); + ret = libnvme_lookup_key(h->ctx, "psk", identity, &id); if (ret && !(ret == -ENOKEY || ret == -EKEYREVOKED)) { nvme_msg(h->ctx, LOG_ERR, "Failed to lookup key for identity %s, error %d\n", @@ -1296,7 +1296,7 @@ int __nvme_import_keys_from_config(nvme_host_t h, nvme_ctrl_t c, return 0; } #else -__public int nvme_lookup_keyring(struct nvme_global_ctx *ctx, const char *keyring, +__public int libnvme_lookup_keyring(struct nvme_global_ctx *ctx, const char *keyring, long *key) { nvme_msg(ctx, LOG_ERR, "key operations not supported; " @@ -1304,14 +1304,14 @@ __public int nvme_lookup_keyring(struct nvme_global_ctx *ctx, const char *keyrin return -ENOTSUP; } -__public char *nvme_describe_key_serial(struct nvme_global_ctx *ctx, long key_id) +__public char *libnvme_describe_key_serial(struct nvme_global_ctx *ctx, long key_id) { nvme_msg(ctx, LOG_ERR, "key operations not supported; " "recompile with keyutils support.\n"); return NULL; } -__public int nvme_lookup_key(struct nvme_global_ctx *ctx, const char *type, +__public int libnvme_lookup_key(struct nvme_global_ctx *ctx, const char *type, const char *identity, long *key) { nvme_msg(ctx, LOG_ERR, "key operations not supported; " @@ -1319,14 +1319,14 @@ __public int nvme_lookup_key(struct nvme_global_ctx *ctx, const char *type, return -ENOTSUP; } -__public int nvme_set_keyring(struct nvme_global_ctx *ctx, long key_id) +__public int libnvme_set_keyring(struct nvme_global_ctx *ctx, long key_id) { nvme_msg(ctx, LOG_ERR, "key operations not supported; " "recompile with keyutils support.\n"); return -ENOTSUP; } -__public int nvme_read_key(struct nvme_global_ctx *ctx, long keyring_id, +__public int libnvme_read_key(struct nvme_global_ctx *ctx, long keyring_id, long key_id, int *len, unsigned char **key) { nvme_msg(ctx, LOG_ERR, "key operations not supported; " @@ -1334,7 +1334,7 @@ __public int nvme_read_key(struct nvme_global_ctx *ctx, long keyring_id, return -ENOTSUP; } -__public int nvme_update_key(struct nvme_global_ctx *ctx, long keyring_id, +__public int libnvme_update_key(struct nvme_global_ctx *ctx, long keyring_id, const char *key_type, const char *identity, unsigned char *key_data, int key_len, long *key) { @@ -1343,7 +1343,7 @@ __public int nvme_update_key(struct nvme_global_ctx *ctx, long keyring_id, return -ENOTSUP; } -__public int nvme_scan_tls_keys(struct nvme_global_ctx *ctx, const char *keyring, +__public int libnvme_scan_tls_keys(struct nvme_global_ctx *ctx, const char *keyring, nvme_scan_tls_keys_cb_t cb, void *data) { nvme_msg(ctx, LOG_ERR, "key operations not supported; " @@ -1351,7 +1351,7 @@ __public int nvme_scan_tls_keys(struct nvme_global_ctx *ctx, const char *keyring return -ENOTSUP; } -__public int nvme_insert_tls_key_versioned(struct nvme_global_ctx *ctx, +__public int libnvme_insert_tls_key_versioned(struct nvme_global_ctx *ctx, const char *keyring, const char *key_type, const char *hostnqn, const char *subsysnqn, int version, int hmac, @@ -1363,7 +1363,7 @@ __public int nvme_insert_tls_key_versioned(struct nvme_global_ctx *ctx, return -ENOTSUP; } -__public int nvme_insert_tls_key_compat(struct nvme_global_ctx *ctx, +__public int libnvme_insert_tls_key_compat(struct nvme_global_ctx *ctx, const char *keyring, const char *key_type, const char *hostnqn, const char *subsysnqn, int version, int hmac, @@ -1375,7 +1375,7 @@ __public int nvme_insert_tls_key_compat(struct nvme_global_ctx *ctx, return -ENOTSUP; } -__public int nvme_revoke_tls_key(struct nvme_global_ctx *ctx, +__public int libnvme_revoke_tls_key(struct nvme_global_ctx *ctx, const char *keyring, const char *key_type, const char *identity) { @@ -1384,7 +1384,7 @@ __public int nvme_revoke_tls_key(struct nvme_global_ctx *ctx, return -ENOTSUP; } -int __nvme_import_keys_from_config(nvme_host_t h, nvme_ctrl_t c, +int __nvme_import_keys_from_config(libnvme_host_t h, libnvme_ctrl_t c, long *keyring_id, long *key_id) { *keyring_id = 0; @@ -1394,12 +1394,12 @@ int __nvme_import_keys_from_config(nvme_host_t h, nvme_ctrl_t c, } #endif -__public int nvme_insert_tls_key(struct nvme_global_ctx *ctx, +__public int libnvme_insert_tls_key(struct nvme_global_ctx *ctx, const char *keyring, const char *key_type, const char *hostnqn, const char *subsysnqn, int hmac, unsigned char *configured_key, int key_len, long *key) { - return nvme_insert_tls_key_versioned(ctx, keyring, key_type, + return libnvme_insert_tls_key_versioned(ctx, keyring, key_type, hostnqn, subsysnqn, 0, hmac, configured_key, key_len, key); } @@ -1416,7 +1416,7 @@ __public int nvme_insert_tls_key(struct nvme_global_ctx *ctx, * s: 32 or 48 bytes binary followed by a CRC-32 of the configured PSK * (4 bytes) encoded as base64 */ -__public int nvme_export_tls_key_versioned(struct nvme_global_ctx *ctx, +__public int libnvme_export_tls_key_versioned(struct nvme_global_ctx *ctx, unsigned char version, unsigned char hmac, const unsigned char *key_data, size_t key_len, char **encoded_keyp) @@ -1466,7 +1466,7 @@ __public int nvme_export_tls_key_versioned(struct nvme_global_ctx *ctx, return 0; } -__public int nvme_export_tls_key(struct nvme_global_ctx *ctx, +__public int libnvme_export_tls_key(struct nvme_global_ctx *ctx, const unsigned char *key_data, int key_len, char **key) { unsigned char hmac; @@ -1476,11 +1476,11 @@ __public int nvme_export_tls_key(struct nvme_global_ctx *ctx, else hmac = NVME_HMAC_ALG_SHA2_384; - return nvme_export_tls_key_versioned(ctx, 1, hmac, key_data, + return libnvme_export_tls_key_versioned(ctx, 1, hmac, key_data, key_len, key); } -__public int nvme_import_tls_key_versioned(struct nvme_global_ctx *ctx, +__public int libnvme_import_tls_key_versioned(struct nvme_global_ctx *ctx, const char *encoded_key, unsigned char *version, unsigned char *hmac, size_t *key_len, unsigned char **keyp) @@ -1549,7 +1549,7 @@ __public int nvme_import_tls_key_versioned(struct nvme_global_ctx *ctx, return 0; } -__public int nvme_import_tls_key(struct nvme_global_ctx *ctx, const char *encoded_key, +__public int libnvme_import_tls_key(struct nvme_global_ctx *ctx, const char *encoded_key, int *key_len, unsigned int *hmac, unsigned char **keyp) { unsigned char version, _hmac; @@ -1557,7 +1557,7 @@ __public int nvme_import_tls_key(struct nvme_global_ctx *ctx, const char *encode size_t len; int ret; - ret = nvme_import_tls_key_versioned(ctx, encoded_key, &version, + ret = libnvme_import_tls_key_versioned(ctx, encoded_key, &version, &_hmac, &len, &psk); if (ret) return ret; @@ -1724,7 +1724,7 @@ static int uuid_from_dmi(char *system_uuid) return ret; } -__public char *nvme_generate_hostid(void) +__public char *libnvme_generate_hostid(void) { int ret; char uuid_str[NVME_UUID_LEN_STRING]; @@ -1734,22 +1734,22 @@ __public char *nvme_generate_hostid(void) if (ret < 0) ret = uuid_from_device_tree(uuid_str); if (ret < 0) { - if (nvme_random_uuid(uuid) < 0) + if (libnvme_random_uuid(uuid) < 0) memset(uuid, 0, NVME_UUID_LEN); - nvme_uuid_to_string(uuid, uuid_str); + libnvme_uuid_to_string(uuid, uuid_str); } return strdup(uuid_str); } -__public char *nvme_generate_hostnqn_from_hostid(char *hostid) +__public char *libnvme_generate_hostnqn_from_hostid(char *hostid) { char *hid = NULL; char *hostnqn; int ret; if (!hostid) - hostid = hid = nvme_generate_hostid(); + hostid = hid = libnvme_generate_hostid(); ret = asprintf(&hostnqn, "nqn.2014-08.org.nvmexpress:uuid:%s", hostid); free(hid); @@ -1757,9 +1757,9 @@ __public char *nvme_generate_hostnqn_from_hostid(char *hostid) return (ret < 0) ? NULL : hostnqn; } -__public char *nvme_generate_hostnqn(void) +__public char *libnvme_generate_hostnqn(void) { - return nvme_generate_hostnqn_from_hostid(NULL); + return libnvme_generate_hostnqn_from_hostid(NULL); } static char *nvmf_read_file(const char *f, int len) @@ -1780,7 +1780,7 @@ static char *nvmf_read_file(const char *f, int len) return strndup(buf, strcspn(buf, "\n")); } -__public char *nvme_read_hostnqn(void) +__public char *libnvme_read_hostnqn(void) { char *hostnqn = getenv("LIBNVME_HOSTNQN"); @@ -1793,7 +1793,7 @@ __public char *nvme_read_hostnqn(void) return nvmf_read_file(NVMF_HOSTNQN_FILE, NVMF_NQN_SIZE); } -__public char *nvme_read_hostid(void) +__public char *libnvme_read_hostid(void) { char *hostid = getenv("LIBNVME_HOSTID"); diff --git a/libnvme/src/nvme/linux.h b/libnvme/src/nvme/linux.h index 2816d4bef8..10199d167e 100644 --- a/libnvme/src/nvme/linux.h +++ b/libnvme/src/nvme/linux.h @@ -33,7 +33,7 @@ enum nvme_hmac_alg { }; /** - * nvme_gen_dhchap_key() - DH-HMAC-CHAP key generation + * libnvme_gen_dhchap_key() - DH-HMAC-CHAP key generation * @ctx: struct nvme_global_ctx object * @hostnqn: Host NVMe Qualified Name * @hmac: HMAC algorithm @@ -44,13 +44,13 @@ enum nvme_hmac_alg { * Return: If key generation was successful the function returns 0 or * a negative error code otherwise. */ -int nvme_gen_dhchap_key(struct nvme_global_ctx *ctx, +int libnvme_gen_dhchap_key(struct nvme_global_ctx *ctx, char *hostnqn, enum nvme_hmac_alg hmac, unsigned int key_len, unsigned char *secret, unsigned char *key); /** - * nvme_lookup_keyring() - Lookup keyring serial number + * libnvme_lookup_keyring() - Lookup keyring serial number * @ctx: struct nvme_global_ctx object * @keyring: Keyring name * @key: Key serial number to return @@ -59,11 +59,11 @@ int nvme_gen_dhchap_key(struct nvme_global_ctx *ctx, * * Return: 0 on success or negative error code otherwise */ -int nvme_lookup_keyring(struct nvme_global_ctx *ctx, +int libnvme_lookup_keyring(struct nvme_global_ctx *ctx, const char *keyring, long *key); /** - * nvme_describe_key_serial() - Return key description + * libnvme_describe_key_serial() - Return key description * @ctx: struct nvme_global_ctx object * @key_id: Key serial number * @@ -73,11 +73,11 @@ int nvme_lookup_keyring(struct nvme_global_ctx *ctx, * Return: The description of @key_id or NULL on failure. * The returned string needs to be freed by the caller. */ -char *nvme_describe_key_serial(struct nvme_global_ctx *ctx, +char *libnvme_describe_key_serial(struct nvme_global_ctx *ctx, long key_id); /** - * nvme_lookup_key() - Lookup key serial number + * libnvme_lookup_key() - Lookup key serial number * @ctx: struct nvme_global_ctx object * @type: Key type * @identity: Key description @@ -88,11 +88,11 @@ char *nvme_describe_key_serial(struct nvme_global_ctx *ctx, * * Return: 0 on success or negative error code otherwise */ -int nvme_lookup_key(struct nvme_global_ctx *ctx, const char *type, +int libnvme_lookup_key(struct nvme_global_ctx *ctx, const char *type, const char *identity, long *key); /** - * nvme_set_keyring() - Link keyring for lookup + * libnvme_set_keyring() - Link keyring for lookup * @ctx: struct nvme_global_ctx object * @keyring_id: Keyring id * @@ -101,10 +101,10 @@ int nvme_lookup_key(struct nvme_global_ctx *ctx, const char *type, * * Return: 0 on success or negative error code otherwise */ -int nvme_set_keyring(struct nvme_global_ctx *ctx, long keyring_id); +int libnvme_set_keyring(struct nvme_global_ctx *ctx, long keyring_id); /** - * nvme_read_key() - Read key raw data + * libnvme_read_key() - Read key raw data * @ctx: struct nvme_global_ctx object * @keyring_id: Id of the keyring holding %key_id * @key_id: Key id @@ -118,11 +118,11 @@ int nvme_set_keyring(struct nvme_global_ctx *ctx, long keyring_id); * * Return: 0 on success or negative error code otherwise */ -int nvme_read_key(struct nvme_global_ctx *ctx, long keyring_id, +int libnvme_read_key(struct nvme_global_ctx *ctx, long keyring_id, long key_id, int *len, unsigned char **key); /** - * nvme_update_key() - Update key raw data + * libnvme_update_key() - Update key raw data * @ctx: struct nvme_global_ctx object * @keyring_id: Id of the keyring holding %key_id * @key_type: Type of the key to insert @@ -138,7 +138,7 @@ int nvme_read_key(struct nvme_global_ctx *ctx, long keyring_id, * * Return: 0 on success or negative error code otherwise */ -int nvme_update_key(struct nvme_global_ctx *ctx, long keyring_id, +int libnvme_update_key(struct nvme_global_ctx *ctx, long keyring_id, const char *key_type, const char *identity, unsigned char *key_data, int key_len, long *key); @@ -157,7 +157,7 @@ typedef void (*nvme_scan_tls_keys_cb_t)(struct nvme_global_ctx *ctx, long keyring, long key, char *desc, int desc_len, void *data); /** - * nvme_scan_tls_keys() - Iterate over TLS keys in a keyring + * libnvme_scan_tls_keys() - Iterate over TLS keys in a keyring * @ctx: struct nvme_global_ctx object * @keyring: Keyring holding TLS keys * @cb: Callback function @@ -171,11 +171,11 @@ typedef void (*nvme_scan_tls_keys_cb_t)(struct nvme_global_ctx *ctx, * * Return: Number of keys for which @cb was called, or negative error code */ -int nvme_scan_tls_keys(struct nvme_global_ctx *ctx, const char *keyring, +int libnvme_scan_tls_keys(struct nvme_global_ctx *ctx, const char *keyring, nvme_scan_tls_keys_cb_t cb, void *data); /** - * nvme_insert_tls_key() - Derive and insert TLS key + * libnvme_insert_tls_key() - Derive and insert TLS key * @ctx: struct nvme_global_ctx object * @keyring: Keyring to use * @key_type: Type of the resulting key @@ -191,13 +191,13 @@ int nvme_scan_tls_keys(struct nvme_global_ctx *ctx, const char *keyring, * * Return: 0 on success or negative error code otherwise */ -int nvme_insert_tls_key(struct nvme_global_ctx *ctx, const char *keyring, +int libnvme_insert_tls_key(struct nvme_global_ctx *ctx, const char *keyring, const char *key_type, const char *hostnqn, const char *subsysnqn, int hmac, unsigned char *configured_key, int key_len, long *key); /** - * nvme_insert_tls_key_versioned() - Derive and insert TLS key + * libnvme_insert_tls_key_versioned() - Derive and insert TLS key * @ctx: struct nvme_global_ctx object * @keyring: Keyring to use * @key_type: Type of the resulting key @@ -215,7 +215,7 @@ int nvme_insert_tls_key(struct nvme_global_ctx *ctx, const char *keyring, * * Return: 0 on success or negative error code otherwise */ -int nvme_insert_tls_key_versioned(struct nvme_global_ctx *ctx, +int libnvme_insert_tls_key_versioned(struct nvme_global_ctx *ctx, const char *keyring, const char *key_type, const char *hostnqn, const char *subsysnqn, int version, int hmac, @@ -223,7 +223,7 @@ int nvme_insert_tls_key_versioned(struct nvme_global_ctx *ctx, long *key); /** - * nvme_insert_tls_key_compat() - Derive and insert TLS key + * libnvme_insert_tls_key_compat() - Derive and insert TLS key * @ctx: struct nvme_global_ctx object * @keyring: Keyring to use * @key_type: Type of the resulting key @@ -238,14 +238,14 @@ int nvme_insert_tls_key_versioned(struct nvme_global_ctx *ctx, * Derives a 'retained' TLS key as specified in NVMe TCP 1.0a (if * @version s set to '0') or NVMe TP8028 (if @version is set to '1) and * stores it as type @key_type in the keyring specified by @keyring. - * This version differs from @nvme_insert_tls_key_versioned() in that it + * This version differs from @libnvme_insert_tls_key_versioned() in that it * uses the original implementation for HKDF Expand-Label which does not * prefix the 'info' and 'label' strings with the length. * * Return: The key serial number if the key could be inserted into * the keyring or 0 with errno otherwise. */ -int nvme_insert_tls_key_compat(struct nvme_global_ctx *ctx, +int libnvme_insert_tls_key_compat(struct nvme_global_ctx *ctx, const char *keyring, const char *key_type, const char *hostnqn, const char *subsysnqn, int version, int hmac, @@ -253,7 +253,7 @@ int nvme_insert_tls_key_compat(struct nvme_global_ctx *ctx, long *key); /** - * nvme_generate_tls_key_identity() - Generate the TLS key identity + * libnvme_generate_tls_key_identity() - Generate the TLS key identity * @ctx: struct nvme_global_ctx object * @hostnqn: Host NVMe Qualified Name * @subsysnqn: Subsystem NVMe Qualified Name @@ -270,14 +270,14 @@ int nvme_insert_tls_key_compat(struct nvme_global_ctx *ctx, * * Return: 0 on success or negative error code otherwise */ -int nvme_generate_tls_key_identity(struct nvme_global_ctx *ctx, +int libnvme_generate_tls_key_identity(struct nvme_global_ctx *ctx, const char *hostnqn, const char *subsysnqn, int version, int hmac, unsigned char *configured_key, int key_len, char **identity); /** - * nvme_generate_tls_key_identity_compat() - Generate the TLS key identity + * libnvme_generate_tls_key_identity_compat() - Generate the TLS key identity * @ctx: struct nvme_global_ctx object * @hostnqn: Host NVMe Qualified Name * @subsysnqn: Subsystem NVMe Qualified Name @@ -289,7 +289,7 @@ int nvme_generate_tls_key_identity(struct nvme_global_ctx *ctx, * * Derives a 'retained' TLS key as specified in NVMe TCP and * generate the corresponding TLs identity. This version differs - * from @nvme_generate_tls_key_identity() in that it uses the original + * from @libnvme_generate_tls_key_identity() in that it uses the original * implementation for HKDF-Expand-Label which does not prefix the 'info' * and 'label' string with the length. * @@ -297,13 +297,13 @@ int nvme_generate_tls_key_identity(struct nvme_global_ctx *ctx, * * Return: 0 on success or negative error code otherwise */ -int nvme_generate_tls_key_identity_compat(struct nvme_global_ctx *ctx, +int libnvme_generate_tls_key_identity_compat(struct nvme_global_ctx *ctx, const char *hostnqn, const char *subsysnqn, int version, int hmac, unsigned char *configured_key, int key_len, char **identity); /** - * nvme_revoke_tls_key() - Revoke TLS key from keyring + * libnvme_revoke_tls_key() - Revoke TLS key from keyring * @ctx: struct nvme_global_ctx object * @keyring: Keyring to use * @key_type: Type of the key to revoke @@ -311,11 +311,11 @@ int nvme_generate_tls_key_identity_compat(struct nvme_global_ctx *ctx, * * Return: 0 on success or negative error code otherwise */ -int nvme_revoke_tls_key(struct nvme_global_ctx *ctx, const char *keyring, +int libnvme_revoke_tls_key(struct nvme_global_ctx *ctx, const char *keyring, const char *key_type, const char *identity); /** - * nvme_export_tls_key() - Export a TLS key + * libnvme_export_tls_key() - Export a TLS key * @ctx: struct nvme_global_ctx object * @key_data: Raw data of the key * @key_len: Length of @key_data @@ -329,11 +329,11 @@ int nvme_revoke_tls_key(struct nvme_global_ctx *ctx, const char *keyring, * * Return: 0 on success or negative error code otherwise */ -int nvme_export_tls_key(struct nvme_global_ctx *ctx, +int libnvme_export_tls_key(struct nvme_global_ctx *ctx, const unsigned char *key_data, int key_len, char **identity); /** - * nvme_export_tls_key_versioned() - Export a TLS pre-shared key + * libnvme_export_tls_key_versioned() - Export a TLS pre-shared key * @ctx: struct nvme_global_ctx object * @version: Indicated the representation of the TLS PSK * @hmac: HMAC algorithm used to transfor the configured PSK @@ -350,13 +350,13 @@ int nvme_export_tls_key(struct nvme_global_ctx *ctx, * * Return: 0 on success or negative error code otherwise */ -int nvme_export_tls_key_versioned(struct nvme_global_ctx *ctx, +int libnvme_export_tls_key_versioned(struct nvme_global_ctx *ctx, unsigned char version, unsigned char hmac, const unsigned char *key_data, size_t key_len, char **identity); /** - * nvme_import_tls_key() - Import a TLS key + * libnvme_import_tls_key() - Import a TLS key * @ctx: struct nvme_global_ctx object * @encoded_key: TLS key in PSK interchange format * @key_len: Length of the resulting key data @@ -370,11 +370,11 @@ int nvme_export_tls_key_versioned(struct nvme_global_ctx *ctx, * * Return: 0 on success or negative error code otherwise */ -int nvme_import_tls_key(struct nvme_global_ctx *ctx, const char *encoded_key, +int libnvme_import_tls_key(struct nvme_global_ctx *ctx, const char *encoded_key, int *key_len, unsigned int *hmac, unsigned char **key); /** - * nvme_import_tls_key_versioned() - Import a TLS key + * libnvme_import_tls_key_versioned() - Import a TLS key * @ctx: struct nvme_global_ctx object * @encoded_key: TLS key in PSK interchange format * @version: Indicated the representation of the TLS PSK @@ -390,19 +390,19 @@ int nvme_import_tls_key(struct nvme_global_ctx *ctx, const char *encoded_key, * * Return: 0 on success or negative error code otherwise */ -int nvme_import_tls_key_versioned(struct nvme_global_ctx *ctx, +int libnvme_import_tls_key_versioned(struct nvme_global_ctx *ctx, const char *encoded_key, unsigned char *version, unsigned char *hmac, size_t *key_len, unsigned char **key); /** - * nvme_generate_hostnqn() - Generate a machine specific host nqn + * libnvme_generate_hostnqn() - Generate a machine specific host nqn * Returns: An nvm namespace qualified name string based on the machine * identifier, or NULL if not successful. */ -char *nvme_generate_hostnqn(void); +char *libnvme_generate_hostnqn(void); /** - * nvme_generate_hostnqn_from_hostid() - Generate a host nqn from + * libnvme_generate_hostnqn_from_hostid() - Generate a host nqn from * host identifier * @hostid: Host identifier * @@ -412,18 +412,18 @@ char *nvme_generate_hostnqn(void); * Return: On success, an NVMe Qualified Name for host identification. This * name is based on the given host identifier. On failure, NULL. */ -char *nvme_generate_hostnqn_from_hostid(char *hostid); +char *libnvme_generate_hostnqn_from_hostid(char *hostid); /** - * nvme_generate_hostid() - Generate a machine specific host identifier + * libnvme_generate_hostid() - Generate a machine specific host identifier * * Return: On success, an identifier string based on the machine identifier to * be used as NVMe Host Identifier, or NULL on failure. */ -char *nvme_generate_hostid(void); +char *libnvme_generate_hostid(void); /** - * nvme_read_hostnqn() - Reads the host nvm qualified name from the config + * libnvme_read_hostnqn() - Reads the host nvm qualified name from the config * default location * * Retrieve the qualified name from the config file located in $SYSCONFDIR/nvme. @@ -432,10 +432,10 @@ char *nvme_generate_hostid(void); * Return: The host nqn, or NULL if unsuccessful. If found, the caller * is responsible to free the string. */ -char *nvme_read_hostnqn(void); +char *libnvme_read_hostnqn(void); /** - * nvme_read_hostid() - Reads the host identifier from the config default + * libnvme_read_hostid() - Reads the host identifier from the config default * location * * Retrieve the host idenditifer from the config file located in @@ -444,4 +444,4 @@ char *nvme_read_hostnqn(void); * Return: The host identifier, or NULL if unsuccessful. If found, the caller * is responsible to free the string. */ -char *nvme_read_hostid(void); +char *libnvme_read_hostid(void); diff --git a/libnvme/src/nvme/log.c b/libnvme/src/nvme/log.c index 705217a069..118cc7d579 100644 --- a/libnvme/src/nvme/log.c +++ b/libnvme/src/nvme/log.c @@ -84,7 +84,7 @@ __nvme_msg(struct nvme_global_ctx *ctx, int level, message ? message : ""); } -__public void nvme_set_logging_level(struct nvme_global_ctx *ctx, int log_level, +__public void libnvme_set_logging_level(struct nvme_global_ctx *ctx, int log_level, bool log_pid, bool log_tstamp) { ctx->log.level = log_level; @@ -92,7 +92,7 @@ __public void nvme_set_logging_level(struct nvme_global_ctx *ctx, int log_level, ctx->log.timestamp = log_tstamp; } -__public int nvme_get_logging_level(struct nvme_global_ctx *ctx, +__public int libnvme_get_logging_level(struct nvme_global_ctx *ctx, bool *log_pid, bool *log_tstamp) { if (log_pid) diff --git a/libnvme/src/nvme/mi-mctp.c b/libnvme/src/nvme/mi-mctp.c index d8daff4620..fde6c3b7d3 100644 --- a/libnvme/src/nvme/mi-mctp.c +++ b/libnvme/src/nvme/mi-mctp.c @@ -652,7 +652,7 @@ static const struct nvme_mi_transport nvme_mi_transport_mctp = { .aem_purge = nvme_mi_mctp_aem_purge, }; -int nvme_mi_aem_open(nvme_mi_ep_t ep) +int libnvme_mi_aem_open(nvme_mi_ep_t ep) { struct nvme_mi_transport_mctp *mctp; @@ -675,7 +675,7 @@ int nvme_mi_aem_open(nvme_mi_ep_t ep) return 0; } -__public nvme_mi_ep_t nvme_mi_open_mctp(struct nvme_global_ctx *ctx, +__public nvme_mi_ep_t libnvme_mi_open_mctp(struct nvme_global_ctx *ctx, unsigned int netid, __u8 eid) { struct nvme_mi_transport_mctp *mctp; @@ -740,7 +740,7 @@ __public nvme_mi_ep_t nvme_mi_open_mctp(struct nvme_global_ctx *ctx, err_close_ep: /* the ep->transport is not set yet, so this will not call back * into nvme_mi_mctp_close() */ - nvme_mi_close(ep); + libnvme_mi_close(ep); errno = errno_save; return NULL; } @@ -762,7 +762,7 @@ static int nvme_mi_mctp_add(struct nvme_global_ctx *ctx, unsigned int netid, __u return 0; } - ep = nvme_mi_open_mctp(ctx, netid, eid); + ep = libnvme_mi_open_mctp(ctx, netid, eid); if (!ep) return -1; @@ -945,7 +945,7 @@ static int handle_mctp_obj(struct nvme_global_ctx *ctx, DBusMessageIter *obj) return 0; } -__public struct nvme_global_ctx *nvme_mi_scan_mctp(void) +__public struct nvme_global_ctx *libnvme_mi_scan_mctp(void) { DBusMessage *msg, *resp = NULL; DBusConnection *bus = NULL; @@ -955,7 +955,7 @@ __public struct nvme_global_ctx *nvme_mi_scan_mctp(void) dbus_bool_t drc; DBusError berr; - ctx = nvme_create_global_ctx(NULL, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(NULL, DEFAULT_LOGLEVEL); if (!ctx) { errno = ENOMEM; return NULL; @@ -1029,7 +1029,7 @@ __public struct nvme_global_ctx *nvme_mi_scan_mctp(void) if (rc < 0) { if (ctx) { - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); } errno = errno_save; ctx = NULL; @@ -1039,7 +1039,7 @@ __public struct nvme_global_ctx *nvme_mi_scan_mctp(void) #else /* CONFIG_DBUS */ -__public struct nvme_global_ctx *nvme_mi_scan_mctp(void) +__public struct nvme_global_ctx *libnvme_mi_scan_mctp(void) { return NULL; } diff --git a/libnvme/src/nvme/mi.c b/libnvme/src/nvme/mi.c index 9897c655aa..1e550bb0fb 100644 --- a/libnvme/src/nvme/mi.c +++ b/libnvme/src/nvme/mi.c @@ -86,7 +86,7 @@ int __nvme_transport_handle_open_mi(struct nvme_transport_handle *hdl, const cha if (rc) return rc; - ep = nvme_mi_open_mctp(hdl->ctx, net, eid); + ep = libnvme_mi_open_mctp(hdl->ctx, net, eid); if (!ep) return -EINVAL; @@ -176,7 +176,7 @@ void nvme_mi_ep_probe(struct nvme_mi_ep *ep) /* start with no quirks, detect as we go */ ep->quirks = 0; - hdl = nvme_mi_init_transport_handle(ep, 0); + hdl = libnvme_mi_init_transport_handle(ep, 0); if (!hdl) return; @@ -194,7 +194,7 @@ void nvme_mi_ep_probe(struct nvme_mi_ep *ep) */ nvme_init_identify_ctrl(&cmd, &id); cmd.data_len = offsetof(struct nvme_id_ctrl, rab); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); if (rc) { nvme_msg(ep->ctx, LOG_WARNING, "Identify Controller failed, no quirks applied\n"); @@ -226,7 +226,7 @@ void nvme_mi_ep_probe(struct nvme_mi_ep *ep) } out_close: - nvme_close(hdl); + libnvme_close(hdl); } static const int nsec_per_sec = 1000 * 1000 * 1000; @@ -297,7 +297,7 @@ struct nvme_mi_ep *nvme_mi_init_ep(struct nvme_global_ctx *ctx) return ep; } -__public int nvme_mi_ep_set_timeout(nvme_mi_ep_t ep, unsigned int timeout_ms) +__public int libnvme_mi_ep_set_timeout(nvme_mi_ep_t ep, unsigned int timeout_ms) { if (ep->transport->check_timeout) { int rc; @@ -310,12 +310,12 @@ __public int nvme_mi_ep_set_timeout(nvme_mi_ep_t ep, unsigned int timeout_ms) return 0; } -void nvme_mi_ep_set_mprt_max(nvme_mi_ep_t ep, unsigned int mprt_max_ms) +void libnvme_mi_ep_set_mprt_max(nvme_mi_ep_t ep, unsigned int mprt_max_ms) { ep->mprt_max = mprt_max_ms; } -__public unsigned int nvme_mi_ep_get_timeout(nvme_mi_ep_t ep) +__public unsigned int libnvme_mi_ep_get_timeout(nvme_mi_ep_t ep) { return ep->timeout; } @@ -325,7 +325,7 @@ static bool nvme_mi_ep_has_quirk(nvme_mi_ep_t ep, unsigned long quirk) return ep->quirks & quirk; } -__public struct nvme_transport_handle *nvme_mi_init_transport_handle(nvme_mi_ep_t ep, __u16 ctrl_id) +__public struct nvme_transport_handle *libnvme_mi_init_transport_handle(nvme_mi_ep_t ep, __u16 ctrl_id) { struct nvme_transport_handle *hdl; @@ -343,12 +343,12 @@ __public struct nvme_transport_handle *nvme_mi_init_transport_handle(nvme_mi_ep_ return hdl; } -__public __u16 nvme_mi_ctrl_id(struct nvme_transport_handle *hdl) +__public __u16 libnvme_mi_ctrl_id(struct nvme_transport_handle *hdl) { return hdl->id; } -__public int nvme_mi_scan_ep(nvme_mi_ep_t ep, bool force_rescan) +__public int libnvme_mi_scan_ep(nvme_mi_ep_t ep, bool force_rescan) { struct nvme_ctrl_list list; unsigned int i, n_ctrl; @@ -358,14 +358,14 @@ __public int nvme_mi_scan_ep(nvme_mi_ep_t ep, bool force_rescan) if (force_rescan) { struct nvme_transport_handle *hdl, *tmp; - nvme_mi_for_each_transport_handle_safe(ep, hdl, tmp) - nvme_close(hdl); + libnvme_mi_for_each_transport_handle_safe(ep, hdl, tmp) + libnvme_close(hdl); } else { return 0; } } - rc = nvme_mi_mi_read_mi_data_ctrl_list(ep, 0, &list); + rc = libnvme_mi_mi_read_mi_data_ctrl_list(ep, 0, &list); if (rc) return rc; @@ -379,7 +379,7 @@ __public int nvme_mi_scan_ep(nvme_mi_ep_t ep, bool force_rescan) id = le16_to_cpu(list.identifier[i]); - hdl = nvme_mi_init_transport_handle(ep, id); + hdl = libnvme_mi_init_transport_handle(ep, id); if (!hdl) break; } @@ -569,7 +569,7 @@ int nvme_mi_submit(nvme_mi_ep_t ep, struct nvme_mi_req *req, return 0; } -__public int nvme_mi_set_csi(nvme_mi_ep_t ep, uint8_t csi) +__public int libnvme_mi_set_csi(nvme_mi_ep_t ep, uint8_t csi) { uint8_t csi_bit = (csi) ? 1 : 0; @@ -722,7 +722,7 @@ static int nvme_mi_get_async_message(nvme_mi_ep_t ep, } -__public int nvme_mi_admin_xfer(struct nvme_transport_handle *hdl, +__public int libnvme_mi_admin_xfer(struct nvme_transport_handle *hdl, struct nvme_mi_admin_req_hdr *admin_req, size_t req_data_size, struct nvme_mi_admin_resp_hdr *admin_resp, @@ -868,12 +868,12 @@ int nvme_mi_admin_admin_passthru(struct nvme_transport_handle *hdl, * timeout and override */ if (cmd->timeout_ms != 0) { - timeout_save = nvme_mi_ep_get_timeout(hdl->ep); - nvme_mi_ep_set_timeout(hdl->ep, cmd->timeout_ms); + timeout_save = libnvme_mi_ep_get_timeout(hdl->ep); + libnvme_mi_ep_set_timeout(hdl->ep, cmd->timeout_ms); } rc = nvme_mi_submit(hdl->ep, &req, &resp); if (cmd->timeout_ms != 0) - nvme_mi_ep_set_timeout(hdl->ep, timeout_save); + libnvme_mi_ep_set_timeout(hdl->ep, timeout_save); if (rc) return rc; @@ -888,7 +888,7 @@ int nvme_mi_admin_admin_passthru(struct nvme_transport_handle *hdl, return 0; } -__public int nvme_mi_control(nvme_mi_ep_t ep, __u8 opcode, +__public int libnvme_mi_control(nvme_mi_ep_t ep, __u8 opcode, __u16 cpsp, __u16 *result_cpsr) { struct nvme_mi_control_resp control_resp; @@ -960,7 +960,7 @@ static int nvme_mi_read_data(nvme_mi_ep_t ep, __u32 cdw0, return 0; } -__public int nvme_mi_mi_xfer(nvme_mi_ep_t ep, +__public int libnvme_mi_mi_xfer(nvme_mi_ep_t ep, struct nvme_mi_mi_req_hdr *mi_req, size_t req_data_size, struct nvme_mi_mi_resp_hdr *mi_resp, @@ -1010,7 +1010,7 @@ __public int nvme_mi_mi_xfer(nvme_mi_ep_t ep, return 0; } -__public int nvme_mi_mi_read_mi_data_subsys(nvme_mi_ep_t ep, +__public int libnvme_mi_mi_read_mi_data_subsys(nvme_mi_ep_t ep, struct nvme_mi_read_nvm_ss_info *s) { size_t len; @@ -1035,7 +1035,7 @@ __public int nvme_mi_mi_read_mi_data_subsys(nvme_mi_ep_t ep, return 0; } -__public int nvme_mi_mi_read_mi_data_port(nvme_mi_ep_t ep, __u8 portid, +__public int libnvme_mi_mi_read_mi_data_port(nvme_mi_ep_t ep, __u8 portid, struct nvme_mi_read_port_info *p) { size_t len; @@ -1055,7 +1055,7 @@ __public int nvme_mi_mi_read_mi_data_port(nvme_mi_ep_t ep, __u8 portid, return 0; } -__public int nvme_mi_mi_read_mi_data_ctrl_list(nvme_mi_ep_t ep, __u8 start_ctrlid, +__public int libnvme_mi_mi_read_mi_data_ctrl_list(nvme_mi_ep_t ep, __u8 start_ctrlid, struct nvme_ctrl_list *list) { size_t len; @@ -1072,7 +1072,7 @@ __public int nvme_mi_mi_read_mi_data_ctrl_list(nvme_mi_ep_t ep, __u8 start_ctrli return 0; } -__public int nvme_mi_mi_read_mi_data_ctrl(nvme_mi_ep_t ep, __u16 ctrl_id, +__public int libnvme_mi_mi_read_mi_data_ctrl(nvme_mi_ep_t ep, __u16 ctrl_id, struct nvme_mi_read_ctrl_info *ctrl) { size_t len; @@ -1092,7 +1092,7 @@ __public int nvme_mi_mi_read_mi_data_ctrl(nvme_mi_ep_t ep, __u16 ctrl_id, return 0; } -__public int nvme_mi_mi_subsystem_health_status_poll(nvme_mi_ep_t ep, bool clear, +__public int libnvme_mi_mi_subsystem_health_status_poll(nvme_mi_ep_t ep, bool clear, struct nvme_mi_nvm_ss_health_status *sshs) { struct nvme_mi_mi_resp_hdr resp_hdr; @@ -1168,7 +1168,7 @@ int nvme_mi_mi_config_set_get_ex(nvme_mi_ep_t ep, __u8 opcode, __u32 dw0, return 0; } -__public int nvme_mi_mi_config_get(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1, +__public int libnvme_mi_mi_config_get(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1, __u32 *nmresp) { size_t data_in_len = 0; @@ -1184,7 +1184,7 @@ __public int nvme_mi_mi_config_get(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1, nmresp); } -__public int nvme_mi_mi_config_set(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1) +__public int libnvme_mi_mi_config_set(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1) { size_t data_in_len = 0; @@ -1199,7 +1199,7 @@ __public int nvme_mi_mi_config_set(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1) NULL); } -int nvme_mi_mi_config_get_async_event(nvme_mi_ep_t ep, +int libnvme_mi_mi_config_get_async_event(nvme_mi_ep_t ep, __u8 *aeelver, struct nvme_mi_aem_supported_list *list, size_t *list_num_bytes) @@ -1226,7 +1226,7 @@ int nvme_mi_mi_config_get_async_event(nvme_mi_ep_t ep, return 0; } -int nvme_mi_mi_config_set_async_event(nvme_mi_ep_t ep, +int libnvme_mi_mi_config_set_async_event(nvme_mi_ep_t ep, bool envfa, bool empfa, bool encfa, @@ -1268,15 +1268,15 @@ int nvme_mi_mi_config_set_async_event(nvme_mi_ep_t ep, } -__public void nvme_mi_close(nvme_mi_ep_t ep) +__public void libnvme_mi_close(nvme_mi_ep_t ep) { struct nvme_transport_handle *hdl, *tmp; /* don't look for controllers during destruction */ ep->controllers_scanned = true; - nvme_mi_for_each_transport_handle_safe(ep, hdl, tmp) - nvme_close(hdl); + libnvme_mi_for_each_transport_handle_safe(ep, hdl, tmp) + libnvme_close(hdl); if (ep->transport && ep->transport->close) ep->transport->close(ep); @@ -1284,7 +1284,7 @@ __public void nvme_mi_close(nvme_mi_ep_t ep) free(ep); } -__public char *nvme_mi_endpoint_desc(nvme_mi_ep_t ep) +__public char *libnvme_mi_endpoint_desc(nvme_mi_ep_t ep) { char tsbuf[101], *s = NULL; size_t tslen; @@ -1314,22 +1314,22 @@ __public char *nvme_mi_endpoint_desc(nvme_mi_ep_t ep) return s; } -__public nvme_mi_ep_t nvme_mi_first_endpoint(struct nvme_global_ctx *ctx) +__public nvme_mi_ep_t libnvme_mi_first_endpoint(struct nvme_global_ctx *ctx) { return list_top(&ctx->endpoints, struct nvme_mi_ep, root_entry); } -__public nvme_mi_ep_t nvme_mi_next_endpoint(struct nvme_global_ctx *ctx, nvme_mi_ep_t ep) +__public nvme_mi_ep_t libnvme_mi_next_endpoint(struct nvme_global_ctx *ctx, nvme_mi_ep_t ep) { return ep ? list_next(&ctx->endpoints, ep, root_entry) : NULL; } -struct nvme_transport_handle *nvme_mi_first_transport_handle(nvme_mi_ep_t ep) +struct nvme_transport_handle *libnvme_mi_first_transport_handle(nvme_mi_ep_t ep) { return list_top(&ep->controllers, struct nvme_transport_handle, ep_entry); } -struct nvme_transport_handle *nvme_mi_next_transport_handle(nvme_mi_ep_t ep, +struct nvme_transport_handle *libnvme_mi_next_transport_handle(nvme_mi_ep_t ep, struct nvme_transport_handle *hdl) { return hdl ? list_next(&ep->controllers, hdl, ep_entry) : NULL; @@ -1357,8 +1357,8 @@ static const char *const mi_status[] = { }; /* kept in mi.c while we have a split libnvme/libnvme-mi; consider moving - * to utils.c (with nvme_status_to_string) if we ever merge. */ -__public const char *nvme_mi_status_to_string(int status) + * to utils.c (with libnvme_status_to_string) if we ever merge. */ +__public const char *libnvme_mi_status_to_string(int status) { const char *s = "Unknown status"; @@ -1368,24 +1368,24 @@ __public const char *nvme_mi_status_to_string(int status) return s; } -bool nvme_mi_aem_aeei_get_aee(__le16 aeei) +bool libnvme_mi_aem_aeei_get_aee(__le16 aeei) { return !!(le16_to_cpu(aeei) & 0x8000); } -__u8 nvme_mi_aem_aeei_get_aeeid(__le16 aeei) +__u8 libnvme_mi_aem_aeei_get_aeeid(__le16 aeei) { return (le16_to_cpu(aeei) & 0xFF); } -void nvme_mi_aem_aeei_set_aeeid(struct nvme_mi_aem_enable_item *item, __u8 aeeid) +void libnvme_mi_aem_aeei_set_aeeid(struct nvme_mi_aem_enable_item *item, __u8 aeeid) { __u16 temp = le16_to_cpu(item->aeei); item->aeei = cpu_to_le16((temp & 0xFF00) | aeeid); } -void nvme_mi_aem_aeei_set_aee(struct nvme_mi_aem_enable_item *item, bool enabled) +void libnvme_mi_aem_aeei_set_aee(struct nvme_mi_aem_enable_item *item, bool enabled) { __u16 temp = le16_to_cpu(item->aeei); __u8 bit = (enabled) ? 1 : 0; @@ -1393,24 +1393,24 @@ void nvme_mi_aem_aeei_set_aee(struct nvme_mi_aem_enable_item *item, bool enabled item->aeei = cpu_to_le16((temp & 0xFF) | (bit << 15)); } -bool nvme_mi_aem_aesi_get_aese(__le16 aesi) +bool libnvme_mi_aem_aesi_get_aese(__le16 aesi) { return !!(le16_to_cpu(aesi) & 0x8000); } -__u8 nvme_mi_aem_aesi_get_aesid(__le16 aesi) +__u8 libnvme_mi_aem_aesi_get_aesid(__le16 aesi) { return le16_to_cpu(aesi) & 0xff; } -void nvme_mi_aem_aesi_set_aesid(struct nvme_mi_aem_supported_item *item, __u8 aesid) +void libnvme_mi_aem_aesi_set_aesid(struct nvme_mi_aem_supported_item *item, __u8 aesid) { __u16 temp = le16_to_cpu(item->aesi); item->aesi = cpu_to_le16((temp & 0xFF00) | aesid); } -void nvme_mi_aem_aesi_set_aee(struct nvme_mi_aem_supported_item *item, bool enabled) +void libnvme_mi_aem_aesi_set_aee(struct nvme_mi_aem_supported_item *item, bool enabled) { __u16 temp = le16_to_cpu(item->aesi); __u8 bit = (enabled) ? 1 : 0; @@ -1418,12 +1418,12 @@ void nvme_mi_aem_aesi_set_aee(struct nvme_mi_aem_supported_item *item, bool enab item->aesi = cpu_to_le16((temp & 0xFF) | (bit << 15)); } -__u8 nvme_mi_aem_aemti_get_aemgn(__u8 aemti) +__u8 libnvme_mi_aem_aemti_get_aemgn(__u8 aemti) { return aemti >> 3 & 0x1f; } -__u32 nvme_mi_aem_aeolli_get_aeoltl(__u8 *aeolli) +__u32 libnvme_mi_aem_aeolli_get_aeoltl(__u8 *aeolli) { //First 23-bits contain the aeoltl __u32 aeoltl = aeolli[0] | (aeolli[1] << 8) | (aeolli[2] << 16); @@ -1431,7 +1431,7 @@ __u32 nvme_mi_aem_aeolli_get_aeoltl(__u8 *aeolli) return aeoltl & 0x7FFFFF; } -void nvme_mi_aem_aeolli_set_aeoltl(struct nvme_mi_aem_occ_list_hdr *hdr, __u32 aeoltl) +void libnvme_mi_aem_aeolli_set_aeoltl(struct nvme_mi_aem_occ_list_hdr *hdr, __u32 aeoltl) { hdr->aeolli[0] = aeoltl & 0xFF; hdr->aeolli[1] = (aeoltl >> 8) & 0xFF; @@ -1470,19 +1470,19 @@ static int validate_occ_list_update_ctx( //Make sure header is the right version and length err = -EPROTO; goto err_cleanup; - } else if (nvme_mi_aem_aeolli_get_aeoltl(occ_header->aeolli) > len) { + } else if (libnvme_mi_aem_aeolli_get_aeoltl(occ_header->aeolli) > len) { //Full length is bigger than the data that was received err = -EPROTO; goto err_cleanup; } else if (check_generation_num && ctx->last_generation_num == - (int) nvme_mi_aem_aemti_get_aemgn(occ_header->aemti)) { + (int) libnvme_mi_aem_aemti_get_aemgn(occ_header->aemti)) { //This is a duplicate and shouldn't be parsed. //Let's just act like there's no updates occ_header->numaeo = 0; } else if (check_generation_num) { ctx->last_generation_num = - nvme_mi_aem_aemti_get_aemgn(occ_header->aemti); + libnvme_mi_aem_aemti_get_aemgn(occ_header->aemti); } //Header is fine. Let's go through the data @@ -1512,7 +1512,7 @@ static int validate_occ_list_update_ctx( uint32_t offset = sizeof(*current) + current->aeosil + current->aeovsil; bytes_so_far += offset; - if (bytes_so_far > nvme_mi_aem_aeolli_get_aeoltl(occ_header->aeolli)) { + if (bytes_so_far > libnvme_mi_aem_aeolli_get_aeoltl(occ_header->aeolli)) { err = -EPROTO; goto err_cleanup; } @@ -1526,7 +1526,7 @@ static int validate_occ_list_update_ctx( return err; } -__public int nvme_mi_aem_get_fd(nvme_mi_ep_t ep) +__public int libnvme_mi_aem_get_fd(nvme_mi_ep_t ep) { if (!ep || !ep->aem_ctx || !ep->transport || !ep->transport->aem_fd) return -1; @@ -1579,7 +1579,7 @@ static int aem_sync(nvme_mi_ep_t ep, } //Send it - int rc = nvme_mi_mi_config_set_async_event(ep, + int rc = libnvme_mi_mi_config_set_async_event(ep, envfa, empfa, encfa, @@ -1604,7 +1604,7 @@ static int aem_disable_enabled(nvme_mi_ep_t ep) // First, let's figure out if anything is already enabled that we need to // disable - int rc = nvme_mi_aem_get_enabled(ep, &already_enabled); + int rc = libnvme_mi_aem_get_enabled(ep, &already_enabled); if (rc) return rc; @@ -1616,8 +1616,8 @@ static int aem_disable_enabled(nvme_mi_ep_t ep) for (int i = 0; i < NUM_ENABLES; i++) { if (already_enabled.enabled[i]) { - nvme_mi_aem_aeei_set_aeeid(&sync_data[sync_data_count], i); - nvme_mi_aem_aeei_set_aee(&sync_data[sync_data_count], false); + libnvme_mi_aem_aeei_set_aeeid(&sync_data[sync_data_count], i); + libnvme_mi_aem_aeei_set_aee(&sync_data[sync_data_count], false); sync_data_count++; } } @@ -1635,14 +1635,14 @@ static int aem_disable_enabled(nvme_mi_ep_t ep) return rc; } -__public int nvme_mi_aem_enable(nvme_mi_ep_t ep, +__public int libnvme_mi_aem_enable(nvme_mi_ep_t ep, struct nvme_mi_aem_config *config, void *userdata) { if (!ep || !config || !config->aem_handler) return -1; - int rc = nvme_mi_aem_open(ep); + int rc = libnvme_mi_aem_open(ep); if (rc < 0) return rc; @@ -1673,8 +1673,8 @@ __public int nvme_mi_aem_enable(nvme_mi_ep_t ep, //Now, let's do a fresh enable of what's asked for (int i = 0; i < NUM_ENABLES; i++) { if (config->enabled_map.enabled[i]) { - nvme_mi_aem_aeei_set_aeeid(&sync_data[sync_data_count], i); - nvme_mi_aem_aeei_set_aee(&sync_data[sync_data_count], true); + libnvme_mi_aem_aeei_set_aeeid(&sync_data[sync_data_count], i); + libnvme_mi_aem_aeei_set_aee(&sync_data[sync_data_count], true); sync_data_count++; } } @@ -1709,7 +1709,7 @@ __public int nvme_mi_aem_enable(nvme_mi_ep_t ep, return rc; } -__public int nvme_mi_aem_get_enabled(nvme_mi_ep_t ep, +__public int libnvme_mi_aem_get_enabled(nvme_mi_ep_t ep, struct nvme_mi_aem_enabled_map *enabled_map) { if (!ep || !enabled_map) @@ -1724,7 +1724,7 @@ __public int nvme_mi_aem_get_enabled(nvme_mi_ep_t ep, if (!enabled_list) return -1; - rc = nvme_mi_mi_config_get_async_event( + rc = libnvme_mi_mi_config_get_async_event( ep, &aeelver, enabled_list, &ae_list_bytes); if (rc) goto cleanup; @@ -1739,8 +1739,8 @@ __public int nvme_mi_aem_get_enabled(nvme_mi_ep_t ep, (struct nvme_mi_aem_enable_item *)(enabled_list + 1); for (int i = 0; i < enabled_list->hdr.numaes; i++) { - __u8 aeeid = nvme_mi_aem_aeei_get_aeeid(items[i].aeei); - bool enabled = nvme_mi_aem_aeei_get_aee(items[i].aeei); + __u8 aeeid = libnvme_mi_aem_aeei_get_aeeid(items[i].aeei); + bool enabled = libnvme_mi_aem_aeei_get_aee(items[i].aeei); enabled_map->enabled[aeeid] = enabled; } @@ -1750,7 +1750,7 @@ __public int nvme_mi_aem_get_enabled(nvme_mi_ep_t ep, return rc; } -__public int nvme_mi_aem_disable(nvme_mi_ep_t ep) +__public int libnvme_mi_aem_disable(nvme_mi_ep_t ep) { if (!ep) return -1; @@ -1768,7 +1768,7 @@ __public int nvme_mi_aem_disable(nvme_mi_ep_t ep) *spec_info and vend_spec_info must be copied to persist as they will not be valid after *the aem_handler has returned. */ -__public struct nvme_mi_event *nvme_mi_aem_get_next_event(nvme_mi_ep_t ep) +__public struct nvme_mi_event *libnvme_mi_aem_get_next_event(nvme_mi_ep_t ep) { if (!ep || !ep->aem_ctx || !ep->aem_ctx->list_current || @@ -1805,7 +1805,7 @@ __public struct nvme_mi_event *nvme_mi_aem_get_next_event(nvme_mi_ep_t ep) /* POLLIN has indicated events. This function reads and processes them. * A callback will likely be invoked. */ -__public int nvme_mi_aem_process(nvme_mi_ep_t ep, void *userdata) +__public int libnvme_mi_aem_process(nvme_mi_ep_t ep, void *userdata) { int rc = 0; uint8_t response_buffer[4096]; @@ -1840,7 +1840,7 @@ __public int nvme_mi_aem_process(nvme_mi_ep_t ep, void *userdata) goto cleanup; if (response->occ_list_hdr.numaeo) { - enum nvme_mi_aem_handler_next_action action = + enum libnvme_mi_aem_handler_next_action action = ep->aem_ctx->callbacks.aem_handler(ep, response->occ_list_hdr.numaeo, userdata); @@ -1850,7 +1850,7 @@ __public int nvme_mi_aem_process(nvme_mi_ep_t ep, void *userdata) if (action == NVME_MI_AEM_HNA_ACK) { response_len = sizeof(response_buffer); - rc = nvme_mi_aem_ack(ep, &response->occ_list_hdr, &response_len); + rc = libnvme_mi_aem_ack(ep, &response->occ_list_hdr, &response_len); if (rc) goto cleanup; diff --git a/libnvme/src/nvme/mi.h b/libnvme/src/nvme/mi.h index d7beda872c..8e06c0c3ad 100644 --- a/libnvme/src/nvme/mi.h +++ b/libnvme/src/nvme/mi.h @@ -40,7 +40,7 @@ * - We currently support either MI commands and Admin commands. The * former adds a _mi prefix, the latter an _admin prefix. [This does * result in the MI functions having a double _mi, like - * &nvme_mi_mi_subsystem_health_status_poll, which is apparently amusing + * &libnvme_mi_mi_subsystem_health_status_poll, which is apparently amusing * for our German-speaking readers] * * For return values: unless specified in the per-function documentation, @@ -283,7 +283,7 @@ enum nvme_mi_dtyp { * @NVME_MI_CONFIG_AE: Asynchronous Events configuration * Configuration parameters for the MI Get/Set Configuration commands. * - * See &nvme_mi_mi_config_get() and &nvme_mi_config_set(). + * See &libnvme_mi_mi_config_get() and &libnvme_mi_config_set(). */ enum nvme_mi_config_id { NVME_MI_CONFIG_SMBUS_FREQ = 0x1, @@ -299,7 +299,7 @@ enum nvme_mi_config_id { * @NVME_MI_CONFIG_SMBUS_FREQ_1MHz: 1MHz * * Values used in the SMBus Frequency device configuration. See - * &nvme_mi_mi_config_get_smbus_freq() and &nvme_mi_mi_config_set_smbus_freq(). + * &libnvme_mi_mi_config_get_smbus_freq() and &libnvme_mi_mi_config_set_smbus_freq(). */ enum nvme_mi_config_smbus_freq { NVME_MI_CONFIG_SMBUS_FREQ_100kHz = 0x1, @@ -339,34 +339,34 @@ struct nvme_mi_aem_supported_item { } __attribute__((packed)); /** - * nvme_mi_aem_aesi_get_aese() - return aese from aesi field + * libnvme_mi_aem_aesi_get_aese() - return aese from aesi field * @aesi: aesi field from @nvme_mi_aem_supported_item * * Returns: A bool representing the aese value */ -bool nvme_mi_aem_aesi_get_aese(__le16 aesi); +bool libnvme_mi_aem_aesi_get_aese(__le16 aesi); /** - * nvme_mi_aem_aesi_get_aesid() - return aesid from aesi field + * libnvme_mi_aem_aesi_get_aesid() - return aesid from aesi field * @aesi: aesi field from @nvme_mi_aem_supported_item * * Returns: aesid value */ -__u8 nvme_mi_aem_aesi_get_aesid(__le16 aesi); +__u8 libnvme_mi_aem_aesi_get_aesid(__le16 aesi); /** - * nvme_mi_aem_aesi_set_aesid() - set aesid in the aesi field + * libnvme_mi_aem_aesi_set_aesid() - set aesid in the aesi field * @item: Pointer to @nvme_mi_aem_supported_item to update the aesi field * @aesid: aesid value to use */ -void nvme_mi_aem_aesi_set_aesid(struct nvme_mi_aem_supported_item *item, __u8 aesid); +void libnvme_mi_aem_aesi_set_aesid(struct nvme_mi_aem_supported_item *item, __u8 aesid); /** - * nvme_mi_aem_aesi_set_aee() - set aee in the aesi field + * libnvme_mi_aem_aesi_set_aee() - set aee in the aesi field * @item: Pointer to @nvme_mi_aem_supported_item to update the aesi field * @enabled: aee value to use */ -void nvme_mi_aem_aesi_set_aee(struct nvme_mi_aem_supported_item *item, bool enabled); +void libnvme_mi_aem_aesi_set_aee(struct nvme_mi_aem_supported_item *item, bool enabled); /** * struct nvme_mi_aem_supported_list - AE Supported List received with GET CONFIG Asynchronous Event @@ -391,34 +391,34 @@ struct nvme_mi_aem_enable_item { } __attribute__((packed)); /** - * nvme_mi_aem_aeei_get_aee() - return aee from aeei field + * libnvme_mi_aem_aeei_get_aee() - return aee from aeei field * @aeei: aeei field from @nvme_mi_aem_enable_item * * Returns: aee value */ -bool nvme_mi_aem_aeei_get_aee(__le16 aeei); +bool libnvme_mi_aem_aeei_get_aee(__le16 aeei); /** - * nvme_mi_aem_aeei_get_aeeid() - return aeeid from aeei field + * libnvme_mi_aem_aeei_get_aeeid() - return aeeid from aeei field * @aeei: aeei field from @nvme_mi_aem_enable_item * * Returns: aeeid value */ -__u8 nvme_mi_aem_aeei_get_aeeid(__le16 aeei); +__u8 libnvme_mi_aem_aeei_get_aeeid(__le16 aeei); /** - * nvme_mi_aem_aeei_set_aeeid() - set aeeid in the aeei field + * libnvme_mi_aem_aeei_set_aeeid() - set aeeid in the aeei field * @item: Pointer to @nvme_mi_aem_enable_item to update the aeei field * @aeeid: aeeid value to use */ -void nvme_mi_aem_aeei_set_aeeid(struct nvme_mi_aem_enable_item *item, __u8 aeeid); +void libnvme_mi_aem_aeei_set_aeeid(struct nvme_mi_aem_enable_item *item, __u8 aeeid); /** - * nvme_mi_aem_aeei_set_aee() - set aee in the aeei field + * libnvme_mi_aem_aeei_set_aee() - set aee in the aeei field * @item: Pointer to @nvme_mi_aem_enable_item to update the aee field * @enabled: aee value to use */ -void nvme_mi_aem_aeei_set_aee(struct nvme_mi_aem_enable_item *item, bool enabled); +void libnvme_mi_aem_aeei_set_aee(struct nvme_mi_aem_enable_item *item, bool enabled); /** * struct nvme_mi_aem_enable_list_header - AE Enable list header @@ -490,27 +490,27 @@ struct nvme_mi_aem_occ_list_hdr { } __attribute__((packed)); /** - * nvme_mi_aem_aemti_get_aemgn() - return aemgn from aemti field + * libnvme_mi_aem_aemti_get_aemgn() - return aemgn from aemti field * @aemti: aemti field from @nvme_mi_aem_occ_list_hdr * * Returns: aemgn value */ -__u8 nvme_mi_aem_aemti_get_aemgn(__u8 aemti); +__u8 libnvme_mi_aem_aemti_get_aemgn(__u8 aemti); /** - * nvme_mi_aem_aeolli_get_aeoltl() - return aeoltl from aeolli field + * libnvme_mi_aem_aeolli_get_aeoltl() - return aeoltl from aeolli field * @aeolli: Pointer to 3 byte aeolli field from @nvme_mi_aem_occ_list_hdr * * Returns: aeoltl value */ -__u32 nvme_mi_aem_aeolli_get_aeoltl(__u8 *aeolli); +__u32 libnvme_mi_aem_aeolli_get_aeoltl(__u8 *aeolli); /** - * nvme_mi_aem_aeolli_set_aeoltl() - set aeoltl in the aeolli field + * libnvme_mi_aem_aeolli_set_aeoltl() - set aeoltl in the aeolli field * @hdr:Pointer to @nvme_mi_aem_occ_list_hdr to set the aeolli field * @aeoltl: aeoltl value to use */ -void nvme_mi_aem_aeolli_set_aeoltl(struct nvme_mi_aem_occ_list_hdr *hdr, __u32 aeoltl); +void libnvme_mi_aem_aeolli_set_aeoltl(struct nvme_mi_aem_occ_list_hdr *hdr, __u32 aeoltl); /** * struct nvme_mi_aem_msg - AEM Message definition. @@ -637,7 +637,7 @@ struct nvme_mi_control_resp { } __attribute((packed)); /** - * nvme_mi_status_to_string() - return a string representation of the MI + * libnvme_mi_status_to_string() - return a string representation of the MI * status. * @status: MI response status * @@ -649,7 +649,7 @@ struct nvme_mi_control_resp { * * Returns: A string representing the status value */ -const char *nvme_mi_status_to_string(int status); +const char *libnvme_mi_status_to_string(int status); /* Top level management object: NVMe-MI Management Endpoint */ struct nvme_mi_ep; @@ -663,75 +663,75 @@ struct nvme_mi_ep; * (see &nvme_mi_init_ctrl). * * Endpoints are created through a transport-specific constructor; currently - * only MCTP-connected endpoints are supported, through &nvme_mi_open_mctp. + * only MCTP-connected endpoints are supported, through &libnvme_mi_open_mctp. * Subsequent operations on the endpoint (and related controllers) are * transport-independent. */ typedef struct nvme_mi_ep * nvme_mi_ep_t; /** - * nvme_mi_set_csi - Assign a CSI to an endpoint. + * libnvme_mi_set_csi - Assign a CSI to an endpoint. * @ep: Endpoint * @csi: value to use for CSI bit in NMP (0 or 1) for this endpoint * * Return: 0 if successful, -1 otherwise (some endpoints may not support) * */ -int nvme_mi_set_csi(nvme_mi_ep_t ep, uint8_t csi); +int libnvme_mi_set_csi(nvme_mi_ep_t ep, uint8_t csi); /** - * nvme_mi_first_endpoint - Start endpoint iterator + * libnvme_mi_first_endpoint - Start endpoint iterator * @ctx: &struct nvme_global_ctx object * * Return: first MI endpoint object under this root, or NULL if no endpoints * are present. * - * See: &nvme_mi_next_endpoint, &nvme_mi_for_each_endpoint + * See: &libnvme_mi_next_endpoint, &libnvme_mi_for_each_endpoint */ -nvme_mi_ep_t nvme_mi_first_endpoint(struct nvme_global_ctx *ctx); +nvme_mi_ep_t libnvme_mi_first_endpoint(struct nvme_global_ctx *ctx); /** - * nvme_mi_next_endpoint - Continue endpoint iterator + * libnvme_mi_next_endpoint - Continue endpoint iterator * @ctx: &struct nvme_global_ctx object * @e: &nvme_mi_ep_t current position of iterator * * Return: next endpoint MI endpoint object after @e under this root, or NULL * if no further endpoints are present. * - * See: &nvme_mi_first_endpoint, &nvme_mi_for_each_endpoint + * See: &libnvme_mi_first_endpoint, &libnvme_mi_for_each_endpoint */ -nvme_mi_ep_t nvme_mi_next_endpoint(struct nvme_global_ctx *ctx, nvme_mi_ep_t e); +nvme_mi_ep_t libnvme_mi_next_endpoint(struct nvme_global_ctx *ctx, nvme_mi_ep_t e); /** - * nvme_mi_for_each_endpoint - Iterator for NVMe-MI endpoints. + * libnvme_mi_for_each_endpoint - Iterator for NVMe-MI endpoints. * @c: &struct nvme_global_ctx object * @e: &nvme_mi_ep_t object, set on each iteration */ -#define nvme_mi_for_each_endpoint(c, e) \ - for (e = nvme_mi_first_endpoint(c); e != NULL; \ - e = nvme_mi_next_endpoint(c, e)) +#define libnvme_mi_for_each_endpoint(c, e) \ + for (e = libnvme_mi_first_endpoint(c); e != NULL; \ + e = libnvme_mi_next_endpoint(c, e)) /** - * nvme_mi_for_each_endpoint_safe - Iterator for NVMe-MI endpoints, allowing + * libnvme_mi_for_each_endpoint_safe - Iterator for NVMe-MI endpoints, allowing * deletion during traversal * @c: &struct nvme_global_ctx object * @e: &nvme_mi_ep_t object, set on each iteration * @_e: &nvme_mi_ep_t object used as temporary storage */ -#define nvme_mi_for_each_endpoint_safe(c, e, _e) \ - for (e = nvme_mi_first_endpoint(c), _e = nvme_mi_next_endpoint(c, e); \ +#define libnvme_mi_for_each_endpoint_safe(c, e, _e) \ + for (e = libnvme_mi_first_endpoint(c), _e = libnvme_mi_next_endpoint(c, e); \ e != NULL; \ - e = _e, _e = nvme_mi_next_endpoint(c, e)) + e = _e, _e = libnvme_mi_next_endpoint(c, e)) /** - * nvme_mi_ep_set_timeout - set a timeout for NVMe-MI responses + * libnvme_mi_ep_set_timeout - set a timeout for NVMe-MI responses * @ep: MI endpoint object * @timeout_ms: Timeout for MI responses, given in milliseconds */ -int nvme_mi_ep_set_timeout(nvme_mi_ep_t ep, unsigned int timeout_ms); +int libnvme_mi_ep_set_timeout(nvme_mi_ep_t ep, unsigned int timeout_ms); /** - * nvme_mi_ep_set_mprt_max - set the maximum wait time for a More Processing + * libnvme_mi_ep_set_mprt_max - set the maximum wait time for a More Processing * Required response * @ep: MI endpoint object * @mprt_max_ms: Maximum more processing required wait time @@ -744,59 +744,59 @@ int nvme_mi_ep_set_timeout(nvme_mi_ep_t ep, unsigned int timeout_ms); * This function provides a way to limit the maximum time we're prepared to * wait for the final response. Specify zero in @mprt_max_ms for no limit. * This should be larger than the command/response timeout set in - * &nvme_mi_ep_set_timeout(). + * &libnvme_mi_ep_set_timeout(). */ -void nvme_mi_ep_set_mprt_max(nvme_mi_ep_t ep, unsigned int mprt_max_ms); +void libnvme_mi_ep_set_mprt_max(nvme_mi_ep_t ep, unsigned int mprt_max_ms); /** - * nvme_mi_ep_get_timeout - get the current timeout value for NVMe-MI responses + * libnvme_mi_ep_get_timeout - get the current timeout value for NVMe-MI responses * @ep: MI endpoint object * * Returns the current timeout value, in milliseconds, for this endpoint. */ -unsigned int nvme_mi_ep_get_timeout(nvme_mi_ep_t ep); +unsigned int libnvme_mi_ep_get_timeout(nvme_mi_ep_t ep); /** - * nvme_mi_first_transport_handle - Start transport handle iterator + * libnvme_mi_first_transport_handle - Start transport handle iterator * @ep: &nvme_mi_ep_t object * * Return: first transport handle to a MI controller object under this * root, or NULL if no controllers are present. * - * See: &nvme_mi_next_transport_handle, &nvme_mi_for_each_transport_handle + * See: &libnvme_mi_next_transport_handle, &libnvme_mi_for_each_transport_handle */ -struct nvme_transport_handle *nvme_mi_first_transport_handle(nvme_mi_ep_t ep); +struct nvme_transport_handle *libnvme_mi_first_transport_handle(nvme_mi_ep_t ep); /** - * nvme_mi_next_transport_handle - Continue transport handle iterator + * libnvme_mi_next_transport_handle - Continue transport handle iterator * @ep: &nvme_mi_ep_t object * @hdl: &nvme_transport_handle current position of iterator * * Return: next transport handle to MI controller object after @c under * this endpoint, or NULL if no further controllers are present. * - * See: &nvme_mi_first_transport_handle, &nvme_mi_for_each_transport_handle + * See: &libnvme_mi_first_transport_handle, &libnvme_mi_for_each_transport_handle */ -struct nvme_transport_handle *nvme_mi_next_transport_handle(nvme_mi_ep_t ep, +struct nvme_transport_handle *libnvme_mi_next_transport_handle(nvme_mi_ep_t ep, struct nvme_transport_handle *hdl); /** - * nvme_mi_for_each_transport_handle - Iterator for transport handle to NVMe-MI controllers. + * libnvme_mi_for_each_transport_handle - Iterator for transport handle to NVMe-MI controllers. * @ep: &nvme_mi_ep_t containing endpoints * @hdl: &nvme_trasnport_handle object, set on each iteration * * Allows iteration of the list of controllers behind an endpoint. Unless the * controllers have already been created explicitly, you'll probably want to - * call &nvme_mi_scan_ep() to scan for the controllers first. + * call &libnvme_mi_scan_ep() to scan for the controllers first. * - * See: &nvme_mi_scan_ep() + * See: &libnvme_mi_scan_ep() */ -#define nvme_mi_for_each_transport_handle(ep, hdl) \ - for (hdl = nvme_mi_first_transport_handle(ep); hdl != NULL; \ - hdl = nvme_mi_next_transport_handle(ep, hdl)) +#define libnvme_mi_for_each_transport_handle(ep, hdl) \ + for (hdl = libnvme_mi_first_transport_handle(ep); hdl != NULL; \ + hdl = libnvme_mi_next_transport_handle(ep, hdl)) /** - * nvme_mi_for_each_transport_handle_safe - Iterator for transport handle to NVMe-MI controllers, allowing + * libnvme_mi_for_each_transport_handle_safe - Iterator for transport handle to NVMe-MI controllers, allowing * deletion during traversal * @ep: &nvme_mi_ep_t containing controllers * @hdl: &nvme_transport_handle object, set on each iteration @@ -805,18 +805,18 @@ struct nvme_transport_handle *nvme_mi_next_transport_handle(nvme_mi_ep_t ep, * Allows iteration of the list of controllers behind an endpoint, safe against * deletion during iteration. Unless the controllers have already been created * explicitly (or you're just iterating to destroy controllers) you'll probably - * want to call &nvme_mi_scan_ep() to scan for the controllers first. + * want to call &libnvme_mi_scan_ep() to scan for the controllers first. * - * See: &nvme_mi_scan_ep() + * See: &libnvme_mi_scan_ep() */ -#define nvme_mi_for_each_transport_handle_safe(ep, hdl, _hdl) \ - for (hdl = nvme_mi_first_transport_handle(ep), \ - _hdl = nvme_mi_next_transport_handle(ep, hdl); \ +#define libnvme_mi_for_each_transport_handle_safe(ep, hdl, _hdl) \ + for (hdl = libnvme_mi_first_transport_handle(ep), \ + _hdl = libnvme_mi_next_transport_handle(ep, hdl); \ hdl != NULL; \ - hdl = _hdl, _hdl = nvme_mi_next_transport_handle(ep, hdl)) + hdl = _hdl, _hdl = libnvme_mi_next_transport_handle(ep, hdl)) /** - * nvme_mi_open_mctp() - Create an endpoint using a MCTP connection. + * libnvme_mi_open_mctp() - Create an endpoint using a MCTP connection. * @ctx: &struct nvme_global_ctx object * @netid: MCTP network ID on this system * @eid: MCTP endpoint ID @@ -826,29 +826,29 @@ struct nvme_transport_handle *nvme_mi_next_transport_handle(nvme_mi_ep_t ep, * * Return: New endpoint object for @netid & @eid, or NULL on failure. * - * See &nvme_mi_close + * See &libnvme_mi_close */ -nvme_mi_ep_t nvme_mi_open_mctp(struct nvme_global_ctx *ctx, +nvme_mi_ep_t libnvme_mi_open_mctp(struct nvme_global_ctx *ctx, unsigned int netid, uint8_t eid); /** - * nvme_mi_aem_open() - Prepare an existing endpoint to receive AEMs + * libnvme_mi_aem_open() - Prepare an existing endpoint to receive AEMs * @ep: Endpoint to configure for AEMs * * Return: 0 if success, -1 otherwise */ -int nvme_mi_aem_open(nvme_mi_ep_t ep); +int libnvme_mi_aem_open(nvme_mi_ep_t ep); /** - * nvme_mi_close() - Close an endpoint connection and release resources, + * libnvme_mi_close() - Close an endpoint connection and release resources, * including controller objects. * * @ep: Endpoint object to close */ -void nvme_mi_close(nvme_mi_ep_t ep); +void libnvme_mi_close(nvme_mi_ep_t ep); /** - * nvme_mi_scan_mctp - look for MCTP-connected NVMe-MI endpoints. + * libnvme_mi_scan_mctp - look for MCTP-connected NVMe-MI endpoints. * * Description: This function queries the system MCTP daemon ("mctpd") over * D-Bus, to find MCTP endpoints that report support for NVMe-MI over MCTP. @@ -859,10 +859,10 @@ void nvme_mi_close(nvme_mi_ep_t ep); * Return: A @struct nvme_global_ctx populated with a set of * MCTP-connected endpoints, or NULL on failure */ -struct nvme_global_ctx *nvme_mi_scan_mctp(void); +struct nvme_global_ctx *libnvme_mi_scan_mctp(void); /** - * nvme_mi_scan_ep - query an endpoint for its NVMe controllers. + * libnvme_mi_scan_ep - query an endpoint for its NVMe controllers. * @ep: Endpoint to scan * @force_rescan: close existing controllers and rescan * @@ -880,38 +880,38 @@ struct nvme_global_ctx *nvme_mi_scan_mctp(void); * * See: &nvme_mi_for_each_ctrl */ -int nvme_mi_scan_ep(nvme_mi_ep_t ep, bool force_rescan); +int libnvme_mi_scan_ep(nvme_mi_ep_t ep, bool force_rescan); /** - * nvme_mi_init_transport_handle() - initialise a transport handle to NVMe controller. + * libnvme_mi_init_transport_handle() - initialise a transport handle to NVMe controller. * @ep: Endpoint to create under * @ctrl_id: ID of controller to initialize. * * Create a connection to a controller behind the endpoint specified in @ep. * Controller IDs may be queried from the endpoint through - * &nvme_mi_mi_read_mi_data_ctrl_list. + * &libnvme_mi_mi_read_mi_data_ctrl_list. * * Return: New transport handle object, or NULL on failure. * * See &nvme_mi_close_transport_handle */ -struct nvme_transport_handle *nvme_mi_init_transport_handle(nvme_mi_ep_t ep, __u16 ctrl_id); +struct nvme_transport_handle *libnvme_mi_init_transport_handle(nvme_mi_ep_t ep, __u16 ctrl_id); /** - * nvme_mi_ctrl_id() - get the ID of a controller + * libnvme_mi_ctrl_id() - get the ID of a controller * @hdl: transport handle to controller to query * * Retrieve the ID of the controller, as defined by hardware, and available * in the Identify (Controller List) data. This is the value passed to - * @nvme_mi_init_transport_handle, but may have been created internally via - * @nvme_mi_scan_ep. + * @libnvme_mi_init_transport_handle, but may have been created internally via + * @libnvme_mi_scan_ep. * * Return: the (locally-stored) ID of this controller. */ -__u16 nvme_mi_ctrl_id(struct nvme_transport_handle *hdl); +__u16 libnvme_mi_ctrl_id(struct nvme_transport_handle *hdl); /** - * nvme_mi_endpoint_desc - Get a string describing a MI endpoint. + * libnvme_mi_endpoint_desc - Get a string describing a MI endpoint. * @ep: endpoint to describe * * Generates a human-readable string describing the endpoint, with possibly @@ -921,12 +921,12 @@ __u16 nvme_mi_ctrl_id(struct nvme_transport_handle *hdl); * Return: a newly-allocated string containing the endpoint description, or * NULL on failure. */ -char *nvme_mi_endpoint_desc(nvme_mi_ep_t ep); +char *libnvme_mi_endpoint_desc(nvme_mi_ep_t ep); /* MI Command API: nvme_mi_mi_ prefix */ /** - * nvme_mi_mi_xfer() - Raw mi transfer interface. + * libnvme_mi_mi_xfer() - Raw mi transfer interface. * @ep: endpoint to send the MI command to * @mi_req: request data * @req_data_size: size of request data payload @@ -949,14 +949,14 @@ char *nvme_mi_endpoint_desc(nvme_mi_ep_t ep); * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -int nvme_mi_mi_xfer(nvme_mi_ep_t ep, +int libnvme_mi_mi_xfer(nvme_mi_ep_t ep, struct nvme_mi_mi_req_hdr *mi_req, size_t req_data_size, struct nvme_mi_mi_resp_hdr *mi_resp, size_t *resp_data_size); /** - * nvme_mi_mi_read_mi_data_subsys() - Perform a Read MI Data Structure command, + * libnvme_mi_mi_read_mi_data_subsys() - Perform a Read MI Data Structure command, * retrieving subsystem data. * @ep: endpoint for MI communication * @s: subsystem information to populate @@ -967,18 +967,18 @@ int nvme_mi_mi_xfer(nvme_mi_ep_t ep, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -int nvme_mi_mi_read_mi_data_subsys(nvme_mi_ep_t ep, +int libnvme_mi_mi_read_mi_data_subsys(nvme_mi_ep_t ep, struct nvme_mi_read_nvm_ss_info *s); /** - * nvme_mi_mi_read_mi_data_port() - Perform a Read MI Data Structure command, + * libnvme_mi_mi_read_mi_data_port() - Perform a Read MI Data Structure command, * retrieving port data. * @ep: endpoint for MI communication * @portid: id of port data to retrieve * @p: port information to populate * * Retrieves the Port information, for the specified port ID. The subsystem - * data (from &nvme_mi_mi_read_mi_data_subsys) nmp field contains the allowed + * data (from &libnvme_mi_mi_read_mi_data_subsys) nmp field contains the allowed * range of port IDs. * * See &struct nvme_mi_read_port_info. @@ -986,11 +986,11 @@ int nvme_mi_mi_read_mi_data_subsys(nvme_mi_ep_t ep, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -int nvme_mi_mi_read_mi_data_port(nvme_mi_ep_t ep, __u8 portid, +int libnvme_mi_mi_read_mi_data_port(nvme_mi_ep_t ep, __u8 portid, struct nvme_mi_read_port_info *p); /** - * nvme_mi_mi_read_mi_data_ctrl_list() - Perform a Read MI Data Structure + * libnvme_mi_mi_read_mi_data_ctrl_list() - Perform a Read MI Data Structure * command, retrieving the list of attached controllers. * @ep: endpoint for MI communication * @start_ctrlid: starting controller ID @@ -1004,11 +1004,11 @@ int nvme_mi_mi_read_mi_data_port(nvme_mi_ep_t ep, __u8 portid, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -int nvme_mi_mi_read_mi_data_ctrl_list(nvme_mi_ep_t ep, __u8 start_ctrlid, +int libnvme_mi_mi_read_mi_data_ctrl_list(nvme_mi_ep_t ep, __u8 start_ctrlid, struct nvme_ctrl_list *list); /** - * nvme_mi_mi_read_mi_data_ctrl() - Perform a Read MI Data Structure command, + * libnvme_mi_mi_read_mi_data_ctrl() - Perform a Read MI Data Structure command, * retrieving controller information * @ep: endpoint for MI communication * @ctrl_id: ID of controller to query @@ -1022,11 +1022,11 @@ int nvme_mi_mi_read_mi_data_ctrl_list(nvme_mi_ep_t ep, __u8 start_ctrlid, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -int nvme_mi_mi_read_mi_data_ctrl(nvme_mi_ep_t ep, __u16 ctrl_id, +int libnvme_mi_mi_read_mi_data_ctrl(nvme_mi_ep_t ep, __u16 ctrl_id, struct nvme_mi_read_ctrl_info *ctrl); /** - * nvme_mi_mi_subsystem_health_status_poll() - Read the Subsystem Health + * libnvme_mi_mi_subsystem_health_status_poll() - Read the Subsystem Health * Data Structure from the NVM subsystem * @ep: endpoint for MI communication * @clear: flag to clear the Composite Controller Status state @@ -1041,11 +1041,11 @@ int nvme_mi_mi_read_mi_data_ctrl(nvme_mi_ep_t ep, __u16 ctrl_id, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -int nvme_mi_mi_subsystem_health_status_poll(nvme_mi_ep_t ep, bool clear, +int libnvme_mi_mi_subsystem_health_status_poll(nvme_mi_ep_t ep, bool clear, struct nvme_mi_nvm_ss_health_status *nshds); /** - * nvme_mi_mi_config_get - query a configuration parameter + * libnvme_mi_mi_config_get - query a configuration parameter * @ep: endpoint for MI communication * @dw0: management doubleword 0, containing configuration identifier, plus * config-specific fields @@ -1064,11 +1064,11 @@ int nvme_mi_mi_subsystem_health_status_poll(nvme_mi_ep_t ep, bool clear, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -int nvme_mi_mi_config_get(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1, +int libnvme_mi_mi_config_get(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1, __u32 *nmresp); /** - * nvme_mi_mi_config_set - set a configuration parameter + * libnvme_mi_mi_config_set - set a configuration parameter * @ep: endpoint for MI communication * @dw0: management doubleword 0, containing configuration identifier, plus * config-specific fields @@ -1082,10 +1082,10 @@ int nvme_mi_mi_config_get(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -int nvme_mi_mi_config_set(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1); +int libnvme_mi_mi_config_set(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1); /** - * nvme_mi_mi_config_get_smbus_freq - get configuration: SMBus port frequency + * libnvme_mi_mi_config_get_smbus_freq - get configuration: SMBus port frequency * @ep: endpoint for MI communication * @port: port ID to query * @freq: output value for current frequency configuration @@ -1097,7 +1097,7 @@ int nvme_mi_mi_config_set(nvme_mi_ep_t ep, __u32 dw0, __u32 dw1); * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -static inline int nvme_mi_mi_config_get_smbus_freq(nvme_mi_ep_t ep, __u8 port, +static inline int libnvme_mi_mi_config_get_smbus_freq(nvme_mi_ep_t ep, __u8 port, enum nvme_mi_config_smbus_freq *freq) { __u32 tmp, dw0; @@ -1105,14 +1105,14 @@ static inline int nvme_mi_mi_config_get_smbus_freq(nvme_mi_ep_t ep, __u8 port, dw0 = port << 24 | NVME_MI_CONFIG_SMBUS_FREQ; - rc = nvme_mi_mi_config_get(ep, dw0, 0, &tmp); + rc = libnvme_mi_mi_config_get(ep, dw0, 0, &tmp); if (!rc) *freq = (enum nvme_mi_config_smbus_freq)(tmp & 0x3); return rc; } /** - * nvme_mi_mi_config_set_smbus_freq - set configuration: SMBus port frequency + * libnvme_mi_mi_config_set_smbus_freq - set configuration: SMBus port frequency * @ep: endpoint for MI communication * @port: port ID to set * @freq: new frequency configuration @@ -1126,18 +1126,18 @@ static inline int nvme_mi_mi_config_get_smbus_freq(nvme_mi_ep_t ep, __u8 port, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -static inline int nvme_mi_mi_config_set_smbus_freq(nvme_mi_ep_t ep, __u8 port, +static inline int libnvme_mi_mi_config_set_smbus_freq(nvme_mi_ep_t ep, __u8 port, enum nvme_mi_config_smbus_freq freq) { __u32 dw0 = port << 24 | (freq & 0x3) << 8 | NVME_MI_CONFIG_SMBUS_FREQ; - return nvme_mi_mi_config_set(ep, dw0, 0); + return libnvme_mi_mi_config_set(ep, dw0, 0); } /** - * nvme_mi_mi_config_set_health_status_change - clear CCS bits in health status + * libnvme_mi_mi_config_set_health_status_change - clear CCS bits in health status * @ep: endpoint for MI communication * @mask: bitmask to clear * @@ -1146,21 +1146,21 @@ static inline int nvme_mi_mi_config_set_smbus_freq(nvme_mi_ep_t ep, __u8 port, * be cleared from future health status poll data, and may be re-triggered by * a future health change event. * - * See &nvme_mi_mi_subsystem_health_status_poll(), &enum nvme_mi_ccs for + * See &libnvme_mi_mi_subsystem_health_status_poll(), &enum nvme_mi_ccs for * values in @mask. * * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -static inline int nvme_mi_mi_config_set_health_status_change(nvme_mi_ep_t ep, +static inline int libnvme_mi_mi_config_set_health_status_change(nvme_mi_ep_t ep, __u32 mask) { - return nvme_mi_mi_config_set(ep, NVME_MI_CONFIG_HEALTH_STATUS_CHANGE, + return libnvme_mi_mi_config_set(ep, NVME_MI_CONFIG_HEALTH_STATUS_CHANGE, mask); } /** - * nvme_mi_mi_config_get_mctp_mtu - get configuration: MCTP MTU + * libnvme_mi_mi_config_get_mctp_mtu - get configuration: MCTP MTU * @ep: endpoint for MI communication * @port: port ID to query * @mtu: output value for current MCTP MTU configuration @@ -1177,7 +1177,7 @@ static inline int nvme_mi_mi_config_set_health_status_change(nvme_mi_ep_t ep, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -static inline int nvme_mi_mi_config_get_mctp_mtu(nvme_mi_ep_t ep, __u8 port, +static inline int libnvme_mi_mi_config_get_mctp_mtu(nvme_mi_ep_t ep, __u8 port, __u16 *mtu) { __u32 tmp, dw0; @@ -1185,14 +1185,14 @@ static inline int nvme_mi_mi_config_get_mctp_mtu(nvme_mi_ep_t ep, __u8 port, dw0 = port << 24 | NVME_MI_CONFIG_MCTP_MTU; - rc = nvme_mi_mi_config_get(ep, dw0, 0, &tmp); + rc = libnvme_mi_mi_config_get(ep, dw0, 0, &tmp); if (!rc) *mtu = tmp & 0xffff; return rc; } /** - * nvme_mi_mi_config_set_mctp_mtu - set configuration: MCTP MTU + * libnvme_mi_mi_config_set_mctp_mtu - set configuration: MCTP MTU * @ep: endpoint for MI communication * @port: port ID to set * @mtu: new MTU configuration @@ -1208,17 +1208,17 @@ static inline int nvme_mi_mi_config_get_mctp_mtu(nvme_mi_ep_t ep, __u8 port, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -static inline int nvme_mi_mi_config_set_mctp_mtu(nvme_mi_ep_t ep, __u8 port, +static inline int libnvme_mi_mi_config_set_mctp_mtu(nvme_mi_ep_t ep, __u8 port, __u16 mtu) { __u32 dw0 = port << 24 | NVME_MI_CONFIG_MCTP_MTU; - return nvme_mi_mi_config_set(ep, dw0, mtu); + return libnvme_mi_mi_config_set(ep, dw0, mtu); } /** - * nvme_mi_mi_config_get_async_event - get configuration: Asynchronous Event + * libnvme_mi_mi_config_get_async_event - get configuration: Asynchronous Event * @ep: endpoint for MI communication * @aeelver: Asynchronous Event Enable List Version Number * @list: AE Supported list header and list contents @@ -1231,13 +1231,13 @@ static inline int nvme_mi_mi_config_set_mctp_mtu(nvme_mi_ep_t ep, __u8 port, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -int nvme_mi_mi_config_get_async_event(nvme_mi_ep_t ep, +int libnvme_mi_mi_config_get_async_event(nvme_mi_ep_t ep, __u8 *aeelver, struct nvme_mi_aem_supported_list *list, size_t *list_num_bytes); /** - * nvme_mi_mi_config_set_async_event - set configuration: Asynchronous Event + * libnvme_mi_mi_config_set_async_event - set configuration: Asynchronous Event * @ep: endpoint for MI communication * @envfa: Enable SR-IOV Virtual Functions AE * @empfa: Enable SR-IOV Physical Functions AE @@ -1262,7 +1262,7 @@ int nvme_mi_mi_config_get_async_event(nvme_mi_ep_t ep, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -int nvme_mi_mi_config_set_async_event(nvme_mi_ep_t ep, +int libnvme_mi_mi_config_set_async_event(nvme_mi_ep_t ep, bool envfa, bool empfa, bool encfa, @@ -1273,7 +1273,7 @@ int nvme_mi_mi_config_set_async_event(nvme_mi_ep_t ep, struct nvme_mi_aem_occ_list_hdr *occ_list, size_t *occ_list_size); -static inline int nvme_mi_aem_ack(nvme_mi_ep_t ep, +static inline int libnvme_mi_aem_ack(nvme_mi_ep_t ep, struct nvme_mi_aem_occ_list_hdr *occ_list, size_t *occ_list_size) { @@ -1285,7 +1285,7 @@ static inline int nvme_mi_aem_ack(nvme_mi_ep_t ep, list.hdr.aeetl = sizeof(struct nvme_mi_aem_enable_list_header); list.hdr.numaee = 0; - return nvme_mi_mi_config_set_async_event(ep, false, false, false, 0, 0, + return libnvme_mi_mi_config_set_async_event(ep, false, false, false, 0, 0, &list, sizeof(list), occ_list, occ_list_size); } @@ -1293,7 +1293,7 @@ static inline int nvme_mi_aem_ack(nvme_mi_ep_t ep, /* Admin channel functions */ /** - * nvme_mi_admin_xfer() - Raw admin transfer interface. + * libnvme_mi_admin_xfer() - Raw admin transfer interface. * @hdl: transport handle to send the admin command to * @admin_req: request data * @req_data_size: size of request data payload @@ -1319,7 +1319,7 @@ static inline int nvme_mi_aem_ack(nvme_mi_ep_t ep, * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise.. */ -int nvme_mi_admin_xfer(struct nvme_transport_handle *hdl, +int libnvme_mi_admin_xfer(struct nvme_transport_handle *hdl, struct nvme_mi_admin_req_hdr *admin_req, size_t req_data_size, struct nvme_mi_admin_resp_hdr *admin_resp, @@ -1327,7 +1327,7 @@ int nvme_mi_admin_xfer(struct nvme_transport_handle *hdl, size_t *resp_data_size); /** - * nvme_mi_control() - Perform a Control Primitive command + * libnvme_mi_control() - Perform a Control Primitive command * @ep: endpoint for MI communication * @opcode: Control Primitive opcode (using &enum nvme_mi_control_opcode) * @cpsp: Control Primitive Specific Parameter @@ -1341,17 +1341,17 @@ int nvme_mi_admin_xfer(struct nvme_transport_handle *hdl, * See: &enum nvme_mi_control_opcode * */ -int nvme_mi_control(nvme_mi_ep_t ep, __u8 opcode, +int libnvme_mi_control(nvme_mi_ep_t ep, __u8 opcode, __u16 cpsp, __u16 *result_cpsr); /** - * enum nvme_mi_aem_handler_next_action - Next action for the AEM state machine handler + * enum libnvme_mi_aem_handler_next_action - Next action for the AEM state machine handler * @NVME_MI_AEM_HNA_ACK: Send an ack for the AEM * @NVME_MI_AEM_HNA_NONE: No further action * - * Used as return value for the AE callback generated when calling nvme_mi_aem_process + * Used as return value for the AE callback generated when calling libnvme_mi_aem_process */ -enum nvme_mi_aem_handler_next_action { +enum libnvme_mi_aem_handler_next_action { NVME_MI_AEM_HNA_ACK, NVME_MI_AEM_HNA_NONE, }; @@ -1366,8 +1366,8 @@ enum nvme_mi_aem_handler_next_action { * @vend_spec_info: Vendor specific info buffer * @vend_spec_info_len: Length of vendor specific info buffer * - * Application callbacks for nvme_mi_aem_process will be able to call - * nvme_mi_aem_get_next_event which will return a pointer to such an identifier + * Application callbacks for libnvme_mi_aem_process will be able to call + * libnvme_mi_aem_get_next_event which will return a pointer to such an identifier * for the next event the application should parse */ struct nvme_mi_event { @@ -1381,7 +1381,7 @@ struct nvme_mi_event { }; /** - * nvme_mi_aem_get_next_event() - Get details for the next event to parse + * libnvme_mi_aem_get_next_event() - Get details for the next event to parse * @ep: The endpoint with the event * * When inside a aem_handler, call this and a returned struct pointer @@ -1391,14 +1391,14 @@ struct nvme_mi_event { * * Return: Pointer no next nvme_mi_event or NULL if this is the last one */ -struct nvme_mi_event *nvme_mi_aem_get_next_event(nvme_mi_ep_t ep); +struct nvme_mi_event *libnvme_mi_aem_get_next_event(nvme_mi_ep_t ep); struct nvme_mi_aem_enabled_map { bool enabled[256]; }; /** - * struct nvme_mi_aem_config - Provided for nvme_mi_aem_enable + * struct nvme_mi_aem_config - Provided for libnvme_mi_aem_enable * @aem_handler: Callback function for application processing of events * @enabled_map: Map indicating which AE should be enabled on the endpoint * @envfa: Enable SR-IOV virtual functions AE @@ -1407,17 +1407,17 @@ struct nvme_mi_aem_enabled_map { * @aemd: AEM Delay (time in seconds from when event happens to AEM being batched and sent) * @aerd: AEM Retry Delay (time in 100s of ms between AEM retries from the endpoint) * - * Application callbacks for nvme_mi_aem_process will be able to call - * nvme_mi_aem_get_next_event which will return a pointer to such an identifier + * Application callbacks for libnvme_mi_aem_process will be able to call + * libnvme_mi_aem_get_next_event which will return a pointer to such an identifier * for the next event the application should parse */ struct nvme_mi_aem_config { /* * This is called from inside nvme_mi_process when a payload has been validated and - * can be parsed. The application may call nvme_mi_aem_get_next_event from inside + * can be parsed. The application may call libnvme_mi_aem_get_next_event from inside * the callback to parse event data. */ - enum nvme_mi_aem_handler_next_action (*aem_handler)( + enum libnvme_mi_aem_handler_next_action (*aem_handler)( nvme_mi_ep_t ep, size_t num_events, void *userdata); @@ -1432,69 +1432,69 @@ struct nvme_mi_aem_config { }; /** - * nvme_mi_aem_get_fd() - Returns the pollable fd for AEM data available + * libnvme_mi_aem_get_fd() - Returns the pollable fd for AEM data available * @ep: The endpoint being monitored for asynchronous data * * This populated structure can be polled from the application to understand if - * a call to nvme_mi_aem_process() is required (when a poll returns > 0). + * a call to libnvme_mi_aem_process() is required (when a poll returns > 0). * * Return: The fd value or -1 if error */ -int nvme_mi_aem_get_fd(nvme_mi_ep_t ep); +int libnvme_mi_aem_get_fd(nvme_mi_ep_t ep); /** - * nvme_mi_aem_enable() - Enable AE on the provided endpoint + * libnvme_mi_aem_enable() - Enable AE on the provided endpoint * @ep: Endpoint to enable AEs * @config: AE configuraiton including which events are enabled and the callback function * @userdata: Application provided context pointer for callback function * * This function is called to enable AE on the endpoint. Endpoint will provide initial state * (if any) of enabled AEs and application can parse those via the aem_handler fn pointer in - * callbacks. Thes can be obtained in the callback by calling nvme_mi_aem_get_next_event(). + * callbacks. Thes can be obtained in the callback by calling libnvme_mi_aem_get_next_event(). * - * Application should poll the fd that can be obtained from nvme_mi_aem_get_fd and then call - * nvme_mi_aem_process() when poll() indicates data available. + * Application should poll the fd that can be obtained from libnvme_mi_aem_get_fd and then call + * libnvme_mi_aem_process() when poll() indicates data available. * - * A call to nvme_mi_aem_process() will grab AEM data and call the aem_handler fn pointer. - * At this point the application can call nvme_mi_aem_get_next_event() to get information for + * A call to libnvme_mi_aem_process() will grab AEM data and call the aem_handler fn pointer. + * At this point the application can call libnvme_mi_aem_get_next_event() to get information for * each triggered event. * * Return: 0 is a success, nonzero is an error and errno may be read for further details */ -int nvme_mi_aem_enable(nvme_mi_ep_t ep, +int libnvme_mi_aem_enable(nvme_mi_ep_t ep, struct nvme_mi_aem_config *config, void *userdata); /** - * nvme_mi_aem_get_enabled() - Return information on which AEs are enabled + * libnvme_mi_aem_get_enabled() - Return information on which AEs are enabled * @ep: Endpoint to check enabled status * @enabled: nvme_mi_aem_enabled_map indexed by AE event ID of enabled state * * Return: 0 is a success, nonzero is an error and errno may be read for further details */ -int nvme_mi_aem_get_enabled(nvme_mi_ep_t ep, +int libnvme_mi_aem_get_enabled(nvme_mi_ep_t ep, struct nvme_mi_aem_enabled_map *enabled); /** - * nvme_mi_aem_disable() - Disable AE on the provided endpoint + * libnvme_mi_aem_disable() - Disable AE on the provided endpoint * @ep: Endpoint to disable AEs * * Return: 0 is a success, nonzero is an error and errno may be read for further details */ -int nvme_mi_aem_disable(nvme_mi_ep_t ep); +int libnvme_mi_aem_disable(nvme_mi_ep_t ep); /** - * nvme_mi_aem_process() - Process AEM on the provided endpoint + * libnvme_mi_aem_process() - Process AEM on the provided endpoint * @ep: Endpoint to process * @userdata: Application provided context pointer for callback function * - * Call this if poll() indicates data is available on the fd provided by nvme_mi_aem_get_fd() + * Call this if poll() indicates data is available on the fd provided by libnvme_mi_aem_get_fd() * * This will call the fn pointer, aem_handler, provided with nvme_mi_aem_config and the - * application can call nvme_mi_aem_get_next_event() from within this callback to get + * application can call libnvme_mi_aem_get_next_event() from within this callback to get * aem event data. The callback function should return NVME_MI_AEM_HNA_ACK for normal operation. * * Return: 0 is a success, nonzero is an error and errno may be read for further details */ -int nvme_mi_aem_process(nvme_mi_ep_t ep, void *userdata); +int libnvme_mi_aem_process(nvme_mi_ep_t ep, void *userdata); diff --git a/libnvme/src/nvme/nbft.c b/libnvme/src/nvme/nbft.c index c2b96804c5..db082e7f02 100644 --- a/libnvme/src/nvme/nbft.c +++ b/libnvme/src/nvme/nbft.c @@ -712,7 +712,7 @@ static int parse_raw_nbft(struct nvme_global_ctx *ctx, struct nbft_info *nbft) return 0; } -__public void nvme_free_nbft(struct nvme_global_ctx *ctx, struct nbft_info *nbft) +__public void libnvme_free_nbft(struct nvme_global_ctx *ctx, struct nbft_info *nbft) { struct nbft_info_hfi **hfi; struct nbft_info_security **sec; @@ -738,7 +738,7 @@ __public void nvme_free_nbft(struct nvme_global_ctx *ctx, struct nbft_info *nbft free(nbft); } -__public int nvme_read_nbft(struct nvme_global_ctx *ctx, struct nbft_info **nbft, +__public int libnvme_read_nbft(struct nvme_global_ctx *ctx, struct nbft_info **nbft, const char *filename) { __u8 *raw_nbft = NULL; @@ -752,14 +752,14 @@ __public int nvme_read_nbft(struct nvme_global_ctx *ctx, struct nbft_info **nbft raw_nbft_fp = fopen(filename, "rb"); if (raw_nbft_fp == NULL) { nvme_msg(ctx, LOG_ERR, "Failed to open %s: %s\n", - filename, nvme_strerror(errno)); + filename, libnvme_strerror(errno)); return -EINVAL; } i = fseek(raw_nbft_fp, 0L, SEEK_END); if (i) { nvme_msg(ctx, LOG_ERR, "Failed to read from %s: %s\n", - filename, nvme_strerror(errno)); + filename, libnvme_strerror(errno)); fclose(raw_nbft_fp); return -EINVAL; } @@ -778,7 +778,7 @@ __public int nvme_read_nbft(struct nvme_global_ctx *ctx, struct nbft_info **nbft i = fread(raw_nbft, sizeof(*raw_nbft), raw_nbft_size, raw_nbft_fp); if (i != raw_nbft_size) { nvme_msg(ctx, LOG_ERR, "Failed to read from %s: %s\n", - filename, nvme_strerror(errno)); + filename, libnvme_strerror(errno)); fclose(raw_nbft_fp); free(raw_nbft); return -EINVAL; @@ -802,7 +802,7 @@ __public int nvme_read_nbft(struct nvme_global_ctx *ctx, struct nbft_info **nbft if (parse_raw_nbft(ctx, *nbft)) { nvme_msg(ctx, LOG_ERR, "Failed to parse %s\n", filename); - nvme_free_nbft(ctx, *nbft); + libnvme_free_nbft(ctx, *nbft); return -EINVAL; } return 0; diff --git a/libnvme/src/nvme/nbft.h b/libnvme/src/nvme/nbft.h index 48d60ffb1b..cb78b844a5 100644 --- a/libnvme/src/nvme/nbft.h +++ b/libnvme/src/nvme/nbft.h @@ -1234,26 +1234,26 @@ struct nbft_info { }; /** - * nvme_read_nbft() - Read and parse contents of an ACPI NBFT table + * libnvme_read_nbft() - Read and parse contents of an ACPI NBFT table * * @ctx: struct nvme_global_ctx object * @nbft: Parsed NBFT table data. * @filename: Filename of the raw NBFT table to read. * * Read and parse the specified NBFT file into a struct nbft_info. - * Free with nvme_free_nbft(). + * Free with libnvme_free_nbft(). * * Return: 0 on success, errno otherwise. */ -int nvme_read_nbft(struct nvme_global_ctx *ctx, struct nbft_info **nbft, +int libnvme_read_nbft(struct nvme_global_ctx *ctx, struct nbft_info **nbft, const char *filename); /** - * nvme_free_nbft() - Free the struct nbft_info and its contents + * libnvme_free_nbft() - Free the struct nbft_info and its contents * @ctx: struct nvme_global_ctx object * @nbft: Parsed NBFT table data. */ -void nvme_free_nbft(struct nvme_global_ctx *ctx, struct nbft_info *nbft); +void libnvme_free_nbft(struct nvme_global_ctx *ctx, struct nbft_info *nbft); /** * struct nbft_file_entry - Linked list entry for NBFT files diff --git a/libnvme/src/nvme/private.h b/libnvme/src/nvme/private.h index 1f92efbc19..bde3bacb10 100644 --- a/libnvme/src/nvme/private.h +++ b/libnvme/src/nvme/private.h @@ -128,12 +128,12 @@ struct nvme_transport_handle { struct nvme_log *log; }; -struct nvme_path { /*!generate-accessors*/ +struct libnvme_path { /*!generate-accessors*/ struct list_node entry; struct list_node nentry; - struct nvme_ctrl *c; - struct nvme_ns *n; + struct libnvme_ctrl *c; + struct libnvme_ns *n; char *name; char *sysfs_dir; @@ -143,19 +143,19 @@ struct nvme_path { /*!generate-accessors*/ int queue_depth; //!accessors:none }; -struct nvme_ns_head { +struct libnvme_ns_head { struct list_head paths; - struct nvme_ns *n; + struct libnvme_ns *n; char *sysfs_dir; }; -struct nvme_ns { /*!generate-accessors*/ +struct libnvme_ns { /*!generate-accessors*/ struct list_node entry; - struct nvme_subsystem *s; - struct nvme_ctrl *c; - struct nvme_ns_head *head; + struct libnvme_subsystem *s; + struct libnvme_ctrl *c; + struct libnvme_ns_head *head; struct nvme_global_ctx *ctx; struct nvme_transport_handle *hdl; @@ -176,11 +176,11 @@ struct nvme_ns { /*!generate-accessors*/ enum nvme_csi csi; }; -struct nvme_ctrl { /*!generate-accessors*/ +struct libnvme_ctrl { /*!generate-accessors*/ struct list_node entry; struct list_head paths; struct list_head namespaces; - struct nvme_subsystem *s; + struct libnvme_subsystem *s; struct nvme_global_ctx *ctx; struct nvme_transport_handle *hdl; @@ -216,11 +216,11 @@ struct nvme_ctrl { /*!generate-accessors*/ struct nvme_fabrics_config cfg; }; -struct nvme_subsystem { /*!generate-accessors*/ +struct libnvme_subsystem { /*!generate-accessors*/ struct list_node entry; struct list_head ctrls; struct list_head namespaces; - struct nvme_host *h; + struct libnvme_host *h; char *name; /*!accessors:readonly*/ char *sysfs_dir; /*!accessors:readonly*/ @@ -233,7 +233,7 @@ struct nvme_subsystem { /*!generate-accessors*/ char *iopolicy; }; -struct nvme_host { /*!generate-accessors*/ +struct libnvme_host { /*!generate-accessors*/ struct list_node entry; struct list_head subsystems; struct nvme_global_ctx *ctx; @@ -247,7 +247,7 @@ struct nvme_host { /*!generate-accessors*/ * value */ }; -struct nvme_fabric_options { /*!generate-accessors*/ +struct libnvme_fabric_options { /*!generate-accessors*/ bool cntlid; bool concat; bool ctrl_loss_tmo; @@ -296,7 +296,7 @@ struct nvme_global_ctx { bool ioctl_probing; bool create_only; bool dry_run; - struct nvme_fabric_options *options; + struct libnvme_fabric_options *options; struct ifaddrs *ifaddrs_cache; /* init with nvme_getifaddrs() */ enum nvme_io_uring_state uring_state; @@ -310,10 +310,10 @@ struct nvmf_context { /* common callbacks */ bool (*decide_retry)(struct nvmf_context *fctx, int err, void *user_data); - void (*connected)(struct nvmf_context *fctx, struct nvme_ctrl *c, + void (*connected)(struct nvmf_context *fctx, struct libnvme_ctrl *c, void *user_data); void (*already_connected)(struct nvmf_context *fctx, - struct nvme_host *host, const char *subsysnqn, + struct libnvme_host *host, const char *subsysnqn, const char *transport, const char *traddr, const char *trsvcid, void *user_data); @@ -383,24 +383,24 @@ void __nvme_transport_handle_close_mi(struct nvme_transport_handle *hdl); int _nvme_create_ctrl(struct nvme_global_ctx *ctx, struct nvmf_context *fctx, - nvme_ctrl_t *cp); -bool _nvme_ctrl_match_config(struct nvme_ctrl *c, struct nvmf_context *fctx); + libnvme_ctrl_t *cp); +bool _nvme_ctrl_match_config(struct libnvme_ctrl *c, struct nvmf_context *fctx); void *__nvme_alloc(size_t len); void *__nvme_realloc(void *p, size_t len); -nvme_host_t nvme_lookup_host(struct nvme_global_ctx *ctx, const char *hostnqn, +libnvme_host_t nvme_lookup_host(struct nvme_global_ctx *ctx, const char *hostnqn, const char *hostid); -nvme_subsystem_t nvme_lookup_subsystem(struct nvme_host *h, +libnvme_subsystem_t nvme_lookup_subsystem(struct libnvme_host *h, const char *name, const char *subsysnqn); -nvme_ctrl_t nvme_lookup_ctrl(nvme_subsystem_t s, +libnvme_ctrl_t nvme_lookup_ctrl(libnvme_subsystem_t s, struct nvmf_context *fctx, - nvme_ctrl_t p); -nvme_ctrl_t nvme_ctrl_find(nvme_subsystem_t s, struct nvmf_context *fctx); + libnvme_ctrl_t p); +libnvme_ctrl_t nvme_ctrl_find(libnvme_subsystem_t s, struct nvmf_context *fctx); -void __nvme_free_host(nvme_host_t h); +void __nvme_free_host(libnvme_host_t h); #if (LOG_FUNCNAME == 1) #define __nvme_log_func __func__ @@ -517,7 +517,7 @@ void __nvme_mi_mctp_set_ops(const struct __mi_mctp_socket_ops *newops); #define SECTOR_SIZE 512 #define SECTOR_SHIFT 9 -int __nvme_import_keys_from_config(nvme_host_t h, nvme_ctrl_t c, +int __nvme_import_keys_from_config(libnvme_host_t h, libnvme_ctrl_t c, long *keyring_id, long *key_id); static inline char *xstrdup(const char *s) @@ -708,7 +708,7 @@ static inline __u16 nvmf_exat_size(size_t val_len) * * Return: On success 0, else error code. */ -int nvme_ns_get_transport_handle(nvme_ns_t n, +int nvme_ns_get_transport_handle(libnvme_ns_t n, struct nvme_transport_handle **hdl); /** @@ -716,7 +716,7 @@ int nvme_ns_get_transport_handle(nvme_ns_t n, * @n: Namespace instance * */ -void nvme_ns_release_transport_handle(nvme_ns_t n); +void nvme_ns_release_transport_handle(libnvme_ns_t n); /** * nvme_mi_admin_admin_passthru() - Submit an nvme admin passthrough command diff --git a/libnvme/src/nvme/tree.c b/libnvme/src/nvme/tree.c index 010dd3ce93..0dedbf2b7c 100644 --- a/libnvme/src/nvme/tree.c +++ b/libnvme/src/nvme/tree.c @@ -55,16 +55,16 @@ struct candidate_args { bool (*addreq)(const char *, const char *); bool well_known_nqn; }; -typedef bool (*ctrl_match_t)(struct nvme_ctrl *c, struct candidate_args *candidate); +typedef bool (*ctrl_match_t)(struct libnvme_ctrl *c, struct candidate_args *candidate); -static void __nvme_free_ctrl(nvme_ctrl_t c); +static void __nvme_free_ctrl(libnvme_ctrl_t c); static int nvme_subsystem_scan_namespace(struct nvme_global_ctx *ctx, - struct nvme_subsystem *s, char *name); -static int nvme_init_subsystem(nvme_subsystem_t s, const char *name); + struct libnvme_subsystem *s, char *name); +static int nvme_init_subsystem(libnvme_subsystem_t s, const char *name); static int nvme_scan_subsystem(struct nvme_global_ctx *ctx, const char *name); -static int nvme_ctrl_scan_namespace(struct nvme_global_ctx *ctx, struct nvme_ctrl *c, +static int nvme_ctrl_scan_namespace(struct nvme_global_ctx *ctx, struct libnvme_ctrl *c, char *name); -static int nvme_ctrl_scan_path(struct nvme_global_ctx *ctx, struct nvme_ctrl *c, char *name); +static int nvme_ctrl_scan_path(struct nvme_global_ctx *ctx, struct libnvme_ctrl *c, char *name); /** * Compare two C strings and handle NULL pointers gracefully. @@ -119,14 +119,14 @@ static char *nvme_hostid_from_hostnqn(const char *hostnqn) return strdup(uuid + strlen("uuid:")); } -__public int nvme_host_get_ids(struct nvme_global_ctx *ctx, +__public int libnvme_host_get_ids(struct nvme_global_ctx *ctx, const char *hostnqn_arg, const char *hostid_arg, char **hostnqn, char **hostid) { _cleanup_free_ char *nqn = NULL; _cleanup_free_ char *hid = NULL; _cleanup_free_ char *hnqn = NULL; - nvme_host_t h; + libnvme_host_t h; /* command line argumments */ if (hostid_arg) @@ -135,19 +135,19 @@ __public int nvme_host_get_ids(struct nvme_global_ctx *ctx, hnqn = strdup(hostnqn_arg); /* JSON config: assume the first entry is the default host */ - h = nvme_first_host(ctx); + h = libnvme_first_host(ctx); if (h) { if (!hid) - hid = xstrdup(nvme_host_get_hostid(h)); + hid = xstrdup(libnvme_host_get_hostid(h)); if (!hnqn) - hnqn = xstrdup(nvme_host_get_hostnqn(h)); + hnqn = xstrdup(libnvme_host_get_hostnqn(h)); } /* /etc/nvme/hostid and/or /etc/nvme/hostnqn */ if (!hid) - hid = nvme_read_hostid(); + hid = libnvme_read_hostid(); if (!hnqn) - hnqn = nvme_read_hostnqn(); + hnqn = libnvme_read_hostnqn(); /* incomplete configuration, thus derive hostid from hostnqn */ if (!hid && hnqn) @@ -158,7 +158,7 @@ __public int nvme_host_get_ids(struct nvme_global_ctx *ctx, * fails generate one */ if (!hid) { - hid = nvme_generate_hostid(); + hid = libnvme_generate_hostid(); if (!hid) return -ENOMEM; @@ -168,7 +168,7 @@ __public int nvme_host_get_ids(struct nvme_global_ctx *ctx, /* incomplete configuration, thus derive hostnqn from hostid */ if (!hnqn) { - hnqn = nvme_generate_hostnqn_from_hostid(hid); + hnqn = libnvme_generate_hostnqn_from_hostid(hid); if (!hnqn) return -ENOMEM; } @@ -189,15 +189,15 @@ __public int nvme_host_get_ids(struct nvme_global_ctx *ctx, return 0; } -__public int nvme_get_host(struct nvme_global_ctx *ctx, const char *hostnqn, - const char *hostid, nvme_host_t *host) +__public int libnvme_get_host(struct nvme_global_ctx *ctx, const char *hostnqn, + const char *hostid, libnvme_host_t *host) { _cleanup_free_ char *hnqn = NULL; _cleanup_free_ char *hid = NULL; - struct nvme_host *h; + struct libnvme_host *h; int err; - err = nvme_host_get_ids(ctx, hostnqn, hostid, &hnqn, &hid); + err = libnvme_host_get_ids(ctx, hostnqn, hostid, &hnqn, &hid); if (err) return err; @@ -205,64 +205,64 @@ __public int nvme_get_host(struct nvme_global_ctx *ctx, const char *hostnqn, if (!h) return -ENOMEM; - nvme_host_set_hostsymname(h, NULL); + libnvme_host_set_hostsymname(h, NULL); *host = h; return 0; } -static void nvme_filter_subsystem(struct nvme_global_ctx *ctx, nvme_subsystem_t s, - nvme_scan_filter_t f, void *f_args) +static void nvme_filter_subsystem(struct nvme_global_ctx *ctx, libnvme_subsystem_t s, + libnvme_scan_filter_t f, void *f_args) { if (f(s, NULL, NULL, f_args)) return; nvme_msg(ctx, LOG_DEBUG, "filter out subsystem %s\n", - nvme_subsystem_get_name(s)); - nvme_free_subsystem(s); + libnvme_subsystem_get_name(s)); + libnvme_free_subsystem(s); } -static void nvme_filter_ns(struct nvme_global_ctx *ctx, nvme_ns_t n, - nvme_scan_filter_t f, void *f_args) +static void nvme_filter_ns(struct nvme_global_ctx *ctx, libnvme_ns_t n, + libnvme_scan_filter_t f, void *f_args) { if (f(NULL, NULL, n, f_args)) return; nvme_msg(ctx, LOG_DEBUG, "filter out namespace %s\n", - nvme_ns_get_name(n)); - nvme_free_ns(n); + libnvme_ns_get_name(n)); + libnvme_free_ns(n); } -static void nvme_filter_ctrl(struct nvme_global_ctx *ctx, nvme_ctrl_t c, - nvme_scan_filter_t f, void *f_args) +static void nvme_filter_ctrl(struct nvme_global_ctx *ctx, libnvme_ctrl_t c, + libnvme_scan_filter_t f, void *f_args) { if (f(NULL, c, NULL, f_args)) return; nvme_msg(ctx, LOG_DEBUG, "filter out controller %s\n", - nvme_ctrl_get_name(c)); - nvme_free_ctrl(c); + libnvme_ctrl_get_name(c)); + libnvme_free_ctrl(c); } -static void nvme_filter_tree(struct nvme_global_ctx *ctx, nvme_scan_filter_t f, void *f_args) +static void nvme_filter_tree(struct nvme_global_ctx *ctx, libnvme_scan_filter_t f, void *f_args) { - nvme_host_t h, _h; - nvme_subsystem_t s, _s; - nvme_ns_t n, _n; - nvme_path_t p, _p; - nvme_ctrl_t c, _c; + libnvme_host_t h, _h; + libnvme_subsystem_t s, _s; + libnvme_ns_t n, _n; + libnvme_path_t p, _p; + libnvme_ctrl_t c, _c; if (!f) return; - nvme_for_each_host_safe(ctx, h, _h) { - nvme_for_each_subsystem_safe(h, s, _s) { - nvme_subsystem_for_each_ctrl_safe(s, c, _c) + libnvme_for_each_host_safe(ctx, h, _h) { + libnvme_for_each_subsystem_safe(h, s, _s) { + libnvme_subsystem_for_each_ctrl_safe(s, c, _c) nvme_filter_ctrl(ctx, c, f, f_args); - nvme_subsystem_for_each_ns_safe(s, n, _n) { - nvme_namespace_for_each_path_safe(n, p, _p) { - nvme_filter_ctrl(ctx, nvme_path_get_ctrl(p), + libnvme_subsystem_for_each_ns_safe(s, n, _n) { + libnvme_namespace_for_each_path_safe(n, p, _p) { + nvme_filter_ctrl(ctx, libnvme_path_get_ctrl(p), f, f_args); } nvme_filter_ns(ctx, n, f, f_args); @@ -273,7 +273,7 @@ static void nvme_filter_tree(struct nvme_global_ctx *ctx, nvme_scan_filter_t f, } } -__public int nvme_scan_topology(struct nvme_global_ctx *ctx, nvme_scan_filter_t f, void *f_args) +__public int libnvme_scan_topology(struct nvme_global_ctx *ctx, libnvme_scan_filter_t f, void *f_args) { _cleanup_dirents_ struct dirents subsys = {}, ctrls = {}; int i, ret; @@ -281,28 +281,28 @@ __public int nvme_scan_topology(struct nvme_global_ctx *ctx, nvme_scan_filter_t if (!ctx) return 0; - ctrls.num = nvme_scan_ctrls(&ctrls.ents); + ctrls.num = libnvme_scan_ctrls(&ctrls.ents); if (ctrls.num < 0) { nvme_msg(ctx, LOG_DEBUG, "failed to scan ctrls: %s\n", - nvme_strerror(-ctrls.num)); + libnvme_strerror(-ctrls.num)); return ctrls.num; } for (i = 0; i < ctrls.num; i++) { - nvme_ctrl_t c; + libnvme_ctrl_t c; - ret = nvme_scan_ctrl(ctx, ctrls.ents[i]->d_name, &c); + ret = libnvme_scan_ctrl(ctx, ctrls.ents[i]->d_name, &c); if (ret < 0) { nvme_msg(ctx, LOG_DEBUG, "failed to scan ctrl %s: %s\n", - ctrls.ents[i]->d_name, nvme_strerror(-ret)); + ctrls.ents[i]->d_name, libnvme_strerror(-ret)); continue; } } - subsys.num = nvme_scan_subsystems(&subsys.ents); + subsys.num = libnvme_scan_subsystems(&subsys.ents); if (subsys.num < 0) { nvme_msg(ctx, LOG_DEBUG, "failed to scan subsystems: %s\n", - nvme_strerror(-subsys.num)); + libnvme_strerror(-subsys.num)); return subsys.num; } @@ -311,7 +311,7 @@ __public int nvme_scan_topology(struct nvme_global_ctx *ctx, nvme_scan_filter_t if (ret < 0) { nvme_msg(ctx, LOG_DEBUG, "failed to scan subsystem %s: %s\n", - subsys.ents[i]->d_name, nvme_strerror(-ret)); + subsys.ents[i]->d_name, libnvme_strerror(-ret)); } } @@ -324,7 +324,7 @@ __public int nvme_scan_topology(struct nvme_global_ctx *ctx, nvme_scan_filter_t return 0; } -__public int nvme_read_config(struct nvme_global_ctx *ctx, const char *config_file) +__public int libnvme_read_config(struct nvme_global_ctx *ctx, const char *config_file) { int err; @@ -346,22 +346,22 @@ __public int nvme_read_config(struct nvme_global_ctx *ctx, const char *config_fi return err; } -__public int nvme_dump_config(struct nvme_global_ctx *ctx, int fd) +__public int libnvme_dump_config(struct nvme_global_ctx *ctx, int fd) { return json_update_config(ctx, fd); } -__public int nvme_dump_tree(struct nvme_global_ctx *ctx) +__public int libnvme_dump_tree(struct nvme_global_ctx *ctx) { return json_dump_tree(ctx); } -__public const char *nvme_get_application(struct nvme_global_ctx *ctx) +__public const char *libnvme_get_application(struct nvme_global_ctx *ctx) { return ctx->application; } -__public void nvme_set_application(struct nvme_global_ctx *ctx, const char *a) +__public void libnvme_set_application(struct nvme_global_ctx *ctx, const char *a) { free(ctx->application); ctx->application = NULL; @@ -370,111 +370,111 @@ __public void nvme_set_application(struct nvme_global_ctx *ctx, const char *a) ctx->application = strdup(a); } -__public void nvme_skip_namespaces(struct nvme_global_ctx *ctx) +__public void libnvme_skip_namespaces(struct nvme_global_ctx *ctx) { ctx->create_only = true; } -__public nvme_host_t nvme_first_host(struct nvme_global_ctx *ctx) +__public libnvme_host_t libnvme_first_host(struct nvme_global_ctx *ctx) { - return list_top(&ctx->hosts, struct nvme_host, entry); + return list_top(&ctx->hosts, struct libnvme_host, entry); } -__public nvme_host_t nvme_next_host(struct nvme_global_ctx *ctx, nvme_host_t h) +__public libnvme_host_t libnvme_next_host(struct nvme_global_ctx *ctx, libnvme_host_t h) { return h ? list_next(&ctx->hosts, h, entry) : NULL; } -__public struct nvme_global_ctx *nvme_host_get_global_ctx(nvme_host_t h) +__public struct nvme_global_ctx *libnvme_host_get_global_ctx(libnvme_host_t h) { return h->ctx; } -__public void nvme_host_set_pdc_enabled(nvme_host_t h, bool enabled) +__public void libnvme_host_set_pdc_enabled(libnvme_host_t h, bool enabled) { h->pdc_enabled_valid = true; h->pdc_enabled = enabled; } -__public bool nvme_host_is_pdc_enabled(nvme_host_t h, bool fallback) +__public bool libnvme_host_is_pdc_enabled(libnvme_host_t h, bool fallback) { if (h->pdc_enabled_valid) return h->pdc_enabled; return fallback; } -__public nvme_subsystem_t nvme_first_subsystem(nvme_host_t h) +__public libnvme_subsystem_t libnvme_first_subsystem(libnvme_host_t h) { - return list_top(&h->subsystems, struct nvme_subsystem, entry); + return list_top(&h->subsystems, struct libnvme_subsystem, entry); } -__public nvme_subsystem_t nvme_next_subsystem(nvme_host_t h, nvme_subsystem_t s) +__public libnvme_subsystem_t libnvme_next_subsystem(libnvme_host_t h, libnvme_subsystem_t s) { return s ? list_next(&h->subsystems, s, entry) : NULL; } -__public void nvme_refresh_topology(struct nvme_global_ctx *ctx) +__public void libnvme_refresh_topology(struct nvme_global_ctx *ctx) { - struct nvme_host *h, *_h; + struct libnvme_host *h, *_h; - nvme_for_each_host_safe(ctx, h, _h) + libnvme_for_each_host_safe(ctx, h, _h) __nvme_free_host(h); - nvme_scan_topology(ctx, NULL, NULL); + libnvme_scan_topology(ctx, NULL, NULL); } void nvme_root_release_fds(struct nvme_global_ctx *ctx) { - struct nvme_host *h, *_h; + struct libnvme_host *h, *_h; - nvme_for_each_host_safe(ctx, h, _h) - nvme_host_release_fds(h); + libnvme_for_each_host_safe(ctx, h, _h) + libnvme_host_release_fds(h); } -__public nvme_ctrl_t nvme_subsystem_first_ctrl(nvme_subsystem_t s) +__public libnvme_ctrl_t libnvme_subsystem_first_ctrl(libnvme_subsystem_t s) { - return list_top(&s->ctrls, struct nvme_ctrl, entry); + return list_top(&s->ctrls, struct libnvme_ctrl, entry); } -__public nvme_ctrl_t nvme_subsystem_next_ctrl(nvme_subsystem_t s, nvme_ctrl_t c) +__public libnvme_ctrl_t libnvme_subsystem_next_ctrl(libnvme_subsystem_t s, libnvme_ctrl_t c) { return c ? list_next(&s->ctrls, c, entry) : NULL; } -__public nvme_host_t nvme_subsystem_get_host(nvme_subsystem_t s) +__public libnvme_host_t libnvme_subsystem_get_host(libnvme_subsystem_t s) { return s->h; } -__public nvme_ns_t nvme_subsystem_first_ns(nvme_subsystem_t s) +__public libnvme_ns_t libnvme_subsystem_first_ns(libnvme_subsystem_t s) { - return list_top(&s->namespaces, struct nvme_ns, entry); + return list_top(&s->namespaces, struct libnvme_ns, entry); } -__public nvme_ns_t nvme_subsystem_next_ns(nvme_subsystem_t s, nvme_ns_t n) +__public libnvme_ns_t libnvme_subsystem_next_ns(libnvme_subsystem_t s, libnvme_ns_t n) { return n ? list_next(&s->namespaces, n, entry) : NULL; } -__public nvme_path_t nvme_namespace_first_path(nvme_ns_t ns) +__public libnvme_path_t libnvme_namespace_first_path(libnvme_ns_t ns) { - return list_top(&ns->head->paths, struct nvme_path, nentry); + return list_top(&ns->head->paths, struct libnvme_path, nentry); } -__public nvme_path_t nvme_namespace_next_path(nvme_ns_t ns, nvme_path_t p) +__public libnvme_path_t libnvme_namespace_next_path(libnvme_ns_t ns, libnvme_path_t p) { return p ? list_next(&ns->head->paths, p, nentry) : NULL; } -static void __nvme_free_ns(struct nvme_ns *n) +static void __nvme_free_ns(struct libnvme_ns *n) { - struct nvme_path *p, *_p; + struct libnvme_path *p, *_p; list_del_init(&n->entry); nvme_ns_release_transport_handle(n); free(n->generic_name); free(n->name); free(n->sysfs_dir); - nvme_namespace_for_each_path_safe(n, p, _p) { + libnvme_namespace_for_each_path_safe(n, p, _p) { list_del_init(&p->nentry); p->n = NULL; } @@ -485,21 +485,21 @@ static void __nvme_free_ns(struct nvme_ns *n) } /* Stub for SWIG */ -__public void nvme_free_ns(struct nvme_ns *n) +__public void libnvme_free_ns(struct libnvme_ns *n) { __nvme_free_ns(n); } -static void __nvme_free_subsystem(struct nvme_subsystem *s) +static void __nvme_free_subsystem(struct libnvme_subsystem *s) { - struct nvme_ctrl *c, *_c; - struct nvme_ns *n, *_n; + struct libnvme_ctrl *c, *_c; + struct libnvme_ns *n, *_n; list_del_init(&s->entry); - nvme_subsystem_for_each_ctrl_safe(s, c, _c) + libnvme_subsystem_for_each_ctrl_safe(s, c, _c) __nvme_free_ctrl(c); - nvme_subsystem_for_each_ns_safe(s, n, _n) + libnvme_subsystem_for_each_ns_safe(s, n, _n) __nvme_free_ns(n); free(s->name); @@ -514,30 +514,30 @@ static void __nvme_free_subsystem(struct nvme_subsystem *s) free(s); } -__public void nvme_subsystem_release_fds(struct nvme_subsystem *s) +__public void libnvme_subsystem_release_fds(struct libnvme_subsystem *s) { - struct nvme_ctrl *c, *_c; - struct nvme_ns *n, *_n; + struct libnvme_ctrl *c, *_c; + struct libnvme_ns *n, *_n; - nvme_subsystem_for_each_ctrl_safe(s, c, _c) - nvme_ctrl_release_transport_handle(c); + libnvme_subsystem_for_each_ctrl_safe(s, c, _c) + libnvme_ctrl_release_transport_handle(c); - nvme_subsystem_for_each_ns_safe(s, n, _n) + libnvme_subsystem_for_each_ns_safe(s, n, _n) nvme_ns_release_transport_handle(n); } /* * Stub for SWIG */ -__public void nvme_free_subsystem(nvme_subsystem_t s) +__public void libnvme_free_subsystem(libnvme_subsystem_t s) { } -struct nvme_subsystem *nvme_alloc_subsystem(struct nvme_host *h, +struct libnvme_subsystem *nvme_alloc_subsystem(struct libnvme_host *h, const char *name, const char *subsysnqn) { - struct nvme_subsystem *s; + struct libnvme_subsystem *s; s = calloc(1, sizeof(*s)); if (!s) @@ -554,13 +554,13 @@ struct nvme_subsystem *nvme_alloc_subsystem(struct nvme_host *h, return s; } -struct nvme_subsystem *nvme_lookup_subsystem(struct nvme_host *h, +struct libnvme_subsystem *nvme_lookup_subsystem(struct libnvme_host *h, const char *name, const char *subsysnqn) { - struct nvme_subsystem *s; + struct libnvme_subsystem *s; - nvme_for_each_subsystem(h, s) { + libnvme_for_each_subsystem(h, s) { if (subsysnqn && s->subsysnqn && strcmp(s->subsysnqn, subsysnqn)) continue; @@ -578,11 +578,11 @@ struct nvme_subsystem *nvme_lookup_subsystem(struct nvme_host *h, return nvme_alloc_subsystem(h, name, subsysnqn); } -__public int nvme_get_subsystem(struct nvme_global_ctx *ctx, - struct nvme_host *h, const char *name, - const char *subsysnqn, struct nvme_subsystem **subsys) +__public int libnvme_get_subsystem(struct nvme_global_ctx *ctx, + struct libnvme_host *h, const char *name, + const char *subsysnqn, struct libnvme_subsystem **subsys) { - struct nvme_subsystem *s; + struct libnvme_subsystem *s; s = nvme_lookup_subsystem(h, name, subsysnqn); if (!s) @@ -593,38 +593,38 @@ __public int nvme_get_subsystem(struct nvme_global_ctx *ctx, return 0; } -void __nvme_free_host(struct nvme_host *h) +void __nvme_free_host(struct libnvme_host *h) { - struct nvme_subsystem *s, *_s; + struct libnvme_subsystem *s, *_s; list_del_init(&h->entry); - nvme_for_each_subsystem_safe(h, s, _s) + libnvme_for_each_subsystem_safe(h, s, _s) __nvme_free_subsystem(s); free(h->hostnqn); free(h->hostid); free(h->dhchap_host_key); - nvme_host_set_hostsymname(h, NULL); + libnvme_host_set_hostsymname(h, NULL); free(h); } -__public void nvme_host_release_fds(struct nvme_host *h) +__public void libnvme_host_release_fds(struct libnvme_host *h) { - struct nvme_subsystem *s, *_s; + struct libnvme_subsystem *s, *_s; - nvme_for_each_subsystem_safe(h, s, _s) - nvme_subsystem_release_fds(s); + libnvme_for_each_subsystem_safe(h, s, _s) + libnvme_subsystem_release_fds(s); } /* Stub for SWIG */ -__public void nvme_free_host(struct nvme_host *h) +__public void libnvme_free_host(struct libnvme_host *h) { __nvme_free_host(h); } static int nvme_create_host(struct nvme_global_ctx *ctx, const char *hostnqn, - const char *hostid, struct nvme_host **host) + const char *hostid, struct libnvme_host **host) { - struct nvme_host *h; + struct libnvme_host *h; h = calloc(1, sizeof(*h)); if (!h) @@ -644,15 +644,15 @@ static int nvme_create_host(struct nvme_global_ctx *ctx, const char *hostnqn, return 0; } -struct nvme_host *nvme_lookup_host(struct nvme_global_ctx *ctx, +struct libnvme_host *nvme_lookup_host(struct nvme_global_ctx *ctx, const char *hostnqn, const char *hostid) { - struct nvme_host *h; + struct libnvme_host *h; if (!hostnqn) return NULL; - nvme_for_each_host(ctx, h) { + libnvme_for_each_host(ctx, h) { if (strcmp(h->hostnqn, hostnqn)) continue; if (hostid && (!h->hostid || @@ -667,7 +667,7 @@ struct nvme_host *nvme_lookup_host(struct nvme_global_ctx *ctx, return h; } -static int nvme_subsystem_scan_namespaces(struct nvme_global_ctx *ctx, nvme_subsystem_t s) +static int nvme_subsystem_scan_namespaces(struct nvme_global_ctx *ctx, libnvme_subsystem_t s) { _cleanup_dirents_ struct dirents namespaces = {}; int i, ret; @@ -678,11 +678,11 @@ static int nvme_subsystem_scan_namespaces(struct nvme_global_ctx *ctx, nvme_subs s->subsysnqn); return 0; } - namespaces.num = nvme_scan_subsystem_namespaces(s, &namespaces.ents); + namespaces.num = libnvme_scan_subsystem_namespaces(s, &namespaces.ents); if (namespaces.num < 0) { nvme_msg(ctx, LOG_DEBUG, "failed to scan namespaces for subsys %s: %s\n", - s->subsysnqn, nvme_strerror(-namespaces.num)); + s->subsysnqn, libnvme_strerror(-namespaces.num)); return namespaces.num; } @@ -692,25 +692,25 @@ static int nvme_subsystem_scan_namespaces(struct nvme_global_ctx *ctx, nvme_subs if (ret < 0) nvme_msg(ctx, LOG_DEBUG, "failed to scan namespace %s: %s\n", - namespaces.ents[i]->d_name, nvme_strerror(-ret)); + namespaces.ents[i]->d_name, libnvme_strerror(-ret)); } return 0; } -static int nvme_init_subsystem(nvme_subsystem_t s, const char *name) +static int nvme_init_subsystem(libnvme_subsystem_t s, const char *name) { char *path; if (asprintf(&path, "%s/%s", nvme_subsys_sysfs_dir(), name) < 0) return -ENOMEM; - s->model = nvme_get_attr(path, "model"); + s->model = libnvme_get_attr(path, "model"); if (!s->model) s->model = strdup("undefined"); - s->serial = nvme_get_attr(path, "serial"); - s->firmware = nvme_get_attr(path, "firmware_rev"); - s->subsystype = nvme_get_attr(path, "subsystype"); + s->serial = libnvme_get_attr(path, "serial"); + s->firmware = libnvme_get_attr(path, "firmware_rev"); + s->subsystype = libnvme_get_attr(path, "subsystype"); if (!s->subsystype) { if (!strcmp(s->subsysnqn, NVME_DISC_SUBSYS_NAME)) s->subsystype = strdup("discovery"); @@ -721,16 +721,16 @@ static int nvme_init_subsystem(nvme_subsystem_t s, const char *name) s->sysfs_dir = (char *)path; if (s->h->ctx->application) s->application = strdup(s->h->ctx->application); - s->iopolicy = nvme_get_attr(path, "iopolicy"); + s->iopolicy = libnvme_get_attr(path, "iopolicy"); return 0; } static int nvme_scan_subsystem(struct nvme_global_ctx *ctx, const char *name) { - struct nvme_subsystem *s = NULL, *_s; + struct libnvme_subsystem *s = NULL, *_s; _cleanup_free_ char *path = NULL, *subsysnqn = NULL; - nvme_host_t h = NULL; + libnvme_host_t h = NULL; int ret; nvme_msg(ctx, LOG_DEBUG, "scan subsystem %s\n", name); @@ -738,13 +738,13 @@ static int nvme_scan_subsystem(struct nvme_global_ctx *ctx, const char *name) if (ret < 0) return -ENOMEM; - subsysnqn = nvme_get_attr(path, "subsysnqn"); + subsysnqn = libnvme_get_attr(path, "subsysnqn"); if (!subsysnqn) return -ENODEV; - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, _s) { + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, _s) { /* - * We are always called after nvme_scan_ctrl(), + * We are always called after libnvme_scan_ctrl(), * so any subsystem we're interested at _must_ * have a name. */ @@ -765,7 +765,7 @@ static int nvme_scan_subsystem(struct nvme_global_ctx *ctx, const char *name) */ nvme_msg(ctx, LOG_DEBUG, "creating detached subsystem '%s'\n", name); - ret = nvme_get_host(ctx, NULL, NULL, &h); + ret = libnvme_get_host(ctx, NULL, NULL, &h); if (ret) return ret; s = nvme_alloc_subsystem(h, name, subsysnqn); @@ -782,21 +782,21 @@ static int nvme_scan_subsystem(struct nvme_global_ctx *ctx, const char *name) return 0; } -__public nvme_ctrl_t nvme_path_get_ctrl(nvme_path_t p) +__public libnvme_ctrl_t libnvme_path_get_ctrl(libnvme_path_t p) { return p->c; } -__public nvme_ns_t nvme_path_get_ns(nvme_path_t p) +__public libnvme_ns_t libnvme_path_get_ns(libnvme_path_t p) { return p->n; } -__public int nvme_path_get_queue_depth(nvme_path_t p) +__public int libnvme_path_get_queue_depth(libnvme_path_t p) { _cleanup_free_ char *queue_depth = NULL; - queue_depth = nvme_get_path_attr(p, "queue_depth"); + queue_depth = libnvme_get_path_attr(p, "queue_depth"); if (queue_depth) { sscanf(queue_depth, "%d", &p->queue_depth); } @@ -804,7 +804,7 @@ __public int nvme_path_get_queue_depth(nvme_path_t p) return p->queue_depth; } -void nvme_free_path(struct nvme_path *p) +void nvme_free_path(struct libnvme_path *p) { list_del_init(&p->entry); list_del_init(&p->nentry); @@ -815,9 +815,9 @@ void nvme_free_path(struct nvme_path *p) free(p); } -static int nvme_ctrl_scan_path(struct nvme_global_ctx *ctx, struct nvme_ctrl *c, char *name) +static int nvme_ctrl_scan_path(struct nvme_global_ctx *ctx, struct libnvme_ctrl *c, char *name) { - struct nvme_path *p; + struct libnvme_path *p; _cleanup_free_ char *path = NULL, *grpid = NULL, *queue_depth = NULL; int ret; @@ -838,20 +838,20 @@ static int nvme_ctrl_scan_path(struct nvme_global_ctx *ctx, struct nvme_ctrl *c, p->name = strdup(name); p->sysfs_dir = path; path = NULL; - p->ana_state = nvme_get_path_attr(p, "ana_state"); + p->ana_state = libnvme_get_path_attr(p, "ana_state"); if (!p->ana_state) p->ana_state = strdup("optimized"); - p->numa_nodes = nvme_get_path_attr(p, "numa_nodes"); + p->numa_nodes = libnvme_get_path_attr(p, "numa_nodes"); if (!p->numa_nodes) p->numa_nodes = strdup("-1"); - grpid = nvme_get_path_attr(p, "ana_grpid"); + grpid = libnvme_get_path_attr(p, "ana_grpid"); if (grpid) { sscanf(grpid, "%d", &p->grpid); } - queue_depth = nvme_get_path_attr(p, "queue_depth"); + queue_depth = libnvme_get_path_attr(p, "queue_depth"); if (queue_depth) { sscanf(queue_depth, "%d", &p->queue_depth); } @@ -862,12 +862,12 @@ static int nvme_ctrl_scan_path(struct nvme_global_ctx *ctx, struct nvme_ctrl *c, return 0; } -__public struct nvme_transport_handle *nvme_ctrl_get_transport_handle(nvme_ctrl_t c) +__public struct nvme_transport_handle *libnvme_ctrl_get_transport_handle(libnvme_ctrl_t c) { if (!c->hdl) { int err; - err = nvme_open(c->ctx, c->name, &c->hdl); + err = libnvme_open(c->ctx, c->name, &c->hdl); if (err) nvme_msg(c->ctx, LOG_ERR, "Failed to open ctrl %s, errno %d\n", @@ -876,22 +876,22 @@ __public struct nvme_transport_handle *nvme_ctrl_get_transport_handle(nvme_ctrl_ return c->hdl; } -__public void nvme_ctrl_release_transport_handle(nvme_ctrl_t c) +__public void libnvme_ctrl_release_transport_handle(libnvme_ctrl_t c) { if (!c->hdl) return; - nvme_close(c->hdl); + libnvme_close(c->hdl); c->hdl = NULL; } -__public nvme_subsystem_t nvme_ctrl_get_subsystem(nvme_ctrl_t c) +__public libnvme_subsystem_t libnvme_ctrl_get_subsystem(libnvme_ctrl_t c) { return c->s; } -__public char *nvme_ctrl_get_src_addr(nvme_ctrl_t c, char *src_addr, size_t src_addr_len) +__public char *libnvme_ctrl_get_src_addr(libnvme_ctrl_t c, char *src_addr, size_t src_addr_len) { size_t l; char *p; @@ -917,54 +917,54 @@ __public char *nvme_ctrl_get_src_addr(nvme_ctrl_t c, char *src_addr, size_t src_ return src_addr; } -__public const char *nvme_ctrl_get_state(nvme_ctrl_t c) +__public const char *libnvme_ctrl_get_state(libnvme_ctrl_t c) { char *state = c->state; - c->state = nvme_get_ctrl_attr(c, "state"); + c->state = libnvme_get_ctrl_attr(c, "state"); free(state); return c->state; } -__public struct nvme_fabrics_config *nvme_ctrl_get_config(nvme_ctrl_t c) +__public struct nvme_fabrics_config *libnvme_ctrl_get_config(libnvme_ctrl_t c) { return &c->cfg; } -__public int nvme_ctrl_identify(nvme_ctrl_t c, struct nvme_id_ctrl *id) +__public int libnvme_ctrl_identify(libnvme_ctrl_t c, struct nvme_id_ctrl *id) { - struct nvme_transport_handle *hdl = nvme_ctrl_get_transport_handle(c); + struct nvme_transport_handle *hdl = libnvme_ctrl_get_transport_handle(c); struct nvme_passthru_cmd cmd; nvme_init_identify_ctrl(&cmd, id); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } -__public nvme_ns_t nvme_ctrl_first_ns(nvme_ctrl_t c) +__public libnvme_ns_t libnvme_ctrl_first_ns(libnvme_ctrl_t c) { - return list_top(&c->namespaces, struct nvme_ns, entry); + return list_top(&c->namespaces, struct libnvme_ns, entry); } -__public nvme_ns_t nvme_ctrl_next_ns(nvme_ctrl_t c, nvme_ns_t n) +__public libnvme_ns_t libnvme_ctrl_next_ns(libnvme_ctrl_t c, libnvme_ns_t n) { return n ? list_next(&c->namespaces, n, entry) : NULL; } -__public nvme_path_t nvme_ctrl_first_path(nvme_ctrl_t c) +__public libnvme_path_t libnvme_ctrl_first_path(libnvme_ctrl_t c) { - return list_top(&c->paths, struct nvme_path, entry); + return list_top(&c->paths, struct libnvme_path, entry); } -__public nvme_path_t nvme_ctrl_next_path(nvme_ctrl_t c, nvme_path_t p) +__public libnvme_path_t libnvme_ctrl_next_path(libnvme_ctrl_t c, libnvme_path_t p) { return p ? list_next(&c->paths, p, entry) : NULL; } #define FREE_CTRL_ATTR(a) \ do { free(a); (a) = NULL; } while (0) -void nvme_deconfigure_ctrl(nvme_ctrl_t c) +void nvme_deconfigure_ctrl(libnvme_ctrl_t c) { - nvme_ctrl_release_transport_handle(c); + libnvme_ctrl_release_transport_handle(c); FREE_CTRL_ATTR(c->name); FREE_CTRL_ATTR(c->sysfs_dir); FREE_CTRL_ATTR(c->firmware); @@ -986,12 +986,12 @@ void nvme_deconfigure_ctrl(nvme_ctrl_t c) FREE_CTRL_ATTR(c->phy_slot); } -__public int nvme_disconnect_ctrl(nvme_ctrl_t c) +__public int libnvme_disconnect_ctrl(libnvme_ctrl_t c) { struct nvme_global_ctx *ctx = c->s && c->s->h ? c->s->h->ctx : NULL; int ret; - ret = nvme_set_attr(nvme_ctrl_get_sysfs_dir(c), + ret = nvme_set_attr(libnvme_ctrl_get_sysfs_dir(c), "delete_controller", "1"); if (ret < 0) { nvme_msg(ctx, LOG_ERR, "%s: failed to disconnect, error %d\n", @@ -1003,23 +1003,23 @@ __public int nvme_disconnect_ctrl(nvme_ctrl_t c) return 0; } -__public void nvme_unlink_ctrl(nvme_ctrl_t c) +__public void libnvme_unlink_ctrl(libnvme_ctrl_t c) { list_del_init(&c->entry); c->s = NULL; } -static void __nvme_free_ctrl(nvme_ctrl_t c) +static void __nvme_free_ctrl(libnvme_ctrl_t c) { - struct nvme_path *p, *_p; - struct nvme_ns *n, *_n; + struct libnvme_path *p, *_p; + struct libnvme_ns *n, *_n; - nvme_unlink_ctrl(c); + libnvme_unlink_ctrl(c); - nvme_ctrl_for_each_path_safe(c, p, _p) + libnvme_ctrl_for_each_path_safe(c, p, _p) nvme_free_path(p); - nvme_ctrl_for_each_ns_safe(c, n, _n) + libnvme_ctrl_for_each_ns_safe(c, n, _n) __nvme_free_ns(n); nvme_deconfigure_ctrl(c); @@ -1033,7 +1033,7 @@ static void __nvme_free_ctrl(nvme_ctrl_t c) free(c); } -__public void nvme_free_ctrl(nvme_ctrl_t c) +__public void libnvme_free_ctrl(libnvme_ctrl_t c) { __nvme_free_ctrl(c); } @@ -1064,9 +1064,9 @@ __public void nvmf_default_config(struct nvme_fabrics_config *cfg) int _nvme_create_ctrl(struct nvme_global_ctx *ctx, struct nvmf_context *fctx, - nvme_ctrl_t *cp) + libnvme_ctrl_t *cp) { - struct nvme_ctrl *c; + struct libnvme_ctrl *c; if (!fctx->transport) { nvme_msg(ctx, LOG_ERR, "No transport specified\n"); @@ -1113,11 +1113,11 @@ int _nvme_create_ctrl(struct nvme_global_ctx *ctx, return 0; } -__public int nvme_create_ctrl(struct nvme_global_ctx *ctx, +__public int libnvme_create_ctrl(struct nvme_global_ctx *ctx, const char *subsysnqn, const char *transport, const char *traddr, const char *host_traddr, const char *host_iface, const char *trsvcid, - nvme_ctrl_t *cp) + libnvme_ctrl_t *cp) { struct nvmf_context fctx = { .transport = transport, @@ -1144,7 +1144,7 @@ __public int nvme_create_ctrl(struct nvme_global_ctx *ctx, * * Return: true if @c->host_traddr matches @candidate->host_traddr. false otherwise. */ -static bool _tcp_ctrl_match_host_traddr_no_src_addr(struct nvme_ctrl *c, struct candidate_args *candidate) +static bool _tcp_ctrl_match_host_traddr_no_src_addr(struct libnvme_ctrl *c, struct candidate_args *candidate) { if (c->host_traddr) return candidate->addreq(candidate->host_traddr, c->host_traddr); @@ -1167,7 +1167,7 @@ static bool _tcp_ctrl_match_host_traddr_no_src_addr(struct nvme_ctrl *c, struct */ nvme_msg(c->ctx, LOG_DEBUG, "Not enough data, but assume %s matches candidate's host_traddr: %s\n", - nvme_ctrl_get_name(c), candidate->host_traddr); + libnvme_ctrl_get_name(c), candidate->host_traddr); return true; } @@ -1185,7 +1185,7 @@ static bool _tcp_ctrl_match_host_traddr_no_src_addr(struct nvme_ctrl *c, struct * * Return: true if @c->host_iface matches @candidate->host_iface. false otherwise. */ -static bool _tcp_ctrl_match_host_iface_no_src_addr(struct nvme_ctrl *c, struct candidate_args *candidate) +static bool _tcp_ctrl_match_host_iface_no_src_addr(struct libnvme_ctrl *c, struct candidate_args *candidate) { if (c->host_iface) return streq0(candidate->host_iface, c->host_iface); @@ -1207,7 +1207,7 @@ static bool _tcp_ctrl_match_host_iface_no_src_addr(struct nvme_ctrl *c, struct c */ nvme_msg(c->ctx, LOG_DEBUG, "Not enough data, but assume %s matches candidate's host_iface: %s\n", - nvme_ctrl_get_name(c), candidate->host_iface); + libnvme_ctrl_get_name(c), candidate->host_iface); return true; } @@ -1229,7 +1229,7 @@ static bool _tcp_ctrl_match_host_iface_no_src_addr(struct nvme_ctrl *c, struct c * * Return: true if @c matches @candidate. false otherwise. */ -static bool _tcp_opt_params_match_no_src_addr(struct nvme_ctrl *c, struct candidate_args *candidate) +static bool _tcp_opt_params_match_no_src_addr(struct libnvme_ctrl *c, struct candidate_args *candidate) { /* Check host_traddr only if candidate is interested */ if (candidate->host_traddr) { @@ -1284,12 +1284,12 @@ static bool _tcp_opt_params_match_no_src_addr(struct nvme_ctrl *c, struct candid * * Return: true if @c matches @candidate. false otherwise. */ -static bool _tcp_opt_params_match(struct nvme_ctrl *c, struct candidate_args *candidate) +static bool _tcp_opt_params_match(struct libnvme_ctrl *c, struct candidate_args *candidate) { char *src_addr, buffer[INET6_ADDRSTRLEN]; /* Check if src_addr is available (kernel 6.1 or later) */ - src_addr = nvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); + src_addr = libnvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); if (!src_addr) return _tcp_opt_params_match_no_src_addr(c, candidate); @@ -1325,7 +1325,7 @@ static bool _tcp_opt_params_match(struct nvme_ctrl *c, struct candidate_args *ca * * Return: true if a match is found, false otherwise. */ -static bool _tcp_match_ctrl(struct nvme_ctrl *c, struct candidate_args *candidate) +static bool _tcp_match_ctrl(struct libnvme_ctrl *c, struct candidate_args *candidate) { if (!streq0(c->transport, candidate->transport)) return false; @@ -1336,7 +1336,7 @@ static bool _tcp_match_ctrl(struct nvme_ctrl *c, struct candidate_args *candidat if (!candidate->addreq(c->traddr, candidate->traddr)) return false; - if (candidate->well_known_nqn && !nvme_ctrl_get_discovery_ctrl(c)) + if (candidate->well_known_nqn && !libnvme_ctrl_get_discovery_ctrl(c)) return false; if (candidate->subsysnqn && !streq0(c->subsysnqn, candidate->subsysnqn)) @@ -1361,7 +1361,7 @@ static bool _tcp_match_ctrl(struct nvme_ctrl *c, struct candidate_args *candidat * * Return: true if a match is found, false otherwise. */ -static bool _match_ctrl(struct nvme_ctrl *c, struct candidate_args *candidate) +static bool _match_ctrl(struct libnvme_ctrl *c, struct candidate_args *candidate) { if (!streq0(c->transport, candidate->transport)) return false; @@ -1382,7 +1382,7 @@ static bool _match_ctrl(struct nvme_ctrl *c, struct candidate_args *candidate) !streq0(c->trsvcid, candidate->trsvcid)) return false; - if (candidate->well_known_nqn && !nvme_ctrl_get_discovery_ctrl(c)) + if (candidate->well_known_nqn && !libnvme_ctrl_get_discovery_ctrl(c)) return false; if (candidate->subsysnqn && !streq0(c->subsysnqn, candidate->subsysnqn)) @@ -1451,19 +1451,19 @@ static ctrl_match_t _candidate_init(struct nvme_global_ctx *ctx, return _match_ctrl; } -static nvme_ctrl_t __nvme_ctrl_find(nvme_subsystem_t s, +static libnvme_ctrl_t __nvme_ctrl_find(libnvme_subsystem_t s, struct nvmf_context *fctx, - nvme_ctrl_t p) + libnvme_ctrl_t p) { struct candidate_args candidate = {}; - struct nvme_ctrl *c, *matching_c = NULL; + struct libnvme_ctrl *c, *matching_c = NULL; ctrl_match_t ctrl_match; /* Init candidate and get the matching function to use */ ctrl_match = _candidate_init(s->h->ctx, &candidate, fctx); - c = p ? nvme_subsystem_next_ctrl(s, p) : nvme_subsystem_first_ctrl(s); - for (; c != NULL; c = nvme_subsystem_next_ctrl(s, c)) { + c = p ? libnvme_subsystem_next_ctrl(s, p) : libnvme_subsystem_first_ctrl(s); + for (; c != NULL; c = libnvme_subsystem_next_ctrl(s, c)) { if (ctrl_match(c, &candidate)) { matching_c = c; break; @@ -1473,7 +1473,7 @@ static nvme_ctrl_t __nvme_ctrl_find(nvme_subsystem_t s, return matching_c; } -bool _nvme_ctrl_match_config(struct nvme_ctrl *c, struct nvmf_context *fctx) +bool _nvme_ctrl_match_config(struct libnvme_ctrl *c, struct nvmf_context *fctx) { struct candidate_args candidate = {}; ctrl_match_t ctrl_match; @@ -1484,7 +1484,7 @@ bool _nvme_ctrl_match_config(struct nvme_ctrl *c, struct nvmf_context *fctx) return ctrl_match(c, &candidate); } -__public bool nvme_ctrl_match_config(struct nvme_ctrl *c, const char *transport, +__public bool libnvme_ctrl_match_config(struct libnvme_ctrl *c, const char *transport, const char *traddr, const char *trsvcid, const char *subsysnqn, const char *host_traddr, const char *host_iface) @@ -1501,17 +1501,17 @@ __public bool nvme_ctrl_match_config(struct nvme_ctrl *c, const char *transport, return _nvme_ctrl_match_config(c, &fctx); } -nvme_ctrl_t nvme_ctrl_find(nvme_subsystem_t s, struct nvmf_context *fctx) +libnvme_ctrl_t nvme_ctrl_find(libnvme_subsystem_t s, struct nvmf_context *fctx) { return __nvme_ctrl_find(s, fctx, NULL/*p*/); } -nvme_ctrl_t nvme_lookup_ctrl(nvme_subsystem_t s, +libnvme_ctrl_t nvme_lookup_ctrl(libnvme_subsystem_t s, struct nvmf_context *fctx, - nvme_ctrl_t p) + libnvme_ctrl_t p) { struct nvme_global_ctx *ctx; - struct nvme_ctrl *c; + struct libnvme_ctrl *c; const char *subsysnqn = fctx->subsysnqn; int ret; @@ -1541,7 +1541,7 @@ nvme_ctrl_t nvme_lookup_ctrl(nvme_subsystem_t s, return c; } -static int nvme_ctrl_scan_paths(struct nvme_global_ctx *ctx, struct nvme_ctrl *c) +static int nvme_ctrl_scan_paths(struct nvme_global_ctx *ctx, struct libnvme_ctrl *c) { _cleanup_dirents_ struct dirents paths = {}; int err, i; @@ -1551,7 +1551,7 @@ static int nvme_ctrl_scan_paths(struct nvme_global_ctx *ctx, struct nvme_ctrl *c "skipping path scan for ctrl %s\n", c->name); return 0; } - paths.num = nvme_scan_ctrl_namespace_paths(c, &paths.ents); + paths.num = libnvme_scan_ctrl_namespace_paths(c, &paths.ents); if (paths.num < 0) return paths.num; @@ -1564,7 +1564,7 @@ static int nvme_ctrl_scan_paths(struct nvme_global_ctx *ctx, struct nvme_ctrl *c return 0; } -static int nvme_ctrl_scan_namespaces(struct nvme_global_ctx *ctx, struct nvme_ctrl *c) +static int nvme_ctrl_scan_namespaces(struct nvme_global_ctx *ctx, struct libnvme_ctrl *c) { _cleanup_dirents_ struct dirents namespaces = {}; int err, i; @@ -1574,7 +1574,7 @@ static int nvme_ctrl_scan_namespaces(struct nvme_global_ctx *ctx, struct nvme_ct c->name); return 0; } - namespaces.num = nvme_scan_ctrl_namespaces(c, &namespaces.ents); + namespaces.num = libnvme_scan_ctrl_namespaces(c, &namespaces.ents); for (i = 0; i < namespaces.num; i++) { err = nvme_ctrl_scan_namespace(ctx, c, namespaces.ents[i]->d_name); @@ -1593,7 +1593,7 @@ static int nvme_ctrl_lookup_subsystem_name(struct nvme_global_ctx *ctx, _cleanup_dirents_ struct dirents subsys = {}; int i; - subsys.num = nvme_scan_subsystems(&subsys.ents); + subsys.num = libnvme_scan_subsystems(&subsys.ents); if (subsys.num < 0) return subsys.num; @@ -1619,7 +1619,7 @@ static int nvme_ctrl_lookup_subsystem_name(struct nvme_global_ctx *ctx, } static int nvme_ctrl_lookup_phy_slot(struct nvme_global_ctx *ctx, - nvme_ctrl_t c) + libnvme_ctrl_t c) { const char *slots_sysfs_dir = nvme_slots_sysfs_dir(); _cleanup_free_ char *target_addr = NULL; @@ -1650,7 +1650,7 @@ static int nvme_ctrl_lookup_phy_slot(struct nvme_global_ctx *ctx, slots_sysfs_dir, entry->d_name); if (ret < 0) return -ENOMEM; - addr = nvme_get_attr(path, "address"); + addr = libnvme_get_attr(path, "address"); /* some directories don't have an address entry */ if (!addr) @@ -1669,46 +1669,46 @@ static int nvme_ctrl_lookup_phy_slot(struct nvme_global_ctx *ctx, return -ENOENT; } -static void nvme_read_sysfs_dhchap(struct nvme_global_ctx *ctx, nvme_ctrl_t c) +static void nvme_read_sysfs_dhchap(struct nvme_global_ctx *ctx, libnvme_ctrl_t c) { char *host_key, *ctrl_key; - host_key = nvme_get_ctrl_attr(c, "dhchap_secret"); + host_key = libnvme_get_ctrl_attr(c, "dhchap_secret"); if (host_key && !strcmp(host_key, "none")) { free(host_key); host_key = NULL; } if (host_key) { - nvme_ctrl_set_dhchap_host_key(c, NULL); + libnvme_ctrl_set_dhchap_host_key(c, NULL); c->dhchap_host_key = host_key; } - ctrl_key = nvme_get_ctrl_attr(c, "dhchap_ctrl_secret"); + ctrl_key = libnvme_get_ctrl_attr(c, "dhchap_ctrl_secret"); if (ctrl_key && !strcmp(ctrl_key, "none")) { free(ctrl_key); ctrl_key = NULL; } if (ctrl_key) { - nvme_ctrl_set_dhchap_ctrl_key(c, NULL); + libnvme_ctrl_set_dhchap_ctrl_key(c, NULL); c->dhchap_ctrl_key = ctrl_key; } } -static void nvme_read_sysfs_tls(struct nvme_global_ctx *ctx, nvme_ctrl_t c) +static void nvme_read_sysfs_tls(struct nvme_global_ctx *ctx, libnvme_ctrl_t c) { char *endptr; long key_id; char *key, *keyring; - key = nvme_get_ctrl_attr(c, "tls_key"); + key = libnvme_get_ctrl_attr(c, "tls_key"); if (!key) { /* tls_key is only present if --tls has been used. */ return; } c->cfg.tls = true; - keyring = nvme_get_ctrl_attr(c, "tls_keyring"); - nvme_ctrl_set_keyring(c, keyring); + keyring = libnvme_get_ctrl_attr(c, "tls_keyring"); + libnvme_ctrl_set_keyring(c, keyring); free(keyring); /* the sysfs entry is not prefixing the id but it's in hex */ @@ -1718,7 +1718,7 @@ static void nvme_read_sysfs_tls(struct nvme_global_ctx *ctx, nvme_ctrl_t c) free(key); - key = nvme_get_ctrl_attr(c, "tls_configured_key"); + key = libnvme_get_ctrl_attr(c, "tls_configured_key"); if (!key) return; @@ -1730,7 +1730,7 @@ static void nvme_read_sysfs_tls(struct nvme_global_ctx *ctx, nvme_ctrl_t c) free(key); } -static int nvme_reconfigure_ctrl(struct nvme_global_ctx *ctx, nvme_ctrl_t c, const char *path, +static int nvme_reconfigure_ctrl(struct nvme_global_ctx *ctx, libnvme_ctrl_t c, const char *path, const char *name) { DIR *d; @@ -1739,7 +1739,7 @@ static int nvme_reconfigure_ctrl(struct nvme_global_ctx *ctx, nvme_ctrl_t c, con * It's necesssary to release any resources first because a ctrl * can be reused. */ - nvme_ctrl_release_transport_handle(c); + libnvme_ctrl_release_transport_handle(c); FREE_CTRL_ATTR(c->name); FREE_CTRL_ATTR(c->sysfs_dir); FREE_CTRL_ATTR(c->firmware); @@ -1765,16 +1765,16 @@ static int nvme_reconfigure_ctrl(struct nvme_global_ctx *ctx, nvme_ctrl_t c, con c->hdl = NULL; c->name = xstrdup(name); c->sysfs_dir = xstrdup(path); - c->firmware = nvme_get_ctrl_attr(c, "firmware_rev"); - c->model = nvme_get_ctrl_attr(c, "model"); - c->state = nvme_get_ctrl_attr(c, "state"); - c->numa_node = nvme_get_ctrl_attr(c, "numa_node"); - c->queue_count = nvme_get_ctrl_attr(c, "queue_count"); - c->serial = nvme_get_ctrl_attr(c, "serial"); - c->sqsize = nvme_get_ctrl_attr(c, "sqsize"); - c->cntrltype = nvme_get_ctrl_attr(c, "cntrltype"); - c->cntlid = nvme_get_ctrl_attr(c, "cntlid"); - c->dctype = nvme_get_ctrl_attr(c, "dctype"); + c->firmware = libnvme_get_ctrl_attr(c, "firmware_rev"); + c->model = libnvme_get_ctrl_attr(c, "model"); + c->state = libnvme_get_ctrl_attr(c, "state"); + c->numa_node = libnvme_get_ctrl_attr(c, "numa_node"); + c->queue_count = libnvme_get_ctrl_attr(c, "queue_count"); + c->serial = libnvme_get_ctrl_attr(c, "serial"); + c->sqsize = libnvme_get_ctrl_attr(c, "sqsize"); + c->cntrltype = libnvme_get_ctrl_attr(c, "cntrltype"); + c->cntlid = libnvme_get_ctrl_attr(c, "cntlid"); + c->dctype = libnvme_get_ctrl_attr(c, "dctype"); nvme_ctrl_lookup_phy_slot(ctx, c); nvme_read_sysfs_dhchap(ctx, c); nvme_read_sysfs_tls(ctx, c); @@ -1782,10 +1782,10 @@ static int nvme_reconfigure_ctrl(struct nvme_global_ctx *ctx, nvme_ctrl_t c, con return 0; } -__public int nvme_init_ctrl(nvme_host_t h, nvme_ctrl_t c, int instance) +__public int libnvme_init_ctrl(libnvme_host_t h, libnvme_ctrl_t c, int instance) { _cleanup_free_ char *subsys_name = NULL, *name = NULL, *path = NULL; - nvme_subsystem_t s; + libnvme_subsystem_t s; int ret; ret = asprintf(&name, "nvme%d", instance); @@ -1800,7 +1800,7 @@ __public int nvme_init_ctrl(nvme_host_t h, nvme_ctrl_t c, int instance) if (ret < 0) return ret; - c->address = nvme_get_attr(path, "address"); + c->address = libnvme_get_attr(path, "address"); if (!c->address && strcmp(c->transport, "loop")) return -ENVME_CONNECT_INVAL_TR; @@ -1825,23 +1825,23 @@ __public int nvme_init_ctrl(nvme_host_t h, nvme_ctrl_t c, int instance) return ret; } -int nvme_ctrl_alloc(struct nvme_global_ctx *ctx, nvme_subsystem_t s, +int nvme_ctrl_alloc(struct nvme_global_ctx *ctx, libnvme_subsystem_t s, const char *path, const char *name, - nvme_ctrl_t *cp) + libnvme_ctrl_t *cp) { _cleanup_free_ char *addr = NULL, *address = NULL, *transport = NULL; char *host_traddr = NULL, *host_iface = NULL; char *traddr = NULL, *trsvcid = NULL; char *a = NULL, *e = NULL; - nvme_ctrl_t c, p; + libnvme_ctrl_t c, p; int ret; - transport = nvme_get_attr(path, "transport"); + transport = libnvme_get_attr(path, "transport"); if (!transport) return -ENXIO; /* Parse 'address' string into components */ - addr = nvme_get_attr(path, "address"); + addr = libnvme_get_attr(path, "address"); if (!addr) { _cleanup_free_ char *rpath = NULL; char *p = NULL, *_a = NULL; @@ -1929,16 +1929,16 @@ int nvme_ctrl_alloc(struct nvme_global_ctx *ctx, nvme_subsystem_t s, return 0; } -__public int nvme_scan_ctrl(struct nvme_global_ctx *ctx, const char *name, - nvme_ctrl_t *cp) +__public int libnvme_scan_ctrl(struct nvme_global_ctx *ctx, const char *name, + libnvme_ctrl_t *cp) { _cleanup_free_ char *subsysnqn = NULL, *subsysname = NULL; _cleanup_free_ char *hostnqn = NULL, *hostid = NULL; _cleanup_free_ char *path = NULL; char *host_key; - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; int ret; nvme_msg(ctx, LOG_DEBUG, "scan controller %s\n", name); @@ -1946,13 +1946,13 @@ __public int nvme_scan_ctrl(struct nvme_global_ctx *ctx, const char *name, if (ret < 0) return -ENOMEM; - hostnqn = nvme_get_attr(path, "hostnqn"); - hostid = nvme_get_attr(path, "hostid"); - ret = nvme_get_host(ctx, hostnqn, hostid, &h); + hostnqn = libnvme_get_attr(path, "hostnqn"); + hostid = libnvme_get_attr(path, "hostid"); + ret = libnvme_get_host(ctx, hostnqn, hostid, &h); if (ret) return ret; - host_key = nvme_get_attr(path, "dhchap_secret"); + host_key = libnvme_get_attr(path, "dhchap_secret"); if (host_key && strcmp(host_key, "none")) { free(h->dhchap_host_key); h->dhchap_host_key = host_key; @@ -1960,7 +1960,7 @@ __public int nvme_scan_ctrl(struct nvme_global_ctx *ctx, const char *name, } free(host_key); - subsysnqn = nvme_get_attr(path, "subsysnqn"); + subsysnqn = libnvme_get_attr(path, "subsysnqn"); if (!subsysnqn) return -ENXIO; @@ -1982,13 +1982,13 @@ __public int nvme_scan_ctrl(struct nvme_global_ctx *ctx, const char *name, ret = nvme_ctrl_scan_paths(ctx, c); if (ret) { - nvme_free_ctrl(c); + libnvme_free_ctrl(c); return ret; } ret = nvme_ctrl_scan_namespaces(ctx, c); if (ret) { - nvme_free_ctrl(c); + libnvme_free_ctrl(c); return ret; } @@ -1996,7 +1996,7 @@ __public int nvme_scan_ctrl(struct nvme_global_ctx *ctx, const char *name, return 0; } -__public void nvme_rescan_ctrl(struct nvme_ctrl *c) +__public void libnvme_rescan_ctrl(struct libnvme_ctrl *c) { struct nvme_global_ctx *ctx = c->s && c->s->h ? c->s->h->ctx : NULL; if (!c->s) @@ -2006,12 +2006,12 @@ __public void nvme_rescan_ctrl(struct nvme_ctrl *c) nvme_subsystem_scan_namespaces(ctx, c->s); } -static int nvme_bytes_to_lba(nvme_ns_t n, off_t offset, size_t count, +static int nvme_bytes_to_lba(libnvme_ns_t n, off_t offset, size_t count, __u64 *lba, __u16 *nlb) { int bs; - bs = nvme_ns_get_lba_size(n); + bs = libnvme_ns_get_lba_size(n); if (!count || offset & (bs - 1) || count & (bs - 1)) return -EINVAL; @@ -2021,7 +2021,7 @@ static int nvme_bytes_to_lba(nvme_ns_t n, off_t offset, size_t count, return 0; } -int nvme_ns_get_transport_handle(nvme_ns_t n, +int nvme_ns_get_transport_handle(libnvme_ns_t n, struct nvme_transport_handle **hdl) { int err; @@ -2029,7 +2029,7 @@ int nvme_ns_get_transport_handle(nvme_ns_t n, if (n->hdl) goto valid; - err = nvme_open(n->ctx, n->name, &n->hdl); + err = libnvme_open(n->ctx, n->name, &n->hdl); if (err) { nvme_msg(n->ctx, LOG_ERR, "Failed to open ns %s, error %d\n", n->name, err); @@ -2041,71 +2041,71 @@ int nvme_ns_get_transport_handle(nvme_ns_t n, return 0; } -void nvme_ns_release_transport_handle(nvme_ns_t n) +void nvme_ns_release_transport_handle(libnvme_ns_t n) { if (!n->hdl) return; - nvme_close(n->hdl); + libnvme_close(n->hdl); n->hdl = NULL; } -__public nvme_subsystem_t nvme_ns_get_subsystem(nvme_ns_t n) +__public libnvme_subsystem_t libnvme_ns_get_subsystem(libnvme_ns_t n) { return n->s; } -__public nvme_ctrl_t nvme_ns_get_ctrl(nvme_ns_t n) +__public libnvme_ctrl_t libnvme_ns_get_ctrl(libnvme_ns_t n) { return n->c; } -const char *nvme_ns_head_get_sysfs_dir(nvme_ns_head_t head) +const char *libnvme_ns_head_get_sysfs_dir(libnvme_ns_head_t head) { return head->sysfs_dir; } -__public const char *nvme_ns_get_generic_name(nvme_ns_t n) +__public const char *libnvme_ns_get_generic_name(libnvme_ns_t n) { return n->generic_name; } -__public const char *nvme_ns_get_model(nvme_ns_t n) +__public const char *libnvme_ns_get_model(libnvme_ns_t n) { return n->c ? n->c->model : n->s->model; } -__public const char *nvme_ns_get_serial(nvme_ns_t n) +__public const char *libnvme_ns_get_serial(libnvme_ns_t n) { return n->c ? n->c->serial : n->s->serial; } -__public const char *nvme_ns_get_firmware(nvme_ns_t n) +__public const char *libnvme_ns_get_firmware(libnvme_ns_t n) { return n->c ? n->c->firmware : n->s->firmware; } -__public enum nvme_csi nvme_ns_get_csi(nvme_ns_t n) +__public enum nvme_csi libnvme_ns_get_csi(libnvme_ns_t n) { return n->csi; } -__public const uint8_t *nvme_ns_get_eui64(nvme_ns_t n) +__public const uint8_t *libnvme_ns_get_eui64(libnvme_ns_t n) { return n->eui64; } -__public const uint8_t *nvme_ns_get_nguid(nvme_ns_t n) +__public const uint8_t *libnvme_ns_get_nguid(libnvme_ns_t n) { return n->nguid; } -__public void nvme_ns_get_uuid(nvme_ns_t n, unsigned char out[NVME_UUID_LEN]) +__public void libnvme_ns_get_uuid(libnvme_ns_t n, unsigned char out[NVME_UUID_LEN]) { memcpy(out, n->uuid, NVME_UUID_LEN); } -__public int nvme_ns_identify(nvme_ns_t n, struct nvme_id_ns *ns) +__public int libnvme_ns_identify(libnvme_ns_t n, struct nvme_id_ns *ns) { struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; @@ -2115,11 +2115,11 @@ __public int nvme_ns_identify(nvme_ns_t n, struct nvme_id_ns *ns) if (err) return err; - nvme_init_identify_ns(&cmd, nvme_ns_get_nsid(n), ns); - return nvme_submit_admin_passthru(hdl, &cmd); + nvme_init_identify_ns(&cmd, libnvme_ns_get_nsid(n), ns); + return libnvme_submit_admin_passthru(hdl, &cmd); } -int nvme_ns_identify_descs(nvme_ns_t n, struct nvme_ns_id_desc *descs) +int libnvme_ns_identify_descs(libnvme_ns_t n, struct nvme_ns_id_desc *descs) { struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; @@ -2129,11 +2129,11 @@ int nvme_ns_identify_descs(nvme_ns_t n, struct nvme_ns_id_desc *descs) if (err) return err; - nvme_init_identify_ns_descs_list(&cmd, nvme_ns_get_nsid(n), descs); - return nvme_submit_admin_passthru(hdl, &cmd); + nvme_init_identify_ns_descs_list(&cmd, libnvme_ns_get_nsid(n), descs); + return libnvme_submit_admin_passthru(hdl, &cmd); } -__public int nvme_ns_verify(nvme_ns_t n, off_t offset, size_t count) +__public int libnvme_ns_verify(libnvme_ns_t n, off_t offset, size_t count) { struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; @@ -2148,13 +2148,13 @@ __public int nvme_ns_verify(nvme_ns_t n, off_t offset, size_t count) if (nvme_bytes_to_lba(n, offset, count, &slba, &nlb)) return -1; - nvme_init_verify(&cmd, nvme_ns_get_nsid(n), slba, nlb, + nvme_init_verify(&cmd, libnvme_ns_get_nsid(n), slba, nlb, 0, 0, NULL, 0, NULL, 0); - return nvme_submit_io_passthru(hdl, &cmd); + return libnvme_submit_io_passthru(hdl, &cmd); } -__public int nvme_ns_write_uncorrectable(nvme_ns_t n, off_t offset, size_t count) +__public int libnvme_ns_write_uncorrectable(libnvme_ns_t n, off_t offset, size_t count) { struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; @@ -2169,13 +2169,13 @@ __public int nvme_ns_write_uncorrectable(nvme_ns_t n, off_t offset, size_t count if (nvme_bytes_to_lba(n, offset, count, &slba, &nlb)) return -1; - nvme_init_write_uncorrectable(&cmd, nvme_ns_get_nsid(n), slba, nlb, + nvme_init_write_uncorrectable(&cmd, libnvme_ns_get_nsid(n), slba, nlb, 0, 0); - return nvme_submit_io_passthru(hdl, &cmd); + return libnvme_submit_io_passthru(hdl, &cmd); } -__public int nvme_ns_write_zeros(nvme_ns_t n, off_t offset, size_t count) +__public int libnvme_ns_write_zeros(libnvme_ns_t n, off_t offset, size_t count) { struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; @@ -2190,12 +2190,12 @@ __public int nvme_ns_write_zeros(nvme_ns_t n, off_t offset, size_t count) if (nvme_bytes_to_lba(n, offset, count, &slba, &nlb)) return -1; - nvme_init_write_zeros(&cmd, nvme_ns_get_nsid(n), slba, nlb, 0, 0, 0, 0); + nvme_init_write_zeros(&cmd, libnvme_ns_get_nsid(n), slba, nlb, 0, 0, 0, 0); - return nvme_submit_io_passthru(hdl, &cmd); + return libnvme_submit_io_passthru(hdl, &cmd); } -__public int nvme_ns_write(nvme_ns_t n, void *buf, off_t offset, size_t count) +__public int libnvme_ns_write(libnvme_ns_t n, void *buf, off_t offset, size_t count) { struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; @@ -2210,13 +2210,13 @@ __public int nvme_ns_write(nvme_ns_t n, void *buf, off_t offset, size_t count) if (nvme_bytes_to_lba(n, offset, count, &slba, &nlb)) return -1; - nvme_init_write(&cmd, nvme_ns_get_nsid(n), slba, nlb, + nvme_init_write(&cmd, libnvme_ns_get_nsid(n), slba, nlb, 0, 0, 0, 0, buf, count, NULL, 0); - return nvme_submit_io_passthru(hdl, &cmd); + return libnvme_submit_io_passthru(hdl, &cmd); } -__public int nvme_ns_read(nvme_ns_t n, void *buf, off_t offset, size_t count) +__public int libnvme_ns_read(libnvme_ns_t n, void *buf, off_t offset, size_t count) { struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; @@ -2231,13 +2231,13 @@ __public int nvme_ns_read(nvme_ns_t n, void *buf, off_t offset, size_t count) if (nvme_bytes_to_lba(n, offset, count, &slba, &nlb)) return -1; - nvme_init_read(&cmd, nvme_ns_get_nsid(n), slba, nlb, + nvme_init_read(&cmd, libnvme_ns_get_nsid(n), slba, nlb, 0, 0, 0, buf, count, NULL, 0); - return nvme_submit_io_passthru(hdl, &cmd); + return libnvme_submit_io_passthru(hdl, &cmd); } -__public int nvme_ns_compare(nvme_ns_t n, void *buf, off_t offset, size_t count) +__public int libnvme_ns_compare(libnvme_ns_t n, void *buf, off_t offset, size_t count) { struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; @@ -2252,13 +2252,13 @@ __public int nvme_ns_compare(nvme_ns_t n, void *buf, off_t offset, size_t count) if (nvme_bytes_to_lba(n, offset, count, &slba, &nlb)) return -1; - nvme_init_compare(&cmd, nvme_ns_get_nsid(n), slba, nlb, + nvme_init_compare(&cmd, libnvme_ns_get_nsid(n), slba, nlb, 0, 0, buf, count, NULL, 0); - return nvme_submit_io_passthru(hdl, &cmd); + return libnvme_submit_io_passthru(hdl, &cmd); } -__public int nvme_ns_flush(nvme_ns_t n) +__public int libnvme_ns_flush(libnvme_ns_t n) { struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; @@ -2268,8 +2268,8 @@ __public int nvme_ns_flush(nvme_ns_t n) if (err) return err; - nvme_init_flush(&cmd, nvme_ns_get_nsid(n)); - return nvme_submit_io_passthru(hdl, &cmd); + nvme_init_flush(&cmd, libnvme_ns_get_nsid(n)); + return libnvme_submit_io_passthru(hdl, &cmd); } static int nvme_strtou64(const char *str, void *res) @@ -2362,7 +2362,7 @@ static int parse_attrs(const char *path, struct sysfs_attr_table *tbl, int size) for (i = 0; i < size; i++) { struct sysfs_attr_table *e = &tbl[i]; - str = nvme_get_attr(path, e->name); + str = libnvme_get_attr(path, e->name); if (!str) { if (!e->mandatory) continue; @@ -2377,7 +2377,7 @@ static int parse_attrs(const char *path, struct sysfs_attr_table *tbl, int size) return 0; } -static int nvme_ns_init(const char *path, struct nvme_ns *ns) +static int nvme_ns_init(const char *path, struct libnvme_ns *ns) { _cleanup_free_ char *attr = NULL; struct stat sb; @@ -2428,7 +2428,7 @@ static int nvme_ns_init(const char *path, struct nvme_ns *ns) if (!id) return -ENOMEM; - ret = nvme_ns_identify(ns, id); + ret = libnvme_ns_identify(ns, id); if (ret) return ret; @@ -2441,7 +2441,7 @@ static int nvme_ns_init(const char *path, struct nvme_ns *ns) return 0; } -static void nvme_ns_set_generic_name(struct nvme_ns *n, const char *name) +static void nvme_ns_set_generic_name(struct libnvme_ns *n, const char *name) { char generic_name[PATH_MAX]; int instance, head_instance; @@ -2456,11 +2456,11 @@ static void nvme_ns_set_generic_name(struct nvme_ns *n, const char *name) } static int nvme_ns_open(struct nvme_global_ctx *ctx, const char *sys_path, - const char *name, nvme_ns_t *ns) + const char *name, libnvme_ns_t *ns) { int ret; - struct nvme_ns *n; - struct nvme_ns_head *head; + struct libnvme_ns *n; + struct libnvme_ns_head *head; struct stat arg; _cleanup_free_ char *path = NULL; @@ -2545,11 +2545,11 @@ static char *nvme_ns_generic_to_blkdev(const char *generic) } static int __nvme_scan_namespace(struct nvme_global_ctx *ctx, - const char *sysfs_dir, const char *name, nvme_ns_t *ns) + const char *sysfs_dir, const char *name, libnvme_ns_t *ns) { _cleanup_free_ char *blkdev = NULL; _cleanup_free_ char *path = NULL; - struct nvme_ns *n = NULL; + struct libnvme_ns *n = NULL; int ret; blkdev = nvme_ns_generic_to_blkdev(name); @@ -2571,21 +2571,21 @@ static int __nvme_scan_namespace(struct nvme_global_ctx *ctx, return 0; } -__public int nvme_scan_namespace(struct nvme_global_ctx *ctx, const char *name, - nvme_ns_t *ns) +__public int libnvme_scan_namespace(struct nvme_global_ctx *ctx, const char *name, + libnvme_ns_t *ns) { return __nvme_scan_namespace(ctx, nvme_ns_sysfs_dir(), name, ns); } -static void nvme_ns_head_scan_path(nvme_subsystem_t s, nvme_ns_t n, char *name) +static void nvme_ns_head_scan_path(libnvme_subsystem_t s, libnvme_ns_t n, char *name) { - nvme_ctrl_t c; - nvme_path_t p; + libnvme_ctrl_t c; + libnvme_path_t p; - nvme_subsystem_for_each_ctrl(s, c) { - nvme_ctrl_for_each_path(c, p) { - if (!strcmp(nvme_path_get_name(p), name)) { + libnvme_subsystem_for_each_ctrl(s, c) { + libnvme_ctrl_for_each_path(c, p) { + if (!strcmp(libnvme_path_get_name(p), name)) { list_add_tail(&n->head->paths, &p->nentry); p->n = n; return; @@ -2594,11 +2594,11 @@ static void nvme_ns_head_scan_path(nvme_subsystem_t s, nvme_ns_t n, char *name) } } -static void nvme_subsystem_set_ns_path(nvme_subsystem_t s, nvme_ns_t n) +static void nvme_subsystem_set_ns_path(libnvme_subsystem_t s, libnvme_ns_t n) { - struct nvme_ns_head *head = n->head; + struct libnvme_ns_head *head = n->head; - if (nvme_ns_head_get_sysfs_dir(head)) { + if (libnvme_ns_head_get_sysfs_dir(head)) { struct dirents paths = {}; int i; @@ -2606,29 +2606,29 @@ static void nvme_subsystem_set_ns_path(nvme_subsystem_t s, nvme_ns_t n) * When multipath is configured on kernel version >= 6.15, * we use multipath sysfs link to get each path of a namespace. */ - paths.num = nvme_scan_ns_head_paths(head, &paths.ents); + paths.num = libnvme_scan_ns_head_paths(head, &paths.ents); for (i = 0; i < paths.num; i++) nvme_ns_head_scan_path(s, n, paths.ents[i]->d_name); } else { - nvme_ctrl_t c; - nvme_path_t p; + libnvme_ctrl_t c; + libnvme_path_t p; int ns_ctrl, ns_nsid, ret; /* * If multipath is not configured or we're running on kernel * version < 6.15, fallback to the old way. */ - ret = sscanf(nvme_ns_get_name(n), "nvme%dn%d", + ret = sscanf(libnvme_ns_get_name(n), "nvme%dn%d", &ns_ctrl, &ns_nsid); if (ret != 2) return; - nvme_subsystem_for_each_ctrl(s, c) { - nvme_ctrl_for_each_path(c, p) { + libnvme_subsystem_for_each_ctrl(s, c) { + libnvme_ctrl_for_each_path(c, p) { int p_subsys, p_ctrl, p_nsid; - ret = sscanf(nvme_path_get_name(p), + ret = sscanf(libnvme_path_get_name(p), "nvme%dc%dn%d", &p_subsys, &p_ctrl, &p_nsid); if (ret != 3) @@ -2642,10 +2642,10 @@ static void nvme_subsystem_set_ns_path(nvme_subsystem_t s, nvme_ns_t n) } } -static int nvme_ctrl_scan_namespace(struct nvme_global_ctx *ctx, struct nvme_ctrl *c, +static int nvme_ctrl_scan_namespace(struct nvme_global_ctx *ctx, struct libnvme_ctrl *c, char *name) { - struct nvme_ns *n, *_n, *__n; + struct libnvme_ns *n, *_n, *__n; int ret; nvme_msg(ctx, LOG_DEBUG, "scan controller %s namespace %s\n", @@ -2659,7 +2659,7 @@ static int nvme_ctrl_scan_namespace(struct nvme_global_ctx *ctx, struct nvme_ctr nvme_msg(ctx, LOG_DEBUG, "failed to scan namespace %s\n", name); return ret; } - nvme_ctrl_for_each_ns_safe(c, _n, __n) { + libnvme_ctrl_for_each_ns_safe(c, _n, __n) { if (strcmp(n->name, _n->name)) continue; __nvme_free_ns(_n); @@ -2672,10 +2672,10 @@ static int nvme_ctrl_scan_namespace(struct nvme_global_ctx *ctx, struct nvme_ctr return 0; } -static int nvme_subsystem_scan_namespace(struct nvme_global_ctx *ctx, nvme_subsystem_t s, +static int nvme_subsystem_scan_namespace(struct nvme_global_ctx *ctx, libnvme_subsystem_t s, char *name) { - struct nvme_ns *n, *_n, *__n; + struct libnvme_ns *n, *_n, *__n; int ret; nvme_msg(ctx, LOG_DEBUG, "scan subsystem %s namespace %s\n", @@ -2685,7 +2685,7 @@ static int nvme_subsystem_scan_namespace(struct nvme_global_ctx *ctx, nvme_subsy nvme_msg(ctx, LOG_DEBUG, "failed to scan namespace %s\n", name); return ret; } - nvme_subsystem_for_each_ns_safe(s, _n, __n) { + libnvme_subsystem_for_each_ns_safe(s, _n, __n) { if (strcmp(n->name, _n->name)) continue; __nvme_free_ns(_n); @@ -2696,13 +2696,13 @@ static int nvme_subsystem_scan_namespace(struct nvme_global_ctx *ctx, nvme_subsy return 0; } -__public struct nvme_ns *nvme_subsystem_lookup_namespace(struct nvme_subsystem *s, +__public struct libnvme_ns *libnvme_subsystem_lookup_namespace(struct libnvme_subsystem *s, __u32 nsid) { - struct nvme_ns *n; + struct libnvme_ns *n; - nvme_subsystem_for_each_ns(s, n) { - if (nvme_ns_get_nsid(n) == nsid) + libnvme_subsystem_for_each_ns(s, n) { + if (libnvme_ns_get_nsid(n) == nsid) return n; } return NULL; diff --git a/libnvme/src/nvme/tree.h b/libnvme/src/nvme/tree.h index 07b75677cd..2ec4fd35e5 100644 --- a/libnvme/src/nvme/tree.h +++ b/libnvme/src/nvme/tree.h @@ -20,43 +20,43 @@ * libnvme tree object interface */ -typedef struct nvme_ns *nvme_ns_t; -typedef struct nvme_ns_head *nvme_ns_head_t; -typedef struct nvme_path *nvme_path_t; -typedef struct nvme_ctrl *nvme_ctrl_t; -typedef struct nvme_subsystem *nvme_subsystem_t; -typedef struct nvme_host *nvme_host_t; +typedef struct libnvme_ns *libnvme_ns_t; +typedef struct libnvme_ns_head *libnvme_ns_head_t; +typedef struct libnvme_path *libnvme_path_t; +typedef struct libnvme_ctrl *libnvme_ctrl_t; +typedef struct libnvme_subsystem *libnvme_subsystem_t; +typedef struct libnvme_host *libnvme_host_t; -typedef bool (*nvme_scan_filter_t)(nvme_subsystem_t, nvme_ctrl_t, - nvme_ns_t, void *); +typedef bool (*libnvme_scan_filter_t)(libnvme_subsystem_t, libnvme_ctrl_t, + libnvme_ns_t, void *); /** - * nvme_set_application - Specify managing application + * libnvme_set_application - Specify managing application * @ctx: struct nvme_global_ctx object * @a: Application string * * Sets the managing application string for @r. */ -void nvme_set_application(struct nvme_global_ctx *ctx, const char *a); +void libnvme_set_application(struct nvme_global_ctx *ctx, const char *a); /** - * nvme_get_application - Get managing application + * libnvme_get_application - Get managing application * @ctx: struct nvme_global_ctx object * * Returns the managing application string for @r or NULL if not set. */ -const char *nvme_get_application(struct nvme_global_ctx *ctx); +const char *libnvme_get_application(struct nvme_global_ctx *ctx); /** - * nvme_skip_namespaces - Skip namespace scanning + * libnvme_skip_namespaces - Skip namespace scanning * @ctx: struct nvme_global_ctx object * * Sets a flag to skip namespaces during scanning. */ -void nvme_skip_namespaces(struct nvme_global_ctx *ctx); +void libnvme_skip_namespaces(struct nvme_global_ctx *ctx); /** - * nvme_release_fds - Close all opened file descriptors in the tree + * libnvme_release_fds - Close all opened file descriptors in the tree * @ctx: struct nvme_global_ctx object * * Controller and Namespace objects cache the file descriptors @@ -64,72 +64,72 @@ void nvme_skip_namespaces(struct nvme_global_ctx *ctx); * clear all cached fds in the tree. * */ -void nvme_release_fds(struct nvme_global_ctx *ctx); +void libnvme_release_fds(struct nvme_global_ctx *ctx); /** - * nvme_first_host() - Start host iterator + * libnvme_first_host() - Start host iterator * @ctx: struct nvme_global_ctx object * - * Return: First &nvme_host_t object in an iterator + * Return: First &libnvme_host_t object in an iterator */ -nvme_host_t nvme_first_host(struct nvme_global_ctx *ctx); +libnvme_host_t libnvme_first_host(struct nvme_global_ctx *ctx); /** - * nvme_next_host() - Next host iterator + * libnvme_next_host() - Next host iterator * @ctx: struct nvme_global_ctx object - * @h: Previous &nvme_host_t iterator + * @h: Previous &libnvme_host_t iterator * - * Return: Next &nvme_host_t object in an iterator + * Return: Next &libnvme_host_t object in an iterator */ -nvme_host_t nvme_next_host(struct nvme_global_ctx *ctx, nvme_host_t h); +libnvme_host_t libnvme_next_host(struct nvme_global_ctx *ctx, libnvme_host_t h); /** - * nvme_host_get_global_ctx() - Returns nvme_global_ctx object - * @h: &nvme_host_t object + * libnvme_host_get_global_ctx() - Returns nvme_global_ctx object + * @h: &libnvme_host_t object * * Return: &struct nvme_global_ctx object from @h */ -struct nvme_global_ctx *nvme_host_get_global_ctx(nvme_host_t h); +struct nvme_global_ctx *libnvme_host_get_global_ctx(libnvme_host_t h); /** - * nvme_host_set_pdc_enabled() - Set Persistent Discovery Controller flag + * libnvme_host_set_pdc_enabled() - Set Persistent Discovery Controller flag * @h: Host for which the falg should be set * @enabled: The bool to set the enabled flag * - * When nvme_host_set_pdc_enabled() is not used to set the PDC flag, - * nvme_host_is_pdc_enabled() will return the default value which was + * When libnvme_host_set_pdc_enabled() is not used to set the PDC flag, + * libnvme_host_is_pdc_enabled() will return the default value which was * passed into the function and not the undefined flag value. */ -void nvme_host_set_pdc_enabled(nvme_host_t h, bool enabled); +void libnvme_host_set_pdc_enabled(libnvme_host_t h, bool enabled); /** - * nvme_host_is_pdc_enabled() - Is Persistenct Discovery Controller enabled + * libnvme_host_is_pdc_enabled() - Is Persistenct Discovery Controller enabled * @h: Host which to check if PDC is enabled * @fallback: The fallback default value of the flag when - * @nvme_host_set_pdc_enabled has not be used + * @libnvme_host_set_pdc_enabled has not be used * to set the flag. * * Return: true if PDC is enabled for @h, else false */ -bool nvme_host_is_pdc_enabled(nvme_host_t h, bool fallback); +bool libnvme_host_is_pdc_enabled(libnvme_host_t h, bool fallback); /** - * nvme_get_host() - Returns a host object + * libnvme_get_host() - Returns a host object * @ctx: struct nvme_global_ctx object * @hostnqn: Host NQN (optional) * @hostid: Host ID (optional) - * @h: &nvme_host_t object to return + * @h: &libnvme_host_t object to return * * Returns a host object based on the hostnqn/hostid values or the default if * hostnqn/hostid are NULL. * * Return: 0 on success or negative error code otherwise */ -int nvme_get_host(struct nvme_global_ctx *ctx, const char *hostnqn, - const char *hostid, nvme_host_t *h); +int libnvme_get_host(struct nvme_global_ctx *ctx, const char *hostnqn, + const char *hostid, libnvme_host_t *h); /** - * nvme_host_get_ids - Retrieve host ids from various sources + * libnvme_host_get_ids - Retrieve host ids from various sources * * @ctx: struct nvme_global_ctx object * @hostnqn_arg: Input hostnqn (command line) argument @@ -137,7 +137,7 @@ int nvme_get_host(struct nvme_global_ctx *ctx, const char *hostnqn, * @hostnqn: Output hostnqn * @hostid: Output hostid * - * nvme_host_get_ids figures out which hostnqn/hostid is to be used. + * libnvme_host_get_ids figures out which hostnqn/hostid is to be used. * There are several sources where this information can be retrieved. * * The order is: @@ -159,129 +159,129 @@ int nvme_get_host(struct nvme_global_ctx *ctx, const char *hostnqn, * Return: 0 on success (@hostnqn and @hostid contain valid strings * which the caller needs to free), or negative error code otherwise. */ -int nvme_host_get_ids(struct nvme_global_ctx *ctx, +int libnvme_host_get_ids(struct nvme_global_ctx *ctx, const char *hostnqn_arg, const char *hostid_arg, char **hostnqn, char **hostid); /** - * nvme_first_subsystem() - Start subsystem iterator - * @h: &nvme_host_t object + * libnvme_first_subsystem() - Start subsystem iterator + * @h: &libnvme_host_t object * - * Return: first &nvme_subsystem_t object in an iterator + * Return: first &libnvme_subsystem_t object in an iterator */ -nvme_subsystem_t nvme_first_subsystem(nvme_host_t h); +libnvme_subsystem_t libnvme_first_subsystem(libnvme_host_t h); /** - * nvme_next_subsystem() - Next subsystem iterator - * @h: &nvme_host_t object - * @s: Previous &nvme_subsystem_t iterator + * libnvme_next_subsystem() - Next subsystem iterator + * @h: &libnvme_host_t object + * @s: Previous &libnvme_subsystem_t iterator * - * Return: next &nvme_subsystem_t object in an iterator + * Return: next &libnvme_subsystem_t object in an iterator */ -nvme_subsystem_t nvme_next_subsystem(nvme_host_t h, nvme_subsystem_t s); +libnvme_subsystem_t libnvme_next_subsystem(libnvme_host_t h, libnvme_subsystem_t s); /** - * nvme_get_subsystem() - Returns nvme_subsystem_t object + * libnvme_get_subsystem() - Returns libnvme_subsystem_t object * @ctx: struct nvme_global_ctx object - * @h: &nvme_host_t object + * @h: &libnvme_host_t object * @name: Name of the subsystem (may be NULL) * @subsysnqn: Subsystem NQN - * @s: nvme_subsystem_t object + * @s: libnvme_subsystem_t object * - * Returns an &nvme_subsystem_t object in @h base on @name (if present) + * Returns an &libnvme_subsystem_t object in @h base on @name (if present) * and @subsysnqn or create one if not found. * */ -int nvme_get_subsystem(struct nvme_global_ctx *ctx, - struct nvme_host *h, const char *name, - const char *subsysnqn, struct nvme_subsystem **s); +int libnvme_get_subsystem(struct nvme_global_ctx *ctx, + struct libnvme_host *h, const char *name, + const char *subsysnqn, struct libnvme_subsystem **s); /** - * nvme_free_subsystem() - Free a subsystem + * libnvme_free_subsystem() - Free a subsystem * @s: subsystem * * Frees @s and all related objects. */ -void nvme_free_subsystem(struct nvme_subsystem *s); +void libnvme_free_subsystem(struct libnvme_subsystem *s); /** - * nvme_subsystem_get_host() - Returns nvme_host_t object + * libnvme_subsystem_get_host() - Returns libnvme_host_t object * @s: subsystem * - * Return: &nvme_host_t object from @s + * Return: &libnvme_host_t object from @s */ -nvme_host_t nvme_subsystem_get_host(nvme_subsystem_t s); +libnvme_host_t libnvme_subsystem_get_host(libnvme_subsystem_t s); /** - * nvme_ctrl_first_ns() - Start namespace iterator + * libnvme_ctrl_first_ns() - Start namespace iterator * @c: Controller instance * - * Return: First &nvme_ns_t object of an @c iterator + * Return: First &libnvme_ns_t object of an @c iterator */ -nvme_ns_t nvme_ctrl_first_ns(nvme_ctrl_t c); +libnvme_ns_t libnvme_ctrl_first_ns(libnvme_ctrl_t c); /** - * nvme_ctrl_next_ns() - Next namespace iterator + * libnvme_ctrl_next_ns() - Next namespace iterator * @c: Controller instance - * @n: Previous nvme_ns_t iterator + * @n: Previous libnvme_ns_t iterator * - * Return: Next nvme_ns_t object of an @c iterator + * Return: Next libnvme_ns_t object of an @c iterator */ -nvme_ns_t nvme_ctrl_next_ns(nvme_ctrl_t c, nvme_ns_t n); +libnvme_ns_t libnvme_ctrl_next_ns(libnvme_ctrl_t c, libnvme_ns_t n); /** - * nvme_ctrl_first_path() - Start path iterator + * libnvme_ctrl_first_path() - Start path iterator * @c: Controller instance * - * Return: First &nvme_path_t object of an @c iterator + * Return: First &libnvme_path_t object of an @c iterator */ -nvme_path_t nvme_ctrl_first_path(nvme_ctrl_t c); +libnvme_path_t libnvme_ctrl_first_path(libnvme_ctrl_t c); /** - * nvme_ctrl_next_path() - Next path iterator + * libnvme_ctrl_next_path() - Next path iterator * @c: Controller instance - * @p: Previous &nvme_path_t object of an @c iterator + * @p: Previous &libnvme_path_t object of an @c iterator * - * Return: Next &nvme_path_t object of an @c iterator + * Return: Next &libnvme_path_t object of an @c iterator */ -nvme_path_t nvme_ctrl_next_path(nvme_ctrl_t c, nvme_path_t p); +libnvme_path_t libnvme_ctrl_next_path(libnvme_ctrl_t c, libnvme_path_t p); /** - * nvme_subsystem_first_ctrl() - First ctrl iterator - * @s: &nvme_subsystem_t object + * libnvme_subsystem_first_ctrl() - First ctrl iterator + * @s: &libnvme_subsystem_t object * * Return: First controller of an @s iterator */ -nvme_ctrl_t nvme_subsystem_first_ctrl(nvme_subsystem_t s); +libnvme_ctrl_t libnvme_subsystem_first_ctrl(libnvme_subsystem_t s); /** - * nvme_subsystem_next_ctrl() - Next ctrl iterator - * @s: &nvme_subsystem_t object + * libnvme_subsystem_next_ctrl() - Next ctrl iterator + * @s: &libnvme_subsystem_t object * @c: Previous controller instance of an @s iterator * * Return: Next controller of an @s iterator */ -nvme_ctrl_t nvme_subsystem_next_ctrl(nvme_subsystem_t s, nvme_ctrl_t c); +libnvme_ctrl_t libnvme_subsystem_next_ctrl(libnvme_subsystem_t s, libnvme_ctrl_t c); /** - * nvme_namespace_first_path() - Start path iterator + * libnvme_namespace_first_path() - Start path iterator * @ns: Namespace instance * - * Return: First &nvme_path_t object of an @ns iterator + * Return: First &libnvme_path_t object of an @ns iterator */ -nvme_path_t nvme_namespace_first_path(nvme_ns_t ns); +libnvme_path_t libnvme_namespace_first_path(libnvme_ns_t ns); /** - * nvme_namespace_next_path() - Next path iterator + * libnvme_namespace_next_path() - Next path iterator * @ns: Namespace instance - * @p: Previous &nvme_path_t object of an @ns iterator + * @p: Previous &libnvme_path_t object of an @ns iterator * - * Return: Next &nvme_path_t object of an @ns iterator + * Return: Next &libnvme_path_t object of an @ns iterator */ -nvme_path_t nvme_namespace_next_path(nvme_ns_t ns, nvme_path_t p); +libnvme_path_t libnvme_namespace_next_path(libnvme_ns_t ns, libnvme_path_t p); /** - * nvme_ctrl_match_config() - Check if ctrl @c matches config params + * libnvme_ctrl_match_config() - Check if ctrl @c matches config params * @c: An existing controller instance * @transport: Transport name * @traddr: Transport address @@ -296,13 +296,13 @@ nvme_path_t nvme_namespace_next_path(nvme_ns_t ns, nvme_path_t p); * * Return: true if there's a match, false otherwise. */ -bool nvme_ctrl_match_config(struct nvme_ctrl *c, const char *transport, +bool libnvme_ctrl_match_config(struct libnvme_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 + * libnvme_create_ctrl() - Allocate an unconnected NVMe controller * @ctx: struct nvme_global_ctx object * @subsysnqn: Subsystem NQN * @transport: Transport type @@ -310,274 +310,274 @@ bool nvme_ctrl_match_config(struct nvme_ctrl *c, const char *transport, * @host_traddr: Host transport address * @host_iface: Host interface name * @trsvcid: Transport service ID - * @c: @nvme_ctrl_t object to return + * @c: @libnvme_ctrl_t object to return * - * Creates an unconnected controller to be used for nvme_add_ctrl(). + * Creates an unconnected controller to be used for libnvme_add_ctrl(). * * Return: 0 on success or negative error code otherwise */ -int nvme_create_ctrl(struct nvme_global_ctx *ctx, +int libnvme_create_ctrl(struct nvme_global_ctx *ctx, const char *subsysnqn, const char *transport, const char *traddr, const char *host_traddr, const char *host_iface, const char *trsvcid, - nvme_ctrl_t *c); + libnvme_ctrl_t *c); /** - * nvme_subsystem_first_ns() - Start namespace iterator - * @s: &nvme_subsystem_t object + * libnvme_subsystem_first_ns() - Start namespace iterator + * @s: &libnvme_subsystem_t object * - * Return: First &nvme_ns_t object of an @s iterator + * Return: First &libnvme_ns_t object of an @s iterator */ -nvme_ns_t nvme_subsystem_first_ns(nvme_subsystem_t s); +libnvme_ns_t libnvme_subsystem_first_ns(libnvme_subsystem_t s); /** - * nvme_subsystem_next_ns() - Next namespace iterator - * @s: &nvme_subsystem_t object - * @n: Previous &nvme_ns_t iterator + * libnvme_subsystem_next_ns() - Next namespace iterator + * @s: &libnvme_subsystem_t object + * @n: Previous &libnvme_ns_t iterator * - * Return: Next &nvme_ns_t object of an @s iterator + * Return: Next &libnvme_ns_t object of an @s iterator */ -nvme_ns_t nvme_subsystem_next_ns(nvme_subsystem_t s, nvme_ns_t n); +libnvme_ns_t libnvme_subsystem_next_ns(libnvme_subsystem_t s, libnvme_ns_t n); /** - * nvme_for_each_host_safe() - Traverse host list + * libnvme_for_each_host_safe() - Traverse host list * @r: &nvme_root_t object - * @h: &nvme_host_t object - * @_h: Temporary &nvme_host_t object + * @h: &libnvme_host_t object + * @_h: Temporary &libnvme_host_t object */ -#define nvme_for_each_host_safe(r, h, _h) \ - for (h = nvme_first_host(r), \ - _h = nvme_next_host(r, h); \ +#define libnvme_for_each_host_safe(r, h, _h) \ + for (h = libnvme_first_host(r), \ + _h = libnvme_next_host(r, h); \ h != NULL; \ - h = _h, _h = nvme_next_host(r, h)) + h = _h, _h = libnvme_next_host(r, h)) /** - * nvme_for_each_host() - Traverse host list + * libnvme_for_each_host() - Traverse host list * @r: &nvme_root_t object - * @h: &nvme_host_t object + * @h: &libnvme_host_t object */ -#define nvme_for_each_host(r, h) \ - for (h = nvme_first_host(r); h != NULL; \ - h = nvme_next_host(r, h)) +#define libnvme_for_each_host(r, h) \ + for (h = libnvme_first_host(r); h != NULL; \ + h = libnvme_next_host(r, h)) /** - * nvme_for_each_subsystem_safe() - Traverse subsystems - * @h: &nvme_host_t object - * @s: &nvme_subsystem_t object - * @_s: Temporary &nvme_subsystem_t object + * libnvme_for_each_subsystem_safe() - Traverse subsystems + * @h: &libnvme_host_t object + * @s: &libnvme_subsystem_t object + * @_s: Temporary &libnvme_subsystem_t object */ -#define nvme_for_each_subsystem_safe(h, s, _s) \ - for (s = nvme_first_subsystem(h), \ - _s = nvme_next_subsystem(h, s); \ +#define libnvme_for_each_subsystem_safe(h, s, _s) \ + for (s = libnvme_first_subsystem(h), \ + _s = libnvme_next_subsystem(h, s); \ s != NULL; \ - s = _s, _s = nvme_next_subsystem(h, s)) + s = _s, _s = libnvme_next_subsystem(h, s)) /** - * nvme_for_each_subsystem() - Traverse subsystems - * @h: &nvme_host_t object - * @s: &nvme_subsystem_t object + * libnvme_for_each_subsystem() - Traverse subsystems + * @h: &libnvme_host_t object + * @s: &libnvme_subsystem_t object */ -#define nvme_for_each_subsystem(h, s) \ - for (s = nvme_first_subsystem(h); s != NULL; \ - s = nvme_next_subsystem(h, s)) +#define libnvme_for_each_subsystem(h, s) \ + for (s = libnvme_first_subsystem(h); s != NULL; \ + s = libnvme_next_subsystem(h, s)) /** - * nvme_subsystem_for_each_ctrl_safe() - Traverse controllers - * @s: &nvme_subsystem_t object + * libnvme_subsystem_for_each_ctrl_safe() - Traverse controllers + * @s: &libnvme_subsystem_t object * @c: Controller instance * @_c: A &nvme_ctrl_t_node to use as temporary storage */ -#define nvme_subsystem_for_each_ctrl_safe(s, c, _c) \ - for (c = nvme_subsystem_first_ctrl(s), \ - _c = nvme_subsystem_next_ctrl(s, c); \ +#define libnvme_subsystem_for_each_ctrl_safe(s, c, _c) \ + for (c = libnvme_subsystem_first_ctrl(s), \ + _c = libnvme_subsystem_next_ctrl(s, c); \ c != NULL; \ - c = _c, _c = nvme_subsystem_next_ctrl(s, c)) + c = _c, _c = libnvme_subsystem_next_ctrl(s, c)) /** - * nvme_subsystem_for_each_ctrl() - Traverse controllers - * @s: &nvme_subsystem_t object + * libnvme_subsystem_for_each_ctrl() - Traverse controllers + * @s: &libnvme_subsystem_t object * @c: Controller instance */ -#define nvme_subsystem_for_each_ctrl(s, c) \ - for (c = nvme_subsystem_first_ctrl(s); c != NULL; \ - c = nvme_subsystem_next_ctrl(s, c)) +#define libnvme_subsystem_for_each_ctrl(s, c) \ + for (c = libnvme_subsystem_first_ctrl(s); c != NULL; \ + c = libnvme_subsystem_next_ctrl(s, c)) /** - * nvme_ctrl_for_each_ns_safe() - Traverse namespaces + * libnvme_ctrl_for_each_ns_safe() - Traverse namespaces * @c: Controller instance - * @n: &nvme_ns_t object + * @n: &libnvme_ns_t object * @_n: A &nvme_ns_t_node to use as temporary storage */ -#define nvme_ctrl_for_each_ns_safe(c, n, _n) \ - for (n = nvme_ctrl_first_ns(c), \ - _n = nvme_ctrl_next_ns(c, n); \ +#define libnvme_ctrl_for_each_ns_safe(c, n, _n) \ + for (n = libnvme_ctrl_first_ns(c), \ + _n = libnvme_ctrl_next_ns(c, n); \ n != NULL; \ - n = _n, _n = nvme_ctrl_next_ns(c, n)) + n = _n, _n = libnvme_ctrl_next_ns(c, n)) /** - * nvme_ctrl_for_each_ns() - Traverse namespaces + * libnvme_ctrl_for_each_ns() - Traverse namespaces * @c: Controller instance - * @n: &nvme_ns_t object + * @n: &libnvme_ns_t object */ -#define nvme_ctrl_for_each_ns(c, n) \ - for (n = nvme_ctrl_first_ns(c); n != NULL; \ - n = nvme_ctrl_next_ns(c, n)) +#define libnvme_ctrl_for_each_ns(c, n) \ + for (n = libnvme_ctrl_first_ns(c); n != NULL; \ + n = libnvme_ctrl_next_ns(c, n)) /** - * nvme_ctrl_for_each_path_safe() - Traverse paths + * libnvme_ctrl_for_each_path_safe() - Traverse paths * @c: Controller instance - * @p: &nvme_path_t object + * @p: &libnvme_path_t object * @_p: A &nvme_path_t_node to use as temporary storage */ -#define nvme_ctrl_for_each_path_safe(c, p, _p) \ - for (p = nvme_ctrl_first_path(c), \ - _p = nvme_ctrl_next_path(c, p); \ +#define libnvme_ctrl_for_each_path_safe(c, p, _p) \ + for (p = libnvme_ctrl_first_path(c), \ + _p = libnvme_ctrl_next_path(c, p); \ p != NULL; \ - p = _p, _p = nvme_ctrl_next_path(c, p)) + p = _p, _p = libnvme_ctrl_next_path(c, p)) /** - * nvme_ctrl_for_each_path() - Traverse paths + * libnvme_ctrl_for_each_path() - Traverse paths * @c: Controller instance - * @p: &nvme_path_t object + * @p: &libnvme_path_t object */ -#define nvme_ctrl_for_each_path(c, p) \ - for (p = nvme_ctrl_first_path(c); p != NULL; \ - p = nvme_ctrl_next_path(c, p)) +#define libnvme_ctrl_for_each_path(c, p) \ + for (p = libnvme_ctrl_first_path(c); p != NULL; \ + p = libnvme_ctrl_next_path(c, p)) /** - * nvme_subsystem_for_each_ns_safe() - Traverse namespaces - * @s: &nvme_subsystem_t object - * @n: &nvme_ns_t object + * libnvme_subsystem_for_each_ns_safe() - Traverse namespaces + * @s: &libnvme_subsystem_t object + * @n: &libnvme_ns_t object * @_n: A &nvme_ns_t_node to use as temporary storage */ -#define nvme_subsystem_for_each_ns_safe(s, n, _n) \ - for (n = nvme_subsystem_first_ns(s), \ - _n = nvme_subsystem_next_ns(s, n); \ +#define libnvme_subsystem_for_each_ns_safe(s, n, _n) \ + for (n = libnvme_subsystem_first_ns(s), \ + _n = libnvme_subsystem_next_ns(s, n); \ n != NULL; \ - n = _n, _n = nvme_subsystem_next_ns(s, n)) + n = _n, _n = libnvme_subsystem_next_ns(s, n)) /** - * nvme_subsystem_for_each_ns() - Traverse namespaces - * @s: &nvme_subsystem_t object - * @n: &nvme_ns_t object + * libnvme_subsystem_for_each_ns() - Traverse namespaces + * @s: &libnvme_subsystem_t object + * @n: &libnvme_ns_t object */ -#define nvme_subsystem_for_each_ns(s, n) \ - for (n = nvme_subsystem_first_ns(s); n != NULL; \ - n = nvme_subsystem_next_ns(s, n)) +#define libnvme_subsystem_for_each_ns(s, n) \ + for (n = libnvme_subsystem_first_ns(s); n != NULL; \ + n = libnvme_subsystem_next_ns(s, n)) /** - * nvme_namespace_for_each_path_safe() - Traverse paths + * libnvme_namespace_for_each_path_safe() - Traverse paths * @n: Namespace instance - * @p: &nvme_path_t object + * @p: &libnvme_path_t object * @_p: A &nvme_path_t_node to use as temporary storage */ -#define nvme_namespace_for_each_path_safe(n, p, _p) \ - for (p = nvme_namespace_first_path(n), \ - _p = nvme_namespace_next_path(n, p); \ +#define libnvme_namespace_for_each_path_safe(n, p, _p) \ + for (p = libnvme_namespace_first_path(n), \ + _p = libnvme_namespace_next_path(n, p); \ p != NULL; \ - p = _p, _p = nvme_namespace_next_path(n, p)) + p = _p, _p = libnvme_namespace_next_path(n, p)) /** - * nvme_namespace_for_each_path() - Traverse paths + * libnvme_namespace_for_each_path() - Traverse paths * @n: Namespace instance - * @p: &nvme_path_t object + * @p: &libnvme_path_t object */ -#define nvme_namespace_for_each_path(n, p) \ - for (p = nvme_namespace_first_path(n); p != NULL; \ - p = nvme_namespace_next_path(n, p)) +#define libnvme_namespace_for_each_path(n, p) \ + for (p = libnvme_namespace_first_path(n); p != NULL; \ + p = libnvme_namespace_next_path(n, p)) /** - * nvme_ns_get_csi() - Command set identifier of a namespace + * libnvme_ns_get_csi() - Command set identifier of a namespace * @n: Namespace instance * * Return: The namespace's command set identifier in use */ -enum nvme_csi nvme_ns_get_csi(nvme_ns_t n); +enum nvme_csi libnvme_ns_get_csi(libnvme_ns_t n); /** - * nvme_ns_get_eui64() - 64-bit eui of a namespace + * libnvme_ns_get_eui64() - 64-bit eui of a namespace * @n: Namespace instance * * Return: A pointer to the 64-bit eui */ -const uint8_t *nvme_ns_get_eui64(nvme_ns_t n); +const uint8_t *libnvme_ns_get_eui64(libnvme_ns_t n); /** - * nvme_ns_get_nguid() - 128-bit nguid of a namespace + * libnvme_ns_get_nguid() - 128-bit nguid of a namespace * @n: Namespace instance * * Return: A pointer to the 128-bit nguid */ -const uint8_t *nvme_ns_get_nguid(nvme_ns_t n); +const uint8_t *libnvme_ns_get_nguid(libnvme_ns_t n); /** - * nvme_ns_get_uuid() - UUID of a namespace + * libnvme_ns_get_uuid() - UUID of a namespace * @n: Namespace instance * @out: buffer for the UUID * * Copies the namespace's uuid into @out */ -void nvme_ns_get_uuid(nvme_ns_t n, unsigned char out[NVME_UUID_LEN]); +void libnvme_ns_get_uuid(libnvme_ns_t n, unsigned char out[NVME_UUID_LEN]); /** - * nvme_ns_get_generic_name() - Returns name of generic namespace chardev. + * libnvme_ns_get_generic_name() - Returns name of generic namespace chardev. * @n: Namespace instance * * Return: Name of generic namespace chardev */ -const char *nvme_ns_get_generic_name(nvme_ns_t n); +const char *libnvme_ns_get_generic_name(libnvme_ns_t n); /** - * nvme_ns_get_firmware() - Firmware string of a namespace + * libnvme_ns_get_firmware() - Firmware string of a namespace * @n: Namespace instance * * Return: Firmware string of @n */ -const char *nvme_ns_get_firmware(nvme_ns_t n); +const char *libnvme_ns_get_firmware(libnvme_ns_t n); /** - * nvme_ns_get_serial() - Serial number of a namespace + * libnvme_ns_get_serial() - Serial number of a namespace * @n: Namespace instance * * Return: Serial number string of @n */ -const char *nvme_ns_get_serial(nvme_ns_t n); +const char *libnvme_ns_get_serial(libnvme_ns_t n); /** - * nvme_ns_get_model() - Model of a namespace + * libnvme_ns_get_model() - Model of a namespace * @n: Namespace instance * * Return: Model string of @n */ -const char *nvme_ns_get_model(nvme_ns_t n); +const char *libnvme_ns_get_model(libnvme_ns_t n); /** - * nvme_ns_get_subsystem() - &nvme_subsystem_t of a namespace + * libnvme_ns_get_subsystem() - &libnvme_subsystem_t of a namespace * @n: Namespace instance * - * Return: nvme_subsystem_t object of @n + * Return: libnvme_subsystem_t object of @n */ -nvme_subsystem_t nvme_ns_get_subsystem(nvme_ns_t n); +libnvme_subsystem_t libnvme_ns_get_subsystem(libnvme_ns_t n); /** - * nvme_ns_get_ctrl() - &nvme_ctrl_t of a namespace + * libnvme_ns_get_ctrl() - &libnvme_ctrl_t of a namespace * @n: Namespace instance * - * nvme_ctrl_t object may be NULL for a multipathed namespace + * libnvme_ctrl_t object may be NULL for a multipathed namespace * - * Return: nvme_ctrl_t object of @n if present + * Return: libnvme_ctrl_t object of @n if present */ -nvme_ctrl_t nvme_ns_get_ctrl(nvme_ns_t n); +libnvme_ctrl_t libnvme_ns_get_ctrl(libnvme_ns_t n); /** - * nvme_free_ns() - Free a namespace object + * libnvme_free_ns() - Free a namespace object * @n: Namespace instance */ -void nvme_free_ns(struct nvme_ns *n); +void libnvme_free_ns(struct libnvme_ns *n); /** - * nvme_ns_read() - Read from a namespace + * libnvme_ns_read() - Read from a namespace * @n: Namespace instance * @buf: Buffer into which the data will be transferred * @offset: LBA offset of @n @@ -585,10 +585,10 @@ void nvme_free_ns(struct nvme_ns *n); * * Return: Number of sectors read or -1 on error. */ -int nvme_ns_read(nvme_ns_t n, void *buf, off_t offset, size_t count); +int libnvme_ns_read(libnvme_ns_t n, void *buf, off_t offset, size_t count); /** - * nvme_ns_write() - Write to a namespace + * libnvme_ns_write() - Write to a namespace * @n: Namespace instance * @buf: Buffer with data to be written * @offset: LBA offset of @n @@ -596,20 +596,20 @@ int nvme_ns_read(nvme_ns_t n, void *buf, off_t offset, size_t count); * * Return: Number of sectors written or -1 on error */ -int nvme_ns_write(nvme_ns_t n, void *buf, off_t offset, size_t count); +int libnvme_ns_write(libnvme_ns_t n, void *buf, off_t offset, size_t count); /** - * nvme_ns_verify() - Verify data on a namespace + * libnvme_ns_verify() - Verify data on a namespace * @n: Namespace instance * @offset: LBA offset of @n * @count: Number of sectors to be verified * * Return: Number of sectors verified */ -int nvme_ns_verify(nvme_ns_t n, off_t offset, size_t count); +int libnvme_ns_verify(libnvme_ns_t n, off_t offset, size_t count); /** - * nvme_ns_compare() - Compare data on a namespace + * libnvme_ns_compare() - Compare data on a namespace * @n: Namespace instance * @buf: Buffer with data to be compared * @offset: LBA offset of @n @@ -617,38 +617,38 @@ int nvme_ns_verify(nvme_ns_t n, off_t offset, size_t count); * * Return: Number of sectors compared */ -int nvme_ns_compare(nvme_ns_t n, void *buf, off_t offset, size_t count); +int libnvme_ns_compare(libnvme_ns_t n, void *buf, off_t offset, size_t count); /** - * nvme_ns_write_zeros() - Write zeros to a namespace + * libnvme_ns_write_zeros() - Write zeros to a namespace * @n: Namespace instance * @offset: LBA offset in @n * @count: Number of sectors to be written * * Return: Number of sectors written */ -int nvme_ns_write_zeros(nvme_ns_t n, off_t offset, size_t count); +int libnvme_ns_write_zeros(libnvme_ns_t n, off_t offset, size_t count); /** - * nvme_ns_write_uncorrectable() - Issus a 'write uncorrectable' command + * libnvme_ns_write_uncorrectable() - Issus a 'write uncorrectable' command * @n: Namespace instance * @offset: LBA offset in @n * @count: Number of sectors to be written * * Return: Number of sectors written */ -int nvme_ns_write_uncorrectable(nvme_ns_t n, off_t offset, size_t count); +int libnvme_ns_write_uncorrectable(libnvme_ns_t n, off_t offset, size_t count); /** - * nvme_ns_flush() - Flush data to a namespace + * libnvme_ns_flush() - Flush data to a namespace * @n: Namespace instance * * Return: 0 on success, -1 on error. */ -int nvme_ns_flush(nvme_ns_t n); +int libnvme_ns_flush(libnvme_ns_t n); /** - * nvme_ns_identify() - Issue an 'identify namespace' command + * libnvme_ns_identify() - Issue an 'identify namespace' command * @n: Namespace instance * @ns: &nvme_id_ns buffer * @@ -657,10 +657,10 @@ int nvme_ns_flush(nvme_ns_t n); * * Return: 0 on success, -1 on error. */ -int nvme_ns_identify(nvme_ns_t n, struct nvme_id_ns *ns); +int libnvme_ns_identify(libnvme_ns_t n, struct nvme_id_ns *ns); /** - * nvme_ns_identify_descs() - Issue an 'identify descriptors' command + * libnvme_ns_identify_descs() - Issue an 'identify descriptors' command * @n: Namespace instance * @descs: List of identify descriptors * @@ -669,97 +669,97 @@ int nvme_ns_identify(nvme_ns_t n, struct nvme_id_ns *ns); * * Return: 0 on success, -1 on error. */ -int nvme_ns_identify_descs(nvme_ns_t n, struct nvme_ns_id_desc *descs); +int libnvme_ns_identify_descs(libnvme_ns_t n, struct nvme_ns_id_desc *descs); /** - * nvme_path_get_queue_depth() - Queue depth of an nvme_path_t object - * @p: &nvme_path_t object + * libnvme_path_get_queue_depth() - Queue depth of an libnvme_path_t object + * @p: &libnvme_path_t object * * Return: Queue depth of @p */ -int nvme_path_get_queue_depth(nvme_path_t p); +int libnvme_path_get_queue_depth(libnvme_path_t p); /** - * nvme_path_get_ctrl() - Parent controller of an nvme_path_t object - * @p: &nvme_path_t object + * libnvme_path_get_ctrl() - Parent controller of an libnvme_path_t object + * @p: &libnvme_path_t object * * Return: Parent controller if present */ -nvme_ctrl_t nvme_path_get_ctrl(nvme_path_t p); +libnvme_ctrl_t libnvme_path_get_ctrl(libnvme_path_t p); /** - * nvme_path_get_ns() - Parent namespace of an nvme_path_t object - * @p: &nvme_path_t object + * libnvme_path_get_ns() - Parent namespace of an libnvme_path_t object + * @p: &libnvme_path_t object * * Return: Parent namespace if present */ -nvme_ns_t nvme_path_get_ns(nvme_path_t p); +libnvme_ns_t libnvme_path_get_ns(libnvme_path_t p); /** - * nvme_ctrl_get_transport_handle() - Get associated transport handle + * libnvme_ctrl_get_transport_handle() - Get associated transport handle * @c: Controller instance * * libnvme will open() the device (if not already opened) and keep an * internal copy of the link handle. Following calls to this API retrieve * the internal cached copy of the link handle. The file will remain * opened and the handle will remain cached until the controller object - * is deleted or nvme_ctrl_release_transport_handle() is called. + * is deleted or libnvme_ctrl_release_transport_handle() is called. * * Return: Link handle associated with @c or NULL */ -struct nvme_transport_handle *nvme_ctrl_get_transport_handle(nvme_ctrl_t c); +struct nvme_transport_handle *libnvme_ctrl_get_transport_handle(libnvme_ctrl_t c); /** - * nvme_ctrl_release_transport_handle() - Free transport handle from controller object + * libnvme_ctrl_release_transport_handle() - Free transport handle from controller object * @c: Controller instance * */ -void nvme_ctrl_release_transport_handle(nvme_ctrl_t c); +void libnvme_ctrl_release_transport_handle(libnvme_ctrl_t c); /** - * nvme_ctrl_get_src_addr() - Extract src_addr from the c->address string + * libnvme_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); +char *libnvme_ctrl_get_src_addr(libnvme_ctrl_t c, char *src_addr, size_t src_addr_len); /** - * nvme_ctrl_get_state() - Running state of a controller + * libnvme_ctrl_get_state() - Running state of a controller * @c: Controller instance * * Return: String indicating the running state of @c */ -const char *nvme_ctrl_get_state(nvme_ctrl_t c); +const char *libnvme_ctrl_get_state(libnvme_ctrl_t c); /** - * nvme_ctrl_get_subsystem() - Parent subsystem of a controller + * libnvme_ctrl_get_subsystem() - Parent subsystem of a controller * @c: Controller instance * - * Return: Parent nvme_subsystem_t object + * Return: Parent libnvme_subsystem_t object */ -nvme_subsystem_t nvme_ctrl_get_subsystem(nvme_ctrl_t c); +libnvme_subsystem_t libnvme_ctrl_get_subsystem(libnvme_ctrl_t c); /** - * nvme_ns_head_get_sysfs_dir() - sysfs dir of namespave head + * libnvme_ns_head_get_sysfs_dir() - sysfs dir of namespave head * @head: namespace head instance * * Returns: sysfs directory name of @head */ -const char *nvme_ns_head_get_sysfs_dir(nvme_ns_head_t head); +const char *libnvme_ns_head_get_sysfs_dir(libnvme_ns_head_t head); /** - * nvme_ctrl_get_config() - Fabrics configuration of a controller + * libnvme_ctrl_get_config() - Fabrics configuration of a controller * @c: Controller instance * * Return: Fabrics configuration of @c */ -struct nvme_fabrics_config *nvme_ctrl_get_config(nvme_ctrl_t c); +struct nvme_fabrics_config *libnvme_ctrl_get_config(libnvme_ctrl_t c); /** - * nvme_ctrl_identify() - Issues an 'identify controller' command + * libnvme_ctrl_identify() - Issues an 'identify controller' command * @c: Controller instance * @id: Identify controller data structure * @@ -768,60 +768,60 @@ struct nvme_fabrics_config *nvme_ctrl_get_config(nvme_ctrl_t c); * * Return: 0 on success or -1 on failure. */ -int nvme_ctrl_identify(nvme_ctrl_t c, struct nvme_id_ctrl *id); +int libnvme_ctrl_identify(libnvme_ctrl_t c, struct nvme_id_ctrl *id); /** - * nvme_disconnect_ctrl() - Disconnect a controller + * libnvme_disconnect_ctrl() - Disconnect a controller * @c: Controller instance * * Issues a 'disconnect' fabrics command to @c * * Return: 0 on success, -1 on failure. */ -int nvme_disconnect_ctrl(nvme_ctrl_t c); +int libnvme_disconnect_ctrl(libnvme_ctrl_t c); /** - * nvme_scan_ctrl() - Scan on a controller + * libnvme_scan_ctrl() - Scan on a controller * @ctx: struct nvme_global_ctx object * @name: Name of the controller - * @c: @nvme_ctrl_t object to return + * @c: @libnvme_ctrl_t object to return * * Scans a controller with sysfs name @name and add it to @r. * * Return: 0 on success or negative error code otherwise */ -int nvme_scan_ctrl(struct nvme_global_ctx *ctx, const char *name, nvme_ctrl_t *c); +int libnvme_scan_ctrl(struct nvme_global_ctx *ctx, const char *name, libnvme_ctrl_t *c); /** - * nvme_rescan_ctrl() - Rescan an existing controller + * libnvme_rescan_ctrl() - Rescan an existing controller * @c: Controller instance */ -void nvme_rescan_ctrl(nvme_ctrl_t c); +void libnvme_rescan_ctrl(libnvme_ctrl_t c); /** - * nvme_init_ctrl() - Initialize nvme_ctrl_t object for an existing controller. - * @h: nvme_host_t object - * @c: nvme_ctrl_t object + * libnvme_init_ctrl() - Initialize libnvme_ctrl_t object for an existing controller. + * @h: libnvme_host_t object + * @c: libnvme_ctrl_t object * @instance: Instance number (e.g. 1 for nvme1) * * Return: 0 on success or negative error code otherwise */ -int nvme_init_ctrl(nvme_host_t h, nvme_ctrl_t c, int instance); +int libnvme_init_ctrl(libnvme_host_t h, libnvme_ctrl_t c, int instance); /** - * nvme_free_ctrl() - Free controller + * libnvme_free_ctrl() - Free controller * @c: Controller instance */ -void nvme_free_ctrl(struct nvme_ctrl *c); +void libnvme_free_ctrl(struct libnvme_ctrl *c); /** - * nvme_unlink_ctrl() - Unlink controller + * libnvme_unlink_ctrl() - Unlink controller * @c: Controller instance */ -void nvme_unlink_ctrl(struct nvme_ctrl *c); +void libnvme_unlink_ctrl(struct libnvme_ctrl *c); /** - * nvme_scan_topology() - Scan NVMe topology and apply filter + * libnvme_scan_topology() - Scan NVMe topology and apply filter * @ctx: struct nvme_global_ctx object * @f: filter to apply * @f_args: user-specified argument to @f @@ -831,26 +831,26 @@ void nvme_unlink_ctrl(struct nvme_ctrl *c); * * Return: 0 on success, or negative error code otherwise. */ -int nvme_scan_topology(struct nvme_global_ctx *ctx, nvme_scan_filter_t f, void *f_args); +int libnvme_scan_topology(struct nvme_global_ctx *ctx, libnvme_scan_filter_t f, void *f_args); /** - * nvme_host_release_fds() - Close all opened file descriptors under host - * @h: nvme_host_t object + * libnvme_host_release_fds() - Close all opened file descriptors under host + * @h: libnvme_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); +void libnvme_host_release_fds(struct libnvme_host *h); /** - * nvme_free_host() - Free nvme_host_t object - * @h: nvme_host_t object + * libnvme_free_host() - Free libnvme_host_t object + * @h: libnvme_host_t object */ -void nvme_free_host(nvme_host_t h); +void libnvme_free_host(libnvme_host_t h); /** - * nvme_read_config() - Read NVMe JSON configuration file + * libnvme_read_config() - Read NVMe JSON configuration file * @ctx: &struct nvme_global_ctx object * @config_file: JSON configuration file * @@ -859,18 +859,18 @@ void nvme_free_host(nvme_host_t h); * * Return: 0 on success or negative error code otherwise */ -int nvme_read_config(struct nvme_global_ctx *ctx, const char *config_file); +int libnvme_read_config(struct nvme_global_ctx *ctx, const char *config_file); /** - * nvme_refresh_topology() - Refresh nvme_root_t object contents + * libnvme_refresh_topology() - Refresh nvme_root_t object contents * @ctx: &struct nvme_global_ctx object * * Removes all elements in @r and rescans the existing topology. */ -void nvme_refresh_topology(struct nvme_global_ctx *ctx); +void libnvme_refresh_topology(struct nvme_global_ctx *ctx); /** - * nvme_dump_config() - Print the JSON configuration + * libnvme_dump_config() - Print the JSON configuration * @ctx: &struct nvme_global_ctx object * @fd: File descriptor to write the JSON configuration. * @@ -879,10 +879,10 @@ void nvme_refresh_topology(struct nvme_global_ctx *ctx); * * Return: 0 on success, or negative error code otherwise. */ -int nvme_dump_config(struct nvme_global_ctx *ctx, int fd); +int libnvme_dump_config(struct nvme_global_ctx *ctx, int fd); /** - * nvme_dump_tree() - Dump internal object tree + * libnvme_dump_tree() - Dump internal object tree * @ctx: &struct nvme_global_ctx object * * Prints the internal object tree in JSON format @@ -890,87 +890,87 @@ int nvme_dump_config(struct nvme_global_ctx *ctx, int fd); * * Return: 0 on success or negative error code otherwise */ -int nvme_dump_tree(struct nvme_global_ctx *ctx); +int libnvme_dump_tree(struct nvme_global_ctx *ctx); /** - * nvme_get_attr() - Read sysfs attribute + * libnvme_get_attr() - Read sysfs attribute * @d: sysfs directory * @attr: sysfs attribute name * * Return: String with the contents of @attr or %NULL in case of an empty * value or error. */ -char *nvme_get_attr(const char *d, const char *attr); +char *libnvme_get_attr(const char *d, const char *attr); /** - * nvme_get_subsys_attr() - Read subsystem sysfs attribute - * @s: nvme_subsystem_t object + * libnvme_get_subsys_attr() - Read subsystem sysfs attribute + * @s: libnvme_subsystem_t object * @attr: sysfs attribute name * * Return: String with the contents of @attr or %NULL in case of an empty * value or error. */ -char *nvme_get_subsys_attr(nvme_subsystem_t s, const char *attr); +char *libnvme_get_subsys_attr(libnvme_subsystem_t s, const char *attr); /** - * nvme_get_ctrl_attr() - Read controller sysfs attribute + * libnvme_get_ctrl_attr() - Read controller sysfs attribute * @c: Controller instance * @attr: sysfs attribute name * * Return: String with the contents of @attr or %NULL in case of an empty value * or in case of an error. */ -char *nvme_get_ctrl_attr(nvme_ctrl_t c, const char *attr); +char *libnvme_get_ctrl_attr(libnvme_ctrl_t c, const char *attr); /** - * nvme_get_ns_attr() - Read namespace sysfs attribute - * @n: nvme_ns_t object + * libnvme_get_ns_attr() - Read namespace sysfs attribute + * @n: libnvme_ns_t object * @attr: sysfs attribute name * * Return: String with the contents of @attr or %NULL in case of an empty value * or in case of an error. */ -char *nvme_get_ns_attr(nvme_ns_t n, const char *attr); +char *libnvme_get_ns_attr(libnvme_ns_t n, const char *attr); /** - * nvme_subsystem_lookup_namespace() - lookup namespace by NSID - * @s: nvme_subsystem_t object + * libnvme_subsystem_lookup_namespace() - lookup namespace by NSID + * @s: libnvme_subsystem_t object * @nsid: Namespace id * - * Return: nvme_ns_t of the namespace with id @nsid in subsystem @s + * Return: libnvme_ns_t of the namespace with id @nsid in subsystem @s */ -nvme_ns_t nvme_subsystem_lookup_namespace(struct nvme_subsystem *s, +libnvme_ns_t libnvme_subsystem_lookup_namespace(struct libnvme_subsystem *s, __u32 nsid); /** - * nvme_subsystem_release_fds() - Close all opened fds under subsystem - * @s: nvme_subsystem_t object + * libnvme_subsystem_release_fds() - Close all opened fds under subsystem + * @s: libnvme_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); +void libnvme_subsystem_release_fds(struct libnvme_subsystem *s); /** - * nvme_get_path_attr() - Read path sysfs attribute - * @p: nvme_path_t object + * libnvme_get_path_attr() - Read path sysfs attribute + * @p: libnvme_path_t object * @attr: sysfs attribute name * * Return: String with the contents of @attr or %NULL in case of an empty value * or in case of an error. */ -char *nvme_get_path_attr(nvme_path_t p, const char *attr); +char *libnvme_get_path_attr(libnvme_path_t p, const char *attr); /** - * nvme_scan_namespace() - scan namespace based on sysfs name + * libnvme_scan_namespace() - scan namespace based on sysfs name * @ctx: &struct nvme_global_ctx object * @name: sysfs name of the namespace to scan - * @ns: &nvme_ns_t object to return + * @ns: &libnvme_ns_t object to return * * Return: 0 on success or negative error code otherwise */ -int nvme_scan_namespace(struct nvme_global_ctx *ctx, const char *name, - nvme_ns_t *ns); +int libnvme_scan_namespace(struct nvme_global_ctx *ctx, const char *name, + libnvme_ns_t *ns); diff --git a/libnvme/src/nvme/util.c b/libnvme/src/nvme/util.c index 70916d566d..3fa35936fd 100644 --- a/libnvme/src/nvme/util.c +++ b/libnvme/src/nvme/util.c @@ -175,7 +175,7 @@ static inline __u8 nvme_fabrics_status_to_errno(__u16 status) return EIO; } -__public __u8 nvme_status_to_errno(int status, bool fabrics) +__public __u8 libnvme_status_to_errno(int status, bool fabrics) { __u16 sc; @@ -374,7 +374,7 @@ static const char *arg_str(const char * const *strings, return "unrecognized"; } -__public const char *nvme_status_to_string(int status, bool fabrics) +__public const char *libnvme_status_to_string(int status, bool fabrics) { const char *s = "Unknown status"; __u16 sc, sct; @@ -438,17 +438,17 @@ static const char * const libnvme_status[] = { [ENVME_CONNECT_NOKEY] = "pre-shared TLS key is missing" }; -__public const char *nvme_errno_to_string(int status) +__public const char *libnvme_errno_to_string(int status) { const char *s = ARGSTR(libnvme_status, status); return s; } -__public const char *nvme_strerror(int errnum) +__public const char *libnvme_strerror(int errnum) { if (errnum >= ENVME_CONNECT_RESOLVE) - return nvme_errno_to_string(errnum); + return libnvme_errno_to_string(errnum); return strerror(errnum); } @@ -712,7 +712,7 @@ __public struct nvmf_ext_attr *nvmf_exat_ptr_next(struct nvmf_ext_attr *p) ((uintptr_t)p + (ptrdiff_t)nvmf_exat_size(le16_to_cpu(p->exatlen))); } -__public const char *nvme_get_version(enum nvme_version type) +__public const char *libnvme_get_version(enum nvme_version type) { switch(type) { case NVME_VERSION_PROJECT: @@ -724,7 +724,7 @@ __public const char *nvme_get_version(enum nvme_version type) } } -__public int nvme_uuid_to_string(unsigned char uuid[NVME_UUID_LEN], char *str) +__public int libnvme_uuid_to_string(unsigned char uuid[NVME_UUID_LEN], char *str) { int n; n = snprintf(str, NVME_UUID_LEN_STRING, @@ -736,7 +736,7 @@ __public int nvme_uuid_to_string(unsigned char uuid[NVME_UUID_LEN], char *str) return n != NVME_UUID_LEN_STRING - 1 ? -EINVAL : 0; } -__public int nvme_uuid_from_string(const char *str, unsigned char uuid[NVME_UUID_LEN]) +__public int libnvme_uuid_from_string(const char *str, unsigned char uuid[NVME_UUID_LEN]) { int n; @@ -750,7 +750,7 @@ __public int nvme_uuid_from_string(const char *str, unsigned char uuid[NVME_UUID } -__public int nvme_random_uuid(unsigned char uuid[NVME_UUID_LEN]) +__public int libnvme_random_uuid(unsigned char uuid[NVME_UUID_LEN]) { _cleanup_fd_ int f = -1; ssize_t n; @@ -775,7 +775,7 @@ __public int nvme_random_uuid(unsigned char uuid[NVME_UUID_LEN]) return 0; } -__public int nvme_find_uuid(struct nvme_id_uuid_list *uuid_list, +__public int libnvme_find_uuid(struct nvme_id_uuid_list *uuid_list, const unsigned char uuid[NVME_UUID_LEN]) { const unsigned char uuid_end[NVME_UUID_LEN] = {0}; @@ -987,7 +987,7 @@ const struct ifaddrs *nvme_getifaddrs(struct nvme_global_ctx *ctx) /* This used instead of basename() due to behavioral differences between * the POSIX and the GNU version. This is the glibc implementation. * Original source: https://github.com/bminor/glibc/blob/master/string/basename.c */ -char *nvme_basename(const char *path) +char *libnvme_basename(const char *path) { char *p = (char *) strrchr(path, '/'); return p ? p + 1 : (char *) path; diff --git a/libnvme/src/nvme/util.h b/libnvme/src/nvme/util.h index eb75a133bb..9e1620952f 100644 --- a/libnvme/src/nvme/util.h +++ b/libnvme/src/nvme/util.h @@ -65,33 +65,33 @@ enum nvme_connect_err { }; /** - * nvme_status_to_errno() - Converts nvme return status to errno + * libnvme_status_to_errno() - Converts nvme return status to errno * @status: Return status from an nvme passthrough command * @fabrics: Set to true if &status is to a fabrics target. * * Return: An errno representing the nvme status if it is an nvme status field, * or unchanged status is < 0 since errno is already set. */ -__u8 nvme_status_to_errno(int status, bool fabrics); +__u8 libnvme_status_to_errno(int status, bool fabrics); /** - * nvme_status_to_string() - Returns string describing nvme return status. + * libnvme_status_to_string() - Returns string describing nvme return status. * @status: Return status from an nvme passthrough command * @fabrics: Set to true if &status is to a fabrics target. * * Return: String representation of the nvme status if it is an nvme status field, * or a standard errno string if status is < 0. */ -const char *nvme_status_to_string(int status, bool fabrics); +const char *libnvme_status_to_string(int status, bool fabrics); /** - * nvme_sanitize_ns_status_to_string() - Returns sanitize ns status string. + * libnvme_sanitize_ns_status_to_string() - Returns sanitize ns status string. * @sc: Return status code from an sanitize ns command * * Return: The sanitize ns status string if it is a specific status code. */ static inline const char * -nvme_sanitize_ns_status_to_string(__u16 sc) +libnvme_sanitize_ns_status_to_string(__u16 sc) { switch (sc) { case NVME_SC_EXCEEDS_MAX_NS_SANITIZE: @@ -104,7 +104,7 @@ nvme_sanitize_ns_status_to_string(__u16 sc) }; /** - * nvme_opcode_status_to_string() - Returns nvme opcode status string. + * libnvme_opcode_status_to_string() - Returns nvme opcode status string. * @status: Return status from an nvme passthrough command * @admin: Set to true if an admin command * @opcode: Opcode from an nvme passthrough command @@ -113,7 +113,7 @@ nvme_sanitize_ns_status_to_string(__u16 sc) * or a standard errno string if status is < 0. */ static inline const char * -nvme_opcode_status_to_string(int status, bool admin, __u8 opcode) +libnvme_opcode_status_to_string(int status, bool admin, __u8 opcode) { __u16 sct = nvme_status_code_type(status); __u16 sc = nvme_status_code(status); @@ -121,31 +121,31 @@ nvme_opcode_status_to_string(int status, bool admin, __u8 opcode) if (status >= 0 && sct == NVME_SCT_CMD_SPECIFIC) { if (admin && opcode == nvme_admin_sanitize_ns) - s = nvme_sanitize_ns_status_to_string(sc); + s = libnvme_sanitize_ns_status_to_string(sc); } if (s) return s; - return nvme_status_to_string(status, false); + return libnvme_status_to_string(status, false); } /** - * nvme_errno_to_string() - Returns string describing nvme connect failures - * @err: Returned error code from nvme_add_ctrl() + * libnvme_errno_to_string() - Returns string describing nvme connect failures + * @err: Returned error code from libnvme_add_ctrl() * * Return: String representation of the nvme connect error codes */ -const char *nvme_errno_to_string(int err); +const char *libnvme_errno_to_string(int err); /** - * nvme_strerror() - Returns string describing nvme errors and errno + * libnvme_strerror() - Returns string describing nvme errors and errno * @err: Returned error codes from all libnvme functions * * Return: String representation of either the nvme connect error codes * (positive values) or errno string (negative values) */ -const char *nvme_strerror(int err); +const char *libnvme_strerror(int err); /** * nvmf_exat_ptr_next - Increment @p to the next element in the array. @@ -162,7 +162,7 @@ const char *nvme_strerror(int err); struct nvmf_ext_attr *nvmf_exat_ptr_next(struct nvmf_ext_attr *p); /** - * enum nvme_version - Selector for version to be returned by @nvme_get_version + * enum nvme_version - Selector for version to be returned by @libnvme_get_version * * @NVME_VERSION_PROJECT: Project release version * @NVME_VERSION_GIT: Git reference @@ -173,33 +173,33 @@ enum nvme_version { }; /** - * nvme_get_version - Return version libnvme string + * libnvme_get_version - Return version libnvme string * @type: Selects which version type (see @struct nvme_version) * * Return: Returns version string for known types or else "n/a" */ -const char *nvme_get_version(enum nvme_version type); +const char *libnvme_get_version(enum nvme_version type); /** - * nvme_uuid_to_string - Return string represenation of encoded UUID + * libnvme_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); +int libnvme_uuid_to_string(unsigned char uuid[NVME_UUID_LEN], char *str); /** - * nvme_uuid_from_string - Return encoded UUID represenation of string UUID + * libnvme_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]); +int libnvme_uuid_from_string(const char *str, unsigned char uuid[NVME_UUID_LEN]); /** - * nvme_random_uuid - Generate random UUID + * libnvme_random_uuid - Generate random UUID * @uuid: Generated random UUID * * Generate random number according @@ -207,23 +207,23 @@ int nvme_uuid_from_string(const char *str, unsigned char uuid[NVME_UUID_LEN]); * * Return: Returns error code if generating of random number fails. */ -int nvme_random_uuid(unsigned char uuid[NVME_UUID_LEN]); +int libnvme_random_uuid(unsigned char uuid[NVME_UUID_LEN]); /** - * nvme_find_uuid - Find UUID position on UUID list + * libnvme_find_uuid - Find UUID position on UUID list * @uuid_list: UUID list returned by identify UUID * @uuid: Binary encoded input UUID * * Return: The array position where given UUID is present, or -1 on failure * with errno set. */ -int nvme_find_uuid(struct nvme_id_uuid_list *uuid_list, +int libnvme_find_uuid(struct nvme_id_uuid_list *uuid_list, const unsigned char uuid[NVME_UUID_LEN]); /** - * nvme_basename - Return the final path component (the one after the last '/') + * libnvme_basename - Return the final path component (the one after the last '/') * @path: A string containing a filesystem path * * Return: A pointer into the original null-terminated path string. */ -char *nvme_basename(const char *path); +char *libnvme_basename(const char *path); diff --git a/libnvme/test/config/config-dump.c b/libnvme/test/config/config-dump.c index 0c68195d62..3673758c13 100644 --- a/libnvme/test/config/config-dump.c +++ b/libnvme/test/config/config-dump.c @@ -18,26 +18,26 @@ static bool config_dump(const char *file) bool pass = false; int err; - ctx = nvme_create_global_ctx(stderr, LOG_ERR); + ctx = libnvme_create_global_ctx(stderr, LOG_ERR); if (!ctx) return false; - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err < 0 && err != -ENOENT) goto out; - err = nvme_read_config(ctx, file); + err = libnvme_read_config(ctx, file); if (err) goto out; - err = nvme_dump_config(ctx, STDOUT_FILENO); + err = libnvme_dump_config(ctx, STDOUT_FILENO); if (err) goto out; pass = true; out: - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return pass; } diff --git a/libnvme/test/config/hostnqn-order.c b/libnvme/test/config/hostnqn-order.c index 7500b96675..8b31e64e2c 100644 --- a/libnvme/test/config/hostnqn-order.c +++ b/libnvme/test/config/hostnqn-order.c @@ -18,18 +18,18 @@ static bool command_line(void) int err; char *hostnqn, *hostid, *hnqn, *hid; - ctx = nvme_create_global_ctx(stderr, LOG_ERR); + ctx = libnvme_create_global_ctx(stderr, LOG_ERR); if (!ctx) return false; - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err && err != ENOENT) goto out; hostnqn = "nqn.2014-08.org.nvmexpress:uuid:ce4fee3e-c02c-11ee-8442-830d068a36c6"; hostid = "ce4fee3e-c02c-11ee-8442-830d068a36c6"; - err = nvme_host_get_ids(ctx, hostnqn, hostid, &hnqn, &hid); + err = libnvme_host_get_ids(ctx, hostnqn, hostid, &hnqn, &hid); if (err) goto out; @@ -48,7 +48,7 @@ static bool command_line(void) pass = true; out: - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return pass; } @@ -62,23 +62,23 @@ static bool json_config(char *file) setenv("LIBNVME_HOSTNQN", "", 1); setenv("LIBNVME_HOSTID", "", 1); - ctx = nvme_create_global_ctx(stderr, LOG_ERR); + ctx = libnvme_create_global_ctx(stderr, LOG_ERR); if (!ctx) return false; /* We need to read the config in before we scan */ - err = nvme_read_config(ctx, file); + err = libnvme_read_config(ctx, file); if (err) goto out; - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err && err != ENOENT) goto out; hostnqn = "nqn.2014-08.org.nvmexpress:uuid:2cd2c43b-a90a-45c1-a8cd-86b33ab273b5"; hostid = "2cd2c43b-a90a-45c1-a8cd-86b33ab273b5"; - err = nvme_host_get_ids(ctx, NULL, NULL, &hnqn, &hid); + err = libnvme_host_get_ids(ctx, NULL, NULL, &hnqn, &hid); if (err) goto out; @@ -97,7 +97,7 @@ static bool json_config(char *file) pass = true; out: - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return pass; } @@ -114,15 +114,15 @@ static bool from_file(void) setenv("LIBNVME_HOSTNQN", hostnqn, 1); setenv("LIBNVME_HOSTID", hostid, 1); - ctx = nvme_create_global_ctx(stderr, LOG_ERR); + ctx = libnvme_create_global_ctx(stderr, LOG_ERR); if (!ctx) return false; - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err && err != ENOENT) goto out; - err = nvme_host_get_ids(ctx, NULL, NULL, &hnqn, &hid); + err = libnvme_host_get_ids(ctx, NULL, NULL, &hnqn, &hid); if (err) goto out; @@ -141,7 +141,7 @@ static bool from_file(void) pass = true; out: - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return pass; } diff --git a/libnvme/test/config/psk-json.c b/libnvme/test/config/psk-json.c index b83ebfb32a..bc8afd74b8 100644 --- a/libnvme/test/config/psk-json.c +++ b/libnvme/test/config/psk-json.c @@ -15,32 +15,32 @@ #include "nvme/linux.h" #include "nvme/tree.h" -static bool import_export_key(struct nvme_global_ctx *ctx, nvme_ctrl_t c) +static bool import_export_key(struct nvme_global_ctx *ctx, libnvme_ctrl_t c) { unsigned char version, hmac, *key; char *encoded_key; size_t len; int ret; - ret = nvme_import_tls_key_versioned(ctx, nvme_ctrl_get_tls_key(c), + ret = libnvme_import_tls_key_versioned(ctx, libnvme_ctrl_get_tls_key(c), &version, &hmac, &len, &key); if (ret) { - printf("ERROR: nvme_import_tls_key_versioned failed with %d\n", + printf("ERROR: libnvme_import_tls_key_versioned failed with %d\n", ret); return false; } - ret = nvme_export_tls_key_versioned(ctx, version, hmac, key, len, + ret = libnvme_export_tls_key_versioned(ctx, version, hmac, key, len, &encoded_key); free(key); if (ret) { - printf("ERROR: nvme_export_tls_key_versioned failed with %d\n", + printf("ERROR: libnvme_export_tls_key_versioned failed with %d\n", ret); return false; } - nvme_ctrl_set_tls_key(c, encoded_key); + libnvme_ctrl_set_tls_key(c, encoded_key); free(encoded_key); @@ -51,34 +51,34 @@ static bool psk_json_test(char *file) { struct nvme_global_ctx *ctx; bool pass = false; - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; int err; - ctx = nvme_create_global_ctx(stderr, LOG_ERR); + ctx = libnvme_create_global_ctx(stderr, LOG_ERR); if (!ctx) return false; - err = nvme_read_config(ctx, file); + err = libnvme_read_config(ctx, file); if (err) goto out; - nvme_for_each_host(ctx, h) - nvme_for_each_subsystem(h, s) - nvme_subsystem_for_each_ctrl(s, c) + libnvme_for_each_host(ctx, h) + libnvme_for_each_subsystem(h, s) + libnvme_subsystem_for_each_ctrl(s, c) if (!import_export_key(ctx, c)) goto out; - err = nvme_dump_config(ctx, STDOUT_FILENO); + err = libnvme_dump_config(ctx, STDOUT_FILENO); if (err) goto out; pass = true; out: - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return pass; } diff --git a/libnvme/test/cpp.cc b/libnvme/test/cpp.cc index 6cd0778bea..7c3e01d1f1 100644 --- a/libnvme/test/cpp.cc +++ b/libnvme/test/cpp.cc @@ -13,64 +13,64 @@ int main() { struct nvme_global_ctx *ctx; - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; - nvme_path_t p; - nvme_ns_t n; + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; + libnvme_path_t p; + libnvme_ns_t n; int err; - ctx = nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); if (!ctx) return 1; - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err && !(err == -ENOENT || err == -EACCES)) { - fprintf(stderr, "nvme_scan_topology failed %d\n", err); - nvme_free_global_ctx(ctx); + fprintf(stderr, "libnvme_scan_topology failed %d\n", err); + libnvme_free_global_ctx(ctx); return 1; } - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - std::cout << nvme_subsystem_get_name(s) - << " - NQN=" << nvme_subsystem_get_subsysnqn(s) + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + std::cout << libnvme_subsystem_get_name(s) + << " - NQN=" << libnvme_subsystem_get_subsysnqn(s) << "\n"; - nvme_subsystem_for_each_ctrl(s, c) { - std::cout << " `- " << nvme_ctrl_get_name(c) - << " " << nvme_ctrl_get_transport(c) - << " " << nvme_ctrl_get_traddr(c) - << " " << nvme_ctrl_get_state(c) + libnvme_subsystem_for_each_ctrl(s, c) { + std::cout << " `- " << libnvme_ctrl_get_name(c) + << " " << libnvme_ctrl_get_transport(c) + << " " << libnvme_ctrl_get_traddr(c) + << " " << libnvme_ctrl_get_state(c) << "\n"; - nvme_ctrl_for_each_ns(c, n) { + libnvme_ctrl_for_each_ns(c, n) { std::cout << " `- " - << nvme_ns_get_name(n) + << libnvme_ns_get_name(n) << "lba size:" - << nvme_ns_get_lba_size(n) + << libnvme_ns_get_lba_size(n) << " lba max:" - << nvme_ns_get_lba_count(n) + << libnvme_ns_get_lba_count(n) << "\n"; } - nvme_ctrl_for_each_path(c, p) { + libnvme_ctrl_for_each_path(c, p) { std::cout << " `- " - << nvme_path_get_name(p) + << libnvme_path_get_name(p) << " " - << nvme_path_get_ana_state(p) + << libnvme_path_get_ana_state(p) << "\n"; } } - nvme_subsystem_for_each_ns(s, n) { - std::cout << " `- " << nvme_ns_get_name(n) + libnvme_subsystem_for_each_ns(s, n) { + std::cout << " `- " << libnvme_ns_get_name(n) << "lba size:" - << nvme_ns_get_lba_size(n) + << libnvme_ns_get_lba_size(n) << " lba max:" - << nvme_ns_get_lba_count(n) << "\n"; + << libnvme_ns_get_lba_count(n) << "\n"; } } } std::cout << "\n"; - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return 0; } diff --git a/libnvme/test/ioctl/ana.c b/libnvme/test/ioctl/ana.c index 411e15324c..ee25442d72 100644 --- a/libnvme/test/ioctl/ana.c +++ b/libnvme/test/ioctl/ana.c @@ -629,10 +629,10 @@ static void run_test(const char *test_name, void (*test_fn)(void)) int main(void) { struct nvme_global_ctx *ctx = - nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); set_mock_fd(TEST_FD); - check(!nvme_open(ctx, "NVME_TEST_FD", &test_hdl), + check(!libnvme_open(ctx, "NVME_TEST_FD", &test_hdl), "opening test link failed"); RUN_TEST(no_retries); @@ -648,5 +648,5 @@ int main(void) RUN_TEST(chgcnt_max_retries); RUN_TEST(buffer_too_short); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); } diff --git a/libnvme/test/ioctl/discovery.c b/libnvme/test/ioctl/discovery.c index a39621d8b3..a01889bacb 100644 --- a/libnvme/test/ioctl/discovery.c +++ b/libnvme/test/ioctl/discovery.c @@ -58,7 +58,7 @@ static void arbitrary_entries(size_t len, arbitrary_entry(&entries[i], &log_entries[i]); } -static void test_no_entries(nvme_ctrl_t c) +static void test_no_entries(libnvme_ctrl_t c) { struct nvmf_discovery_log header = {}; /* No entries to fetch after fetching the header */ @@ -80,7 +80,7 @@ static void test_no_entries(nvme_ctrl_t c) free(log); } -static void test_four_entries(nvme_ctrl_t c) +static void test_four_entries(libnvme_ctrl_t c) { size_t num_entries = 4; struct nvmf_disc_log_entry entries[num_entries]; @@ -125,7 +125,7 @@ static void test_four_entries(nvme_ctrl_t c) free(log); } -static void test_five_entries(nvme_ctrl_t c) +static void test_five_entries(libnvme_ctrl_t c) { size_t num_entries = 5; struct nvmf_disc_log_entry entries[num_entries]; @@ -184,7 +184,7 @@ static void test_five_entries(nvme_ctrl_t c) free(log); } -static void test_genctr_change(nvme_ctrl_t c) +static void test_genctr_change(libnvme_ctrl_t c) { struct nvmf_disc_log_entry entries1[1]; struct nvmf_discovery_log header1 = { @@ -252,7 +252,7 @@ static void test_genctr_change(nvme_ctrl_t c) free(log); } -static void test_max_retries(nvme_ctrl_t c) +static void test_max_retries(libnvme_ctrl_t c) { struct nvmf_disc_log_entry entry; struct nvmf_discovery_log header1 = {.numrec = cpu_to_le64(1)}; @@ -313,7 +313,7 @@ static void test_max_retries(nvme_ctrl_t c) check(!log, "unexpected log page returned"); } -static void test_header_error(nvme_ctrl_t c) +static void test_header_error(libnvme_ctrl_t c) { /* Stop after an error in fetching the header the first time */ struct mock_cmd mock_admin_cmds[] = { @@ -333,7 +333,7 @@ static void test_header_error(nvme_ctrl_t c) check(!log, "unexpected log page returned"); } -static void test_entries_error(nvme_ctrl_t c) +static void test_entries_error(libnvme_ctrl_t c) { struct nvmf_discovery_log header = {.numrec = cpu_to_le64(1)}; size_t entry_size = sizeof(struct nvmf_disc_log_entry); @@ -363,7 +363,7 @@ static void test_entries_error(nvme_ctrl_t c) check(!log, "unexpected log page returned"); } -static void test_genctr_error(nvme_ctrl_t c) +static void test_genctr_error(libnvme_ctrl_t c) { struct nvmf_disc_log_entry entry; struct nvmf_discovery_log header = {.numrec = cpu_to_le64(1)}; @@ -402,9 +402,9 @@ static void test_genctr_error(nvme_ctrl_t c) } static void run_test(struct nvme_global_ctx *ctx, const char *test_name, - void (*test_fn)(nvme_ctrl_t)) + void (*test_fn)(libnvme_ctrl_t)) { - struct nvme_ctrl c = { .ctx = ctx, .hdl = test_hdl }; + struct libnvme_ctrl c = { .ctx = ctx, .hdl = test_hdl }; printf("Running test %s...", test_name); fflush(stdout); @@ -419,10 +419,10 @@ static void run_test(struct nvme_global_ctx *ctx, const char *test_name, int main(void) { struct nvme_global_ctx *ctx = - nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); set_mock_fd(TEST_FD); - check(!nvme_open(ctx, "NVME_TEST_FD", &test_hdl), + check(!libnvme_open(ctx, "NVME_TEST_FD", &test_hdl), "opening test link failed"); RUN_TEST(no_entries); @@ -434,5 +434,5 @@ int main(void) RUN_TEST(entries_error); RUN_TEST(genctr_error); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); } diff --git a/libnvme/test/ioctl/features.c b/libnvme/test/ioctl/features.c index 5c4eddcf1e..5fad9f76ca 100644 --- a/libnvme/test/ioctl/features.c +++ b/libnvme/test/ioctl/features.c @@ -57,7 +57,7 @@ static void test_set_features(void) cmd.data_len = sizeof(data); cmd.addr = (__u64)(uintptr_t)data; cmd.timeout_ms = TEST_TIMEOUT; - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -91,7 +91,7 @@ static void test_get_features(void) cmd.data_len = sizeof(get_data); cmd.addr = (__u64)(uintptr_t)get_data; cmd.timeout_ms = TEST_TIMEOUT; - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -120,7 +120,7 @@ static void test_get_features_data(void) cmd.nsid = TEST_NSID; cmd.data_len = sizeof(get_data); cmd.addr = (__u64)(uintptr_t)get_data; - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -143,7 +143,7 @@ static void test_set_arbitration(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_arbitration(&cmd, false, AB, LPW, MPW, HPW); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -163,7 +163,7 @@ static void test_get_arbitration(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_arbitration(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -186,7 +186,7 @@ static void test_set_power_mgmt(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_power_mgmt(&cmd, true, PS, WH); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -206,7 +206,7 @@ static void test_get_power_mgmt(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_power_mgmt(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -234,7 +234,7 @@ static void test_set_lba_range(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_lba_range(&cmd, TEST_NSID, false, NUM, &range_types); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -260,7 +260,7 @@ static void test_get_lba_range(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_lba_range(&cmd, TEST_NSID, TEST_SEL, &get_range_types); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -288,7 +288,7 @@ static void test_set_temp_thresh(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_temp_thresh(&cmd, true, TMPTH, TMPSEL, THSEL, 0); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -313,7 +313,7 @@ static void test_get_temp_thresh(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_temp_thresh(&cmd, TEST_SEL, 0, 0); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -337,7 +337,7 @@ static void test_set_err_recovery(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_err_recovery(&cmd, TEST_NSID, false, TLER, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -358,7 +358,7 @@ static void test_get_err_recovery(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_err_recovery(&cmd, TEST_NSID, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -380,7 +380,7 @@ static void test_set_volatile_wc(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_volatile_wc(&cmd, true, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -401,7 +401,7 @@ static void test_get_volatile_wc(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_volatile_wc(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -421,7 +421,7 @@ static void test_get_num_queues(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_num_queues(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -443,7 +443,7 @@ static void test_set_irq_coalesce(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_irq_coalesce(&cmd, false, THR, TIME); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -463,7 +463,7 @@ static void test_get_irq_coalesce(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_irq_coalesce(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -487,7 +487,7 @@ static void test_set_irq_config(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_irq_config(&cmd, true, IV, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -509,7 +509,7 @@ static void test_get_irq_config(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_irq_config(&cmd, TEST_SEL, IV, false); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -530,7 +530,7 @@ static void test_set_write_atomic(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_write_atomic(&cmd, false, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -550,7 +550,7 @@ static void test_get_write_atomic(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_write_atomic(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -573,7 +573,7 @@ static void test_set_async_event(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_async_event(&cmd, true, EVENTS); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -593,7 +593,7 @@ static void test_get_async_event(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_async_event(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -618,7 +618,7 @@ static void test_set_auto_pst(void) arbitrary(&apst, sizeof(apst)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_auto_pst(&cmd, false, true, &apst); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -642,7 +642,7 @@ static void test_get_auto_pst(void) arbitrary(&apst, sizeof(apst)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_auto_pst(&cmd, TEST_SEL, &get_apst); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -667,7 +667,7 @@ static void test_get_host_mem_buf(void) arbitrary(&attrs, sizeof(attrs)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_host_mem_buf(&cmd, TEST_SEL, &get_attrs); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -698,7 +698,7 @@ static void test_set_timestamp(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_timestamp(&cmd, true, timestamp, &buf); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); } @@ -718,7 +718,7 @@ static void test_get_timestamp(void) arbitrary(&ts, sizeof(ts)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_timestamp(&cmd, TEST_SEL, &get_ts); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); cmp(&get_ts, &ts, sizeof(ts), "incorrect timestamp"); @@ -736,7 +736,7 @@ static void test_get_kato(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_kato(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -758,7 +758,7 @@ static void test_set_hctm(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_hctm(&cmd, false, TMT2, TMT1); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -778,7 +778,7 @@ static void test_get_hctm(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_hctm(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -800,7 +800,7 @@ static void test_set_nopsc(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_nopsc(&cmd, true, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -820,7 +820,7 @@ static void test_get_nopsc(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_nopsc(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -844,7 +844,7 @@ static void test_set_rrl(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_rrl(&cmd, false, NVMSETID, RRL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -865,7 +865,7 @@ static void test_get_rrl(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_rrl(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -893,7 +893,7 @@ static void test_set_plm_config(void) arbitrary(&config, sizeof(config)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_plm_config(&cmd, true, NVMSETID, true, &config); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -920,7 +920,7 @@ static void test_get_plm_config(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_plm_config(&cmd, TEST_SEL, NVMSETID, &get_config); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -945,7 +945,7 @@ static void test_set_plm_window(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_plm_window(&cmd, false, NVMSETID, SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -967,7 +967,7 @@ static void test_get_plm_window(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_plm_window(&cmd, TEST_SEL, NVMSETID); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -990,7 +990,7 @@ static void test_set_lba_sts_interval(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_lba_sts_interval(&cmd, true, LSIRI, LSIPI); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1010,7 +1010,7 @@ static void test_get_lba_sts_interval(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_lba_sts_interval(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1034,7 +1034,7 @@ static void test_set_host_behavior(void) arbitrary(&behavior, sizeof(behavior)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_host_behavior(&cmd, false, &behavior); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); } @@ -1055,7 +1055,7 @@ static void test_get_host_behavior(void) arbitrary(&behavior, sizeof(behavior)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_host_behavior(&cmd, TEST_SEL, &get_behavior); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1077,7 +1077,7 @@ static void test_set_sanitize(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_sanitize(&cmd, false, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1097,7 +1097,7 @@ static void test_get_sanitize(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_sanitize(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1121,7 +1121,7 @@ static void test_set_endurance_evt_cfg(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_endurance_evt_cfg(&cmd, true, ENDGID, EGWARN); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1143,7 +1143,7 @@ static void test_get_endurance_event_cfg(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_endurance_event_cfg(&cmd, TEST_SEL, ENDGID); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1164,7 +1164,7 @@ static void test_set_iocs_profile(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_iocs_profile(&cmd, false, IOCSI); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); } @@ -1181,7 +1181,7 @@ static void test_get_iocs_profile(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_iocs_profile(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1204,7 +1204,7 @@ static void test_set_sw_progress(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_sw_progress(&cmd, true, PBSLC); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1224,7 +1224,7 @@ static void test_get_sw_progress(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_sw_progress(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1249,7 +1249,7 @@ static void test_set_host_id(void) arbitrary(hostid, sizeof(hostid)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_host_id(&cmd, true, false,hostid); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); } @@ -1271,7 +1271,7 @@ static void test_set_host_id_extended(void) arbitrary(hostid, sizeof(hostid)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_host_id(&cmd, false, true, hostid); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); } @@ -1293,7 +1293,7 @@ static void test_get_host_id(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_host_id(&cmd, TEST_SEL, false, get_hostid, sizeof(hostid)); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); cmp(get_hostid, hostid, sizeof(hostid), "incorrect host identifier"); @@ -1317,7 +1317,7 @@ static void test_get_host_id_extended(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_host_id(&cmd, TEST_SEL, true, get_hostid, sizeof(hostid)); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); cmp(get_hostid, hostid, sizeof(hostid), "incorrect host identifier"); @@ -1339,7 +1339,7 @@ static void test_set_resv_mask(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_resv_mask(&cmd, TEST_NSID, true, MASK); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1360,7 +1360,7 @@ static void test_get_resv_mask(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_resv_mask(&cmd, TEST_NSID, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1382,7 +1382,7 @@ static void test_set_resv_persist(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_resv_persist(&cmd, TEST_NSID, false, true); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1403,7 +1403,7 @@ static void test_get_resv_persist(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_resv_persist(&cmd, TEST_NSID, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1429,7 +1429,7 @@ static void test_set_write_protect(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_write_protect(&cmd, TEST_NSID, true, STATE); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1450,7 +1450,7 @@ static void test_get_write_protect(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_write_protect(&cmd, TEST_NSID, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d", err); check(cmd.result == TEST_RESULT, @@ -1478,7 +1478,7 @@ static void test_set_status_code_error(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_async_event(&cmd, false, EVENTS); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == TEST_SC, "got error %d, expected %d", err, TEST_SC); check(cmd.result == TEST_RESULT, @@ -1502,7 +1502,7 @@ static void test_set_kernel_error(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_features_resv_mask(&cmd, TEST_NSID, false, MASK); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == -EIO, "got error %d, expected -EIO", err); check(!cmd.result, @@ -1527,7 +1527,7 @@ static void test_get_status_code_error(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_kato(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == TEST_SC, "got error %d, expected %d", err, TEST_SC); check(cmd.result == TEST_RESULT, @@ -1548,7 +1548,7 @@ static void test_get_kernel_error(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_features_num_queues(&cmd, TEST_SEL); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == -EBUSY, "got error %d, expected -EBUSY", err); check(!cmd.result, @@ -1574,7 +1574,7 @@ static void test_lm_set_features_ctrl_data_queue(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lm_set_features_ctrl_data_queue(&cmd, TEST_CDQID, hp, tpt, etpt); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "set features returned error %d, errno %m", err); check(cmd.result == TEST_RESULT, @@ -1601,7 +1601,7 @@ static void test_lm_get_features_ctrl_data_queue(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lm_get_features_ctrl_data_queue(&cmd, TEST_SEL, TEST_CDQID, &data); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "get features returned error %d, errno %m", err); check(cmd.result == TEST_RESULT, @@ -1623,10 +1623,10 @@ static void run_test(const char *test_name, void (*test_fn)(void)) int main(void) { struct nvme_global_ctx *ctx = - nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); set_mock_fd(TEST_FD); - check(!nvme_open(ctx, "NVME_TEST_FD64", &test_hdl), + check(!libnvme_open(ctx, "NVME_TEST_FD64", &test_hdl), "opening test link failed"); RUN_TEST(set_features); @@ -1698,5 +1698,5 @@ int main(void) RUN_TEST(lm_set_features_ctrl_data_queue); RUN_TEST(lm_get_features_ctrl_data_queue); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); } diff --git a/libnvme/test/ioctl/identify.c b/libnvme/test/ioctl/identify.c index cdafd22b1e..fdd9e9193b 100644 --- a/libnvme/test/ioctl/identify.c +++ b/libnvme/test/ioctl/identify.c @@ -37,7 +37,7 @@ static void test_ns(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ns(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d, errno %m", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -58,7 +58,7 @@ static void test_ctrl(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ctrl(&cmd, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -80,7 +80,7 @@ static void test_active_ns_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_active_ns_list(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -105,7 +105,7 @@ static void test_ns_descs(void) check(id, "memory allocation failed"); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ns_descs_list(&cmd, TEST_NSID, id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(id, expected_id, sizeof(expected_id), "incorrect identify data"); @@ -128,7 +128,7 @@ static void test_nvmset_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_nvmset_list(&cmd, NVME_NSID_NONE, TEST_NVMSETID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -153,7 +153,7 @@ static void test_ns_csi(void) arbitrary(expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_csi_ns(&cmd, TEST_NSID, TEST_CSI, TEST_UUID, id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(id, expected_id, sizeof(id), "incorrect identify data"); @@ -176,7 +176,7 @@ static void test_zns_identify_ns(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_zns_identify_ns(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -198,7 +198,7 @@ static void test_nvm_identify_ctrl(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_csi_ctrl(&cmd, NVME_CSI_NVM, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -220,7 +220,7 @@ static void test_zns_identify_ctrl(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_zns_identify_ctrl(&cmd, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -243,7 +243,7 @@ static void test_active_ns_list_csi(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_csi_active_ns_list(&cmd, TEST_NSID, TEST_CSI, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -266,7 +266,7 @@ static void test_independent_identify_ns(void) set_mock_admin_cmds(&mock_admin_cmd, 1); /* That's a mouthful! */ nvme_init_identify_csi_independent_identify_id_ns(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -288,7 +288,7 @@ static void test_allocated_ns_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_allocated_ns_list(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -310,7 +310,7 @@ static void test_allocated_ns(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_allocated_ns(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -333,7 +333,7 @@ static void test_nsid_ctrl_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ns_ctrl_list(&cmd, TEST_NSID, TEST_CNTID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -355,7 +355,7 @@ static void test_ctrl_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ctrl_list(&cmd, TEST_CNTID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -377,7 +377,7 @@ static void test_primary_ctrl(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_primary_ctrl_cap(&cmd, TEST_CNTID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -399,7 +399,7 @@ static void test_secondary_ctrl_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_secondary_ctrl_list(&cmd, TEST_CNTID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -420,7 +420,7 @@ static void test_ns_granularity(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ns_granularity(&cmd, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -441,7 +441,7 @@ static void test_uuid(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_uuid_list(&cmd, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -463,7 +463,7 @@ static void test_domain_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_domain_list(&cmd, TEST_DOMID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -485,7 +485,7 @@ static void test_endurance_group_list(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_endurance_group_id(&cmd, TEST_ENDGID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -508,7 +508,7 @@ static void test_allocated_ns_list_csi(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_csi_allocated_ns_list(&cmd, TEST_NSID, TEST_CSI, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -530,7 +530,7 @@ static void test_iocs(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_command_set_structure(&cmd, TEST_CNTID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -556,7 +556,7 @@ static void test_status_code_error(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_nvmset_list(&cmd, NVME_NSID_NONE, TEST_NVMSETID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == TEST_SC, "got error %d, expected TEST_SC", err); } @@ -576,7 +576,7 @@ static void test_kernel_error(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ns(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == -EIO, "got error %d, expected -EIO", err); } @@ -601,7 +601,7 @@ static void test_identify_ns_csi_user_data_format(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_ns_user_data_format(&cmd, NVME_CSI_NVM, TEST_FIDX, TEST_UUID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d, errno %m", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -626,7 +626,7 @@ static void test_identify_iocs_ns_csi_user_data_format(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_identify_csi_ns_user_data_format(&cmd, TEST_CSI, TEST_FIDX, TEST_UUID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "identify returned error %d, errno %m", err); cmp(&id, &expected_id, sizeof(id), "incorrect identify data"); @@ -645,10 +645,10 @@ static void run_test(const char *test_name, void (*test_fn)(void)) int main(void) { struct nvme_global_ctx * ctx = - nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); set_mock_fd(TEST_FD); - check(!nvme_open(ctx, "NVME_TEST_FD", &test_hdl), + check(!libnvme_open(ctx, "NVME_TEST_FD", &test_hdl), "opening test link failed"); RUN_TEST(ns); @@ -679,5 +679,5 @@ int main(void) RUN_TEST(identify_ns_csi_user_data_format); RUN_TEST(identify_iocs_ns_csi_user_data_format); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); } diff --git a/libnvme/test/ioctl/logs.c b/libnvme/test/ioctl/logs.c index b048a3df98..e61a927b4d 100644 --- a/libnvme/test/ioctl/logs.c +++ b/libnvme/test/ioctl/logs.c @@ -1103,10 +1103,10 @@ static void run_test(const char *test_name, void (*test_fn)(void)) int main(void) { struct nvme_global_ctx * ctx = - nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); set_mock_fd(TEST_FD); - check(!nvme_open(ctx, "NVME_TEST_FD", &test_hdl), + check(!libnvme_open(ctx, "NVME_TEST_FD", &test_hdl), "opening test link failed"); RUN_TEST(get_log_sanitize); @@ -1153,5 +1153,5 @@ int main(void) RUN_TEST(get_log_persistent_event); RUN_TEST(get_log_lockdown); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); } diff --git a/libnvme/test/ioctl/misc.c b/libnvme/test/ioctl/misc.c index b6dc618dd3..c6fb15ffb2 100644 --- a/libnvme/test/ioctl/misc.c +++ b/libnvme/test/ioctl/misc.c @@ -35,7 +35,7 @@ static void test_format_nvm(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_format_nvm(&cmd, nsid, lbaf, mset, pi, pil, ses); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -62,7 +62,7 @@ static void test_ns_mgmt(void) arbitrary(&expected_data, sizeof(expected_data)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_ns_mgmt(&cmd, nsid, sel, csi, &data); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -90,7 +90,7 @@ static void test_ns_mgmt_create(void) arbitrary(&expected_data, sizeof(expected_data)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_ns_mgmt_create(&cmd, NVME_CSI_ZNS, &data); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == TEST_NSID, @@ -110,7 +110,7 @@ static void test_ns_mgmt_delete(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_ns_mgmt_delete(&cmd, TEST_NSID); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } @@ -131,7 +131,7 @@ static void test_get_property(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_property(&cmd, NVME_REG_ACQ); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == expected_result, "returned wrong result"); @@ -153,7 +153,7 @@ static void test_set_property(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_set_property(&cmd, NVME_REG_BPMBL, value); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -177,7 +177,7 @@ static void test_ns_attach(void) arbitrary(&expected_ctrlist, sizeof(expected_ctrlist)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_ns_attach(&cmd, nsid, sel, &ctrlist); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -201,7 +201,7 @@ static void test_ns_attach_ctrls(void) arbitrary(&ctrlist, sizeof(ctrlist)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_ns_attach_ctrls(&cmd, TEST_NSID, &ctrlist); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } @@ -222,7 +222,7 @@ static void test_ns_detach_ctrls(void) arbitrary(&ctrlist, sizeof(ctrlist)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_ns_detach_ctrls(&cmd, TEST_NSID, &ctrlist); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } @@ -247,7 +247,7 @@ static void test_fw_download(void) set_mock_admin_cmds(&mock_admin_cmd, 1); err = nvme_init_fw_download(&cmd, data, data_len, offset); check(err == 0, "download initializing error %d", err); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -268,7 +268,7 @@ static void test_fw_commit(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_fw_commit(&cmd, slot, action, bpid); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -299,7 +299,7 @@ static void test_security_send(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_security_send(&cmd, nsid, nssf, spsp, secp, tl, data, data_len); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -328,7 +328,7 @@ static void test_security_receive(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_security_receive(&cmd, TEST_NSID, nssf, spsp, secp, al, data, sizeof(data)); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -370,7 +370,7 @@ static void test_get_lba_status(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_get_lba_status(&cmd, TEST_NSID, slba, mndw, atype, rl, lbas); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned wrong result"); @@ -401,7 +401,7 @@ static void test_directive_send(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_send(&cmd, TEST_NSID, doper, dtype, dspec, expected_data, data_len); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned wrong result"); @@ -429,7 +429,7 @@ static void test_directive_send_id_endir(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_send_id_endir(&cmd, TEST_NSID, true, NVME_DIRECTIVE_DTYPE_STREAMS, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect id"); @@ -451,7 +451,7 @@ static void test_directive_send_stream_release_identifier(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_send_stream_release_identifier(&cmd, TEST_NSID, stream_id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } @@ -469,7 +469,7 @@ static void test_directive_send_stream_release_resource(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_send_stream_release_resource(&cmd, TEST_NSID); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } @@ -496,7 +496,7 @@ static void test_directive_recv(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_recv(&cmd, TEST_NSID, doper, dtype, dspec, data, data_len); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned wrong result"); @@ -521,7 +521,7 @@ static void test_directive_recv_identify_parameters(void) arbitrary(&expected_id, sizeof(expected_id)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_recv_identify_parameters(&cmd, TEST_NSID, &id); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(&id, &expected_id, sizeof(id), "incorrect id"); @@ -545,7 +545,7 @@ static void test_directive_recv_stream_parameters(void) arbitrary(&expected_params, sizeof(expected_params)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_recv_stream_parameters(&cmd, TEST_NSID, ¶ms); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(¶ms, &expected_params, sizeof(params), "incorrect params"); @@ -583,7 +583,7 @@ static void test_directive_recv_stream_status(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_recv_stream_status(&cmd, TEST_NSID, nr_entries, status); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(status, expected_status, stream_status_size, "incorrect status"); @@ -606,7 +606,7 @@ static void test_directive_recv_stream_allocate(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_directive_recv_stream_allocate(&cmd, TEST_NSID, nsr); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == expected_result, "wrong result"); @@ -631,7 +631,7 @@ void test_capacity_mgmt(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_capacity_mgmt(&cmd, op, elid, cap); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == expected_result, "wrong result"); @@ -657,7 +657,7 @@ static void test_lockdown(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lockdown(&cmd, scp, prhbt, ifc, ofi, uuidx); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == expected_result, "wrong result"); @@ -687,7 +687,7 @@ static void test_sanitize_nvm(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_sanitize_nvm(&cmd, sanact, ause, owpass, oipbp, ndas, emvs, ovrpat); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == expected_result, "wrong result"); @@ -707,7 +707,7 @@ static void test_dev_self_test(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_dev_self_test(&cmd, TEST_NSID, NVME_DST_STC_ABORT); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == expected_result, "wrong result"); @@ -731,7 +731,7 @@ static void test_virtual_mgmt(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_virtual_mgmt(&cmd, act, rt, cntlid, nr); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == expected_result, "wrong result"); @@ -748,7 +748,7 @@ static void test_flush(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_flush(&cmd, TEST_NSID); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } @@ -781,7 +781,7 @@ static void test_read(void) nvme_init_read(&cmd, TEST_NSID, slba, nlb, control, dsm, 0, data, sizeof(data), NULL, 0); nvme_init_app_tag(&cmd, apptag, appmask); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -816,7 +816,7 @@ static void test_write(void) nvme_init_write(&cmd, TEST_NSID, slba, nlb, control, dspec, dsm, 0, expected_data, sizeof(expected_data), NULL, 0); nvme_init_app_tag(&cmd, apptag, appmask); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -850,7 +850,7 @@ static void test_compare(void) nvme_init_compare(&cmd, TEST_NSID, slba, nlb, control, cev, data, sizeof(data), NULL, 0); nvme_init_app_tag(&cmd, apptag, appmask); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -882,7 +882,7 @@ static void test_write_zeros(void) nvme_init_write_zeros(&cmd, TEST_NSID, slba, nlb, control, dspec, dsm, cev); nvme_init_app_tag(&cmd, apptag, appmask); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -913,7 +913,7 @@ static void test_write_uncorrectable(void) nvme_init_write_uncorrectable(&cmd, TEST_NSID, slba, nlb, control, dspec); nvme_init_app_tag(&cmd, apptag, appmask); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -943,7 +943,7 @@ static void test_verify(void) nvme_init_verify(&cmd, TEST_NSID, slba, nlb, control, cev, NULL, 0, NULL, 0); nvme_init_app_tag(&cmd, apptag, appmask); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -974,7 +974,7 @@ static void test_dsm(void) arbitrary(dsm, dsm_size); set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_dsm(&cmd, TEST_NSID, nr_ranges, 0, 0, 1, dsm, dsm_size); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -1027,7 +1027,7 @@ static void test_copy(void) nvme_init_copy(&cmd, TEST_NSID, sdlba, nr, desfmt, prinfor, prinfow, cetype, dtype, stcw, stcr, fua, lr, cev, dspec, (void *)copy); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -1054,7 +1054,7 @@ static void test_resv_acquire(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_resv_acquire(&cmd, TEST_NSID, racqa, iekey, false, rtype, 1, 2, payload); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -1081,7 +1081,7 @@ static void test_resv_register(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_resv_register(&cmd, TEST_NSID, rrega, iekey, false, cptpl, 0xffffffffffffffff, 0, payload); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -1108,7 +1108,7 @@ static void test_resv_release(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_resv_release(&cmd, TEST_NSID, rrela, iekey, false, rtype, 0xffffffffffffffff, payload); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -1134,7 +1134,7 @@ static void test_resv_report(void) arbitrary(&expected_status, sizeof(expected_status)); set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_resv_report(&cmd, TEST_NSID, eds, disnsrs, &status, len); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -1161,7 +1161,7 @@ static void test_io_mgmt_recv(void) arbitrary(&expected_data, sizeof(expected_data)); set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_io_mgmt_recv(&cmd, TEST_NSID, mo, mos, data, data_len); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(&data, &expected_data, sizeof(data), "incorrect data"); @@ -1187,7 +1187,7 @@ static void test_io_mgmt_send(void) memcpy(&data, &expected_data, sizeof(expected_data)); set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_io_mgmt_send(&cmd, TEST_NSID, mo, mos, data, data_len); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(&data, &expected_data, sizeof(data), "incorrect data"); @@ -1212,7 +1212,7 @@ static void test_fdp_reclaim_unit_handle_status(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_fdp_reclaim_unit_handle_status(&cmd, TEST_NSID, &data, data_len); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); cmp(&data, &expected_data, sizeof(data), "incorrect data"); @@ -1235,7 +1235,7 @@ static void test_fdp_reclaim_unit_handle_update(void) arbitrary(&pids, sizeof(pids)); set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_fdp_reclaim_unit_handle_update(&cmd, TEST_NSID, &pids, npids); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); } @@ -1258,7 +1258,7 @@ static void test_dim_send(void) memcpy(&data, &expected_data, sizeof(expected_data)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_dim_send(&cmd, tas, data, data_len); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -1287,7 +1287,7 @@ static void test_lm_cdq_delete(void) memcpy(&data, &expected_data, sizeof(expected_data)); set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lm_cdq_delete(&cmd, mos, cdqid); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -1309,7 +1309,7 @@ static void test_lm_track_send(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lm_track_send(&cmd, sel, mos, cdqid); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -1347,7 +1347,7 @@ static void test_lm_migration_send(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lm_migration_send(&cmd, sel, mos, cntlid, stype, dudmq, csvi, csuuidi, offset, uidx, &data, sizeof(data)); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -1384,7 +1384,7 @@ static void test_lm_migration_recv(void) set_mock_admin_cmds(&mock_admin_cmd, 1); nvme_init_lm_migration_recv(&cmd, offset, mos, cntlid, csuuidi, sel, uidx, csuidxp, data, sizeof(data)); - err = nvme_submit_admin_passthru(test_hdl, &cmd); + err = libnvme_submit_admin_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(cmd.result == 0, "returned result %" PRIu64, (uint64_t)cmd.result); @@ -1404,10 +1404,10 @@ static void run_test(const char *test_name, void (*test_fn)(void)) int main(void) { struct nvme_global_ctx *ctx = - nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); set_mock_fd(TEST_FD); - check(!nvme_open(ctx, "NVME_TEST_FD64", &test_hdl), + check(!libnvme_open(ctx, "NVME_TEST_FD64", &test_hdl), "opening test link failed"); RUN_TEST(format_nvm); @@ -1461,5 +1461,5 @@ int main(void) RUN_TEST(lm_migration_send); RUN_TEST(lm_migration_recv); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); } diff --git a/libnvme/test/ioctl/zns.c b/libnvme/test/ioctl/zns.c index b5cf859f96..d7f9ef5e3f 100644 --- a/libnvme/test/ioctl/zns.c +++ b/libnvme/test/ioctl/zns.c @@ -51,7 +51,7 @@ static void test_zns_append(void) if (elbas) nvme_init_var_size_tags(&cmd, pif, sts, reftag, storage_tag); nvme_init_app_tag(&cmd, lbat, lbatm); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(result == 0, "wrong result"); @@ -82,7 +82,7 @@ static void test_zns_report_zones(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_zns_report_zones(&cmd, TEST_NSID, TEST_SLBA, opts, extended, partial, &data, sizeof(data)); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(result == 0, "returned result %"PRIu64, (uint64_t)result); @@ -114,7 +114,7 @@ static void test_zns_mgmt_send(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_zns_mgmt_send(&cmd, TEST_NSID, slba, zsa, select_all, zsaso, false, data, sizeof(data)); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(result == 0, "returned result %"PRIu64, (uint64_t)result); @@ -143,7 +143,7 @@ static void test_zns_mgmt_recv(void) set_mock_io_cmds(&mock_io_cmd, 1); nvme_init_zns_mgmt_recv(&cmd, TEST_NSID, 0, zra, zrasf, zras_feat, data, sizeof(data)); - err = nvme_submit_io_passthru(test_hdl, &cmd); + err = libnvme_submit_io_passthru(test_hdl, &cmd); end_mock_cmds(); check(err == 0, "returned error %d", err); check(result == 0, "returned result %"PRIu64, (uint64_t)result); @@ -163,10 +163,10 @@ static void run_test(const char *test_name, void (*test_fn)(void)) int main(void) { struct nvme_global_ctx *ctx = - nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); set_mock_fd(TEST_FD); - check(!nvme_open(ctx, "NVME_TEST_FD", &test_hdl), + check(!libnvme_open(ctx, "NVME_TEST_FD", &test_hdl), "opening test link failed"); RUN_TEST(zns_append); @@ -174,5 +174,5 @@ int main(void) RUN_TEST(zns_mgmt_send); RUN_TEST(zns_mgmt_recv); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); } diff --git a/libnvme/test/mi-mctp.c b/libnvme/test/mi-mctp.c index c666b0119d..22bd4c74e1 100644 --- a/libnvme/test/mi-mctp.c +++ b/libnvme/test/mi-mctp.c @@ -244,7 +244,7 @@ static void test_rx_err(nvme_mi_ep_t ep, struct test_peer *peer) peer->rx_rc = -1; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); } @@ -261,7 +261,7 @@ static void test_tx_none(nvme_mi_ep_t ep, struct test_peer *peer) peer->tx_buf_len = 0; peer->tx_fn = tx_none; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); } @@ -272,7 +272,7 @@ static void test_tx_err(nvme_mi_ep_t ep, struct test_peer *peer) peer->tx_rc = -1; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); } @@ -283,7 +283,7 @@ static void test_tx_short(nvme_mi_ep_t ep, struct test_peer *peer) peer->tx_buf_len = 11; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); } @@ -300,7 +300,7 @@ static void test_poll_err(nvme_mi_ep_t ep, struct test_peer *peer) peer->poll_fn = poll_fn_err; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); } @@ -312,7 +312,7 @@ static void test_read_mi_data(nvme_mi_ep_t ep, struct test_peer *peer) /* empty response data */ peer->tx_buf_len = 8 + 32; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc == 0); } @@ -325,7 +325,7 @@ static void test_mi_resp_err(nvme_mi_ep_t ep, struct test_peer *peer) peer->tx_buf[4] = 0x02; /* internal error */ peer->tx_buf_len = 8; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc == 0x2); } @@ -359,7 +359,7 @@ static void test_mi_resp_unaligned(nvme_mi_ep_t ep, struct test_peer *peer) memset(&list, 0, sizeof(list)); - rc = nvme_mi_mi_read_mi_data_ctrl_list(ep, 0, &list); + rc = libnvme_mi_mi_read_mi_data_ctrl_list(ep, 0, &list); assert(rc == 0); assert(le16_to_cpu(list.num) == 2); @@ -419,7 +419,7 @@ static void test_admin_resp_err(nvme_mi_ep_t ep, struct test_peer *peer) struct nvme_id_ctrl id; int rc; - hdl = nvme_mi_init_transport_handle(ep, 1); + hdl = libnvme_mi_init_transport_handle(ep, 1); assert(hdl); /* Simple error response, will be shorter than the expected Admin @@ -428,7 +428,7 @@ static void test_admin_resp_err(nvme_mi_ep_t ep, struct test_peer *peer) peer->tx_buf_len = 8; nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(nvme_status_get_type(rc) == NVME_STATUS_TYPE_MI); assert(nvme_status_get_value(rc) == NVME_MI_RESP_INTERNAL_ERR); } @@ -447,7 +447,7 @@ static void test_admin_resp_sizes(nvme_mi_ep_t ep, struct test_peer *peer) unsigned int i; int rc; - hdl = nvme_mi_init_transport_handle(ep, 1); + hdl = libnvme_mi_init_transport_handle(ep, 1); assert(hdl); peer->tx_buf[4] = 0x02; /* internal error */ @@ -455,12 +455,12 @@ static void test_admin_resp_sizes(nvme_mi_ep_t ep, struct test_peer *peer) for (i = 8; i <= 4096 + 8; i+=4) { peer->tx_buf_len = i; nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(nvme_status_get_type(rc) == NVME_STATUS_TYPE_MI); assert(nvme_status_get_value(rc) == NVME_MI_RESP_INTERNAL_ERR); } - nvme_close(hdl); + libnvme_close(hdl); } /* test: timeout value passed to poll */ @@ -480,9 +480,9 @@ static void test_poll_timeout_value(nvme_mi_ep_t ep, struct test_peer *peer) peer->tx_buf_len = 8 + 32; peer->poll_fn = poll_fn_timeout_value; - nvme_mi_ep_set_timeout(ep, 3141); + libnvme_mi_ep_set_timeout(ep, 3141); - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc == 0); } @@ -500,7 +500,7 @@ static void test_poll_timeout(nvme_mi_ep_t ep, struct test_peer *peer) peer->poll_fn = poll_fn_timeout; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); assert(errno == ETIMEDOUT); } @@ -558,7 +558,7 @@ static void test_mpr_mi(nvme_mi_ep_t ep, struct test_peer *peer) peer->tx_fn = tx_mpr; peer->tx_data = &tx_info; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc == 0); } @@ -577,13 +577,13 @@ static void test_mpr_admin(nvme_mi_ep_t ep, struct test_peer *peer) peer->tx_fn = tx_mpr; peer->tx_data = &tx_info; - hdl = nvme_mi_init_transport_handle(ep, 1); + hdl = libnvme_mi_init_transport_handle(ep, 1); nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(rc == 0); - nvme_close(hdl); + libnvme_close(hdl); } /* We have seen drives that send a MPR response as a full Admin message, @@ -604,13 +604,13 @@ static void test_mpr_admin_quirked(nvme_mi_ep_t ep, struct test_peer *peer) peer->tx_fn = tx_mpr; peer->tx_data = &tx_info; - hdl = nvme_mi_init_transport_handle(ep, 1); + hdl = libnvme_mi_init_transport_handle(ep, 1); nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(rc == 0); - nvme_close(hdl); + libnvme_close(hdl); } /* helpers for the MPR + poll tests */ @@ -681,7 +681,7 @@ static void test_mpr_timeouts(nvme_mi_ep_t ep, struct test_peer *peer) struct mpr_tx_info tx_info; int rc; - nvme_mi_ep_set_timeout(ep, 3141); + libnvme_mi_ep_set_timeout(ep, 3141); tx_info.msg_no = 1; tx_info.final_len = sizeof(struct nvme_mi_mi_resp_hdr) + sizeof(ss_info); @@ -697,7 +697,7 @@ static void test_mpr_timeouts(nvme_mi_ep_t ep, struct test_peer *peer) peer->poll_fn = poll_fn_mpr_poll; peer->poll_data = &poll_info; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc == 0); } @@ -709,8 +709,8 @@ static void test_mpr_timeout_clamp(nvme_mi_ep_t ep, struct test_peer *peer) struct mpr_tx_info tx_info; int rc; - nvme_mi_ep_set_timeout(ep, 3141); - nvme_mi_ep_set_mprt_max(ep, 123400); + libnvme_mi_ep_set_timeout(ep, 3141); + libnvme_mi_ep_set_mprt_max(ep, 123400); tx_info.msg_no = 1; tx_info.final_len = sizeof(struct nvme_mi_mi_resp_hdr) + sizeof(ss_info); @@ -726,7 +726,7 @@ static void test_mpr_timeout_clamp(nvme_mi_ep_t ep, struct test_peer *peer) peer->poll_fn = poll_fn_mpr_poll; peer->poll_data = &poll_info; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc == 0); } @@ -738,8 +738,8 @@ static void test_mpr_mprt_zero(nvme_mi_ep_t ep, struct test_peer *peer) struct mpr_tx_info tx_info; int rc; - nvme_mi_ep_set_timeout(ep, 3141); - nvme_mi_ep_set_mprt_max(ep, 123400); + libnvme_mi_ep_set_timeout(ep, 3141); + libnvme_mi_ep_set_mprt_max(ep, 123400); tx_info.msg_no = 1; tx_info.final_len = sizeof(struct nvme_mi_mi_resp_hdr) + sizeof(ss_info); @@ -755,7 +755,7 @@ static void test_mpr_mprt_zero(nvme_mi_ep_t ep, struct test_peer *peer) peer->poll_fn = poll_fn_mpr_poll; peer->poll_data = &poll_info; - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc == 0); } @@ -868,7 +868,7 @@ static void populate_tx_occ_list(bool aem_not_ack, } } - nvme_mi_aem_aeolli_set_aeoltl(list_hdr, aeoltl); + libnvme_mi_aem_aeolli_set_aeoltl(list_hdr, aeoltl); test_peer.tx_buf_len = hdr_len + aeoltl; if ((fn_data->fc == AEM_FC_BAD_OCC_RSP_BUFFER_LEN_SYNC && !aem_not_ack) || @@ -915,8 +915,8 @@ static void check_aem_sync_message(struct nvme_mi_aem_enabled_map *expected_mask bool found = false; for (int j = 0; j < count; j++) { - if (nvme_mi_aem_aesi_get_aesid(item[j].aesi) == i && - nvme_mi_aem_aesi_get_aese(item[j].aesi) == + if (libnvme_mi_aem_aesi_get_aesid(item[j].aesi) == i && + libnvme_mi_aem_aesi_get_aese(item[j].aesi) == expected_state->enabled[i]) { found = true; break; @@ -965,8 +965,8 @@ static int aem_rcv_enable_fn(struct test_peer *peer, void *buf, size_t len, int for (int i = 0; i < 256; i++) { if (fn_data->ep_enabled_map.enabled[i]) { list_hdr->numaes++; - nvme_mi_aem_aesi_set_aesid(&item[item_count], i); - nvme_mi_aem_aesi_set_aee(&item[item_count], 1); + libnvme_mi_aem_aesi_set_aesid(&item[item_count], i); + libnvme_mi_aem_aesi_set_aee(&item[item_count], 1); item[item_count].aesl = sizeof(struct nvme_mi_aem_supported_item); item_count++; @@ -1005,10 +1005,10 @@ static int aem_rcv_enable_fn(struct test_peer *peer, void *buf, size_t len, int list_hdr->aelver = 0; list_hdr->aeolhl = sizeof(*list_hdr); list_hdr->numaeo = 0; - nvme_mi_aem_aeolli_set_aeoltl(list_hdr, list_hdr->aeolhl); + libnvme_mi_aem_aeolli_set_aeoltl(list_hdr, list_hdr->aeolhl); test_peer.tx_buf_len = sizeof(struct nvme_mi_mi_resp_hdr) + - nvme_mi_aem_aeolli_get_aeoltl(list_hdr->aeolli); + libnvme_mi_aem_aeolli_get_aeoltl(list_hdr->aeolli); test_set_tx_mic(&test_peer); @@ -1052,7 +1052,7 @@ static int aem_rcv_enable_fn(struct test_peer *peer, void *buf, size_t len, int return 0; } -enum nvme_mi_aem_handler_next_action aem_handler(nvme_mi_ep_t ep, size_t num_events, void *userdata) +enum libnvme_mi_aem_handler_next_action aem_handler(nvme_mi_ep_t ep, size_t num_events, void *userdata) { struct aem_rcv_enable_fn_data *fn_data = userdata; @@ -1089,7 +1089,7 @@ enum nvme_mi_aem_handler_next_action aem_handler(nvme_mi_ep_t ep, size_t num_eve assert(num_events == item_count); for (int i = 0; i < num_events; i++) { - struct nvme_mi_event *e = nvme_mi_aem_get_next_event(ep); + struct nvme_mi_event *e = libnvme_mi_aem_get_next_event(ep); uint8_t idx = e->aeoi; assert(fn_data->events[idx]); @@ -1106,7 +1106,7 @@ enum nvme_mi_aem_handler_next_action aem_handler(nvme_mi_ep_t ep, size_t num_eve e->vend_spec_info, e->vend_spec_info_len) == 0); } - assert(nvme_mi_aem_get_next_event(ep) == NULL); + assert(libnvme_mi_aem_get_next_event(ep) == NULL); break; } default: @@ -1126,22 +1126,22 @@ static void aem_test_aem_api_helper(nvme_mi_ep_t ep, test_peer.tx_fn = aem_rcv_enable_fn; //This should not work outside the handler - assert(nvme_mi_aem_get_next_event(ep) == NULL); + assert(libnvme_mi_aem_get_next_event(ep) == NULL); - rc = nvme_mi_aem_enable(ep, config, test_peer.tx_data); + rc = libnvme_mi_aem_enable(ep, config, test_peer.tx_data); assert(rc == 0); //This should not work outside the handler - assert(nvme_mi_aem_get_next_event(ep) == NULL); + assert(libnvme_mi_aem_get_next_event(ep) == NULL); - rc = nvme_mi_aem_process(ep, test_peer.tx_data); + rc = libnvme_mi_aem_process(ep, test_peer.tx_data); assert(rc == 0); //One for initial enable, one for AEM. No ACK events assert(fn_data->callback_count == expected_event_count); //This should not work outside the handler - assert(nvme_mi_aem_get_next_event(ep) == NULL); + assert(libnvme_mi_aem_get_next_event(ep) == NULL); } static void aem_test_aem_disable_helper(nvme_mi_ep_t ep, @@ -1151,7 +1151,7 @@ static void aem_test_aem_disable_helper(nvme_mi_ep_t ep, sizeof(fn_data->host_enabled_map)); fn_data->state = AEM_ES_GET_ENABLED;//This is the flow for disabling - assert(nvme_mi_aem_disable(ep) == 0); + assert(libnvme_mi_aem_disable(ep) == 0); } static void test_mi_aem_ep_based_failure_helper(nvme_mi_ep_t ep, @@ -1185,14 +1185,14 @@ static void test_mi_aem_ep_based_failure_helper(nvme_mi_ep_t ep, case AEM_FC_BAD_OCC_RSP_TOTAL_LEN_SYNC: case AEM_FC_BAD_OCC_RSP_BUFFER_LEN_SYNC: //These all should fail before processing - assert(nvme_mi_aem_enable(ep, &config, &fn_data) == -EPROTO); + assert(libnvme_mi_aem_enable(ep, &config, &fn_data) == -EPROTO); break; case AEM_FC_BAD_OCC_RSP_HDR_LEN_AEM: case AEM_FC_BAD_OCC_RSP_TOTAL_LEN_AEM: case AEM_FC_BAD_OCC_RSP_BUFFER_LEN_AEM: //These should fail on the processing - assert(nvme_mi_aem_enable(ep, &config, &fn_data) == 0); - assert(nvme_mi_aem_process(ep, &fn_data) == -EPROTO); + assert(libnvme_mi_aem_enable(ep, &config, &fn_data) == 0); + assert(libnvme_mi_aem_process(ep, &fn_data) == -EPROTO); break; default: assert(false);//Unexpected @@ -1224,46 +1224,46 @@ static void test_mi_aem_enable_invalid_usage(nvme_mi_ep_t ep, struct test_peer * config.aerd = 2; //Call with invalid config due to nothing enabled - assert(nvme_mi_aem_enable(ep, &config, NULL) == -1); + assert(libnvme_mi_aem_enable(ep, &config, NULL) == -1); config.aem_handler = NULL; config.enabled_map.enabled[0] = true; //Call with invalid config due to no callback - assert(nvme_mi_aem_enable(ep, &config, NULL) == -1); + assert(libnvme_mi_aem_enable(ep, &config, NULL) == -1); //Call with invalid config due to being NULL - assert(nvme_mi_aem_enable(ep, NULL, NULL) == -1); + assert(libnvme_mi_aem_enable(ep, NULL, NULL) == -1); config.aem_handler = aem_handler; config.enabled_map.enabled[0] = true; //Call with invalid endpoint - assert(nvme_mi_aem_enable(NULL, &config, NULL) == -1); + assert(libnvme_mi_aem_enable(NULL, &config, NULL) == -1); } /* test: Check aem process logic when API used improperly */ static void test_mi_aem_process_invalid_usage(nvme_mi_ep_t ep, struct test_peer *peer) { //Without calling enable first - assert(nvme_mi_aem_process(ep, NULL) == -1); + assert(libnvme_mi_aem_process(ep, NULL) == -1); //Call with invalid ep - assert(nvme_mi_aem_process(NULL, NULL) == -1); + assert(libnvme_mi_aem_process(NULL, NULL) == -1); } /* test: Check aem disable logic when API used improperly */ static void test_mi_aem_disable_invalid_usage(nvme_mi_ep_t ep, struct test_peer *peer) { - assert(nvme_mi_aem_disable(NULL) == -1); + assert(libnvme_mi_aem_disable(NULL) == -1); } static void test_mi_aem_get_enabled_invalid_usage(nvme_mi_ep_t ep, struct test_peer *peer) { struct nvme_mi_aem_enabled_map map; - assert(nvme_mi_aem_get_enabled(ep, NULL) == -1); - assert(nvme_mi_aem_get_enabled(NULL, &map) == -1); + assert(libnvme_mi_aem_get_enabled(ep, NULL) == -1); + assert(libnvme_mi_aem_get_enabled(NULL, &map) == -1); } /* test: Check aem get enabled logic*/ @@ -1280,7 +1280,7 @@ static void test_mi_aem_get_enabled(nvme_mi_ep_t ep, struct test_peer *peer) fn_data.ep_enabled_map.enabled[51] = true; fn_data.ep_enabled_map.enabled[255] = true; - assert(nvme_mi_aem_get_enabled(ep, &map) == 0); + assert(libnvme_mi_aem_get_enabled(ep, &map) == 0); assert(memcmp(&fn_data.ep_enabled_map, &map, sizeof(map)) == 0); } @@ -1462,10 +1462,10 @@ int main(void) __nvme_mi_mctp_set_ops(&ops); - ctx = nvme_create_global_ctx(fd, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(fd, DEFAULT_LOGLEVEL); assert(ctx); - ep = nvme_mi_open_mctp(ctx, 0, 0); + ep = libnvme_mi_open_mctp(ctx, 0, 0); assert(ep); for (i = 0; i < ARRAY_SIZE(tests); i++) { @@ -1473,8 +1473,8 @@ int main(void) run_test(&tests[i], fd, ep, &test_peer); } - nvme_mi_close(ep); - nvme_free_global_ctx(ctx); + libnvme_mi_close(ep); + libnvme_free_global_ctx(ctx); test_close_log(fd); diff --git a/libnvme/test/mi.c b/libnvme/test/mi.c index 3a890bc716..184d3cf9a4 100644 --- a/libnvme/test/mi.c +++ b/libnvme/test/mi.c @@ -140,7 +140,7 @@ unsigned int count_root_eps(struct nvme_global_ctx *ctx) unsigned int i = 0; nvme_mi_ep_t ep; - nvme_mi_for_each_endpoint(ctx, ep) + libnvme_mi_for_each_endpoint(ctx, ep) i++; return i; @@ -161,7 +161,7 @@ static void test_endpoint_lifetime(nvme_mi_ep_t ep) count = count_root_eps(ctx); assert(count == 2); - nvme_mi_close(ep2); + libnvme_mi_close(ep2); count = count_root_eps(ctx); assert(count == 1); } @@ -171,7 +171,7 @@ unsigned int count_ep_controllers(nvme_mi_ep_t ep) struct nvme_transport_handle *hdl; unsigned int i = 0; - nvme_mi_for_each_transport_handle(ep, hdl) + libnvme_mi_for_each_transport_handle(ep, hdl) i++; return i; @@ -189,19 +189,19 @@ static void test_ctrl_lifetime(nvme_mi_ep_t ep) count = count_ep_controllers(ep); assert(count == 0); - hdl1 = nvme_mi_init_transport_handle(ep, 1); + hdl1 = libnvme_mi_init_transport_handle(ep, 1); count = count_ep_controllers(ep); assert(count == 1); - hdl2 = nvme_mi_init_transport_handle(ep, 2); + hdl2 = libnvme_mi_init_transport_handle(ep, 2); count = count_ep_controllers(ep); assert(count == 2); - nvme_close(hdl1); + libnvme_close(hdl1); count = count_ep_controllers(ep); assert(count == 1); - nvme_close(hdl2); + libnvme_close(hdl2); count = count_ep_controllers(ep); assert(count == 0); } @@ -254,7 +254,7 @@ static void test_read_mi_data(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_read_mi_data_cb, NULL); - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc == 0); } @@ -273,7 +273,7 @@ static void test_transport_fail(nvme_mi_ep_t ep) int rc; test_set_transport_callback(ep, test_transport_fail_cb, NULL); - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); } @@ -285,13 +285,13 @@ static void test_transport_describe(nvme_mi_ep_t ep) tpd = (struct test_transport_data *)ep->transport_data; tpd->named = false; - str = nvme_mi_endpoint_desc(ep); + str = libnvme_mi_endpoint_desc(ep); assert(str); assert(!strcmp(str, "test-mi endpoint")); free(str); tpd->named = true; - str = nvme_mi_endpoint_desc(ep); + str = libnvme_mi_endpoint_desc(ep); assert(str); assert(!strcmp(str, "test-mi: test endpoint 0x74657374")); free(str); @@ -313,7 +313,7 @@ static void test_invalid_crc(nvme_mi_ep_t ep) int rc; test_set_transport_callback(ep, test_invalid_crc_cb, NULL); - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc < 0); } @@ -368,21 +368,21 @@ static void test_scan_ctrl_list(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_scan_ctrl_list_cb, NULL); - nvme_mi_scan_ep(ep, false); + libnvme_mi_scan_ep(ep, false); - hdl = nvme_mi_first_transport_handle(ep); + hdl = libnvme_mi_first_transport_handle(ep); assert(hdl); assert(hdl->id == 1); - hdl = nvme_mi_next_transport_handle(ep, hdl); + hdl = libnvme_mi_next_transport_handle(ep, hdl); assert(hdl); assert(hdl->id == 4); - hdl = nvme_mi_next_transport_handle(ep, hdl); + hdl = libnvme_mi_next_transport_handle(ep, hdl); assert(hdl); assert(hdl->id == 5); - hdl = nvme_mi_next_transport_handle(ep, hdl); + hdl = libnvme_mi_next_transport_handle(ep, hdl); assert(hdl == NULL); } @@ -445,11 +445,11 @@ static void test_admin_id(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_admin_id_cb, NULL); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(rc == 0); } @@ -501,11 +501,11 @@ static void test_admin_err_mi_resp(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_admin_err_mi_resp_cb, NULL); - hdl = nvme_mi_init_transport_handle(ep, 1); + hdl = libnvme_mi_init_transport_handle(ep, 1); assert(hdl); nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(rc != 0); assert(nvme_status_get_type(rc) == NVME_STATUS_TYPE_MI); assert(nvme_status_get_value(rc) == NVME_MI_RESP_INTERNAL_ERR); @@ -565,11 +565,11 @@ static void test_admin_err_nvme_resp(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_admin_err_nvme_resp_cb, NULL); - hdl = nvme_mi_init_transport_handle(ep, 1); + hdl = libnvme_mi_init_transport_handle(ep, 1); assert(hdl); nvme_init_identify_ctrl(&cmd, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(rc != 0); assert(nvme_status_get_type(rc) == NVME_STATUS_TYPE_NVME); assert(nvme_status_get_value(rc) == @@ -601,42 +601,42 @@ static void test_admin_invalid_formats(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_rejected_command_cb, NULL); - hdl = nvme_mi_init_transport_handle(ep, 1); + hdl = libnvme_mi_init_transport_handle(ep, 1); assert(hdl); /* unaligned req size */ len = 0; - rc = nvme_mi_admin_xfer(hdl, &req.hdr, 1, &resp, 0, &len); + rc = libnvme_mi_admin_xfer(hdl, &req.hdr, 1, &resp, 0, &len); assert(rc != 0); /* unaligned resp size */ len = 1; - rc = nvme_mi_admin_xfer(hdl, &req.hdr, 0, &resp, 0, &len); + rc = libnvme_mi_admin_xfer(hdl, &req.hdr, 0, &resp, 0, &len); assert(rc != 0); /* unaligned resp offset */ len = 4; - rc = nvme_mi_admin_xfer(hdl, &req.hdr, 0, &resp, 1, &len); + rc = libnvme_mi_admin_xfer(hdl, &req.hdr, 0, &resp, 1, &len); assert(rc != 0); /* resp too large */ len = 4096 + 4; - rc = nvme_mi_admin_xfer(hdl, &req.hdr, 0, &resp, 0, &len); + rc = libnvme_mi_admin_xfer(hdl, &req.hdr, 0, &resp, 0, &len); assert(rc != 0); /* resp offset too large */ len = 4; - rc = nvme_mi_admin_xfer(hdl, &req.hdr, 0, &resp, (off_t)1 << 32, &len); + rc = libnvme_mi_admin_xfer(hdl, &req.hdr, 0, &resp, (off_t)1 << 32, &len); assert(rc != 0); /* resp offset with no len */ len = 0; - rc = nvme_mi_admin_xfer(hdl, &req.hdr, 0, &resp, 4, &len); + rc = libnvme_mi_admin_xfer(hdl, &req.hdr, 0, &resp, 4, &len); assert(rc != 0); /* req and resp payloads */ len = 4; - rc = nvme_mi_admin_xfer(hdl, &req.hdr, 4, &resp, 0, &len); + rc = libnvme_mi_admin_xfer(hdl, &req.hdr, 4, &resp, 0, &len); assert(rc != 0); } @@ -653,12 +653,12 @@ static void test_mi_invalid_formats(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_rejected_command_cb, NULL); - hdl = nvme_mi_init_transport_handle(ep, 1); + hdl = libnvme_mi_init_transport_handle(ep, 1); assert(hdl); /* resp too large */ len = 4096 + 4; - rc = nvme_mi_mi_xfer(ep, &req.hdr, 0, &resp, &len); + rc = libnvme_mi_mi_xfer(ep, &req.hdr, 0, &resp, &len); assert(rc != 0); } @@ -680,7 +680,7 @@ static void test_resp_hdr_small(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_resp_hdr_small_cb, NULL); - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); } @@ -702,7 +702,7 @@ static void test_resp_req(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_resp_req_cb, NULL); - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); } @@ -724,7 +724,7 @@ static void test_resp_invalid_type(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_resp_invalid_type_cb, NULL); - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); } @@ -757,15 +757,15 @@ static void test_resp_csi_request(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_resp_csi_check_cb, NULL); - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); - nvme_mi_set_csi(ep, 1);//Change CSI + libnvme_mi_set_csi(ep, 1);//Change CSI - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); - nvme_mi_set_csi(ep, 0);//Change CSI + libnvme_mi_set_csi(ep, 0);//Change CSI } /* test: Ensure that when csi bit set wrong in response, @@ -778,15 +778,15 @@ static void test_resp_csi_mismatch(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_resp_csi_invert_cb, NULL); - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); - nvme_mi_set_csi(ep, 1);//Change CSI + libnvme_mi_set_csi(ep, 1);//Change CSI - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc != 0); - nvme_mi_set_csi(ep, 0);//Change CSI + libnvme_mi_set_csi(ep, 0);//Change CSI } /* test: config get MTU request & response layout, ensure we're handling @@ -827,7 +827,7 @@ static void test_mi_config_get_mtu(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_mi_config_get_mtu_cb, NULL); - rc = nvme_mi_mi_config_get_mctp_mtu(ep, 5, &mtu); + rc = libnvme_mi_mi_config_get_mctp_mtu(ep, 5, &mtu); assert(rc == 0); assert(mtu == 0x1234); } @@ -877,7 +877,7 @@ static void test_mi_config_set_freq(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_mi_config_set_freq_cb, NULL); - rc = nvme_mi_mi_config_set_smbus_freq(ep, 5, + rc = libnvme_mi_mi_config_set_smbus_freq(ep, 5, NVME_MI_CONFIG_SMBUS_FREQ_100kHz); assert(rc == 0); } @@ -888,7 +888,7 @@ static void test_mi_config_set_freq_invalid(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_mi_config_set_freq_cb, NULL); - rc = nvme_mi_mi_config_set_smbus_freq(ep, 5, + rc = libnvme_mi_mi_config_set_smbus_freq(ep, 5, NVME_MI_CONFIG_SMBUS_FREQ_1MHz); assert(rc == 4); } @@ -973,11 +973,11 @@ static void test_get_features(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_admin_get_features_cb, NULL); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_get_features(&cmd, NVME_FEAT_FID_ARBITRATION, 0); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(rc == 0); assert(cmd.result == 0x04030201); } @@ -1043,11 +1043,11 @@ static void test_set_features(nvme_mi_ep_t ep) test_set_transport_callback(ep, test_admin_set_features_cb, NULL); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_set_features_timestamp(&cmd, true, 0x050403020100, &tstmp); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(rc == 0); } @@ -1113,11 +1113,11 @@ static void test_admin_id_alloc_ns_list(struct nvme_mi_ep *ep) type = NS_ALLOC; test_set_transport_callback(ep, test_admin_id_ns_list_cb, &type); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_identify_allocated_ns_list(&cmd, 1, &list); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); assert(le32_to_cpu(list.ns[0]) == 2); @@ -1136,11 +1136,11 @@ static void test_admin_id_active_ns_list(struct nvme_mi_ep *ep) type = NS_ACTIVE; test_set_transport_callback(ep, test_admin_id_ns_list_cb, &type); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_identify_active_ns_list(&cmd, 1, &list); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); assert(le32_to_cpu(list.ns[0]) == 4); @@ -1201,11 +1201,11 @@ static void test_admin_id_alloc_ns(struct nvme_mi_ep *ep) type = NS_ALLOC; test_set_transport_callback(ep, test_admin_id_ns_cb, &type); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_identify_allocated_ns(&cmd, 1, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); assert(le64_to_cpu(id.nsze) == 1); } @@ -1221,11 +1221,11 @@ static void test_admin_id_active_ns(struct nvme_mi_ep *ep) type = NS_ACTIVE; test_set_transport_callback(ep, test_admin_id_ns_cb, &type); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_identify_ns(&cmd, 1, &id); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); assert(le64_to_cpu(id.nsze) == 1); } @@ -1268,11 +1268,11 @@ static void test_admin_id_ns_ctrl_list(struct nvme_mi_ep *ep) test_set_transport_callback(ep, test_admin_id_ns_ctrl_list_cb, NULL); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_identify_ns_ctrl_list(&cmd, 0x01020304, 5, &list); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1311,11 +1311,11 @@ static void test_admin_id_secondary_ctrl_list(struct nvme_mi_ep *ep) test_set_transport_callback(ep, test_admin_id_secondary_ctrl_list_cb, NULL); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_identify_secondary_ctrl_list(&cmd, 5, &list); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1384,18 +1384,18 @@ static void test_admin_ns_mgmt_create(struct nvme_mi_ep *ep) test_set_transport_callback(ep, test_admin_ns_mgmt_cb, NULL); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_ns_mgmt_create(&cmd, NVME_CSI_NVM, &data); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); ns = cmd.result; assert(ns == 0x01020304); data.nsze = cpu_to_le64(42); nvme_init_ns_mgmt_create(&cmd, NVME_CSI_NVM, &data); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(rc); } @@ -1407,11 +1407,11 @@ static void test_admin_ns_mgmt_delete(struct nvme_mi_ep *ep) test_set_transport_callback(ep, test_admin_ns_mgmt_cb, NULL); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_ns_mgmt_delete(&cmd, 0x05060708); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1476,11 +1476,11 @@ static void test_admin_ns_attach(struct nvme_mi_ep *ep) test_set_transport_callback(ep, test_admin_ns_attach_cb, &aop); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_ns_attach_ctrls(&cmd, 0x02030405, &list); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1501,11 +1501,11 @@ static void test_admin_ns_detach(struct nvme_mi_ep *ep) test_set_transport_callback(ep, test_admin_ns_attach_cb, &aop); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); nvme_init_ns_detach_ctrls(&cmd, 0x02030405, &list); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1560,7 +1560,7 @@ static void test_admin_fw_download(struct nvme_mi_ep *ep) test_set_transport_callback(ep, test_admin_fw_download_cb, &info); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); /* invalid (zero) len */ @@ -1586,7 +1586,7 @@ static void test_admin_fw_download(struct nvme_mi_ep *ep) info.offset = 0; rc = nvme_init_fw_download(&cmd, fw, info.len, info.offset); assert(!rc); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); /* largest len */ @@ -1594,7 +1594,7 @@ static void test_admin_fw_download(struct nvme_mi_ep *ep) info.offset = 0; rc = nvme_init_fw_download(&cmd, fw, info.len, info.offset); assert(!rc); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); /* offset value */ @@ -1602,7 +1602,7 @@ static void test_admin_fw_download(struct nvme_mi_ep *ep) info.offset = 4096; rc = nvme_init_fw_download(&cmd, fw, info.len, info.offset); assert(!rc); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1648,7 +1648,7 @@ static void test_admin_fw_commit(struct nvme_mi_ep *ep) test_set_transport_callback(ep, test_admin_fw_commit_cb, &info); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); /* all zeros */ @@ -1656,7 +1656,7 @@ static void test_admin_fw_commit(struct nvme_mi_ep *ep) info.slot = 0; info.action = 0; nvme_init_fw_commit(&cmd, info.slot, info.action, info.bpid); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); /* all ones */ @@ -1664,7 +1664,7 @@ static void test_admin_fw_commit(struct nvme_mi_ep *ep) info.slot = 0x7; info.action = 0x7; nvme_init_fw_commit(&cmd, info.slot, info.action, info.bpid); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); /* correct fields */ @@ -1672,7 +1672,7 @@ static void test_admin_fw_commit(struct nvme_mi_ep *ep) info.slot = 2; info.action = 3; nvme_init_fw_commit(&cmd, info.slot, info.action, info.bpid); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1726,7 +1726,7 @@ static void test_admin_format_nvm(struct nvme_mi_ep *ep) struct nvme_passthru_cmd cmd; int rc; - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); test_set_transport_callback(ep, test_admin_format_nvm_cb, &args); @@ -1742,7 +1742,7 @@ static void test_admin_format_nvm(struct nvme_mi_ep *ep) nvme_init_format_nvm(&cmd, args.nsid, args.lbaf, args.mset, args.pi, args.pil, args.ses); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); args.nsid = ~args.nsid; @@ -1754,7 +1754,7 @@ static void test_admin_format_nvm(struct nvme_mi_ep *ep) nvme_init_format_nvm(&cmd, args.nsid, args.lbaf, args.mset, args.pi, args.pil, args.ses); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1806,7 +1806,7 @@ static void test_admin_sanitize_nvm(struct nvme_mi_ep *ep) struct nvme_passthru_cmd cmd; int rc; - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); assert(hdl); test_set_transport_callback(ep, test_admin_sanitize_nvm_cb, &args); @@ -1820,7 +1820,7 @@ static void test_admin_sanitize_nvm(struct nvme_mi_ep *ep) nvme_init_sanitize_nvm(&cmd, args.sanact, args.ause, args.owpass, args.oipbp, args.ndas, args.emvs, args.ovrpat); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); args.sanact = 0x0; @@ -1832,7 +1832,7 @@ static void test_admin_sanitize_nvm(struct nvme_mi_ep *ep) nvme_init_sanitize_nvm(&cmd, args.sanact, args.ause, args.owpass, args.oipbp, args.ndas, args.emvs, args.ovrpat); - rc = nvme_submit_admin_passthru(hdl, &cmd); + rc = libnvme_submit_admin_passthru(hdl, &cmd); assert(!rc); } @@ -1908,7 +1908,7 @@ static void test_admin_get_log_split(struct nvme_mi_ep *ep) ldata.n = 0; test_set_transport_callback(ep, test_admin_get_log_split_cb, &ldata); - hdl = nvme_mi_init_transport_handle(ep, 5); + hdl = libnvme_mi_init_transport_handle(ep, 5); nvme_init_get_log(&cmd, NVME_NSID_ALL, NVME_LOG_LID_ERROR, NVME_CSI_NVM, buf, sizeof(buf)); @@ -1964,7 +1964,7 @@ static void test_endpoint_quirk_probe(struct nvme_mi_ep *ep) test_set_transport_callback(ep, test_endpoint_quirk_probe_cb_stage1, NULL); - rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info); + rc = libnvme_mi_mi_read_mi_data_subsys(ep, &ss_info); assert(rc == 0); } @@ -2027,10 +2027,10 @@ static void test_admin_dlen_doff_req(struct nvme_mi_ep *ep) test_set_transport_callback(ep, test_admin_dlen_doff_cb, &data); - hdl = nvme_mi_init_transport_handle(ep, 0); + hdl = libnvme_mi_init_transport_handle(ep, 0); assert(hdl); - rc = nvme_mi_admin_xfer(hdl, &admin_req.hdr, sizeof(admin_req.data), + rc = libnvme_mi_admin_xfer(hdl, &admin_req.hdr, sizeof(admin_req.data), &admin_resp, 0, &resp_sz); assert(!rc); @@ -2056,10 +2056,10 @@ static void test_admin_dlen_doff_resp(struct nvme_mi_ep *ep) test_set_transport_callback(ep, test_admin_dlen_doff_cb, &data); - hdl = nvme_mi_init_transport_handle(ep, 0); + hdl = libnvme_mi_init_transport_handle(ep, 0); assert(hdl); - rc = nvme_mi_admin_xfer(hdl, &admin_req, 0, &admin_resp.hdr, 0, + rc = libnvme_mi_admin_xfer(hdl, &admin_req, 0, &admin_resp.hdr, 0, &resp_sz); assert(!rc); @@ -2131,7 +2131,7 @@ int main(void) fd = test_setup_log(); - ctx = nvme_create_global_ctx(fd, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(fd, DEFAULT_LOGLEVEL); assert(ctx); ep = nvme_mi_open_test(ctx); @@ -2141,8 +2141,8 @@ int main(void) run_test(&tests[i], fd, ep); } - nvme_mi_close(ep); - nvme_free_global_ctx(ctx); + libnvme_mi_close(ep); + libnvme_free_global_ctx(ctx); test_close_log(fd); diff --git a/libnvme/test/nbft/nbft-dump.c b/libnvme/test/nbft/nbft-dump.c index 2b14bf5869..f8f91d12a6 100644 --- a/libnvme/test/nbft/nbft-dump.c +++ b/libnvme/test/nbft/nbft-dump.c @@ -112,22 +112,22 @@ int main(int argc, char **argv) return 1; } - ctx = nvme_create_global_ctx(stderr, false); + ctx = libnvme_create_global_ctx(stderr, false); if (!ctx) { fprintf(stderr, "Failed to create global context"); return 1; } - if (nvme_read_nbft(ctx, &table, argv[1]) != 0) { + if (libnvme_read_nbft(ctx, &table, argv[1]) != 0) { fprintf(stderr, "Error parsing the NBFT table %s: %m\n", argv[1]); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return 2; } print_nbft(table); - nvme_free_nbft(ctx, table); - nvme_free_global_ctx(ctx); + libnvme_free_nbft(ctx, table); + libnvme_free_global_ctx(ctx); return 0; } diff --git a/libnvme/test/psk.c b/libnvme/test/psk.c index 7dd810f38a..cbd595c60e 100644 --- a/libnvme/test/psk.c +++ b/libnvme/test/psk.c @@ -148,14 +148,14 @@ static void export_test(struct nvme_global_ctx *ctx, test->hmac == NVME_HMAC_ALG_SHA2_384)) return; - printf("test nvme_export_tls_key hmac %d %s\n", + printf("test libnvme_export_tls_key hmac %d %s\n", test->hmac, test->exported_psk); - ret = nvme_export_tls_key(ctx, test->configured_psk, + ret = libnvme_export_tls_key(ctx, test->configured_psk, test->psk_length, &psk); if (ret) { test_rc = 1; - printf("ERROR: nvme_export_tls_key() failed with %d\n", ret); + printf("ERROR: libnvme_export_tls_key() failed with %d\n", ret); return; } check_str(test->exported_psk, psk); @@ -175,14 +175,14 @@ static void import_test(struct nvme_global_ctx *ctx, test->hmac == NVME_HMAC_ALG_SHA2_384)) return; - printf("test nvme_import_tls_key hmac %d %s\n", + printf("test libnvme_import_tls_key hmac %d %s\n", test->hmac, test->exported_psk); - ret = nvme_import_tls_key(ctx, test->exported_psk, &psk_length, + ret = libnvme_import_tls_key(ctx, test->exported_psk, &psk_length, &hmac, &psk); if (ret) { test_rc = 1; - printf("ERROR: nvme_import_tls_key() failed with %d\n", ret); + printf("ERROR: libnvme_import_tls_key() failed with %d\n", ret); return; } @@ -215,15 +215,15 @@ static void export_versioned_test(struct nvme_global_ctx *ctx, if (test->version != 1) return; - printf("test nvme_export_tls_key_versioned hmac %d %s\n", + printf("test libnvme_export_tls_key_versioned hmac %d %s\n", test->hmac, test->exported_psk); - ret = nvme_export_tls_key_versioned(ctx, test->version, test->hmac, + ret = libnvme_export_tls_key_versioned(ctx, test->version, test->hmac, test->configured_psk, test->psk_length, &psk); if (ret) { test_rc = 1; - printf("ERROR: nvme_export_tls_key_versioned() failed with %d\n", + printf("ERROR: libnvme_export_tls_key_versioned() failed with %d\n", ret); return; } @@ -245,14 +245,14 @@ static void import_versioned_test(struct nvme_global_ctx *ctx, if (test->version != 1) return; - printf("test nvme_import_tls_key_versioned hmac %d %s\n", + printf("test libnvme_import_tls_key_versioned hmac %d %s\n", test->hmac, test->exported_psk); - ret = nvme_import_tls_key_versioned(ctx, test->exported_psk, &version, + ret = libnvme_import_tls_key_versioned(ctx, test->exported_psk, &version, &hmac, &psk_length, &psk); if (ret) { test_rc = 1; - printf("ERROR: nvme_import_tls_key_versioned() failed with %d\n", + printf("ERROR: libnvme_import_tls_key_versioned() failed with %d\n", ret); return; } @@ -295,10 +295,10 @@ static void identity_test(struct nvme_global_ctx *ctx, test->hmac == NVME_HMAC_ALG_SHA2_384)) return; - printf("test nvme_generate_tls_key_identity host %s subsys %s hmac %d %s\n", + printf("test libnvme_generate_tls_key_identity host %s subsys %s hmac %d %s\n", test->hostnqn, test->subsysnqn, test->hmac, test->identity); - ret = nvme_generate_tls_key_identity(ctx, test->hostnqn, + ret = libnvme_generate_tls_key_identity(ctx, test->hostnqn, test->subsysnqn, test->version, test->hmac, (unsigned char *)test->configured_psk, test->psk_length, &id); @@ -306,7 +306,7 @@ static void identity_test(struct nvme_global_ctx *ctx, if (ret == -ENOTSUP) return; test_rc = 1; - printf("ERROR: nvme_generate_tls_key_identity() failed with %d\n", ret); + printf("ERROR: libnvme_generate_tls_key_identity() failed with %d\n", ret); return; } check_str(test->identity, id); @@ -324,10 +324,10 @@ static void identity_test_compat(struct nvme_global_ctx *ctx, test->hmac == NVME_HMAC_ALG_SHA2_384)) return; - printf("test nvme_generate_tls_key_identity_compat host %s subsys %s hmac %d %s\n", + printf("test libnvme_generate_tls_key_identity_compat host %s subsys %s hmac %d %s\n", test->hostnqn, test->subsysnqn, test->hmac, test->identity); - ret = nvme_generate_tls_key_identity_compat(ctx, test->hostnqn, + ret = libnvme_generate_tls_key_identity_compat(ctx, test->hostnqn, test->subsysnqn, test->version, test->hmac, (unsigned char *)test->configured_psk, test->psk_length, &id); @@ -335,7 +335,7 @@ static void identity_test_compat(struct nvme_global_ctx *ctx, if (ret == -ENOTSUP) return; test_rc = 1; - printf("ERROR: nvme_generate_tls_key_identity_compat() failed with %d\n", ret); + printf("ERROR: libnvme_generate_tls_key_identity_compat() failed with %d\n", ret); return; } check_str(test->identity, id); @@ -345,7 +345,7 @@ static void identity_test_compat(struct nvme_global_ctx *ctx, int main(void) { struct nvme_global_ctx *ctx = - nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); for (int i = 0; i < ARRAY_SIZE(test_data_psk); i++) export_test(ctx, &test_data_psk[i]); @@ -365,7 +365,7 @@ int main(void) for (int i = 0; i < ARRAY_SIZE(test_data_identity_compat); i++) identity_test_compat(ctx, &test_data_identity_compat[i]); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return test_rc ? EXIT_FAILURE : EXIT_SUCCESS; } diff --git a/libnvme/test/sysfs/tree-dump.c b/libnvme/test/sysfs/tree-dump.c index a6c9831323..9ac8f8799b 100644 --- a/libnvme/test/sysfs/tree-dump.c +++ b/libnvme/test/sysfs/tree-dump.c @@ -17,24 +17,24 @@ static bool tree_dump(void) bool pass = false; int err; - ctx = nvme_create_global_ctx(stdout, LOG_ERR); + ctx = libnvme_create_global_ctx(stdout, LOG_ERR); if (!ctx) return false; - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err && !(err == ENOENT || err == EACCES)) { - fprintf(stderr, "nvme_scan_topology failed %d\n", err); + fprintf(stderr, "libnvme_scan_topology failed %d\n", err); goto out; } - if (nvme_dump_tree(ctx)) + if (libnvme_dump_tree(ctx)) goto out; printf("\n"); pass = true; out: - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return pass; } diff --git a/libnvme/test/test-util.c b/libnvme/test/test-util.c index 997d72d13e..5fb0c6f12b 100644 --- a/libnvme/test/test-util.c +++ b/libnvme/test/test-util.c @@ -29,7 +29,7 @@ static size_t safe_strlen(const char *p) { static bool test_nvme_get_version(enum nvme_version type, const char * exp_str) { const char * str; - str = nvme_get_version(type); + str = libnvme_get_version(type); return !strcmp(str, exp_str); } @@ -147,19 +147,19 @@ int main(int argc, char *argv[]) { printf("\n------------------------------------------------------------------------------\n"); pass = test_nvme_get_version(NVME_VERSION_PROJECT, LIBNVME_VERSION); - printf("nvme_get_version(NVME_VERSION_PROJECT) %s\n", pass ? "[PASS]" : "[FAIL]"); + printf("libnvme_get_version(NVME_VERSION_PROJECT) %s\n", pass ? "[PASS]" : "[FAIL]"); if (!pass) exit_val = EXIT_FAILURE; printf("\n------------------------------------------------------------------------------\n"); pass = test_nvme_get_version(NVME_VERSION_GIT, GIT_VERSION); - printf("nvme_get_version(NVME_VERSION_GIT) %s\n", pass ? "[PASS]" : "[FAIL]"); + printf("libnvme_get_version(NVME_VERSION_GIT) %s\n", pass ? "[PASS]" : "[FAIL]"); if (!pass) exit_val = EXIT_FAILURE; printf("\n------------------------------------------------------------------------------\n"); pass = test_nvme_get_version(-1, "n/a"); - printf("nvme_get_version(-1) %s\n", pass ? "[PASS]" : "[FAIL]"); + printf("libnvme_get_version(-1) %s\n", pass ? "[PASS]" : "[FAIL]"); if (!pass) exit_val = EXIT_FAILURE; diff --git a/libnvme/test/test.c b/libnvme/test/test.c index cefa97d360..97b77fd714 100644 --- a/libnvme/test/test.c +++ b/libnvme/test/test.c @@ -27,22 +27,22 @@ #include "nvme/private.h" -static bool nvme_match_subsysnqn_filter(nvme_subsystem_t s, - nvme_ctrl_t c, nvme_ns_t ns, void *f_args) +static bool nvme_match_subsysnqn_filter(libnvme_subsystem_t s, + libnvme_ctrl_t c, libnvme_ns_t ns, void *f_args) { char *nqn_match = f_args; if (s) - return strcmp(nvme_subsystem_get_subsysnqn(s), nqn_match) == 0; + return strcmp(libnvme_subsystem_get_subsysnqn(s), nqn_match) == 0; return true; } -static int test_ctrl(nvme_ctrl_t c) +static int test_ctrl(libnvme_ctrl_t c) { static __u8 buf[0x1000]; enum nvme_get_features_sel sel = NVME_GET_FEATURES_SEL_CURRENT; - struct nvme_transport_handle *hdl = nvme_ctrl_get_transport_handle(c); + struct nvme_transport_handle *hdl = libnvme_ctrl_get_transport_handle(c); struct nvme_passthru_cmd cmd; int ret, temp; struct nvme_error_log_page error[64]; @@ -64,9 +64,9 @@ static int test_ctrl(nvme_ctrl_t c) struct nvme_id_ctrl id = { 0 }; nvme_init_identify_ctrl(&cmd, &id); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (ret) { - printf("ERROR: no identify for:%s\n", nvme_ctrl_get_name(c)); + printf("ERROR: no identify for:%s\n", libnvme_ctrl_get_name(c)); return ret; } else { @@ -76,7 +76,7 @@ static int test_ctrl(nvme_ctrl_t c) nvme_init_get_log_smart(&cmd, NVME_NSID_ALL, &smart); ret = nvme_get_log(hdl, &cmd, true, NVME_LOG_PAGE_PDU_SIZE); if (ret) { - printf("ERROR: no smart log for:%s %#x\n", nvme_ctrl_get_name(c), ret); + printf("ERROR: no smart log for:%s %#x\n", libnvme_ctrl_get_name(c), ret); return ret; } else { @@ -84,7 +84,7 @@ static int test_ctrl(nvme_ctrl_t c) } temp = ((smart.temperature[1] << 8) | smart.temperature[0]) - 273; - printf("Controller:%s\n", nvme_ctrl_get_name(c)); + printf("Controller:%s\n", libnvme_ctrl_get_name(c)); printf("\nIdentify:\n"); printf(" vid:%#04x\n", le16_to_cpu(id.vid)); printf(" ssvid:%#04x\n", le16_to_cpu(id.ssvid)); @@ -94,49 +94,49 @@ static int test_ctrl(nvme_ctrl_t c) printf(" model:%-.40s\n", id.mn); nvme_init_identify_allocated_ns_list(&cmd, 0, &ns_list); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Allocated NS List\n"); else printf(" ERROR: Allocated NS List:%x\n", ret); nvme_init_identify_active_ns_list(&cmd, 0, &ns_list); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Active NS List\n"); else printf(" ERROR: Active NS List:%x\n", ret); nvme_init_identify_ctrl_list(&cmd, 0, &ctrlist); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Ctrl List\n"); else printf(" ERROR: CtrlList:%x\n", ret); nvme_init_identify_ctrl_list(&cmd, 1, &ctrlist); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: NSID Ctrl List\n"); else printf(" ERROR: NSID CtrlList:%x\n", ret); nvme_init_identify_primary_ctrl_cap(&cmd, 0, &prim); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Identify Primary\n"); else printf(" ERROR: Identify Primary:%x\n", ret); nvme_init_identify_secondary_ctrl_list(&cmd, 0, &sec); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Identify Secondary\n"); else printf(" ERROR: Identify Secondary:%x\n", ret); nvme_init_identify_ns_granularity(&cmd, &gran); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Identify NS granularity\n"); else printf(" ERROR: Identify NS granularity:%x\n", ret); nvme_init_identify_uuid_list(&cmd, &uuid); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" PASSED: Identify UUID List\n"); else @@ -207,111 +207,111 @@ static int test_ctrl(nvme_ctrl_t c) printf(" ERROR: Error Log:%x\n", ret); printf("\nFeatures\n"); nvme_init_get_features_arbitration(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Arbitration:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Arbitration:%x\n", ret); nvme_init_get_features_power_mgmt(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Power Management:%" PRIu64 "x\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Power Management:%x\n", ret); nvme_init_get_features_temp_thresh(&cmd, sel, 0, 0); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Temperature Threshold:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Temperature Threshold:%x\n", ret); nvme_init_get_features_volatile_wc(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Volatile Write Cache:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Volatile Write Cache:%x\n", ret); nvme_init_get_features_num_queues(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Number of Queues:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Number of Queues:%x\n", ret); nvme_init_get_features_irq_coalesce(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" IRQ Coalescing:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: IRQ Coalescing:%x\n", ret); nvme_init_get_features_write_atomic(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Write Atomic:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Write Atomic:%x\n", ret); nvme_init_get_features_async_event(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Asycn Event Config:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Asycn Event Config:%x\n", ret); nvme_init_get_features_hctm(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" HCTM:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: HCTM:%x\n", ret); nvme_init_get_features_nopsc(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" NOP Power State Config:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: NOP Power State Configrbitration:%x\n", ret); nvme_init_get_features_rrl(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Read Recover Levels:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Read Recover Levels:%x\n", ret); nvme_init_get_features_lba_sts_interval(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" LBA Status Interval:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: LBA Status Interval:%x\n", ret); nvme_init_get_features_sanitize(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Sanitize:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: SW Progress Marker:%x\n", ret); nvme_init_get_features_sw_progress(&cmd, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" SW Progress Marker:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Sanitize:%x\n", ret); nvme_init_get_features_resv_mask(&cmd, 0, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Reservation Mask:%" PRIu64 "\n", (uint64_t)cmd.result); else if (ret > 0) printf(" ERROR: Reservation Mask:%x\n", ret); nvme_init_get_features_resv_persist(&cmd, 0, sel); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Reservation Persistence:%" PRIu64 "\n", (uint64_t)cmd.result); @@ -320,9 +320,9 @@ static int test_ctrl(nvme_ctrl_t c) return 0; } -static int test_namespace(nvme_ns_t n) +static int test_namespace(libnvme_ns_t n) { - int ret, nsid = nvme_ns_get_nsid(n); + int ret, nsid = libnvme_ns_get_nsid(n); struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; struct nvme_id_ns ns = { 0 }, allocated = { 0 }; @@ -334,17 +334,17 @@ static int test_namespace(nvme_ns_t n) if (ret) return ret; - ret = nvme_ns_identify(n, &ns); + ret = libnvme_ns_identify(n, &ns); if (ret) return ret; nvme_id_ns_flbas_to_lbaf_inuse(ns.flbas, &flbas); printf("%s: nsze:%" PRIu64 " lba size:%d\n", - nvme_ns_get_name(n), le64_to_cpu(ns.nsze), + libnvme_ns_get_name(n), le64_to_cpu(ns.nsze), 1 << ns.lbaf[flbas].ds); nvme_init_identify_allocated_ns(&cmd, nsid, &allocated); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Identify allocated ns\n"); else @@ -354,7 +354,7 @@ static int test_namespace(nvme_ns_t n) return -1; nvme_init_identify_ns_descs_list(&cmd, nsid, descs); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Identify NS Descriptors\n"); else @@ -362,7 +362,7 @@ static int test_namespace(nvme_ns_t n) free(descs); nvme_init_get_features_write_protect(&cmd, nsid, NVME_GET_FEATURES_SEL_CURRENT); - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) printf(" Write Protect:%" PRIu64 "\n", (uint64_t)result); else if (ret > 0) @@ -381,36 +381,36 @@ static void print_hex(const uint8_t *x, int len) int main(int argc, char **argv) { struct nvme_global_ctx *ctx; - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; - nvme_path_t p; - nvme_ns_t n; + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; + libnvme_path_t p; + libnvme_ns_t n; int err; const char *ctrl = "nvme4"; const char *nqn_match = "testnqn"; printf("Test filter for common loop back target\n"); - ctx = nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); if (!ctx) return 1; - err = nvme_scan_topology(ctx, nvme_match_subsysnqn_filter, + err = libnvme_scan_topology(ctx, nvme_match_subsysnqn_filter, (void *)nqn_match); if (err && !(err == ENOENT || err == EACCES)) { - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return 1; } - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - printf("%s - NQN=%s\n", nvme_subsystem_get_name(s), - nvme_subsystem_get_subsysnqn(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_traddr(c), - nvme_ctrl_get_state(c)); + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + printf("%s - NQN=%s\n", libnvme_subsystem_get_name(s), + libnvme_subsystem_get_subsysnqn(s)); + libnvme_subsystem_for_each_ctrl(s, c) { + printf(" %s %s %s %s\n", libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_state(c)); } } } @@ -420,78 +420,78 @@ int main(int argc, char **argv) ctrl = argv[1]; printf("Test scan specific controller\n"); - if (!nvme_scan_ctrl(ctx, ctrl, &c)) { - printf("%s %s %s %s\n", nvme_ctrl_get_name(c), - nvme_ctrl_get_transport(c), - nvme_ctrl_get_traddr(c), - nvme_ctrl_get_state(c)); - nvme_free_ctrl(c); + if (!libnvme_scan_ctrl(ctx, ctrl, &c)) { + printf("%s %s %s %s\n", libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_state(c)); + libnvme_free_ctrl(c); } printf("\n"); printf("Test walking the topology\n"); - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - printf("%s - NQN=%s\n", nvme_subsystem_get_name(s), - nvme_subsystem_get_subsysnqn(s)); - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + printf("%s - NQN=%s\n", libnvme_subsystem_get_name(s), + libnvme_subsystem_get_subsysnqn(s)); + libnvme_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_traddr(c), - nvme_ctrl_get_state(c)); + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_state(c)); - nvme_ctrl_for_each_ns(c, n) { + libnvme_ctrl_for_each_ns(c, n) { char uuid_str[NVME_UUID_LEN_STRING]; unsigned char uuid[NVME_UUID_LEN]; printf(" `- %s lba size:%d lba max:%" PRIu64 "\n", - nvme_ns_get_name(n), - nvme_ns_get_lba_size(n), - nvme_ns_get_lba_count(n)); + libnvme_ns_get_name(n), + libnvme_ns_get_lba_size(n), + libnvme_ns_get_lba_count(n)); printf(" eui:"); - print_hex(nvme_ns_get_eui64(n), 8); + print_hex(libnvme_ns_get_eui64(n), 8); printf(" nguid:"); - print_hex(nvme_ns_get_nguid(n), 16); - nvme_ns_get_uuid(n, uuid); - nvme_uuid_to_string(uuid, uuid_str); + print_hex(libnvme_ns_get_nguid(n), 16); + libnvme_ns_get_uuid(n, uuid); + libnvme_uuid_to_string(uuid, uuid_str); printf(" uuid:%s csi:%d\n", uuid_str, - nvme_ns_get_csi(n)); + libnvme_ns_get_csi(n)); } - nvme_ctrl_for_each_path(c, p) + libnvme_ctrl_for_each_path(c, p) printf(" `- %s %s\n", - nvme_path_get_name(p), - nvme_path_get_ana_state(p)); + libnvme_path_get_name(p), + libnvme_path_get_ana_state(p)); } - nvme_subsystem_for_each_ns(s, n) { + libnvme_subsystem_for_each_ns(s, n) { printf(" `- %s lba size:%d lba max:%" PRIu64 "\n", - nvme_ns_get_name(n), - nvme_ns_get_lba_size(n), - nvme_ns_get_lba_count(n)); + libnvme_ns_get_name(n), + libnvme_ns_get_lba_size(n), + libnvme_ns_get_lba_count(n)); } } printf("\n"); } printf("Test identification, logs, and features\n"); - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + libnvme_subsystem_for_each_ctrl(s, c) { test_ctrl(c); printf("\n"); - nvme_ctrl_for_each_ns(c, n) { + libnvme_ctrl_for_each_ns(c, n) { test_namespace(n); printf("\n"); } } - nvme_subsystem_for_each_ns(s, n) { + libnvme_subsystem_for_each_ns(s, n) { test_namespace(n); printf("\n"); } } } - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return 0; } diff --git a/libnvme/test/tree.c b/libnvme/test/tree.c index 6bb23a2b7b..394d78168f 100644 --- a/libnvme/test/tree.c +++ b/libnvme/test/tree.c @@ -21,8 +21,8 @@ struct test_data { const char *subsysname; /* track controller generated by input data */ - nvme_subsystem_t s; - nvme_ctrl_t c; + libnvme_subsystem_t s; + libnvme_ctrl_t c; int ctrl_id; }; @@ -57,7 +57,7 @@ struct test_data test_data[] = { }, }; -static struct test_data *find_test_data(nvme_ctrl_t c) +static struct test_data *find_test_data(libnvme_ctrl_t c) { for (int i = 0; i < ARRAY_SIZE(test_data); i++) { struct test_data *d = &test_data[i]; @@ -69,7 +69,7 @@ static struct test_data *find_test_data(nvme_ctrl_t c) return NULL; } -static void show_ctrl(nvme_ctrl_t c) +static void show_ctrl(libnvme_ctrl_t c) { struct test_data *d = find_test_data(c); @@ -80,15 +80,15 @@ static void show_ctrl(nvme_ctrl_t c) printf("0x%p: %s %s %s %s %s %s", c, - nvme_ctrl_get_subsysnqn(c), - nvme_ctrl_get_transport(c), - nvme_ctrl_get_traddr(c), - nvme_ctrl_get_host_traddr(c), - nvme_ctrl_get_host_iface(c), - nvme_ctrl_get_trsvcid(c)); + libnvme_ctrl_get_subsysnqn(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_host_traddr(c), + libnvme_ctrl_get_host_iface(c), + libnvme_ctrl_get_trsvcid(c)); } -static bool match_ctrl(struct test_data *d, nvme_ctrl_t c) +static bool match_ctrl(struct test_data *d, libnvme_ctrl_t c) { bool pass = true; const char *trsvid, *host_traddr, *host_iface; @@ -96,24 +96,24 @@ static bool match_ctrl(struct test_data *d, nvme_ctrl_t c) if (d->c != c) pass = false; - if (strcmp(d->f.transport, nvme_ctrl_get_transport(d->c))) + if (strcmp(d->f.transport, libnvme_ctrl_get_transport(d->c))) pass = false; - if (strcmp(d->f.traddr, nvme_ctrl_get_traddr(d->c))) + if (strcmp(d->f.traddr, libnvme_ctrl_get_traddr(d->c))) pass = false; - host_traddr = nvme_ctrl_get_host_traddr(c); + host_traddr = libnvme_ctrl_get_host_traddr(c); if (d->f.host_traddr && (!host_traddr || strcmp(d->f.host_traddr, host_traddr))) pass = false; - host_iface = nvme_ctrl_get_host_iface(c); + host_iface = libnvme_ctrl_get_host_iface(c); if (d->f.host_iface && (!host_iface || strcmp(d->f.host_iface, host_iface))) pass = false; - trsvid = nvme_ctrl_get_trsvcid(c); + trsvid = libnvme_ctrl_get_trsvcid(c); if (d->f.trsvcid && (!trsvid || strcmp(d->f.trsvcid, trsvid))) pass = false; @@ -126,18 +126,18 @@ static bool match_ctrl(struct test_data *d, nvme_ctrl_t c) static struct nvme_global_ctx *create_tree() { struct nvme_global_ctx *ctx; - nvme_host_t h; + libnvme_host_t h; - ctx = nvme_create_global_ctx(stdout, LOG_DEBUG); + ctx = libnvme_create_global_ctx(stdout, LOG_DEBUG); assert(ctx); - nvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); + libnvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); assert(h); printf(" ctrls created:\n"); for (int i = 0; i < ARRAY_SIZE(test_data); i++) { struct test_data *d = &test_data[i]; - assert(!nvme_get_subsystem(ctx, h, d->subsysname, + assert(!libnvme_get_subsystem(ctx, h, d->subsysname, d->f.subsysnqn, &d->s)); assert(d->s); d->c = nvme_lookup_ctrl(d->s, &d->f, NULL); @@ -156,22 +156,22 @@ static struct nvme_global_ctx *create_tree() static unsigned int count_entries(struct nvme_global_ctx *ctx) { - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; unsigned int i = 0; - nvme_for_each_host(ctx, h) - nvme_for_each_subsystem(h, s) - nvme_subsystem_for_each_ctrl(s, c) + libnvme_for_each_host(ctx, h) + libnvme_for_each_subsystem(h, s) + libnvme_subsystem_for_each_ctrl(s, c) i++; return i; } -static bool tcp_ctrl_lookup(nvme_subsystem_t s, struct test_data *d) +static bool tcp_ctrl_lookup(libnvme_subsystem_t s, struct test_data *d) { - nvme_ctrl_t c; + libnvme_ctrl_t c; bool pass = true; struct nvmf_context f = d->f; @@ -216,9 +216,9 @@ static bool tcp_ctrl_lookup(nvme_subsystem_t s, struct test_data *d) return pass; } -static bool default_ctrl_lookup(nvme_subsystem_t s, struct test_data *d) +static bool default_ctrl_lookup(libnvme_subsystem_t s, struct test_data *d) { - nvme_ctrl_t c; + libnvme_ctrl_t c; bool pass = true; struct nvmf_context f = d->f; @@ -235,12 +235,12 @@ static bool default_ctrl_lookup(nvme_subsystem_t s, struct test_data *d) static bool ctrl_lookups(struct nvme_global_ctx *ctx) { - nvme_host_t h; - nvme_subsystem_t s; + libnvme_host_t h; + libnvme_subsystem_t s; bool pass = true; - h = nvme_first_host(ctx); - nvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, DEFAULT_SUBSYSNQN, &s); + h = libnvme_first_host(ctx); + libnvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, DEFAULT_SUBSYSNQN, &s); printf(" lookup controller:\n"); for (int i = 0; i < ARRAY_SIZE(test_data); i++) { @@ -272,7 +272,7 @@ static bool test_lookup(void) pass = count_entries(ctx) == ARRAY_SIZE(test_data); pass &= ctrl_lookups(ctx); - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return pass; } @@ -288,21 +288,21 @@ static bool test_src_addr() .trsvcid = "8009", }; bool pass = true; - nvme_host_t h; - nvme_ctrl_t c; - nvme_subsystem_t s; + libnvme_host_t h; + libnvme_ctrl_t c; + libnvme_subsystem_t s; char *src_addr, buffer[100]; /* big enough for IPv6 max length */ printf("\n" "test_src_addr:\n"); - ctx = nvme_create_global_ctx(stdout, LOG_DEBUG); + ctx = libnvme_create_global_ctx(stdout, LOG_DEBUG); assert(ctx); - nvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); + libnvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); assert(h); - nvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, DEFAULT_SUBSYSNQN, &s); + libnvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, DEFAULT_SUBSYSNQN, &s); assert(s); c = nvme_lookup_ctrl(s, &fctx, NULL); @@ -310,11 +310,11 @@ static bool test_src_addr() c->address = NULL; printf(" - Test c->address = NULL : src_addr = NULL "); - src_addr = nvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); + src_addr = libnvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); if (src_addr != NULL) { printf("[FAIL]\n"); fprintf(stderr, - "nvme_ctrl_get_src_addr() c->address=NULL should return src_addr=NULL\n"); + "libnvme_ctrl_get_src_addr() c->address=NULL should return src_addr=NULL\n"); pass = false; } else { printf("[PASS]\n"); @@ -322,11 +322,11 @@ static bool test_src_addr() c->address = ""; printf(" - Test c->address = \"\" : src_addr = NULL "); - src_addr = nvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); + src_addr = libnvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); if (src_addr != NULL) { printf("[FAIL]\n"); fprintf(stderr, - "nvme_ctrl_get_src_addr() c->address="" should return src_addr=NULL\n"); + "libnvme_ctrl_get_src_addr() c->address="" should return src_addr=NULL\n"); pass = false; } else { printf("[PASS]\n"); @@ -334,11 +334,11 @@ static bool test_src_addr() c->address = "traddr=192.168.56.1,trsvcid=8009"; printf(" - Test c->address = \"%s\" : src_addr = NULL ", c->address); - src_addr = nvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); + src_addr = libnvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); if (src_addr != NULL) { printf("[FAIL]\n"); fprintf(stderr, - "nvme_ctrl_get_src_addr() c->address=%s should return src_addr=NULL\n", + "libnvme_ctrl_get_src_addr() c->address=%s should return src_addr=NULL\n", c->address); pass = false; } else { @@ -347,11 +347,11 @@ static bool test_src_addr() c->address = "traddr=192.168.56.1,trsvcid=8009,src_addr=" SRC_ADDR4; printf(" - Test c->address = \"%s\" : src_addr = \"" SRC_ADDR4 "\" ", c->address); - src_addr = nvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); + src_addr = libnvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); if (!src_addr || strcmp(src_addr, SRC_ADDR4)) { printf("[FAIL]\n"); fprintf(stderr, - "nvme_ctrl_get_src_addr() c->address=%s should return src_addr=" SRC_ADDR4 "\n", + "libnvme_ctrl_get_src_addr() c->address=%s should return src_addr=" SRC_ADDR4 "\n", c->address); pass = false; } else { @@ -360,11 +360,11 @@ static bool test_src_addr() c->address = "traddr=192.168.56.1,src_addr=" SRC_ADDR4 ",trsvcid=8009"; printf(" - Test c->address = \"%s\" : src_addr = \"" SRC_ADDR4 "\" ", c->address); - src_addr = nvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); + src_addr = libnvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); if (!src_addr || strcmp(src_addr, SRC_ADDR4)) { printf("[FAIL]\n"); fprintf(stderr, - "nvme_ctrl_get_src_addr() c->address=%s should return src_addr=" SRC_ADDR4 "\n", + "libnvme_ctrl_get_src_addr() c->address=%s should return src_addr=" SRC_ADDR4 "\n", c->address); pass = false; } else { @@ -373,11 +373,11 @@ static bool test_src_addr() c->address = "traddr=1234::abcd,trsvcid=8009,src_addr=" SRC_ADDR6; printf(" - Test c->address = \"%s\" : src_addr = \"" SRC_ADDR6 "\" ", c->address); - src_addr = nvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); + src_addr = libnvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); if (!src_addr || strcmp(src_addr, SRC_ADDR6)) { printf("[FAIL]\n"); fprintf(stderr, - "nvme_ctrl_get_src_addr() c->address=%s should return src_addr=" SRC_ADDR6 "\n", + "libnvme_ctrl_get_src_addr() c->address=%s should return src_addr=" SRC_ADDR6 "\n", c->address); pass = false; } else { @@ -386,11 +386,11 @@ static bool test_src_addr() c->address = "traddr=1234::abcd,src_addr=" SRC_ADDR6 ",trsvcid=8009"; printf(" - Test c->address = \"%s\" : src_addr = \"" SRC_ADDR6 "\" ", c->address); - src_addr = nvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); + src_addr = libnvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); if (!src_addr || strcmp(src_addr, SRC_ADDR6)) { printf("[FAIL]\n"); fprintf(stderr, - "nvme_ctrl_get_src_addr() c->address=%s should return src_addr=" SRC_ADDR6 "\n", + "libnvme_ctrl_get_src_addr() c->address=%s should return src_addr=" SRC_ADDR6 "\n", c->address); pass = false; } else { @@ -399,11 +399,11 @@ static bool test_src_addr() c->address = "traddr=1234::abcd,trsvcid=8009,src_addr=" SRC_ADDR6 "%scope"; printf(" - Test c->address = \"%s\" : src_addr = \"" SRC_ADDR6 "\" ", c->address); - src_addr = nvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); + src_addr = libnvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); if (!src_addr || strcmp(src_addr, SRC_ADDR6)) { printf("[FAIL]\n"); fprintf(stderr, - "nvme_ctrl_get_src_addr() c->address=%s should return src_addr=" SRC_ADDR6 "\n", + "libnvme_ctrl_get_src_addr() c->address=%s should return src_addr=" SRC_ADDR6 "\n", c->address); pass = false; } else { @@ -412,11 +412,11 @@ static bool test_src_addr() c->address = "traddr=1234::abcd,src_addr=" SRC_ADDR6 "%scope,trsvcid=8009"; printf(" - Test c->address = \"%s\" : src_addr = \"" SRC_ADDR6 "\" ", c->address); - src_addr = nvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); + src_addr = libnvme_ctrl_get_src_addr(c, buffer, sizeof(buffer)); if (!src_addr || strcmp(src_addr, SRC_ADDR6)) { printf("[FAIL]\n"); fprintf(stderr, - "nvme_ctrl_get_src_addr() c->address=%s should return src_addr=" SRC_ADDR6 "\n", + "libnvme_ctrl_get_src_addr() c->address=%s should return src_addr=" SRC_ADDR6 "\n", c->address); pass = false; } else { @@ -425,7 +425,7 @@ static bool test_src_addr() c->address = NULL; /* Needed to avoid freeing non-malloced memory (see above) */ - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return pass; } @@ -461,19 +461,19 @@ static bool ctrl_match(const char *tag, bool should_match) { struct nvme_global_ctx *ctx; - nvme_host_t h; - nvme_ctrl_t reference_ctrl; /* Existing controller (from sysfs) */ - nvme_ctrl_t candidate_ctrl; - nvme_ctrl_t found_ctrl; - nvme_subsystem_t s; + libnvme_host_t h; + libnvme_ctrl_t reference_ctrl; /* Existing controller (from sysfs) */ + libnvme_ctrl_t candidate_ctrl; + libnvme_ctrl_t found_ctrl; + libnvme_subsystem_t s; - ctx = nvme_create_global_ctx(stdout, LOG_INFO); + ctx = libnvme_create_global_ctx(stdout, LOG_INFO); assert(ctx); - nvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); + libnvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); assert(h); - assert(!nvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, + assert(!libnvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, reference->f.subsysnqn ? reference->f.subsysnqn : DEFAULT_SUBSYSNQN, &s)); @@ -546,7 +546,7 @@ static bool ctrl_match(const char *tag, reference_ctrl->name = NULL; reference_ctrl->address = NULL; - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return true; } @@ -1085,17 +1085,17 @@ static bool ctrl_config_match(const char *tag, { struct nvme_global_ctx *ctx; bool match; - nvme_host_t h; - nvme_ctrl_t reference_ctrl; /* Existing controller (from sysfs) */ - nvme_subsystem_t s; + libnvme_host_t h; + libnvme_ctrl_t reference_ctrl; /* Existing controller (from sysfs) */ + libnvme_subsystem_t s; - ctx = nvme_create_global_ctx(stdout, LOG_INFO); + ctx = libnvme_create_global_ctx(stdout, LOG_INFO); assert(ctx); - nvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); + libnvme_get_host(ctx, DEFAULT_HOSTNQN, DEFAULT_HOSTID, &h); assert(h); - assert(!nvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, + assert(!libnvme_get_subsystem(ctx, h, DEFAULT_SUBSYSNAME, reference->f.subsysnqn ? reference->f.subsysnqn : DEFAULT_SUBSYSNQN, &s)); @@ -1136,7 +1136,7 @@ static bool ctrl_config_match(const char *tag, reference_ctrl->name = NULL; reference_ctrl->address = NULL; - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return true; } diff --git a/libnvme/test/uriparser.c b/libnvme/test/uriparser.c index 9d5723b965..bce04db5d7 100644 --- a/libnvme/test/uriparser.c +++ b/libnvme/test/uriparser.c @@ -159,7 +159,7 @@ static void test_uriparser(void) int i; printf(" '%s'...", d->uri); - assert(!nvme_parse_uri(d->uri, &parsed_data)); + assert(!libnvme_parse_uri(d->uri, &parsed_data)); assert(strcmp(d->scheme, parsed_data->scheme) == 0); if (d->proto) { @@ -203,7 +203,7 @@ static void test_uriparser_bad(void) struct nvme_fabrics_uri *parsed_data = NULL; printf(" '%s'...", test_data_bad[i]); - assert(nvme_parse_uri(test_data_bad[i], &parsed_data)); + assert(libnvme_parse_uri(test_data_bad[i], &parsed_data)); assert(parsed_data == NULL); printf(" OK\n"); } diff --git a/libnvme/test/uuid.c b/libnvme/test/uuid.c index 3b557969c4..939f217309 100644 --- a/libnvme/test/uuid.c +++ b/libnvme/test/uuid.c @@ -59,9 +59,9 @@ static void tostr_test(struct test_data *test) { char str[NVME_UUID_LEN_STRING]; - if (nvme_uuid_to_string(test->uuid, str)) { + if (libnvme_uuid_to_string(test->uuid, str)) { test_rc = 1; - printf("ERROR: nvme_uuid_to_string() failed\n"); + printf("ERROR: libnvme_uuid_to_string() failed\n"); return; } check_str(test->str, str); @@ -72,9 +72,9 @@ static void fromstr_test(struct test_data *test) unsigned char uuid[NVME_UUID_LEN]; - if (nvme_uuid_from_string(test->str, uuid)) { + if (libnvme_uuid_from_string(test->str, uuid)) { test_rc = 1; - printf("ERROR: nvme_uuid_from_string() failed\n"); + printf("ERROR: libnvme_uuid_from_string() failed\n"); return; } check_uuid(test->uuid, uuid); @@ -85,9 +85,9 @@ static void random_uuid_test(void) unsigned char uuid1[NVME_UUID_LEN], uuid2[NVME_UUID_LEN]; char str1[NVME_UUID_LEN_STRING], str2[NVME_UUID_LEN_STRING]; - if (nvme_random_uuid(uuid1) || nvme_random_uuid(uuid2)) { + if (libnvme_random_uuid(uuid1) || libnvme_random_uuid(uuid2)) { test_rc = 1; - printf("ERROR: nvme_random_uuid() failed\n"); + printf("ERROR: libnvme_random_uuid() failed\n"); return; } @@ -97,8 +97,8 @@ static void random_uuid_test(void) return; } - if (nvme_uuid_to_string(uuid1, str1) || - nvme_uuid_to_string(uuid2, str2)) { + if (libnvme_uuid_to_string(uuid1, str1) || + libnvme_uuid_to_string(uuid2, str2)) { test_rc = 1; printf("ERROR: could not stringify randomly generated UUID\n"); return; diff --git a/libnvme/test/zns.c b/libnvme/test/zns.c index 79051a10fc..159f4551c0 100644 --- a/libnvme/test/zns.c +++ b/libnvme/test/zns.c @@ -21,7 +21,7 @@ #include "nvme/private.h" -static void show_zns_properties(nvme_ns_t n) +static void show_zns_properties(libnvme_ns_t n) { struct nvme_transport_handle *hdl; struct nvme_passthru_cmd cmd; @@ -38,8 +38,8 @@ static void show_zns_properties(nvme_ns_t n) if (!zr) return; - nvme_init_zns_identify_ns(&cmd, nvme_ns_get_nsid(n), &zns_ns); - if (nvme_submit_admin_passthru(hdl, &cmd)) { + nvme_init_zns_identify_ns(&cmd, libnvme_ns_get_nsid(n), &zns_ns); + if (libnvme_submit_admin_passthru(hdl, &cmd)) { fprintf(stderr, "failed to identify zns ns, result %" PRIx64 "\n", (uint64_t)cmd.result); free(zr); @@ -51,17 +51,17 @@ static void show_zns_properties(nvme_ns_t n) le32_to_cpu(zns_ns.mor)); nvme_init_zns_identify_ctrl(&cmd, &zns_ctrl); - if (nvme_submit_admin_passthru(hdl, &cmd)) { + if (libnvme_submit_admin_passthru(hdl, &cmd)) { fprintf(stderr, "failed to identify zns ctrl\n");; free(zr); return; } printf("zasl:%u\n", zns_ctrl.zasl); - nvme_init_zns_report_zones(&cmd, nvme_ns_get_nsid(n), 0, + nvme_init_zns_report_zones(&cmd, libnvme_ns_get_nsid(n), 0, NVME_ZNS_ZRAS_REPORT_ALL, false, true, (void *)zr, 0x1000); - if (nvme_submit_io_passthru(hdl, &cmd)) { + if (libnvme_submit_io_passthru(hdl, &cmd)) { fprintf(stderr, "failed to report zones, result %" PRIx64"\n", (uint64_t)cmd.result); free(zr); @@ -75,37 +75,37 @@ static void show_zns_properties(nvme_ns_t n) int main() { struct nvme_global_ctx *ctx; - nvme_subsystem_t s; - nvme_host_t h; - nvme_ctrl_t c; - nvme_ns_t n; + libnvme_subsystem_t s; + libnvme_host_t h; + libnvme_ctrl_t c; + libnvme_ns_t n; int err; - ctx = nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); if (!ctx) return 1; - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err && !(err == -ENOENT || err == -EACCES)) { - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return 1; } - nvme_for_each_host(ctx, 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) + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + libnvme_subsystem_for_each_ctrl(s, c) { + libnvme_ctrl_for_each_ns(c, n) { + if (libnvme_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) + libnvme_subsystem_for_each_ns(s, n) { + if (libnvme_ns_get_csi(n) == NVME_CSI_ZNS) show_zns_properties(n); } } } - nvme_free_global_ctx(ctx); + libnvme_free_global_ctx(ctx); return 0; } diff --git a/logging.c b/logging.c index 556d383893..ff544e5f3f 100644 --- a/logging.c +++ b/logging.c @@ -105,7 +105,7 @@ static void nvme_log_retry(int errnum) if (log_level < LOG_DEBUG) return; - printf("passthru command returned '%s'\n", nvme_strerror(errnum)); + printf("passthru command returned '%s'\n", libnvme_strerror(errnum)); } void *nvme_submit_entry(struct nvme_transport_handle *hdl, diff --git a/nvme-cmds.c b/nvme-cmds.c index 11148379d0..33a2c13dfc 100644 --- a/nvme-cmds.c +++ b/nvme-cmds.c @@ -18,7 +18,7 @@ static int nvme_ns_attachment(struct nvme_transport_handle *hdl, bool ish, struct nvme_passthru_cmd cmd; nvme_init_ctrl_list(&cntlist, num_ctrls, ctrlist); - if (ish && nvme_transport_handle_is_mi(hdl)) + if (ish && libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); if (attach) @@ -26,7 +26,7 @@ static int nvme_ns_attachment(struct nvme_transport_handle *hdl, bool ish, else nvme_init_ns_detach_ctrls(&cmd, nsid, &cntlist); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } int nvme_namespace_attach_ctrls(struct nvme_transport_handle *hdl, bool ish, diff --git a/nvme-cmds.h b/nvme-cmds.h index 97cd8ba578..a58608b656 100644 --- a/nvme-cmds.h +++ b/nvme-cmds.h @@ -33,7 +33,7 @@ static inline int nvme_flush(struct nvme_transport_handle *hdl, __u32 nsid) cmd.opcode = nvme_cmd_flush; cmd.nsid = nsid; - return nvme_submit_io_passthru(hdl, &cmd); + return libnvme_submit_io_passthru(hdl, &cmd); } /** @@ -61,7 +61,7 @@ nvme_identify(struct nvme_transport_handle *hdl, __u32 nsid, enum nvme_csi csi, nvme_init_identify(&cmd, nsid, csi, cns, data, len); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /** @@ -85,7 +85,7 @@ nvme_identify_ctrl(struct nvme_transport_handle *hdl, nvme_init_identify_ctrl(&cmd, id); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /** @@ -109,7 +109,7 @@ nvme_identify_active_ns_list(struct nvme_transport_handle *hdl, nvme_init_identify_active_ns_list(&cmd, nsid, ns_list); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /** @@ -134,7 +134,7 @@ nvme_identify_ns(struct nvme_transport_handle *hdl, nvme_init_identify_ns(&cmd, nsid, ns); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /** @@ -160,7 +160,7 @@ nvme_identify_csi_ns(struct nvme_transport_handle *hdl, __u32 nsid, nvme_init_identify_csi_ns(&cmd, nsid, csi, uidx, id_ns); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /** @@ -183,7 +183,7 @@ nvme_identify_uuid_list(struct nvme_transport_handle *hdl, nvme_init_identify_uuid_list(&cmd, uuid_list); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /** @@ -209,7 +209,7 @@ nvme_identify_csi_ns_user_data_format(struct nvme_transport_handle *hdl, nvme_init_identify_csi_ns_user_data_format(&cmd, csi, fidx, uidx, data); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /** @@ -232,7 +232,7 @@ nvme_identify_ns_granularity(struct nvme_transport_handle *hdl, nvme_init_identify_ns_granularity(&cmd, gr_list); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /** @@ -257,7 +257,7 @@ nvme_identify_ns_descs_list(struct nvme_transport_handle *hdl, nvme_init_identify_ns_descs_list(&cmd, nsid, descs); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /** @@ -281,7 +281,7 @@ nvme_zns_identify_ns(struct nvme_transport_handle *hdl, nvme_init_zns_identify_ns(&cmd, nsid, data); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /** @@ -1608,7 +1608,7 @@ nvme_set_features(struct nvme_transport_handle *hdl, __u32 nsid, __u8 fid, cmd.data_len = len; cmd.addr = (__u64)(uintptr_t)data; - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (result) *result = cmd.result; return err; @@ -1641,7 +1641,7 @@ nvme_set_features_simple(struct nvme_transport_handle *hdl, cmd.nsid = nsid; cmd.cdw11 = cdw11; - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (result) *result = cmd.result; return err; @@ -1682,7 +1682,7 @@ nvme_get_features(struct nvme_transport_handle *hdl, __u32 nsid, cmd.data_len = len; cmd.addr = (__u64)(uintptr_t)data; - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (result) *result = cmd.result; return err; @@ -1711,7 +1711,7 @@ nvme_get_features_simple(struct nvme_transport_handle *hdl, __u8 fid, nvme_init_get_features(&cmd, fid, sel); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (result) *result = cmd.result; return err; diff --git a/nvme-models.c b/nvme-models.c index eafbb629f1..4a94906deb 100644 --- a/nvme-models.c +++ b/nvme-models.c @@ -246,7 +246,7 @@ static int read_sys_node(char *where, char *save, size_t savesz) fd = open(where, O_RDONLY); if (fd < 0) { fprintf(stderr, "Failed to open %s with errno %s\n", - where, nvme_strerror(errno)); + where, libnvme_strerror(errno)); return 1; } /* -1 so we can safely use strstr below */ @@ -329,7 +329,7 @@ char *nvme_product_name(int id) line = malloc(1024); if (!line) { - fprintf(stderr, "malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "malloc: %s\n", libnvme_strerror(errno)); goto error0; } diff --git a/nvme-print-json.c b/nvme-print-json.c index 15ca6f4dd0..27c34e6654 100644 --- a/nvme-print-json.c +++ b/nvme-print-json.c @@ -2661,26 +2661,26 @@ static void json_nvme_fdp_ruh_status(struct nvme_fdp_ruh_status *status, size_t json_print(r); } -static unsigned int json_print_nvme_subsystem_multipath(nvme_subsystem_t s, json_object *paths) +static unsigned int json_print_nvme_subsystem_multipath(libnvme_subsystem_t s, json_object *paths) { - nvme_ns_t n; - nvme_path_t p; + libnvme_ns_t n; + libnvme_path_t p; unsigned int i = 0; - n = nvme_subsystem_first_ns(s); + n = libnvme_subsystem_first_ns(s); if (!n) return 0; - nvme_namespace_for_each_path(n, p) { + libnvme_namespace_for_each_path(n, p) { struct json_object *path_attrs; - nvme_ctrl_t c = nvme_path_get_ctrl(p); + libnvme_ctrl_t c = libnvme_path_get_ctrl(p); path_attrs = json_create_object(); - obj_add_str(path_attrs, "Name", nvme_ctrl_get_name(c)); - obj_add_str(path_attrs, "Transport", nvme_ctrl_get_transport(c)); - obj_add_str(path_attrs, "Address", nvme_ctrl_get_traddr(c)); - obj_add_str(path_attrs, "State", nvme_ctrl_get_state(c)); - obj_add_str(path_attrs, "ANAState", nvme_path_get_ana_state(p)); + obj_add_str(path_attrs, "Name", libnvme_ctrl_get_name(c)); + obj_add_str(path_attrs, "Transport", libnvme_ctrl_get_transport(c)); + obj_add_str(path_attrs, "Address", libnvme_ctrl_get_traddr(c)); + obj_add_str(path_attrs, "State", libnvme_ctrl_get_state(c)); + obj_add_str(path_attrs, "ANAState", libnvme_path_get_ana_state(p)); array_add_obj(paths, path_attrs); i++; } @@ -2688,19 +2688,19 @@ static unsigned int json_print_nvme_subsystem_multipath(nvme_subsystem_t s, json return i; } -static void json_print_nvme_subsystem_ctrls(nvme_subsystem_t s, +static void json_print_nvme_subsystem_ctrls(libnvme_subsystem_t s, json_object *paths) { - nvme_ctrl_t c; + libnvme_ctrl_t c; - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_subsystem_for_each_ctrl(s, c) { struct json_object *path_attrs; path_attrs = json_create_object(); - obj_add_str(path_attrs, "Name", nvme_ctrl_get_name(c)); - obj_add_str(path_attrs, "Transport", nvme_ctrl_get_transport(c)); - obj_add_str(path_attrs, "Address", nvme_ctrl_get_traddr(c)); - obj_add_str(path_attrs, "State", nvme_ctrl_get_state(c)); + obj_add_str(path_attrs, "Name", libnvme_ctrl_get_name(c)); + obj_add_str(path_attrs, "Transport", libnvme_ctrl_get_transport(c)); + obj_add_str(path_attrs, "Address", libnvme_ctrl_get_traddr(c)); + obj_add_str(path_attrs, "State", libnvme_ctrl_get_state(c)); array_add_obj(paths, path_attrs); } } @@ -2711,42 +2711,42 @@ static void json_print_nvme_subsystem_list(struct nvme_global_ctx *ctx, struct json_object *host_attrs, *subsystem_attrs; struct json_object *subsystems, *paths; struct json_object *a = json_create_array(); - nvme_host_t h; + libnvme_host_t h; - nvme_for_each_host(ctx, h) { - nvme_subsystem_t s; + libnvme_for_each_host(ctx, h) { + libnvme_subsystem_t s; const char *hostid; host_attrs = json_create_object(); - obj_add_str(host_attrs, "HostNQN", nvme_host_get_hostnqn(h)); - hostid = nvme_host_get_hostid(h); + obj_add_str(host_attrs, "HostNQN", libnvme_host_get_hostnqn(h)); + hostid = libnvme_host_get_hostid(h); if (hostid) obj_add_str(host_attrs, "HostID", hostid); subsystems = json_create_array(); - nvme_for_each_subsystem(h, s) { - nvme_ctrl_t c; + libnvme_for_each_subsystem(h, s) { + libnvme_ctrl_t c; bool no_ctrl = true; - nvme_subsystem_for_each_ctrl(s, c) + libnvme_subsystem_for_each_ctrl(s, c) no_ctrl = false; if (no_ctrl) continue; subsystem_attrs = json_create_object(); - obj_add_str(subsystem_attrs, "Name", nvme_subsystem_get_name(s)); - obj_add_str(subsystem_attrs, "NQN", nvme_subsystem_get_subsysnqn(s)); + obj_add_str(subsystem_attrs, "Name", libnvme_subsystem_get_name(s)); + obj_add_str(subsystem_attrs, "NQN", libnvme_subsystem_get_subsysnqn(s)); if (verbose_mode()) { obj_add_str(subsystem_attrs, "Model", - nvme_subsystem_get_model(s)); + libnvme_subsystem_get_model(s)); obj_add_str(subsystem_attrs, "Serial", - nvme_subsystem_get_serial(s)); + libnvme_subsystem_get_serial(s)); obj_add_str(subsystem_attrs, "Firmware", - nvme_subsystem_get_firmware(s)); + libnvme_subsystem_get_firmware(s)); obj_add_str(subsystem_attrs, "IOPolicy", - nvme_subsystem_get_iopolicy(s)); + libnvme_subsystem_get_iopolicy(s)); obj_add_str(subsystem_attrs, "Type", - nvme_subsystem_get_subsystype(s)); + libnvme_subsystem_get_subsystype(s)); } array_add_obj(subsystems, subsystem_attrs); @@ -3274,7 +3274,7 @@ static void json_nvme_id_ns_descs(void *data, unsigned int nsid) break; case NVME_NIDT_UUID: memcpy(desc.uuid, data + off, sizeof(desc.uuid)); - nvme_uuid_to_string(desc.uuid, json_str); + libnvme_uuid_to_string(desc.uuid, json_str); len = sizeof(desc.uuid); nidt_name = "uuid"; break; @@ -4621,50 +4621,50 @@ static void json_support_log(struct nvme_supported_log_pages *support_log, json_print(r); } -static void json_print_detail_list_multipath(nvme_subsystem_t s, +static void json_print_detail_list_multipath(libnvme_subsystem_t s, struct json_object *jss) { - nvme_ns_t n; - nvme_path_t p; + libnvme_ns_t n; + libnvme_path_t p; struct json_object *jnss = json_create_array(); - nvme_subsystem_for_each_ns(s, n) { + libnvme_subsystem_for_each_ns(s, n) { struct json_object *jns = json_create_object(); struct json_object *jpaths = json_create_array(); - int lba = nvme_ns_get_lba_size(n); - uint64_t nsze = nvme_ns_get_lba_count(n) * lba; - uint64_t nuse = nvme_ns_get_lba_util(n) * lba; + int lba = libnvme_ns_get_lba_size(n); + uint64_t nsze = libnvme_ns_get_lba_count(n) * lba; + uint64_t nuse = libnvme_ns_get_lba_util(n) * lba; - obj_add_str(jns, "NameSpace", nvme_ns_get_name(n)); - obj_add_str(jns, "Generic", nvme_ns_get_generic_name(n)); - obj_add_int(jns, "NSID", nvme_ns_get_nsid(n)); + obj_add_str(jns, "NameSpace", libnvme_ns_get_name(n)); + obj_add_str(jns, "Generic", libnvme_ns_get_generic_name(n)); + obj_add_int(jns, "NSID", libnvme_ns_get_nsid(n)); obj_add_uint64(jns, "UsedBytes", nuse); - obj_add_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n)); + obj_add_uint64(jns, "MaximumLBA", libnvme_ns_get_lba_count(n)); obj_add_uint64(jns, "PhysicalSize", nsze); obj_add_int(jns, "SectorSize", lba); - nvme_namespace_for_each_path(n, p) { - nvme_ctrl_t c; + libnvme_namespace_for_each_path(n, p) { + libnvme_ctrl_t c; struct json_object *jpath = json_create_object(); - obj_add_str(jpath, "Path", nvme_path_get_name(p)); - obj_add_str(jpath, "ANAState", nvme_path_get_ana_state(p)); + obj_add_str(jpath, "Path", libnvme_path_get_name(p)); + obj_add_str(jpath, "ANAState", libnvme_path_get_ana_state(p)); /* * For multipath, each path maps to one controller. * So get the controller from the path and then add * controller attributes. */ - c = nvme_path_get_ctrl(p); - obj_add_str(jpath, "Controller", nvme_ctrl_get_name(c)); - obj_add_str(jpath, "Cntlid", nvme_ctrl_get_cntlid(c)); - obj_add_str(jpath, "SerialNumber", nvme_ctrl_get_serial(c)); - obj_add_str(jpath, "ModelNumber", nvme_ctrl_get_model(c)); - obj_add_str(jpath, "Firmware", nvme_ctrl_get_firmware(c)); - obj_add_str(jpath, "Transport", nvme_ctrl_get_transport(c)); - obj_add_str(jpath, "Address", nvme_ctrl_get_traddr(c)); - obj_add_str(jpath, "Slot", nvme_ctrl_get_phy_slot(c)); + c = libnvme_path_get_ctrl(p); + obj_add_str(jpath, "Controller", libnvme_ctrl_get_name(c)); + obj_add_str(jpath, "Cntlid", libnvme_ctrl_get_cntlid(c)); + obj_add_str(jpath, "SerialNumber", libnvme_ctrl_get_serial(c)); + obj_add_str(jpath, "ModelNumber", libnvme_ctrl_get_model(c)); + obj_add_str(jpath, "Firmware", libnvme_ctrl_get_firmware(c)); + obj_add_str(jpath, "Transport", libnvme_ctrl_get_transport(c)); + obj_add_str(jpath, "Address", libnvme_ctrl_get_traddr(c)); + obj_add_str(jpath, "Slot", libnvme_ctrl_get_phy_slot(c)); array_add_obj(jpaths, jpath); } @@ -4675,36 +4675,36 @@ static void json_print_detail_list_multipath(nvme_subsystem_t s, obj_add_obj(jss, "Namespaces", jnss); } -static void json_print_detail_list(nvme_subsystem_t s, struct json_object *jss) +static void json_print_detail_list(libnvme_subsystem_t s, struct json_object *jss) { - nvme_ctrl_t c; - nvme_ns_t n; + libnvme_ctrl_t c; + libnvme_ns_t n; struct json_object *jctrls = json_create_array(); - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_subsystem_for_each_ctrl(s, c) { struct json_object *jctrl = json_create_object(); struct json_object *jnss = json_create_array(); - obj_add_str(jctrl, "Controller", nvme_ctrl_get_name(c)); - obj_add_str(jctrl, "Cntlid", nvme_ctrl_get_cntlid(c)); - obj_add_str(jctrl, "SerialNumber", nvme_ctrl_get_serial(c)); - obj_add_str(jctrl, "ModelNumber", nvme_ctrl_get_model(c)); - obj_add_str(jctrl, "Firmware", nvme_ctrl_get_firmware(c)); - obj_add_str(jctrl, "Transport", nvme_ctrl_get_transport(c)); - obj_add_str(jctrl, "Address", nvme_ctrl_get_traddr(c)); - obj_add_str(jctrl, "Slot", nvme_ctrl_get_phy_slot(c)); + obj_add_str(jctrl, "Controller", libnvme_ctrl_get_name(c)); + obj_add_str(jctrl, "Cntlid", libnvme_ctrl_get_cntlid(c)); + obj_add_str(jctrl, "SerialNumber", libnvme_ctrl_get_serial(c)); + obj_add_str(jctrl, "ModelNumber", libnvme_ctrl_get_model(c)); + obj_add_str(jctrl, "Firmware", libnvme_ctrl_get_firmware(c)); + obj_add_str(jctrl, "Transport", libnvme_ctrl_get_transport(c)); + obj_add_str(jctrl, "Address", libnvme_ctrl_get_traddr(c)); + obj_add_str(jctrl, "Slot", libnvme_ctrl_get_phy_slot(c)); - nvme_ctrl_for_each_ns(c, n) { + libnvme_ctrl_for_each_ns(c, n) { struct json_object *jns = json_create_object(); - int lba = nvme_ns_get_lba_size(n); - uint64_t nsze = nvme_ns_get_lba_count(n) * lba; - uint64_t nuse = nvme_ns_get_lba_util(n) * lba; + int lba = libnvme_ns_get_lba_size(n); + uint64_t nsze = libnvme_ns_get_lba_count(n) * lba; + uint64_t nuse = libnvme_ns_get_lba_util(n) * lba; - obj_add_str(jns, "NameSpace", nvme_ns_get_name(n)); - obj_add_str(jns, "Generic", nvme_ns_get_generic_name(n)); - obj_add_int(jns, "NSID", nvme_ns_get_nsid(n)); + obj_add_str(jns, "NameSpace", libnvme_ns_get_name(n)); + obj_add_str(jns, "Generic", libnvme_ns_get_generic_name(n)); + obj_add_int(jns, "NSID", libnvme_ns_get_nsid(n)); obj_add_uint64(jns, "UsedBytes", nuse); - obj_add_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n)); + obj_add_uint64(jns, "MaximumLBA", libnvme_ns_get_lba_count(n)); obj_add_uint64(jns, "PhysicalSize", nsze); obj_add_int(jns, "SectorSize", lba); @@ -4723,24 +4723,24 @@ static void json_detail_list_v2(struct nvme_global_ctx *ctx) struct json_object *r = json_create_object(); struct json_object *jdev = json_create_array(); - nvme_host_t h; - nvme_subsystem_t s; + libnvme_host_t h; + libnvme_subsystem_t s; - nvme_for_each_host(ctx, h) { + libnvme_for_each_host(ctx, h) { struct json_object *hss = json_create_object(); struct json_object *jsslist = json_create_array(); const char *hostid; - obj_add_str(hss, "HostNQN", nvme_host_get_hostnqn(h)); - hostid = nvme_host_get_hostid(h); + obj_add_str(hss, "HostNQN", libnvme_host_get_hostnqn(h)); + hostid = libnvme_host_get_hostid(h); if (hostid) obj_add_str(hss, "HostID", hostid); - nvme_for_each_subsystem(h, s) { + libnvme_for_each_subsystem(h, s) { struct json_object *jss = json_create_object(); - obj_add_str(jss, "Subsystem", nvme_subsystem_get_name(s)); - obj_add_str(jss, "SubsystemNQN", nvme_subsystem_get_subsysnqn(s)); + obj_add_str(jss, "Subsystem", libnvme_subsystem_get_name(s)); + obj_add_str(jss, "SubsystemNQN", libnvme_subsystem_get_subsysnqn(s)); if (nvme_is_multipath(s)) json_print_detail_list_multipath(s, jss); @@ -4764,55 +4764,55 @@ static void json_detail_list(struct nvme_global_ctx *ctx) struct json_object *r = json_create_object(); struct json_object *jdev = json_create_array(); - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; - nvme_path_t p; - nvme_ns_t n; + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; + libnvme_path_t p; + libnvme_ns_t n; - nvme_for_each_host(ctx, h) { + libnvme_for_each_host(ctx, h) { struct json_object *hss = json_create_object(); struct json_object *jsslist = json_create_array(); const char *hostid; - obj_add_str(hss, "HostNQN", nvme_host_get_hostnqn(h)); - hostid = nvme_host_get_hostid(h); + obj_add_str(hss, "HostNQN", libnvme_host_get_hostnqn(h)); + hostid = libnvme_host_get_hostid(h); if (hostid) obj_add_str(hss, "HostID", hostid); - nvme_for_each_subsystem(h, s) { + libnvme_for_each_subsystem(h, s) { struct json_object *jss = json_create_object(); struct json_object *jctrls = json_create_array(); struct json_object *jnss = json_create_array(); - obj_add_str(jss, "Subsystem", nvme_subsystem_get_name(s)); - obj_add_str(jss, "SubsystemNQN", nvme_subsystem_get_subsysnqn(s)); + obj_add_str(jss, "Subsystem", libnvme_subsystem_get_name(s)); + obj_add_str(jss, "SubsystemNQN", libnvme_subsystem_get_subsysnqn(s)); - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_subsystem_for_each_ctrl(s, c) { struct json_object *jctrl = json_create_object(); struct json_object *jnss = json_create_array(); struct json_object *jpaths = json_create_array(); - obj_add_str(jctrl, "Controller", nvme_ctrl_get_name(c)); - obj_add_str(jctrl, "Cntlid", nvme_ctrl_get_cntlid(c)); - obj_add_str(jctrl, "SerialNumber", nvme_ctrl_get_serial(c)); - obj_add_str(jctrl, "ModelNumber", nvme_ctrl_get_model(c)); - obj_add_str(jctrl, "Firmware", nvme_ctrl_get_firmware(c)); - obj_add_str(jctrl, "Transport", nvme_ctrl_get_transport(c)); - obj_add_str(jctrl, "Address", nvme_ctrl_get_traddr(c)); - obj_add_str(jctrl, "Slot", nvme_ctrl_get_phy_slot(c)); + obj_add_str(jctrl, "Controller", libnvme_ctrl_get_name(c)); + obj_add_str(jctrl, "Cntlid", libnvme_ctrl_get_cntlid(c)); + obj_add_str(jctrl, "SerialNumber", libnvme_ctrl_get_serial(c)); + obj_add_str(jctrl, "ModelNumber", libnvme_ctrl_get_model(c)); + obj_add_str(jctrl, "Firmware", libnvme_ctrl_get_firmware(c)); + obj_add_str(jctrl, "Transport", libnvme_ctrl_get_transport(c)); + obj_add_str(jctrl, "Address", libnvme_ctrl_get_traddr(c)); + obj_add_str(jctrl, "Slot", libnvme_ctrl_get_phy_slot(c)); - nvme_ctrl_for_each_ns(c, n) { + libnvme_ctrl_for_each_ns(c, n) { struct json_object *jns = json_create_object(); - int lba = nvme_ns_get_lba_size(n); - uint64_t nsze = nvme_ns_get_lba_count(n) * lba; - uint64_t nuse = nvme_ns_get_lba_util(n) * lba; + int lba = libnvme_ns_get_lba_size(n); + uint64_t nsze = libnvme_ns_get_lba_count(n) * lba; + uint64_t nuse = libnvme_ns_get_lba_util(n) * lba; - obj_add_str(jns, "NameSpace", nvme_ns_get_name(n)); - obj_add_str(jns, "Generic", nvme_ns_get_generic_name(n)); - obj_add_int(jns, "NSID", nvme_ns_get_nsid(n)); + obj_add_str(jns, "NameSpace", libnvme_ns_get_name(n)); + obj_add_str(jns, "Generic", libnvme_ns_get_generic_name(n)); + obj_add_int(jns, "NSID", libnvme_ns_get_nsid(n)); obj_add_uint64(jns, "UsedBytes", nuse); - obj_add_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n)); + obj_add_uint64(jns, "MaximumLBA", libnvme_ns_get_lba_count(n)); obj_add_uint64(jns, "PhysicalSize", nsze); obj_add_int(jns, "SectorSize", lba); @@ -4820,11 +4820,11 @@ static void json_detail_list(struct nvme_global_ctx *ctx) } obj_add_obj(jctrl, "Namespaces", jnss); - nvme_ctrl_for_each_path(c, p) { + libnvme_ctrl_for_each_path(c, p) { struct json_object *jpath = json_create_object(); - obj_add_str(jpath, "Path", nvme_path_get_name(p)); - obj_add_str(jpath, "ANAState", nvme_path_get_ana_state(p)); + obj_add_str(jpath, "Path", libnvme_path_get_name(p)); + obj_add_str(jpath, "ANAState", libnvme_path_get_ana_state(p)); array_add_obj(jpaths, jpath); } @@ -4834,18 +4834,18 @@ static void json_detail_list(struct nvme_global_ctx *ctx) } obj_add_obj(jss, "Controllers", jctrls); - nvme_subsystem_for_each_ns(s, n) { + libnvme_subsystem_for_each_ns(s, n) { struct json_object *jns = json_create_object(); - int lba = nvme_ns_get_lba_size(n); - uint64_t nsze = nvme_ns_get_lba_count(n) * lba; - uint64_t nuse = nvme_ns_get_lba_util(n) * lba; + int lba = libnvme_ns_get_lba_size(n); + uint64_t nsze = libnvme_ns_get_lba_count(n) * lba; + uint64_t nuse = libnvme_ns_get_lba_util(n) * lba; - obj_add_str(jns, "NameSpace", nvme_ns_get_name(n)); - obj_add_str(jns, "Generic", nvme_ns_get_generic_name(n)); - obj_add_int(jns, "NSID", nvme_ns_get_nsid(n)); + obj_add_str(jns, "NameSpace", libnvme_ns_get_name(n)); + obj_add_str(jns, "Generic", libnvme_ns_get_generic_name(n)); + obj_add_int(jns, "NSID", libnvme_ns_get_nsid(n)); obj_add_uint64(jns, "UsedBytes", nuse); - obj_add_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n)); + obj_add_uint64(jns, "MaximumLBA", libnvme_ns_get_lba_count(n)); obj_add_uint64(jns, "PhysicalSize", nsze); obj_add_int(jns, "SectorSize", lba); @@ -4865,26 +4865,26 @@ static void json_detail_list(struct nvme_global_ctx *ctx) json_print(r); } -static struct json_object *json_list_item_obj(nvme_ns_t n) +static struct json_object *json_list_item_obj(libnvme_ns_t n) { struct json_object *r = json_create_object(); char devname[NAME_LEN] = { 0 }; char genname[NAME_LEN] = { 0 }; - int lba = nvme_ns_get_lba_size(n); - uint64_t nsze = nvme_ns_get_lba_count(n) * lba; - uint64_t nuse = nvme_ns_get_lba_util(n) * lba; + int lba = libnvme_ns_get_lba_size(n); + uint64_t nsze = libnvme_ns_get_lba_count(n) * lba; + uint64_t nuse = libnvme_ns_get_lba_util(n) * lba; nvme_dev_full_path(n, devname, sizeof(devname)); nvme_generic_full_path(n, genname, sizeof(genname)); - obj_add_int(r, "NameSpace", nvme_ns_get_nsid(n)); + obj_add_int(r, "NameSpace", libnvme_ns_get_nsid(n)); obj_add_str(r, "DevicePath", devname); obj_add_str(r, "GenericPath", genname); - obj_add_str(r, "Firmware", nvme_ns_get_firmware(n)); - obj_add_str(r, "ModelNumber", nvme_ns_get_model(n)); - obj_add_str(r, "SerialNumber", nvme_ns_get_serial(n)); + obj_add_str(r, "Firmware", libnvme_ns_get_firmware(n)); + obj_add_str(r, "ModelNumber", libnvme_ns_get_model(n)); + obj_add_str(r, "SerialNumber", libnvme_ns_get_serial(n)); obj_add_uint64(r, "UsedBytes", nuse); - obj_add_uint64(r, "MaximumLBA", nvme_ns_get_lba_count(n)); + obj_add_uint64(r, "MaximumLBA", libnvme_ns_get_lba_count(n)); obj_add_uint64(r, "PhysicalSize", nsze); obj_add_int(r, "SectorSize", lba); @@ -4896,18 +4896,18 @@ static void json_simple_list(struct nvme_global_ctx *ctx) struct json_object *r = json_create_object(); struct json_object *jdevices = json_create_array(); - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; - nvme_ns_t n; + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; + libnvme_ns_t n; - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - nvme_subsystem_for_each_ns(s, n) + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + libnvme_subsystem_for_each_ns(s, n) array_add_obj(jdevices, json_list_item_obj(n)); - nvme_subsystem_for_each_ctrl(s, c) { - nvme_ctrl_for_each_ns(c, n) + libnvme_subsystem_for_each_ctrl(s, c) { + libnvme_ctrl_for_each_ns(c, n) array_add_obj(jdevices, json_list_item_obj(n)); } } @@ -4918,7 +4918,7 @@ static void json_simple_list(struct nvme_global_ctx *ctx) json_print(r); } -static void json_list_item(nvme_ns_t n, struct table *t) +static void json_list_item(libnvme_ns_t n, struct table *t) { struct json_object *r = json_list_item_obj(n); @@ -4936,31 +4936,31 @@ static void json_print_list_items(struct nvme_global_ctx *ctx) json_simple_list(ctx); } -static unsigned int json_subsystem_topology_multipath(nvme_subsystem_t s, +static unsigned int json_subsystem_topology_multipath(libnvme_subsystem_t s, json_object *namespaces) { - nvme_ns_t n; - nvme_path_t p; + libnvme_ns_t n; + libnvme_path_t p; unsigned int i = 0; - const char *iopolicy = nvme_subsystem_get_iopolicy(s); + const char *iopolicy = libnvme_subsystem_get_iopolicy(s); - nvme_subsystem_for_each_ns(s, n) { + libnvme_subsystem_for_each_ns(s, n) { struct json_object *ns_attrs; struct json_object *paths; ns_attrs = json_create_object(); - obj_add_int(ns_attrs, "NSID", nvme_ns_get_nsid(n)); - obj_add_str(ns_attrs, "Name", nvme_ns_get_name(n)); + obj_add_int(ns_attrs, "NSID", libnvme_ns_get_nsid(n)); + obj_add_str(ns_attrs, "Name", libnvme_ns_get_name(n)); paths = json_create_array(); - nvme_namespace_for_each_path(n, p) { + libnvme_namespace_for_each_path(n, p) { struct json_object *path_attrs; struct json_object *ctrls, *ctrl_attrs; - nvme_ctrl_t c; + libnvme_ctrl_t c; path_attrs = json_create_object(); - obj_add_str(path_attrs, "Path", nvme_path_get_name(p)); - obj_add_str(path_attrs, "ANAState", nvme_path_get_ana_state(p)); + obj_add_str(path_attrs, "Path", libnvme_path_get_name(p)); + obj_add_str(path_attrs, "ANAState", libnvme_path_get_ana_state(p)); /* * For iopolicy numa exclude "Qdepth", for iopolicy @@ -4969,18 +4969,18 @@ static unsigned int json_subsystem_topology_multipath(nvme_subsystem_t s, */ if (!strcmp(iopolicy, "numa")) obj_add_str(path_attrs, "NUMANodes", - nvme_path_get_numa_nodes(p)); + libnvme_path_get_numa_nodes(p)); else if (!strcmp(iopolicy, "queue-depth")) obj_add_int(path_attrs, "Qdepth", - nvme_path_get_queue_depth(p)); + libnvme_path_get_queue_depth(p)); - c = nvme_path_get_ctrl(p); + c = libnvme_path_get_ctrl(p); ctrls = json_create_array(); ctrl_attrs = json_create_object(); - obj_add_str(ctrl_attrs, "Name", nvme_ctrl_get_name(c)); - obj_add_str(ctrl_attrs, "Transport", nvme_ctrl_get_transport(c)); - obj_add_str(ctrl_attrs, "Address", nvme_ctrl_get_traddr(c)); - obj_add_str(ctrl_attrs, "State", nvme_ctrl_get_state(c)); + obj_add_str(ctrl_attrs, "Name", libnvme_ctrl_get_name(c)); + obj_add_str(ctrl_attrs, "Transport", libnvme_ctrl_get_transport(c)); + obj_add_str(ctrl_attrs, "Address", libnvme_ctrl_get_traddr(c)); + obj_add_str(ctrl_attrs, "State", libnvme_ctrl_get_state(c)); array_add_obj(ctrls, ctrl_attrs); obj_add_array(path_attrs, "Controller", ctrls); @@ -4994,32 +4994,32 @@ static unsigned int json_subsystem_topology_multipath(nvme_subsystem_t s, return i; } -static void json_print_nvme_subsystem_topology(nvme_subsystem_t s, +static void json_print_nvme_subsystem_topology(libnvme_subsystem_t s, json_object *namespaces) { - nvme_ctrl_t c; - nvme_ns_t n; + libnvme_ctrl_t c; + libnvme_ns_t n; - nvme_subsystem_for_each_ctrl(s, c) { - nvme_ctrl_for_each_ns(c, n) { + libnvme_subsystem_for_each_ctrl(s, c) { + libnvme_ctrl_for_each_ns(c, n) { struct json_object *ctrl_attrs; struct json_object *ns_attrs; struct json_object *ctrl; ns_attrs = json_create_object(); - obj_add_int(ns_attrs, "NSID", nvme_ns_get_nsid(n)); - obj_add_str(ns_attrs, "Name", nvme_ns_get_name(n)); + obj_add_int(ns_attrs, "NSID", libnvme_ns_get_nsid(n)); + obj_add_str(ns_attrs, "Name", libnvme_ns_get_name(n)); ctrl = json_create_array(); ctrl_attrs = json_create_object(); obj_add_str(ctrl_attrs, "Name", - nvme_ctrl_get_name(c)); + libnvme_ctrl_get_name(c)); obj_add_str(ctrl_attrs, "Transport", - nvme_ctrl_get_transport(c)); + libnvme_ctrl_get_transport(c)); obj_add_str(ctrl_attrs, "Address", - nvme_ctrl_get_traddr(c)); + libnvme_ctrl_get_traddr(c)); obj_add_str(ctrl_attrs, "State", - nvme_ctrl_get_state(c)); + libnvme_ctrl_get_state(c)); array_add_obj(ctrl, ctrl_attrs); obj_add_array(ns_attrs, "Controller", ctrl); @@ -5033,34 +5033,34 @@ static void json_simple_topology(struct nvme_global_ctx *ctx) struct json_object *host_attrs, *subsystem_attrs; struct json_object *subsystems, *namespaces; struct json_object *a = json_create_array(); - nvme_host_t h; + libnvme_host_t h; - nvme_for_each_host(ctx, h) { - nvme_subsystem_t s; + libnvme_for_each_host(ctx, h) { + libnvme_subsystem_t s; const char *hostid; host_attrs = json_create_object(); - obj_add_str(host_attrs, "HostNQN", nvme_host_get_hostnqn(h)); - hostid = nvme_host_get_hostid(h); + obj_add_str(host_attrs, "HostNQN", libnvme_host_get_hostnqn(h)); + hostid = libnvme_host_get_hostid(h); if (hostid) obj_add_str(host_attrs, "HostID", hostid); subsystems = json_create_array(); - nvme_for_each_subsystem(h, s) { + libnvme_for_each_subsystem(h, s) { subsystem_attrs = json_create_object(); - obj_add_str(subsystem_attrs, "Name", nvme_subsystem_get_name(s)); - obj_add_str(subsystem_attrs, "NQN", nvme_subsystem_get_subsysnqn(s)); + obj_add_str(subsystem_attrs, "Name", libnvme_subsystem_get_name(s)); + obj_add_str(subsystem_attrs, "NQN", libnvme_subsystem_get_subsysnqn(s)); obj_add_str(subsystem_attrs, "IOPolicy", - nvme_subsystem_get_iopolicy(s)); + libnvme_subsystem_get_iopolicy(s)); if (verbose_mode()) { obj_add_str(subsystem_attrs, "Model", - nvme_subsystem_get_model(s)); + libnvme_subsystem_get_model(s)); obj_add_str(subsystem_attrs, "Serial", - nvme_subsystem_get_serial(s)); + libnvme_subsystem_get_serial(s)); obj_add_str(subsystem_attrs, "Firmware", - nvme_subsystem_get_firmware(s)); + libnvme_subsystem_get_firmware(s)); obj_add_str(subsystem_attrs, "Type", - nvme_subsystem_get_subsystype(s)); + libnvme_subsystem_get_subsystype(s)); } array_add_obj(subsystems, subsystem_attrs); @@ -5247,11 +5247,11 @@ static void json_discovery_log(struct nvmf_discovery_log *log, int numrec) static void json_discovery_log(struct nvmf_discovery_log *log, int numrec) {} #endif -static void json_connect_msg(nvme_ctrl_t c) +static void json_connect_msg(libnvme_ctrl_t c) { struct json_object *r = json_create_object(); - obj_add_str(r, "device", nvme_ctrl_get_name(c)); + obj_add_str(r, "device", libnvme_ctrl_get_name(c)); json_print(r); } @@ -5272,7 +5272,7 @@ static void json_output_status(int status) r = obj_create(json_str); if (status < 0) { - obj_add_str(r, "error", nvme_strerror(errno)); + obj_add_str(r, "error", libnvme_strerror(errno)); obj_print(r); return; } @@ -5282,11 +5282,11 @@ static void json_output_status(int status) switch (type) { case NVME_STATUS_TYPE_NVME: - obj_add_str(r, "error", nvme_status_to_string(val, false)); + obj_add_str(r, "error", libnvme_status_to_string(val, false)); obj_add_str(r, "type", "nvme"); break; case NVME_STATUS_TYPE_MI: - obj_add_str(r, "error", nvme_mi_status_to_string(val)); + obj_add_str(r, "error", libnvme_mi_status_to_string(val)); obj_add_str(r, "type", "nvme-mi"); break; default: @@ -5308,7 +5308,7 @@ static void json_output_opcode_status(int status, bool admin, __u8 opcode) sprintf(json_str, "status: %d", status); r = obj_create(json_str); obj_add_str(r, "error", - nvme_opcode_status_to_string(val, admin, opcode)); + libnvme_opcode_status_to_string(val, admin, opcode)); obj_add_str(r, "type", "nvme"); obj_print(r); return; @@ -5333,7 +5333,7 @@ static void json_output_error_status(int status, const char *msg, va_list ap) r = obj_create(json_str); if (status < 0) { - obj_add_str(r, "error", nvme_strerror(errno)); + obj_add_str(r, "error", libnvme_strerror(errno)); obj_print(r); return; } @@ -5343,11 +5343,11 @@ static void json_output_error_status(int status, const char *msg, va_list ap) switch (type) { case NVME_STATUS_TYPE_NVME: - obj_add_str(r, "status", nvme_status_to_string(val, false)); + obj_add_str(r, "status", libnvme_status_to_string(val, false)); obj_add_str(r, "type", "nvme"); break; case NVME_STATUS_TYPE_MI: - obj_add_str(r, "status", nvme_mi_status_to_string(val)); + obj_add_str(r, "status", libnvme_mi_status_to_string(val)); obj_add_str(r, "type", "nvme-mi"); break; default: @@ -5384,7 +5384,7 @@ static void json_output_perror(const char *msg, va_list ap) error = NULL; obj_add_key(r, "error", "%s: %s", error ? error : alloc_error, - nvme_strerror(errno)); + libnvme_strerror(errno)); json_output_object(r); } diff --git a/nvme-print-stdout.c b/nvme-print-stdout.c index 3188dafaf3..56d9a66580 100644 --- a/nvme-print-stdout.c +++ b/nvme-print-stdout.c @@ -42,63 +42,63 @@ static const char dash[100] = {[0 ... 99] = '-'}; static struct print_ops stdout_print_ops; -static const char *subsys_key(const struct nvme_subsystem *s) +static const char *subsys_key(const struct libnvme_subsystem *s) { - return nvme_subsystem_get_name((nvme_subsystem_t)s); + return libnvme_subsystem_get_name((libnvme_subsystem_t)s); } -static const char *ctrl_key(const struct nvme_ctrl *c) +static const char *ctrl_key(const struct libnvme_ctrl *c) { - return nvme_ctrl_get_name((nvme_ctrl_t)c); + return libnvme_ctrl_get_name((libnvme_ctrl_t)c); } -static const char *ns_key(const struct nvme_ns *n) +static const char *ns_key(const struct libnvme_ns *n) { - return nvme_ns_get_name((nvme_ns_t)n); + return libnvme_ns_get_name((libnvme_ns_t)n); } -static bool subsys_cmp(const struct nvme_subsystem *s, const char *name) +static bool subsys_cmp(const struct libnvme_subsystem *s, const char *name) { - return !strcmp(nvme_subsystem_get_name((nvme_subsystem_t)s), name); + return !strcmp(libnvme_subsystem_get_name((libnvme_subsystem_t)s), name); } -static bool ctrl_cmp(const struct nvme_ctrl *c, const char *name) +static bool ctrl_cmp(const struct libnvme_ctrl *c, const char *name) { - return !strcmp(nvme_ctrl_get_name((nvme_ctrl_t)c), name); + return !strcmp(libnvme_ctrl_get_name((libnvme_ctrl_t)c), name); } -static bool ns_cmp(const struct nvme_ns *n, const char *name) +static bool ns_cmp(const struct libnvme_ns *n, const char *name) { - return !strcmp(nvme_ns_get_name((nvme_ns_t)n), name); + return !strcmp(libnvme_ns_get_name((libnvme_ns_t)n), name); } -HTABLE_DEFINE_TYPE(struct nvme_subsystem, subsys_key, hash_string, +HTABLE_DEFINE_TYPE(struct libnvme_subsystem, subsys_key, hash_string, subsys_cmp, htable_subsys); -HTABLE_DEFINE_TYPE(struct nvme_ctrl, ctrl_key, hash_string, +HTABLE_DEFINE_TYPE(struct libnvme_ctrl, ctrl_key, hash_string, ctrl_cmp, htable_ctrl); -HTABLE_DEFINE_TYPE(struct nvme_ns, ns_key, hash_string, +HTABLE_DEFINE_TYPE(struct libnvme_ns, ns_key, hash_string, ns_cmp, htable_ns); -static void htable_ctrl_add_unique(struct htable_ctrl *ht, nvme_ctrl_t c) +static void htable_ctrl_add_unique(struct htable_ctrl *ht, libnvme_ctrl_t c) { - if (htable_ctrl_get(ht, nvme_ctrl_get_name(c))) + if (htable_ctrl_get(ht, libnvme_ctrl_get_name(c))) return; htable_ctrl_add(ht, c); } -static void htable_ns_add_unique(struct htable_ns *ht, nvme_ns_t n) +static void htable_ns_add_unique(struct htable_ns *ht, libnvme_ns_t n) { struct htable_ns_iter it; - nvme_ns_t _n; + libnvme_ns_t _n; /* * Test if namespace pointer is already in the hash, and thus avoid * inserting severaltimes the same pointer. */ - for (_n = htable_ns_getfirst(ht, nvme_ns_get_name(n), &it); + for (_n = htable_ns_getfirst(ht, libnvme_ns_get_name(n), &it); _n; - _n = htable_ns_getnext(ht, nvme_ns_get_name(n), &it)) { + _n = htable_ns_getnext(ht, libnvme_ns_get_name(n), &it)) { if (_n == n) return; } @@ -123,11 +123,11 @@ struct nvme_resources_table { static int nvme_resources_init(struct nvme_global_ctx *ctx, struct nvme_resources *res) { - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; - nvme_ns_t n; - nvme_path_t p; + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; + libnvme_ns_t n; + libnvme_path_t p; res->ctx = ctx; htable_subsys_init(&res->ht_s); @@ -137,32 +137,32 @@ static int nvme_resources_init(struct nvme_global_ctx *ctx, struct nvme_resource strset_init(&res->ctrls); strset_init(&res->namespaces); - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { htable_subsys_add(&res->ht_s, s); - strset_add(&res->subsystems, nvme_subsystem_get_name(s)); + strset_add(&res->subsystems, libnvme_subsystem_get_name(s)); - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_subsystem_for_each_ctrl(s, c) { htable_ctrl_add_unique(&res->ht_c, c); - strset_add(&res->ctrls, nvme_ctrl_get_name(c)); + strset_add(&res->ctrls, libnvme_ctrl_get_name(c)); - nvme_ctrl_for_each_ns(c, n) { + libnvme_ctrl_for_each_ns(c, n) { htable_ns_add_unique(&res->ht_n, n); - strset_add(&res->namespaces, nvme_ns_get_name(n)); + strset_add(&res->namespaces, libnvme_ns_get_name(n)); } - nvme_ctrl_for_each_path(c, p) { - n = nvme_path_get_ns(p); + libnvme_ctrl_for_each_path(c, p) { + n = libnvme_path_get_ns(p); if (n) { htable_ns_add_unique(&res->ht_n, n); - strset_add(&res->namespaces, nvme_ns_get_name(n)); + strset_add(&res->namespaces, libnvme_ns_get_name(n)); } } } - nvme_subsystem_for_each_ns(s, n) { + libnvme_subsystem_for_each_ns(s, n) { htable_ns_add_unique(&res->ht_n, n); - strset_add(&res->namespaces, nvme_ns_get_name(n)); + strset_add(&res->namespaces, libnvme_ns_get_name(n)); } } } @@ -1171,25 +1171,25 @@ static void stdout_supported_cap_config_log(struct nvme_supported_cap_config_lis } } -static unsigned int stdout_subsystem_multipath(nvme_subsystem_t s) +static unsigned int stdout_subsystem_multipath(libnvme_subsystem_t s) { - nvme_ns_t n; - nvme_path_t p; + libnvme_ns_t n; + libnvme_path_t p; unsigned int i = 0; - n = nvme_subsystem_first_ns(s); + n = libnvme_subsystem_first_ns(s); if (!n) return 0; - nvme_namespace_for_each_path(n, p) { - nvme_ctrl_t c = nvme_path_get_ctrl(p); - const char *ana_state = ana_state = nvme_path_get_ana_state(p); + libnvme_namespace_for_each_path(n, p) { + libnvme_ctrl_t c = libnvme_path_get_ctrl(p); + const char *ana_state = ana_state = libnvme_path_get_ana_state(p); printf(" +- %s %s %s %s %s\n", - nvme_ctrl_get_name(c), - nvme_ctrl_get_transport(c), - nvme_ctrl_get_traddr(c), - nvme_ctrl_get_state(c), + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_state(c), ana_state); i++; } @@ -1197,56 +1197,56 @@ static unsigned int stdout_subsystem_multipath(nvme_subsystem_t s) return i; } -static void stdout_subsystem_ctrls(nvme_subsystem_t s) +static void stdout_subsystem_ctrls(libnvme_subsystem_t s) { - nvme_ctrl_t c; + libnvme_ctrl_t c; - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_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_traddr(c), - nvme_ctrl_get_state(c)); + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_state(c)); } } -static void stdout_subsys_config(nvme_subsystem_t s, bool show_iopolicy) +static void stdout_subsys_config(libnvme_subsystem_t s, bool show_iopolicy) { - int len = strlen(nvme_subsystem_get_name(s)); + int len = strlen(libnvme_subsystem_get_name(s)); - printf("%s - NQN=%s\n", nvme_subsystem_get_name(s), - nvme_subsystem_get_subsysnqn(s)); + printf("%s - NQN=%s\n", libnvme_subsystem_get_name(s), + libnvme_subsystem_get_subsysnqn(s)); printf("%*s hostnqn=%s\n", len, " ", - nvme_host_get_hostnqn(nvme_subsystem_get_host(s))); + libnvme_host_get_hostnqn(libnvme_subsystem_get_host(s))); if (show_iopolicy) printf("%*s iopolicy=%s\n", len, " ", - nvme_subsystem_get_iopolicy(s)); + libnvme_subsystem_get_iopolicy(s)); if (stdout_print_ops.flags & VERBOSE) { printf("%*s model=%s\n", len, " ", - nvme_subsystem_get_model(s)); + libnvme_subsystem_get_model(s)); printf("%*s serial=%s\n", len, " ", - nvme_subsystem_get_serial(s)); + libnvme_subsystem_get_serial(s)); printf("%*s firmware=%s\n", len, " ", - nvme_subsystem_get_firmware(s)); + libnvme_subsystem_get_firmware(s)); printf("%*s type=%s\n", len, " ", - nvme_subsystem_get_subsystype(s)); + libnvme_subsystem_get_subsystype(s)); } } static void stdout_subsystem(struct nvme_global_ctx *ctx, bool show_ana) { - nvme_host_t h; + libnvme_host_t h; bool first = true; - nvme_for_each_host(ctx, h) { - nvme_subsystem_t s; + libnvme_for_each_host(ctx, h) { + libnvme_subsystem_t s; - nvme_for_each_subsystem(h, s) { + libnvme_for_each_subsystem(h, s) { bool no_ctrl = true; - nvme_ctrl_t c; + libnvme_ctrl_t c; - nvme_subsystem_for_each_ctrl(s, c) + libnvme_subsystem_for_each_ctrl(s, c) no_ctrl = false; if (no_ctrl) continue; @@ -1801,7 +1801,7 @@ static void stdout_status(int status) * sensible fallback anyway */ if (status < 0) { - fprintf(stderr, "Error: %s\n", nvme_strerror(errno)); + fprintf(stderr, "Error: %s\n", libnvme_strerror(errno)); return; } @@ -1811,11 +1811,11 @@ static void stdout_status(int status) switch (type) { case NVME_STATUS_TYPE_NVME: fprintf(stderr, "NVMe status: %s(%#x)\n", - nvme_status_to_string(val, false), val); + libnvme_status_to_string(val, false), val); break; case NVME_STATUS_TYPE_MI: fprintf(stderr, "NVMe-MI status: %s(%#x)\n", - nvme_mi_status_to_string(val), val); + libnvme_mi_status_to_string(val), val); break; default: fprintf(stderr, "Unknown status type %d, value %#x\n", type, @@ -1831,7 +1831,7 @@ static void stdout_opcode_status(int status, bool admin, __u8 opcode) if (status >= 0 && type == NVME_STATUS_TYPE_NVME) { fprintf(stderr, "NVMe status: %s(0x%x)\n", - nvme_opcode_status_to_string(val, admin, opcode), val); + libnvme_opcode_status_to_string(val, admin, opcode), val); return; } @@ -3201,7 +3201,7 @@ static void stdout_id_ns_descs(void *data, unsigned int nsid) break; case NVME_NIDT_UUID: memcpy(uuid, data + pos + sizeof(*cur), 16); - nvme_uuid_to_string(uuid, uuid_str); + libnvme_uuid_to_string(uuid, uuid_str); if (verbose) printf("type : uuid\n"); printf("uuid : %s\n", uuid_str); @@ -4223,7 +4223,7 @@ static void stdout_error_log(struct nvme_error_log_page *err_log, int entries, printf("sqid : %d\n", err_log[i].sqid); printf("cmdid : %#x\n", err_log[i].cmdid); printf("status_field : %#x (%s)\n", status, - nvme_status_to_string(status, false)); + libnvme_status_to_string(status, false)); printf("phase_tag : %#x\n", le16_to_cpu(err_log[i].status_field) & 0x1); printf("parm_err_loc : %#x\n", err_log[i].parm_error_location); @@ -4729,7 +4729,7 @@ static void stdout_self_test_result(struct nvme_st_result *res) if (res->vdi & NVME_ST_VALID_DIAG_INFO_SC) { printf(" Status Code : %#x", res->sc); if (stdout_print_ops.flags & VERBOSE) - printf(" %s", nvme_status_to_string( + printf(" %s", libnvme_status_to_string( (res->sct & 7) << 8 | res->sc, false)); printf("\n"); } @@ -5548,15 +5548,15 @@ static void stdout_lba_status(struct nvme_lba_status *list, } } -static void stdout_dev_full_path(nvme_ns_t n, char *path, size_t len) +static void stdout_dev_full_path(libnvme_ns_t n, char *path, size_t len) { struct stat st; - snprintf(path, len, "%s", nvme_ns_get_name(n)); + snprintf(path, len, "%s", libnvme_ns_get_name(n)); if (strncmp(path, "/dev/spdk/", 10) == 0 && stat(path, &st) == 0) return; - snprintf(path, len, "/dev/%s", nvme_ns_get_name(n)); + snprintf(path, len, "/dev/%s", libnvme_ns_get_name(n)); if (stat(path, &st) == 0) return; @@ -5564,10 +5564,10 @@ static void stdout_dev_full_path(nvme_ns_t n, char *path, size_t len) * We could start trying to search for it but let's make * it simple and just don't show the path at all. */ - snprintf(path, len, "%s", nvme_ns_get_name(n)); + snprintf(path, len, "%s", libnvme_ns_get_name(n)); } -static void stdout_generic_full_path(nvme_ns_t n, char *path, size_t len) +static void stdout_generic_full_path(libnvme_ns_t n, char *path, size_t len) { int head_instance; int instance; @@ -5577,11 +5577,11 @@ static void stdout_generic_full_path(nvme_ns_t n, char *path, size_t len) * There is no block devices for SPDK, point generic path to existing * chardevice. */ - snprintf(path, len, "%s", nvme_ns_get_name(n)); + snprintf(path, len, "%s", libnvme_ns_get_name(n)); if (strncmp(path, "/dev/spdk/", 10) == 0 && stat(path, &st) == 0) return; - if (sscanf(nvme_ns_get_name(n), "nvme%dn%d", &instance, &head_instance) != 2) + if (sscanf(libnvme_ns_get_name(n), "nvme%dn%d", &instance, &head_instance) != 2) return; snprintf(path, len, "/dev/ng%dn%d", instance, head_instance); @@ -5596,14 +5596,14 @@ static void stdout_generic_full_path(nvme_ns_t n, char *path, size_t len) snprintf(path, len, "ng%dn%d", instance, head_instance); } -static void list_item(nvme_ns_t n, struct table *t) +static void list_item(libnvme_ns_t n, struct table *t) { char usage[128] = { 0 }, format[128] = { 0 }; char devname[128] = { 0 }; char genname[128] = { 0 }; - long long lba = nvme_ns_get_lba_size(n); - double nsze = nvme_ns_get_lba_count(n) * lba; - double nuse = nvme_ns_get_lba_util(n) * lba; + long long lba = libnvme_ns_get_lba_size(n); + double nsze = libnvme_ns_get_lba_count(n) * lba; + double nuse = libnvme_ns_get_lba_util(n) * lba; const char *s_suffix = suffix_si_get(&nsze); const char *u_suffix = suffix_si_get(&nuse); @@ -5614,7 +5614,7 @@ static void list_item(nvme_ns_t n, struct table *t) snprintf(usage, sizeof(usage), "%6.2f %2sB / %6.2f %2sB", nuse, u_suffix, nsze, s_suffix); snprintf(format, sizeof(format), "%3.0f %2sB + %2d B", (double)lba, - l_suffix, nvme_ns_get_meta_size(n)); + l_suffix, libnvme_ns_get_meta_size(n)); stdout_dev_full_path(n, devname, sizeof(devname)); stdout_generic_full_path(n, genname, sizeof(genname)); @@ -5632,15 +5632,15 @@ static void list_item(nvme_ns_t n, struct table *t) printf("Failed to set generic value\n"); return; } - if (table_set_value_str(t, SIMPLE_LIST_COL_SN, row, nvme_ns_get_serial(n), LEFT)) { + if (table_set_value_str(t, SIMPLE_LIST_COL_SN, row, libnvme_ns_get_serial(n), LEFT)) { printf("Failed to set sn value\n"); return; } - if (table_set_value_str(t, SIMPLE_LIST_COL_MODEL, row, nvme_ns_get_model(n), LEFT)) { + if (table_set_value_str(t, SIMPLE_LIST_COL_MODEL, row, libnvme_ns_get_model(n), LEFT)) { printf("Failed to set model value\n"); return; } - if (!sprintf(ns, "0x%x", nvme_ns_get_nsid(n))) { + if (!sprintf(ns, "0x%x", libnvme_ns_get_nsid(n))) { printf("Failed to output ns string\n"); return; } @@ -5656,19 +5656,19 @@ static void list_item(nvme_ns_t n, struct table *t) printf("Failed to set format value\n"); return; } - if (table_set_value_str(t, SIMPLE_LIST_COL_FW_REV, row, nvme_ns_get_firmware(n), LEFT)) { + if (table_set_value_str(t, SIMPLE_LIST_COL_FW_REV, row, libnvme_ns_get_firmware(n), LEFT)) { printf("Failed to set fw rev value\n"); return; } table_add_row(t, row); } -static void stdout_list_item(nvme_ns_t n, struct table *t) +static void stdout_list_item(libnvme_ns_t n, struct table *t) { list_item(n, t); } -static void stdout_list_item_table(nvme_ns_t n, struct table *t) +static void stdout_list_item_table(libnvme_ns_t n, struct table *t) { list_item(n, t); } @@ -5677,7 +5677,7 @@ static bool stdout_simple_ns(const char *name, void *arg) { struct nvme_resources_table *rst_t = arg; struct nvme_resources *res = rst_t->res; - nvme_ns_t n; + libnvme_ns_t n; n = htable_ns_get(&res->ht_n, name); stdout_list_item_table(n, rst_t->t); @@ -5716,14 +5716,14 @@ static void stdout_simple_list(struct nvme_global_ctx *ctx) table_free(t); } -static void stdout_ns_details(nvme_ns_t n) +static void stdout_ns_details(libnvme_ns_t n) { char usage[128] = { 0 }, format[128] = { 0 }, usage_binary[128] = { 0 }; char devname[128] = { 0 }, genname[128] = { 0 }; - long long lba = nvme_ns_get_lba_size(n); - double nsze = nvme_ns_get_lba_count(n) * lba; - double nuse = nvme_ns_get_lba_util(n) * lba; + long long lba = libnvme_ns_get_lba_size(n); + double nsze = libnvme_ns_get_lba_count(n) * lba; + double nuse = libnvme_ns_get_lba_util(n) * lba; double nsze_binary = nsze, nuse_binary = nuse; const char *s_suffix = suffix_si_get(&nsze); @@ -5734,7 +5734,7 @@ static void stdout_ns_details(nvme_ns_t n) sprintf(usage, "%6.2f %1sB / %6.2f %1sB", nuse, u_suffix, nsze, s_suffix); sprintf(format, "%3.0f %2sB + %2d B", (double)lba, l_suffix, - nvme_ns_get_meta_size(n)); + libnvme_ns_get_meta_size(n)); s_suffix_binary = suffix_dbinary_get(&nsze_binary); u_suffix_binary = suffix_dbinary_get(&nuse_binary); @@ -5745,7 +5745,7 @@ static void stdout_ns_details(nvme_ns_t n) nvme_generic_full_path(n, genname, sizeof(genname)); printf("%-17s %-17s %#-10x %-21s %-25s %-16s ", devname, - genname, nvme_ns_get_nsid(n), usage, usage_binary, format); + genname, libnvme_ns_get_nsid(n), usage, usage_binary, format); } static bool stdout_detailed_name(const char *name, void *arg) @@ -5763,8 +5763,8 @@ static bool stdout_detailed_subsys(const char *name, void *arg) struct nvme_resources *res = arg; struct htable_subsys_iter it; struct strset ctrls; - nvme_subsystem_t s; - nvme_ctrl_t c; + libnvme_subsystem_t s; + libnvme_ctrl_t c; bool first; strset_init(&ctrls); @@ -5774,12 +5774,12 @@ static bool stdout_detailed_subsys(const char *name, void *arg) s = htable_subsys_getnext(&res->ht_s, name, &it)) { if (first) { printf("%-16s %-96s ", name, - nvme_subsystem_get_subsysnqn(s)); + libnvme_subsystem_get_subsysnqn(s)); first = false; } - nvme_subsystem_for_each_ctrl(s, c) - strset_add(&ctrls, nvme_ctrl_get_name(c)); + libnvme_subsystem_for_each_ctrl(s, c) + strset_add(&ctrls, libnvme_ctrl_get_name(c)); } first = true; @@ -5794,34 +5794,34 @@ static bool stdout_detailed_ctrl(const char *name, void *arg) { struct nvme_resources *res = arg; struct strset namespaces; - nvme_ctrl_t c; - nvme_path_t p; - nvme_ns_t n; + libnvme_ctrl_t c; + libnvme_path_t p; + libnvme_ns_t n; bool first; c = htable_ctrl_get(&res->ht_c, name); assert(c); printf("%-16s %-6s %-20s %-40s %-8s %-6s %-14s %-6s %-12s ", - nvme_ctrl_get_name(c), - nvme_ctrl_get_cntlid(c), - nvme_ctrl_get_serial(c), - nvme_ctrl_get_model(c), - nvme_ctrl_get_firmware(c), - nvme_ctrl_get_transport(c), - nvme_ctrl_get_traddr(c), - nvme_ctrl_get_phy_slot(c), - nvme_subsystem_get_name(nvme_ctrl_get_subsystem(c))); + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_cntlid(c), + libnvme_ctrl_get_serial(c), + libnvme_ctrl_get_model(c), + libnvme_ctrl_get_firmware(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_phy_slot(c), + libnvme_subsystem_get_name(libnvme_ctrl_get_subsystem(c))); strset_init(&namespaces); - nvme_ctrl_for_each_ns(c, n) - strset_add(&namespaces, nvme_ns_get_name(n)); - nvme_ctrl_for_each_path(c, p) { - n = nvme_path_get_ns(p); + libnvme_ctrl_for_each_ns(c, n) + strset_add(&namespaces, libnvme_ns_get_name(n)); + libnvme_ctrl_for_each_path(c, p) { + n = libnvme_path_get_ns(p); if (!n) continue; - strset_add(&namespaces, nvme_ns_get_name(n)); + strset_add(&namespaces, libnvme_ns_get_name(n)); } first = true; @@ -5838,9 +5838,9 @@ static bool stdout_detailed_ns(const char *name, void *arg) struct nvme_resources *res = arg; struct htable_ns_iter it; struct strset ctrls; - nvme_ctrl_t c; - nvme_path_t p; - nvme_ns_t n; + libnvme_ctrl_t c; + libnvme_path_t p; + libnvme_ns_t n; bool first; strset_init(&ctrls); @@ -5853,14 +5853,14 @@ static bool stdout_detailed_ns(const char *name, void *arg) first = false; } - if (nvme_ns_get_ctrl(n)) { - printf("%s\n", nvme_ctrl_get_name(nvme_ns_get_ctrl(n))); + if (libnvme_ns_get_ctrl(n)) { + printf("%s\n", libnvme_ctrl_get_name(libnvme_ns_get_ctrl(n))); return true; } - nvme_namespace_for_each_path(n, p) { - c = nvme_path_get_ctrl(p); - strset_add(&ctrls, nvme_ctrl_get_name(c)); + libnvme_namespace_for_each_path(n, p) { + c = libnvme_path_get_ctrl(p); + strset_add(&ctrls, libnvme_ctrl_get_name(c)); } } @@ -5910,8 +5910,8 @@ static void stdout_list_items(struct nvme_global_ctx *ctx) static bool subsystem_iopolicy_filter(const char *name, void *arg) { - nvme_subsystem_t s = arg; - const char *iopolicy = nvme_subsystem_get_iopolicy(s); + libnvme_subsystem_t s = arg; + const char *iopolicy = libnvme_subsystem_get_iopolicy(s); if (!strcmp(iopolicy, "queue-depth")) { /* exclude "Nodes" for iopolicy queue-depth */ @@ -5930,15 +5930,15 @@ static bool subsystem_iopolicy_filter(const char *name, void *arg) return true; } -static void stdout_tabular_subsystem_topology_multipath(nvme_subsystem_t s) +static void stdout_tabular_subsystem_topology_multipath(libnvme_subsystem_t s) { - nvme_ns_t n; - nvme_path_t p; - nvme_ctrl_t c; + libnvme_ns_t n; + libnvme_path_t p; + libnvme_ctrl_t c; int row, col; bool first; struct table *t; - const char *iopolicy = nvme_subsystem_get_iopolicy(s); + const char *iopolicy = libnvme_subsystem_get_iopolicy(s); struct table_column columns[] = { {"NSHead", LEFT, 0}, {"NSID", LEFT, 0}, @@ -5964,10 +5964,10 @@ static void stdout_tabular_subsystem_topology_multipath(nvme_subsystem_t s) goto free_tbl; } - nvme_subsystem_for_each_ns(s, n) { + libnvme_subsystem_for_each_ns(s, n) { first = true; - nvme_namespace_for_each_path(n, p) { - c = nvme_path_get_ctrl(p); + libnvme_namespace_for_each_path(n, p) { + c = libnvme_path_get_ctrl(p); row = table_get_row_id(t); if (row < 0) { @@ -5984,42 +5984,42 @@ static void stdout_tabular_subsystem_topology_multipath(nvme_subsystem_t s) /* col 0: NSHead */ if (first) { table_set_value_str(t, ++col, row, - nvme_ns_get_name(n), LEFT); + libnvme_ns_get_name(n), LEFT); first = false; } else table_set_value_str(t, ++col, row, "-->", CENTERED); /* col 1: NSID */ table_set_value_int(t, ++col, row, - nvme_ns_get_nsid(n), CENTERED); + libnvme_ns_get_nsid(n), CENTERED); /* col 2: NSPath */ table_set_value_str(t, ++col, row, - nvme_path_get_name(p), LEFT); + libnvme_path_get_name(p), LEFT); /* col 3: ANAState */ table_set_value_str(t, ++col, row, - nvme_path_get_ana_state(p), LEFT); + libnvme_path_get_ana_state(p), LEFT); if (!strcmp(iopolicy, "numa")) /* col 4: Nodes */ table_set_value_str(t, ++col, row, - nvme_path_get_numa_nodes(p), CENTERED); + libnvme_path_get_numa_nodes(p), CENTERED); else if (!strcmp(iopolicy, "queue-depth")) /* col 4 : Qdepth */ table_set_value_int(t, ++col, row, - nvme_path_get_queue_depth(p), CENTERED); + libnvme_path_get_queue_depth(p), CENTERED); /* col 5: Controller */ table_set_value_str(t, ++col, row, - nvme_ctrl_get_name(c), LEFT); + libnvme_ctrl_get_name(c), LEFT); /* col 6: TrType */ table_set_value_str(t, ++col, row, - nvme_ctrl_get_transport(c), LEFT); + libnvme_ctrl_get_transport(c), LEFT); /* col 7: Address */ table_set_value_str(t, ++col, row, - nvme_ctrl_get_traddr(c), LEFT); + libnvme_ctrl_get_traddr(c), LEFT); /* col 8: State */ table_set_value_str(t, ++col, row, - nvme_ctrl_get_state(c), LEFT); + libnvme_ctrl_get_state(c), LEFT); table_add_row(t, row); } @@ -6029,63 +6029,63 @@ static void stdout_tabular_subsystem_topology_multipath(nvme_subsystem_t s) table_free(t); } -static void stdout_subsystem_topology_multipath(nvme_subsystem_t s, +static void stdout_subsystem_topology_multipath(libnvme_subsystem_t s, enum nvme_cli_topo_ranking ranking) { - nvme_ns_t n; - nvme_path_t p; - nvme_ctrl_t c; - const char *iopolicy = nvme_subsystem_get_iopolicy(s); + libnvme_ns_t n; + libnvme_path_t p; + libnvme_ctrl_t c; + const char *iopolicy = libnvme_subsystem_get_iopolicy(s); if (ranking == NVME_CLI_TOPO_NAMESPACE) { - nvme_subsystem_for_each_ns(s, n) { - if (!nvme_namespace_first_path(n)) + libnvme_subsystem_for_each_ns(s, n) { + if (!libnvme_namespace_first_path(n)) continue; - printf(" +- ns %d\n", nvme_ns_get_nsid(n)); + printf(" +- ns %d\n", libnvme_ns_get_nsid(n)); printf(" \\\n"); - nvme_namespace_for_each_path(n, p) { - c = nvme_path_get_ctrl(p); + libnvme_namespace_for_each_path(n, p) { + c = libnvme_path_get_ctrl(p); printf(" +- %s %s %s %s %s\n", - nvme_ctrl_get_name(c), - nvme_ctrl_get_transport(c), - nvme_ctrl_get_traddr(c), - nvme_ctrl_get_state(c), - nvme_path_get_ana_state(p)); + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_state(c), + libnvme_path_get_ana_state(p)); } } } else if (ranking == NVME_CLI_TOPO_CTRL) { /* NVME_CLI_TOPO_CTRL */ - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_subsystem_for_each_ctrl(s, c) { printf(" +- %s %s %s\n", - nvme_ctrl_get_name(c), - nvme_ctrl_get_transport(c), - nvme_ctrl_get_traddr(c)); + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c)); printf(" \\\n"); - nvme_subsystem_for_each_ns(s, n) { - nvme_namespace_for_each_path(n, p) { - if (nvme_path_get_ctrl(p) != c) + libnvme_subsystem_for_each_ns(s, n) { + libnvme_namespace_for_each_path(n, p) { + if (libnvme_path_get_ctrl(p) != c) continue; printf(" +- ns %d %s %s\n", - nvme_ns_get_nsid(n), - nvme_ctrl_get_state(c), - nvme_path_get_ana_state(p)); + libnvme_ns_get_nsid(n), + libnvme_ctrl_get_state(c), + libnvme_path_get_ana_state(p)); } } } } else { /* NVME_CLI_TOPO_MULTIPATH */ - nvme_subsystem_for_each_ns(s, n) { + libnvme_subsystem_for_each_ns(s, n) { printf(" +- %s (ns %d)\n", - nvme_ns_get_name(n), - nvme_ns_get_nsid(n)); + libnvme_ns_get_name(n), + libnvme_ns_get_nsid(n)); printf(" \\\n"); - nvme_namespace_for_each_path(n, p) { - c = nvme_path_get_ctrl(p); + libnvme_namespace_for_each_path(n, p) { + c = libnvme_path_get_ctrl(p); if (!strcmp(iopolicy, "numa")) { /* @@ -6093,13 +6093,13 @@ static void stdout_subsystem_topology_multipath(nvme_subsystem_t s, * qdepth. */ printf(" +- %s %s %s %s %s %s %s\n", - nvme_path_get_name(p), - nvme_path_get_ana_state(p), - nvme_path_get_numa_nodes(p), - nvme_ctrl_get_name(c), - nvme_ctrl_get_transport(c), - nvme_ctrl_get_traddr(c), - nvme_ctrl_get_state(c)); + libnvme_path_get_name(p), + libnvme_path_get_ana_state(p), + libnvme_path_get_numa_nodes(p), + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_state(c)); } else if (!strcmp(iopolicy, "queue-depth")) { /* @@ -6107,13 +6107,13 @@ static void stdout_subsystem_topology_multipath(nvme_subsystem_t s, * printing numa nodes. */ printf(" +- %s %s %d %s %s %s %s\n", - nvme_path_get_name(p), - nvme_path_get_ana_state(p), - nvme_path_get_queue_depth(p), - nvme_ctrl_get_name(c), - nvme_ctrl_get_transport(c), - nvme_ctrl_get_traddr(c), - nvme_ctrl_get_state(c)); + libnvme_path_get_name(p), + libnvme_path_get_ana_state(p), + libnvme_path_get_queue_depth(p), + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_state(c)); } else { /* round-robin */ /* @@ -6121,22 +6121,22 @@ static void stdout_subsystem_topology_multipath(nvme_subsystem_t s, * printing numa nodes and qdepth. */ printf(" +- %s %s %s %s %s %s\n", - nvme_path_get_name(p), - nvme_path_get_ana_state(p), - nvme_ctrl_get_name(c), - nvme_ctrl_get_transport(c), - nvme_ctrl_get_traddr(c), - nvme_ctrl_get_state(c)); + libnvme_path_get_name(p), + libnvme_path_get_ana_state(p), + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_state(c)); } } } } } -static void stdout_tabular_subsystem_topology(nvme_subsystem_t s) +static void stdout_tabular_subsystem_topology(libnvme_subsystem_t s) { - nvme_ctrl_t c; - nvme_ns_t n; + libnvme_ctrl_t c; + libnvme_ns_t n; int row; struct table *t; struct table_column columns[] = { @@ -6159,9 +6159,9 @@ static void stdout_tabular_subsystem_topology(nvme_subsystem_t s) goto free_tbl; } - nvme_subsystem_for_each_ctrl(s, c) { - nvme_ctrl_for_each_ns(c, n) { - c = nvme_ns_get_ctrl(n); + libnvme_subsystem_for_each_ctrl(s, c) { + libnvme_ctrl_for_each_ns(c, n) { + c = libnvme_ns_get_ctrl(n); row = table_get_row_id(t); if (row < 0) { @@ -6171,22 +6171,22 @@ static void stdout_tabular_subsystem_topology(nvme_subsystem_t s) /* col 0: Namespace */ table_set_value_str(t, 0, row, - nvme_ns_get_name(n), LEFT); + libnvme_ns_get_name(n), LEFT); /* col 1: NSID */ table_set_value_int(t, 1, row, - nvme_ns_get_nsid(n), CENTERED); + libnvme_ns_get_nsid(n), CENTERED); /* col 2: Controller */ table_set_value_str(t, 2, row, - nvme_ctrl_get_name(c), LEFT); + libnvme_ctrl_get_name(c), LEFT); /* col 3: Trtype */ table_set_value_str(t, 3, row, - nvme_ctrl_get_transport(c), LEFT); + libnvme_ctrl_get_transport(c), LEFT); /* col 4: Address */ table_set_value_str(t, 4, row, - nvme_ctrl_get_traddr(c), LEFT); + libnvme_ctrl_get_traddr(c), LEFT); /* col 5: State */ table_set_value_str(t, 5, row, - nvme_ctrl_get_state(c), LEFT); + libnvme_ctrl_get_state(c), LEFT); table_add_row(t, row); } @@ -6196,53 +6196,53 @@ static void stdout_tabular_subsystem_topology(nvme_subsystem_t s) table_free(t); } -static void stdout_subsystem_topology(nvme_subsystem_t s, +static void stdout_subsystem_topology(libnvme_subsystem_t s, enum nvme_cli_topo_ranking ranking) { - nvme_ctrl_t c; - nvme_ns_t n; + libnvme_ctrl_t c; + libnvme_ns_t n; if (ranking == NVME_CLI_TOPO_NAMESPACE) { - nvme_subsystem_for_each_ctrl(s, c) { - nvme_ctrl_for_each_ns(c, n) { - printf(" +- ns %d\n", nvme_ns_get_nsid(n)); + libnvme_subsystem_for_each_ctrl(s, c) { + libnvme_ctrl_for_each_ns(c, n) { + printf(" +- ns %d\n", libnvme_ns_get_nsid(n)); printf(" \\\n"); printf(" +- %s %s %s %s\n", - nvme_ctrl_get_name(c), - nvme_ctrl_get_transport(c), - nvme_ctrl_get_traddr(c), - nvme_ctrl_get_state(c)); + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_state(c)); } } } else if (ranking == NVME_CLI_TOPO_CTRL) { /* NVME_CLI_TOPO_CTRL */ - nvme_subsystem_for_each_ctrl(s, c) { + libnvme_subsystem_for_each_ctrl(s, c) { printf(" +- %s %s %s\n", - nvme_ctrl_get_name(c), - nvme_ctrl_get_transport(c), - nvme_ctrl_get_traddr(c)); + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c)); printf(" \\\n"); - nvme_ctrl_for_each_ns(c, n) { + libnvme_ctrl_for_each_ns(c, n) { printf(" +- ns %d %s\n", - nvme_ns_get_nsid(n), - nvme_ctrl_get_state(c)); + libnvme_ns_get_nsid(n), + libnvme_ctrl_get_state(c)); } } } else { /* NVME_CLI_TOPO_MULTIPATH */ - nvme_subsystem_for_each_ctrl(s, c) { - nvme_ctrl_for_each_ns(c, n) { - c = nvme_ns_get_ctrl(n); + libnvme_subsystem_for_each_ctrl(s, c) { + libnvme_ctrl_for_each_ns(c, n) { + c = libnvme_ns_get_ctrl(n); printf(" +- %s (ns %d)\n", - nvme_ns_get_name(n), - nvme_ns_get_nsid(n)); + libnvme_ns_get_name(n), + libnvme_ns_get_nsid(n)); printf(" \\\n"); printf(" +- %s %s %s %s\n", - nvme_ctrl_get_name(c), - nvme_ctrl_get_transport(c), - nvme_ctrl_get_traddr(c), - nvme_ctrl_get_state(c)); + libnvme_ctrl_get_name(c), + libnvme_ctrl_get_transport(c), + libnvme_ctrl_get_traddr(c), + libnvme_ctrl_get_state(c)); } } } @@ -6250,16 +6250,16 @@ static void stdout_subsystem_topology(nvme_subsystem_t s, static void stdout_topology_tabular(struct nvme_global_ctx *ctx) { - nvme_host_t h; - nvme_subsystem_t s; + libnvme_host_t h; + libnvme_subsystem_t s; bool first = true; - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { bool no_ctrl = true; - nvme_ctrl_t c; + libnvme_ctrl_t c; - nvme_subsystem_for_each_ctrl(s, c) + libnvme_subsystem_for_each_ctrl(s, c) no_ctrl = false; if (no_ctrl) @@ -6283,16 +6283,16 @@ static void stdout_topology_tabular(struct nvme_global_ctx *ctx) static void stdout_simple_topology(struct nvme_global_ctx *ctx, enum nvme_cli_topo_ranking ranking) { - nvme_host_t h; - nvme_subsystem_t s; + libnvme_host_t h; + libnvme_subsystem_t s; bool first = true; - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { bool no_ctrl = true; - nvme_ctrl_t c; + libnvme_ctrl_t c; - nvme_subsystem_for_each_ctrl(s, c) + libnvme_subsystem_for_each_ctrl(s, c) no_ctrl = false; if (no_ctrl) @@ -6402,9 +6402,9 @@ static void stdout_discovery_log(struct nvmf_discovery_log *log, int numrec) static void stdout_discovery_log(struct nvmf_discovery_log *log, int numrec) {} #endif -static void stdout_connect_msg(nvme_ctrl_t c) +static void stdout_connect_msg(libnvme_ctrl_t c) { - printf("connecting to device: %s\n", nvme_ctrl_get_name(c)); + printf("connecting to device: %s\n", libnvme_ctrl_get_name(c)); } static void stdout_mgmt_addr_list_log(struct nvme_mgmt_addr_list_log *ma_list) @@ -6628,9 +6628,9 @@ static void stdout_relatives(struct nvme_global_ctx *ctx, const char *name) struct htable_ns_iter it; bool block = true; bool first = true; - nvme_ctrl_t c; - nvme_path_t p; - nvme_ns_t n; + libnvme_ctrl_t c; + libnvme_path_t p; + libnvme_ns_t n; int nsid; int ret; int id; @@ -6653,13 +6653,13 @@ static void stdout_relatives(struct nvme_global_ctx *ctx, const char *name) fprintf(stderr, "Namespace %s has parent controller(s):", name); for (n = htable_ns_getfirst(&res.ht_n, name, &it); n; n = htable_ns_getnext(&res.ht_n, name, &it)) { - if (nvme_ns_get_ctrl(n)) { - fprintf(stderr, "%s", nvme_ctrl_get_name(nvme_ns_get_ctrl(n))); + if (libnvme_ns_get_ctrl(n)) { + fprintf(stderr, "%s", libnvme_ctrl_get_name(libnvme_ns_get_ctrl(n))); break; } - nvme_namespace_for_each_path(n, p) { - c = nvme_path_get_ctrl(p); - fprintf(stderr, "%s%s", first ? "" : ", ", nvme_ctrl_get_name(c)); + libnvme_namespace_for_each_path(n, p) { + c = libnvme_path_get_ctrl(p); + fprintf(stderr, "%s%s", first ? "" : ", ", libnvme_ctrl_get_name(c)); if (first) first = false; } @@ -6669,8 +6669,8 @@ static void stdout_relatives(struct nvme_global_ctx *ctx, const char *name) c = htable_ctrl_get(&res.ht_c, name); if (c) { fprintf(stderr, "Controller %s has child namespace(s):", name); - nvme_ctrl_for_each_ns(c, n) { - fprintf(stderr, "%s%s", first ? "" : ", ", nvme_ns_get_name(n)); + libnvme_ctrl_for_each_ns(c, n) { + fprintf(stderr, "%s%s", first ? "" : ", ", libnvme_ns_get_name(n)); if (first) first = false; } diff --git a/nvme-print.c b/nvme-print.c index 92de312aec..c489e2f3c1 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -528,7 +528,7 @@ static void nvme_show_cmd_err(const char *msg, bool admin, if (!err) return; else if (err < 0) - nvme_show_error("%s: %s", msg, nvme_strerror(-err)); + nvme_show_error("%s: %s", msg, libnvme_strerror(-err)); else if (cmd) nvme_show_opcode_status(err, false, cmd->opcode); else @@ -1558,25 +1558,25 @@ void nvme_show_lba_status(struct nvme_lba_status *list, unsigned long len, nvme_print(lba_status, flags, list, len); } -void nvme_dev_full_path(nvme_ns_t n, char *path, size_t len) +void nvme_dev_full_path(libnvme_ns_t n, char *path, size_t len) { struct stat st; - snprintf(path, len, "%s", nvme_ns_get_name(n)); + snprintf(path, len, "%s", libnvme_ns_get_name(n)); if (strncmp(path, "/dev/spdk/", 10) == 0 && stat(path, &st) == 0) return; - snprintf(path, len, "/dev/%s", nvme_ns_get_name(n)); + snprintf(path, len, "/dev/%s", libnvme_ns_get_name(n)); if (stat(path, &st) == 0) return; /* * We could start trying to search for it but let's make * it simple and just don't show the path at all. */ - snprintf(path, len, "%s", nvme_ns_get_name(n)); + snprintf(path, len, "%s", libnvme_ns_get_name(n)); } -void nvme_generic_full_path(nvme_ns_t n, char *path, size_t len) +void nvme_generic_full_path(libnvme_ns_t n, char *path, size_t len) { int head_instance; int instance; @@ -1586,11 +1586,11 @@ void nvme_generic_full_path(nvme_ns_t n, char *path, size_t len) * There is no block devices for SPDK, point generic path to existing * chardevice. */ - snprintf(path, len, "%s", nvme_ns_get_name(n)); + snprintf(path, len, "%s", libnvme_ns_get_name(n)); if (strncmp(path, "/dev/spdk/", 10) == 0 && stat(path, &st) == 0) return; - sscanf(nvme_ns_get_name(n), "nvme%dn%d", &instance, &head_instance); + sscanf(libnvme_ns_get_name(n), "nvme%dn%d", &instance, &head_instance); snprintf(path, len, "/dev/ng%dn%d", instance, head_instance); if (stat(path, &st) == 0) @@ -1602,7 +1602,7 @@ void nvme_generic_full_path(nvme_ns_t n, char *path, size_t len) snprintf(path, len, "ng%dn%d", instance, head_instance); } -void nvme_show_list_item(nvme_ns_t n, struct table *t) +void nvme_show_list_item(libnvme_ns_t n, struct table *t) { nvme_print(list_item, NORMAL, n, t); } @@ -1683,7 +1683,7 @@ void nvme_show_discovery_log(struct nvmf_discovery_log *log, uint64_t numrec, nvme_print(discovery_log, flags, log, numrec); } -void nvme_show_connect_msg(nvme_ctrl_t c, nvme_print_flags_t flags) +void nvme_show_connect_msg(libnvme_ctrl_t c, nvme_print_flags_t flags) { nvme_print(connect_msg, flags, c); } diff --git a/nvme-print.h b/nvme-print.h index 0d976215d1..da32540562 100644 --- a/nvme-print.h +++ b/nvme-print.h @@ -104,7 +104,7 @@ struct print_ops { void (*log)(const char *devname, struct nvme_get_log_args *args); /* libnvme tree print functions */ - void (*list_item)(nvme_ns_t n, struct table *t); + void (*list_item)(libnvme_ns_t n, struct table *t); void (*list_items)(struct nvme_global_ctx *ctx); void (*print_nvme_subsystem_list)(struct nvme_global_ctx *ctx, bool show_ana); void (*topology_ctrl)(struct nvme_global_ctx *ctx); @@ -113,7 +113,7 @@ struct print_ops { void (*topology_tabular)(struct nvme_global_ctx *ctx); /* status and error messages */ - void (*connect_msg)(nvme_ctrl_t c); + void (*connect_msg)(libnvme_ctrl_t c); void (*show_message)(bool error, const char *msg, va_list ap); void (*show_perror)(const char *msg, va_list ap); void (*show_status)(int status); @@ -291,7 +291,7 @@ void nvme_show_zns_report_zones(void *report, __u32 descs, nvme_print_flags_t flags); void json_nvme_finish_zone_list(__u64 nr_zones, struct json_object *zone_list); -void nvme_show_list_item(nvme_ns_t n, struct table *t); +void nvme_show_list_item(libnvme_ns_t n, struct table *t); void nvme_show_fdp_configs(struct nvme_fdp_config_log *configs, size_t len, nvme_print_flags_t flags); @@ -306,7 +306,7 @@ void nvme_show_fdp_ruh_status(struct nvme_fdp_ruh_status *status, size_t len, void nvme_show_discovery_log(struct nvmf_discovery_log *log, uint64_t numrec, nvme_print_flags_t flags); -void nvme_show_connect_msg(nvme_ctrl_t c, nvme_print_flags_t flags); +void nvme_show_connect_msg(libnvme_ctrl_t c, nvme_print_flags_t flags); const char *nvme_ana_state_to_string(enum nvme_ana_state state); const char *nvme_cmd_to_string(int admin, __u8 opcode); @@ -346,8 +346,8 @@ const char *nvme_feature_power_limit_scale_to_string(__u8 pls); const char *nvme_power_measurement_type_to_string(__u8 pmt); const char *nvme_power_measurement_action_to_string(__u8 act); -void nvme_dev_full_path(nvme_ns_t n, char *path, size_t len); -void nvme_generic_full_path(nvme_ns_t n, char *path, size_t len); +void nvme_dev_full_path(libnvme_ns_t n, char *path, size_t len); +void nvme_generic_full_path(libnvme_ns_t n, char *path, size_t len); void nvme_show_message(bool error, const char *msg, ...); void nvme_show_perror(const char *msg, ...); void nvme_show_error_status(int status, const char *msg, ...); diff --git a/nvme-rpmb.c b/nvme-rpmb.c index 19cdd24e0a..a2052c0fc1 100644 --- a/nvme-rpmb.c +++ b/nvme-rpmb.c @@ -172,7 +172,7 @@ static int read_file(const char *file, unsigned char **data, unsigned int *len) if (file == NULL) return err; if ((fd = open(file, O_RDONLY)) < 0) { - fprintf(stderr, "Failed to open %s: %s\n", file, nvme_strerror(errno)); + fprintf(stderr, "Failed to open %s: %s\n", file, libnvme_strerror(errno)); return fd; } @@ -193,7 +193,7 @@ static int read_file(const char *file, unsigned char **data, unsigned int *len) if (err < 0) { err = -errno; fprintf(stderr, "Failed to read data from file" - " %s with %s\n", file, nvme_strerror(errno)); + " %s with %s\n", file, libnvme_strerror(errno)); free(buf); goto out; } @@ -282,7 +282,7 @@ static int send_rpmb_req(struct nvme_transport_handle *hdl, unsigned char tgt, nvme_init_security_send(&cmd, NVME_NSID_NONE, tgt, RPMB_NVME_SPSP, RPMB_NVME_SECP, 0, req, size); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } static int recv_rpmb_rsp(struct nvme_transport_handle *hdl, int tgt, int size, @@ -292,7 +292,7 @@ static int recv_rpmb_rsp(struct nvme_transport_handle *hdl, int tgt, int size, nvme_init_security_receive(&cmd, 0, tgt, RPMB_NVME_SPSP, RPMB_NVME_SECP, 0, rsp, size); - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /* Initialize nonce value in rpmb request frame */ diff --git a/nvme.c b/nvme.c index 08fb9f8363..61efb67b85 100644 --- a/nvme.c +++ b/nvme.c @@ -352,7 +352,7 @@ static int get_transport_handle(struct nvme_global_ctx *ctx, int argc, devname = argv[optind]; - ret = nvme_open(ctx, devname, hdl); + ret = libnvme_open(ctx, devname, hdl); if (ret) nvme_show_err(devname, ret); else if (log_level >= LOG_DEBUG) @@ -387,24 +387,24 @@ int parse_and_open(struct nvme_global_ctx **ctx, if (ret) return ret; - ctx_new = nvme_create_global_ctx(stdout, log_level); + ctx_new = libnvme_create_global_ctx(stdout, log_level); if (!ctx_new) return -ENOMEM; - nvme_set_ioctl_probing(ctx_new, + libnvme_set_ioctl_probing(ctx_new, !argconfig_parse_seen(opts, "no-ioctl-probing")); ret = get_transport_handle(ctx_new, argc, argv, O_RDONLY, &hdl_new); if (ret) { - nvme_free_global_ctx(ctx_new); + libnvme_free_global_ctx(ctx_new); argconfig_print_help(desc, opts); return -ENXIO; } - nvme_transport_handle_set_submit_entry(hdl_new, nvme_submit_entry); - nvme_transport_handle_set_submit_exit(hdl_new , nvme_submit_exit); - nvme_transport_handle_set_decide_retry(hdl_new, nvme_decide_retry); - nvme_set_dry_run(ctx_new, argconfig_parse_seen(opts, "dry-run")); + libnvme_transport_handle_set_submit_entry(hdl_new, nvme_submit_entry); + libnvme_transport_handle_set_submit_exit(hdl_new , nvme_submit_exit); + libnvme_transport_handle_set_decide_retry(hdl_new, nvme_decide_retry); + libnvme_set_dry_run(ctx_new, argconfig_parse_seen(opts, "dry-run")); *ctx = ctx_new; *hdl = hdl_new; @@ -423,13 +423,13 @@ int open_exclusive(struct nvme_global_ctx **ctx, if (!ignore_exclusive) flags |= O_EXCL; - ctx_new = nvme_create_global_ctx(stdout, log_level); + ctx_new = libnvme_create_global_ctx(stdout, log_level); if (!ctx_new) return -ENOMEM; ret = get_transport_handle(ctx_new, argc, argv, flags, &hdl_new); if (ret) { - nvme_free_global_ctx(ctx_new); + libnvme_free_global_ctx(ctx_new); return -ENXIO; } @@ -445,7 +445,7 @@ static int open_fallback_chardev(struct nvme_global_ctx *ctx, struct nvme_transport_handle *hdl = *phdl; int err; - if (nvme_transport_handle_is_chardev(hdl)) { + if (libnvme_transport_handle_is_chardev(hdl)) { _cleanup_free_ char *cdev = NULL; if (!nsid) { @@ -454,12 +454,12 @@ static int open_fallback_chardev(struct nvme_global_ctx *ctx, } if (asprintf(&cdev, "/dev/%sn%d", - nvme_transport_handle_get_name(hdl), nsid) < 0) + libnvme_transport_handle_get_name(hdl), nsid) < 0) return -ENOMEM; - nvme_close(hdl); + libnvme_close(hdl); - err = nvme_open(ctx, cdev, &hdl); + err = libnvme_open(ctx, cdev, &hdl); if (err) { *phdl = NULL; @@ -566,7 +566,7 @@ static int get_smart_log(int argc, char **argv, struct command *acmd, struct plu } nvme_show_smart_log(smart_log, cfg.namespace_id, - nvme_transport_handle_get_name(hdl), flags); + libnvme_transport_handle_get_name(hdl), flags); return err; } @@ -616,7 +616,7 @@ static int get_ana_log(int argc, char **argv, struct command *acmd, err = nvme_identify_ctrl(hdl, ctrl); if (err) { nvme_show_error("ERROR : nvme_identify_ctrl() failed: %s", - nvme_strerror(err)); + libnvme_strerror(err)); return err; } @@ -637,7 +637,7 @@ static int get_ana_log(int argc, char **argv, struct command *acmd, return err; } - nvme_show_ana_log(ana_log, nvme_transport_handle_get_name(hdl), + nvme_show_ana_log(ana_log, libnvme_transport_handle_get_name(hdl), ana_log_len, flags); return err; @@ -933,7 +933,7 @@ static int get_telemetry_log(int argc, char **argv, struct command *acmd, output = open(cfg.file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (output < 0) { nvme_show_error("Failed to open output file %s: %s!", - cfg.file_name, nvme_strerror(errno)); + cfg.file_name, libnvme_strerror(errno)); return output; } @@ -968,7 +968,7 @@ static int get_telemetry_log(int argc, char **argv, struct command *acmd, if (data_written < 0) { err = -errno; nvme_show_error("ERROR: %s: : write failed with error : %s", - __func__, nvme_strerror(errno)); + __func__, libnvme_strerror(errno)); break; } else if (data_written <= data_remaining) { data_remaining -= data_written; @@ -983,7 +983,7 @@ static int get_telemetry_log(int argc, char **argv, struct command *acmd, } if (fsync(output) < 0) { - nvme_show_error("ERROR : %s: : fsync : %s", __func__, nvme_strerror(errno)); + nvme_show_error("ERROR : %s: : fsync : %s", __func__, libnvme_strerror(errno)); return -1; } @@ -1043,7 +1043,7 @@ static int get_endurance_log(int argc, char **argv, struct command *acmd, struct } nvme_show_endurance_log(endurance_log, cfg.group_id, - nvme_transport_handle_get_name(hdl), flags); + libnvme_transport_handle_get_name(hdl), flags); return err; } @@ -1122,7 +1122,7 @@ static int get_effects_log(int argc, char **argv, struct command *acmd, struct p if (cfg.csi < 0) { __u64 cap; - if (nvme_transport_handle_is_blkdev(hdl)) { + if (libnvme_transport_handle_is_blkdev(hdl)) { nvme_show_error("Block device isn't allowed without csi"); return -EINVAL; } @@ -1133,7 +1133,7 @@ static int get_effects_log(int argc, char **argv, struct command *acmd, struct p munmap(bar, getpagesize()); } else { nvme_init_get_property(&cmd, NVME_REG_CAP); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) goto cleanup_list; cap = cmd.result; @@ -1200,7 +1200,7 @@ static int get_supported_log_pages(int argc, char **argv, struct command *acmd, return err; } - nvme_show_supported_log(supports, nvme_transport_handle_get_name(hdl), + nvme_show_supported_log(supports, libnvme_transport_handle_get_name(hdl), flags); return err; @@ -1274,7 +1274,7 @@ static int get_error_log(int argc, char **argv, struct command *acmd, struct plu } nvme_show_error_log(err_log, cfg.log_entries, - nvme_transport_handle_get_name(hdl), flags); + libnvme_transport_handle_get_name(hdl), flags); return err; } @@ -1324,7 +1324,7 @@ static int get_fw_log(int argc, char **argv, struct command *acmd, struct plugin return err; } - nvme_show_fw_log(fw_log, nvme_transport_handle_get_name(hdl), flags); + nvme_show_fw_log(fw_log, libnvme_transport_handle_get_name(hdl), flags); return err; } @@ -1384,7 +1384,7 @@ static int get_changed_ns_list_log(int argc, char **argv, bool alloc) } nvme_show_changed_ns_list_log(changed_ns_list_log, - nvme_transport_handle_get_name(hdl), + libnvme_transport_handle_get_name(hdl), flags, alloc); return err; @@ -1455,7 +1455,7 @@ static int get_pred_lat_per_nvmset_log(int argc, char **argv, } nvme_show_predictable_latency_per_nvmset(plpns_log, cfg.nvmset_id, - nvme_transport_handle_get_name(hdl), flags); + libnvme_transport_handle_get_name(hdl), flags); return err; } @@ -1537,7 +1537,7 @@ static int get_pred_lat_event_agg_log(int argc, char **argv, } nvme_show_predictable_latency_event_agg_log(pea_log, cfg.log_entries, - log_size, nvme_transport_handle_get_name(hdl), flags); + log_size, libnvme_transport_handle_get_name(hdl), flags); return err; } @@ -1651,7 +1651,7 @@ static int get_persistent_event_log(int argc, char **argv, } nvme_show_persistent_event_log(pevent_log_info, cfg.action, - cfg.log_len, nvme_transport_handle_get_name(hdl), flags); + cfg.log_len, libnvme_transport_handle_get_name(hdl), flags); return err; } @@ -1713,7 +1713,7 @@ static int get_endurance_event_agg_log(int argc, char **argv, err = nvme_identify_ctrl(hdl, ctrl); if (err < 0) { - nvme_show_error("identify controller: %s", nvme_strerror(-err)); + nvme_show_error("identify controller: %s", libnvme_strerror(-err)); return err; } else if (err) { nvme_show_error("could not identify controller"); @@ -1736,7 +1736,7 @@ static int get_endurance_event_agg_log(int argc, char **argv, } nvme_show_endurance_group_event_agg_log(endurance_log, cfg.log_entries, - log_size, nvme_transport_handle_get_name(hdl), flags); + log_size, libnvme_transport_handle_get_name(hdl), flags); return err; } @@ -1792,7 +1792,7 @@ static int get_lba_status_log(int argc, char **argv, } nvme_show_lba_status_log(lba_status, lslplen, - nvme_transport_handle_get_name(hdl), flags); + libnvme_transport_handle_get_name(hdl), flags); return err; } @@ -1833,7 +1833,7 @@ static int get_resv_notif_log(int argc, char **argv, return err; } - nvme_show_resv_notif_log(resv, nvme_transport_handle_get_name(hdl), + nvme_show_resv_notif_log(resv, libnvme_transport_handle_get_name(hdl), flags); return err; @@ -1893,7 +1893,7 @@ static int get_boot_part_log(int argc, char **argv, struct command *acmd, struct output = open(cfg.file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (output < 0) { nvme_show_error("Failed to open output file %s: %s!", - cfg.file_name, nvme_strerror(errno)); + cfg.file_name, libnvme_strerror(errno)); return output; } @@ -1919,7 +1919,7 @@ static int get_boot_part_log(int argc, char **argv, struct command *acmd, struct nvme_show_err("boot partition log", err); else nvme_show_boot_part_log(&bp_log, - nvme_transport_handle_get_name(hdl), + libnvme_transport_handle_get_name(hdl), sizeof(*boot) + bpsz, flags); err = write(output, (void *) bp_log + sizeof(*boot), bpsz); @@ -2163,7 +2163,7 @@ static int io_mgmt_send(int argc, char **argv, struct command *acmd, struct plug return err; if (!cfg.nsid) { - err = nvme_get_nsid(hdl, &cfg.nsid); + err = libnvme_get_nsid(hdl, &cfg.nsid); if (err < 0) { nvme_show_perror("get-namespace-id"); return err; @@ -2191,7 +2191,7 @@ static int io_mgmt_send(int argc, char **argv, struct command *acmd, struct plug } nvme_init_io_mgmt_send(&cmd, cfg.nsid, cfg.mo, cfg.mos, buf, cfg.data_len); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_err("io-mgmt-send", err); return err; @@ -2239,7 +2239,7 @@ static int io_mgmt_recv(int argc, char **argv, struct command *acmd, struct plug return err; if (!cfg.nsid) { - err = nvme_get_nsid(hdl, &cfg.nsid); + err = libnvme_get_nsid(hdl, &cfg.nsid); if (err < 0) { nvme_show_perror("get-namespace-id"); return err; @@ -2254,7 +2254,7 @@ static int io_mgmt_recv(int argc, char **argv, struct command *acmd, struct plug nvme_init_io_mgmt_recv(&cmd, cfg.nsid, cfg.mo, cfg.mos, buf, cfg.data_len); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_err("io-mgmt-recv", err); return err; @@ -2455,7 +2455,7 @@ static int get_log(int argc, char **argv, struct command *acmd, struct plugin *p nvme_init_get_log(&cmd, cfg.namespace_id, cfg.log_id, cfg.csi, log, cfg.log_len); if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); @@ -2483,11 +2483,11 @@ static int get_log(int argc, char **argv, struct command *acmd, struct plugin *p if (!cfg.raw_binary) { printf("Device:%s log-id:%d namespace-id:%#x\n", - nvme_transport_handle_get_name(hdl), cfg.log_id, + libnvme_transport_handle_get_name(hdl), cfg.log_id, cfg.namespace_id); d(log, cfg.log_len, 16, 1); if (argconfig_parse_seen(opts, "verbose")) - nvme_show_log(nvme_transport_handle_get_name(hdl), + nvme_show_log(libnvme_transport_handle_get_name(hdl), &args, VERBOSE); } else { d_raw((unsigned char *)log, cfg.log_len); @@ -2550,7 +2550,7 @@ static int sanitize_log(int argc, char **argv, struct command *acmd, struct plug } nvme_show_sanitize_log(sanitize_log, - nvme_transport_handle_get_name(hdl), flags); + libnvme_transport_handle_get_name(hdl), flags); return err; } @@ -2601,7 +2601,7 @@ static int get_fid_support_effects_log(int argc, char **argv, struct command *ac } nvme_show_fid_support_effects_log(fid_support_log, - nvme_transport_handle_get_name(hdl), + libnvme_transport_handle_get_name(hdl), flags); return err; @@ -2653,7 +2653,7 @@ static int get_mi_cmd_support_effects_log(int argc, char **argv, struct command } nvme_show_mi_cmd_support_effects_log(mi_cmd_support_log, - nvme_transport_handle_get_name(hdl), flags); + libnvme_transport_handle_get_name(hdl), flags); return err; } @@ -2705,7 +2705,7 @@ static int list_ctrl(int argc, char **argv, struct command *acmd, struct plugin nvme_init_identify_ns_ctrl_list(&cmd, cfg.namespace_id, cfg.cntid, cntlist); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("id controller list", err); return err; @@ -2888,7 +2888,7 @@ static int id_endurance_grp_list(int argc, char **argv, struct command *acmd, nvme_init_identify_endurance_group_id(&cmd, cfg.endgrp_id, endgrp_list); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("Id endurance group list", err); return err; @@ -2918,7 +2918,7 @@ static bool is_ns_mgmt_support(struct nvme_transport_handle *hdl) static void ns_mgmt_show_status(struct nvme_transport_handle *hdl, int err, char *cmd, __u32 nsid) { if (err < 0) { - nvme_show_error("%s: %s", cmd, nvme_strerror(-err)); + nvme_show_error("%s: %s", cmd, libnvme_strerror(-err)); return; } @@ -2977,21 +2977,21 @@ static int delete_ns(int argc, char **argv, struct command *acmd, struct plugin } if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } nvme_init_ns_mgmt_delete(&cmd, cfg.namespace_id); if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); ns_mgmt_show_status(hdl, err, acmd->name, cfg.namespace_id); return err; @@ -3038,9 +3038,9 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s return err; } - if (nvme_transport_handle_is_blkdev(hdl)) { + if (libnvme_transport_handle_is_blkdev(hdl)) { nvme_show_error("%s: a block device opened (dev: %s, nsid: %d)", acmd->name, - nvme_transport_handle_get_name(hdl), cfg.nsid); + libnvme_transport_handle_get_name(hdl), cfg.nsid); return -EINVAL; } @@ -3067,7 +3067,7 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s err = nvme_identify_ctrl(hdl, &ctrl); if (err) { - fprintf(stderr, "identify-ctrl %s\n", nvme_strerror(-err)); + fprintf(stderr, "identify-ctrl %s\n", libnvme_strerror(-err)); return err; } cntlist->num = cpu_to_le16(1); @@ -3080,12 +3080,12 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s nvme_init_ns_detach_ctrls(&cmd, cfg.nsid, cntlist); if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); ns_mgmt_show_status(hdl, err, acmd->name, cfg.nsid); return err; @@ -3447,49 +3447,49 @@ static int create_ns(int argc, char **argv, struct command *acmd, struct plugin nvme_init_ns_mgmt_create(&cmd, cfg.csi, data); if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); nsid = cmd.result; ns_mgmt_show_status(hdl, err, acmd->name, nsid); return err; } -static bool nvme_match_devname(char *devname, nvme_ns_t ns) +static bool nvme_match_devname(char *devname, libnvme_ns_t ns) { - nvme_ctrl_t c = nvme_ns_get_ctrl(ns); + libnvme_ctrl_t c = libnvme_ns_get_ctrl(ns); - if (!strcmp(devname, nvme_ns_get_name(ns)) || - (c && !strcmp(devname, nvme_ctrl_get_name(c))) || - !strcmp(devname, nvme_ns_get_generic_name(ns))) + if (!strcmp(devname, libnvme_ns_get_name(ns)) || + (c && !strcmp(devname, libnvme_ctrl_get_name(c))) || + !strcmp(devname, libnvme_ns_get_generic_name(ns))) return true; return false; } -static bool nvme_match_device_filter(nvme_subsystem_t s, - nvme_ctrl_t c, nvme_ns_t ns, void *f_args) +static bool nvme_match_device_filter(libnvme_subsystem_t s, + libnvme_ctrl_t c, libnvme_ns_t ns, void *f_args) { char *devname = f_args; - nvme_ns_t n; + libnvme_ns_t n; if (ns && nvme_match_devname(devname, ns)) return true; if (c) { - s = nvme_ctrl_get_subsystem(c); - nvme_ctrl_for_each_ns(c, n) { + s = libnvme_ctrl_get_subsystem(c); + libnvme_ctrl_for_each_ns(c, n) { if (nvme_match_devname(devname, n)) return true; } } if (s) { - nvme_subsystem_for_each_ns(s, n) { - if (!strcmp(devname, nvme_ns_get_name(n))) + libnvme_subsystem_for_each_ns(s, n) { + if (!strcmp(devname, libnvme_ns_get_name(n))) return true; } } @@ -3503,7 +3503,7 @@ static int list_subsys(int argc, char **argv, struct command *acmd, _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; nvme_print_flags_t flags; const char *desc = "Retrieve information for subsystems"; - nvme_scan_filter_t filter = NULL; + libnvme_scan_filter_t filter = NULL; char *devname; int err; int nsid = NVME_NSID_ALL; @@ -3527,7 +3527,7 @@ static int list_subsys(int argc, char **argv, struct command *acmd, if (argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; - ctx = nvme_create_global_ctx(stdout, log_level); + ctx = libnvme_create_global_ctx(stdout, log_level); if (!ctx) { if (devname) nvme_show_error("Failed to scan nvme subsystem for %s", devname); @@ -3547,9 +3547,9 @@ static int list_subsys(int argc, char **argv, struct command *acmd, filter = nvme_match_device_filter; } - err = nvme_scan_topology(ctx, filter, (void *)devname); + err = libnvme_scan_topology(ctx, filter, (void *)devname); if (err) { - nvme_show_error("Failed to scan topology: %s", nvme_strerror(err)); + nvme_show_error("Failed to scan topology: %s", libnvme_strerror(err)); return -errno; } @@ -3580,14 +3580,14 @@ static int list(int argc, char **argv, struct command *acmd, struct plugin *plug if (argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; - ctx = nvme_create_global_ctx(stdout, log_level); + ctx = libnvme_create_global_ctx(stdout, log_level); if (!ctx) { nvme_show_error("Failed to create global context"); return -ENOMEM; } - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err < 0) { - nvme_show_error("Failed to scan topology: %s", nvme_strerror(-err)); + nvme_show_error("Failed to scan topology: %s", libnvme_strerror(-err)); return err; } @@ -3702,7 +3702,7 @@ static int nvm_id_ctrl(int argc, char **argv, struct command *acmd, return -ENOMEM; nvme_init_identify_csi_ctrl(&cmd, NVME_CSI_NVM, ctrl_nvm); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("nvm identify controller", err); return err; @@ -3755,7 +3755,7 @@ static int nvm_id_ns(int argc, char **argv, struct command *acmd, flags |= VERBOSE; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { nvme_show_perror("get-namespace-id"); return err; @@ -3900,9 +3900,9 @@ static int ns_descs(int argc, char **argv, struct command *acmd, struct plugin * flags |= VERBOSE; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -3981,9 +3981,9 @@ static int id_ns(int argc, char **argv, struct command *acmd, struct plugin *plu flags |= VERBOSE; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -3994,7 +3994,7 @@ static int id_ns(int argc, char **argv, struct command *acmd, struct plugin *plu if (cfg.force) { nvme_init_identify_allocated_ns(&cmd, cfg.namespace_id, ns); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); } else { err = nvme_identify_ns(hdl, cfg.namespace_id, ns); } @@ -4057,7 +4057,7 @@ static int cmd_set_independent_id_ns(int argc, char **argv, struct command *acmd flags |= VERBOSE; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { nvme_show_perror("get-namespace-id"); return err; @@ -4070,7 +4070,7 @@ static int cmd_set_independent_id_ns(int argc, char **argv, struct command *acmd nvme_init_identify_csi_independent_identify_id_ns(&cmd, cfg.namespace_id, ns); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err( "I/O command set independent identify namespace", err); @@ -4163,7 +4163,7 @@ static int id_nvmset(int argc, char **argv, struct command *acmd, struct plugin nvme_init_identify_nvmset_list(&cmd, NVME_NSID_NONE, cfg.nvmset_id, nvmset); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("identify nvm set list", err); return err; @@ -4276,7 +4276,7 @@ static int id_iocs(int argc, char **argv, struct command *acmd, struct plugin *p return -ENOMEM; nvme_init_identify_command_set_structure(&cmd, cfg.cntid, iocs); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("NVMe Identify I/O Command Set", err); return err; @@ -4328,7 +4328,7 @@ static int id_domain(int argc, char **argv, struct command *acmd, struct plugin return -ENOMEM; nvme_init_identify_domain_list(&cmd, cfg.dom_id, id_domain); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("NVMe Identify Domain List", err); return err; @@ -4363,13 +4363,13 @@ static int get_ns_id(int argc, char **argv, struct command *acmd, struct plugin return err; } - err = nvme_get_nsid(hdl, &nsid); + err = libnvme_get_nsid(hdl, &nsid); if (err < 0) { - nvme_show_error("get namespace ID: %s", nvme_strerror(-err)); + nvme_show_error("get namespace ID: %s", libnvme_strerror(-err)); return -errno; } - printf("%s: namespace-id:%d\n", nvme_transport_handle_get_name(hdl), nsid); + printf("%s: namespace-id:%d\n", libnvme_transport_handle_get_name(hdl), nsid); return 0; } @@ -4422,7 +4422,7 @@ static int virtual_mgmt(int argc, char **argv, struct command *acmd, struct plug return err; nvme_init_virtual_mgmt(&cmd, cfg.act, cfg.rt, cfg.cntlid, cfg.nr); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("virt-mgmt", err); return err; @@ -4480,7 +4480,7 @@ static int primary_ctrl_caps(int argc, char **argv, struct command *acmd, struct return -ENOMEM; nvme_init_identify_primary_ctrl_cap(&cmd, cfg.cntlid, caps); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("identify primary controller capabilities", err); @@ -4540,7 +4540,7 @@ static int list_secondary_ctrl(int argc, char **argv, struct command *acmd, stru return -ENOMEM; nvme_init_identify_secondary_ctrl_list(&cmd, cfg.cntid, sc_list); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("id secondary controller list", err); return err; @@ -4583,7 +4583,7 @@ static int wait_self_test(struct nvme_transport_handle *hdl) err = nvme_identify_ctrl(hdl, ctrl); if (err) { - nvme_show_error("identify-ctrl: %s", nvme_strerror(err)); + nvme_show_error("identify-ctrl: %s", libnvme_strerror(err)); return err; } @@ -4637,12 +4637,12 @@ static void abort_self_test(struct nvme_transport_handle *hdl, bool ish, nvme_init_dev_self_test(&cmd, nsid, NVME_DST_STC_ABORT); if (ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("Device self-test", err); return; @@ -4730,12 +4730,12 @@ static int device_self_test(int argc, char **argv, struct command *acmd, struct nvme_init_dev_self_test(&cmd, cfg.namespace_id, cfg.stc); if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("Device self-test", err); goto check_abort; @@ -4808,7 +4808,7 @@ static int self_test_log(int argc, char **argv, struct command *acmd, struct plu } nvme_show_self_test_log(log, cfg.dst_entries, 0, - nvme_transport_handle_get_name(hdl), flags); + libnvme_transport_handle_get_name(hdl), flags); return err; } @@ -4868,7 +4868,7 @@ static void get_feature_id_print(struct feat_cfg cfg, int err, __u64 result, !nvme_status_equals(status, type, NVME_SC_INVALID_NS)) nvme_show_status(err); } else { - nvme_show_error("get-feature: %s", nvme_strerror(err)); + nvme_show_error("get-feature: %s", libnvme_strerror(err)); } } @@ -5005,10 +5005,10 @@ static int get_feature(int argc, char **argv, struct command *acmd, } if (!argconfig_parse_seen(opts, "namespace-id")) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { if (errno != ENOTTY) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } cfg.namespace_id = NVME_NSID_ALL; @@ -5056,7 +5056,7 @@ static int fw_download_single(struct nvme_transport_handle *hdl, void *fw_buf, offset, fw_len, (int)(100 * offset / fw_len)); } - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); for (try = 0; try < max_retries; try++) { @@ -5069,7 +5069,7 @@ static int fw_download_single(struct nvme_transport_handle *hdl, void *fw_buf, if (err) return err; - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err) return 0; @@ -5195,7 +5195,7 @@ static int fw_download(int argc, char **argv, struct command *acmd, struct plugi fw_fd = open(cfg.fw, O_RDONLY); cfg.offset <<= 2; if (fw_fd < 0) { - nvme_show_error("Failed to open firmware file %s: %s", cfg.fw, nvme_strerror(errno)); + nvme_show_error("Failed to open firmware file %s: %s", cfg.fw, libnvme_strerror(errno)); return -EINVAL; } @@ -5214,7 +5214,7 @@ static int fw_download(int argc, char **argv, struct command *acmd, struct plugi if (cfg.xfer == 0) { err = nvme_identify_ctrl(hdl, &ctrl); if (err) { - nvme_show_error("identify-ctrl: %s", nvme_strerror(err)); + nvme_show_error("identify-ctrl: %s", libnvme_strerror(err)); return err; } if (ctrl.fwug == 0 || ctrl.fwug == 0xff) @@ -5236,11 +5236,11 @@ static int fw_download(int argc, char **argv, struct command *acmd, struct plugi if (read(fw_fd, fw_buf, fw_size) != ((ssize_t)(fw_size))) { err = -errno; - nvme_show_error("read :%s :%s", cfg.fw, nvme_strerror(errno)); + nvme_show_error("read :%s :%s", cfg.fw, libnvme_strerror(errno)); return err; } - if (cfg.ish && !nvme_transport_handle_is_mi(hdl)) { + if (cfg.ish && !libnvme_transport_handle_is_mi(hdl)) { printf("ISH is supported only for NVMe-MI\n"); } @@ -5290,7 +5290,7 @@ static bool fw_commit_support_mud(struct nvme_transport_handle *hdl) err = nvme_identify_ctrl(hdl, ctrl); if (err) - nvme_show_error("identify-ctrl: %s", nvme_strerror(err)); + nvme_show_error("identify-ctrl: %s", libnvme_strerror(err)); else if (ctrl->frmw >> 5 & 0x1) return true; @@ -5428,12 +5428,12 @@ static int fw_commit(int argc, char **argv, struct command *acmd, struct plugin nvme_init_fw_commit(&cmd, cfg.slot, cfg.action, cfg.bpid); if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { fw_commit_err(err, cfg.action, cfg.slot, cfg.bpid); return err; @@ -5463,19 +5463,19 @@ static int subsystem_reset(int argc, char **argv, struct command *acmd, struct p if (err) return err; - if (!nvme_transport_handle_is_chardev(hdl)) { + if (!libnvme_transport_handle_is_chardev(hdl)) { nvme_show_error(only_char_dev); return -EINVAL; } - err = nvme_reset_subsystem(hdl); + err = libnvme_reset_subsystem(hdl); if (err < 0) { if (errno == ENOTTY) nvme_show_error("Subsystem-reset: NVM Subsystem Reset not supported."); else - nvme_show_error("Subsystem-reset: %s", nvme_strerror(-err)); + nvme_show_error("Subsystem-reset: %s", libnvme_strerror(-err)); } else if (argconfig_parse_seen(opts, "verbose")) - printf("resetting subsystem through %s\n", nvme_transport_handle_get_name(hdl)); + printf("resetting subsystem through %s\n", libnvme_transport_handle_get_name(hdl)); return err; } @@ -5494,16 +5494,16 @@ static int reset(int argc, char **argv, struct command *acmd, struct plugin *plu if (err) return err; - if (!nvme_transport_handle_is_chardev(hdl)) { + if (!libnvme_transport_handle_is_chardev(hdl)) { nvme_show_error(only_char_dev); return -EINVAL; } - err = nvme_reset_ctrl(hdl); + err = libnvme_reset_ctrl(hdl); if (err < 0) - nvme_show_error("Reset: %s", nvme_strerror(-err)); + nvme_show_error("Reset: %s", libnvme_strerror(-err)); else if (argconfig_parse_seen(opts, "verbose")) - printf("resetting controller %s\n", nvme_transport_handle_get_name(hdl)); + printf("resetting controller %s\n", libnvme_transport_handle_get_name(hdl)); return err; } @@ -5523,7 +5523,7 @@ static int ns_rescan(int argc, char **argv, struct command *acmd, struct plugin if (err) return err; - if (!nvme_transport_handle_is_chardev(hdl)) { + if (!libnvme_transport_handle_is_chardev(hdl)) { nvme_show_error(only_char_dev); return -EINVAL; } @@ -5534,11 +5534,11 @@ static int ns_rescan(int argc, char **argv, struct command *acmd, struct plugin return err; } - err = nvme_rescan_ns(hdl); + err = libnvme_rescan_ns(hdl); if (err < 0) - nvme_show_error("Namespace Rescan: %s\n", nvme_strerror(-err)); + nvme_show_error("Namespace Rescan: %s\n", libnvme_strerror(-err)); else if (argconfig_parse_seen(opts, "verbose")) - printf("rescanning namespaces through %s\n", nvme_transport_handle_get_name(hdl)); + printf("rescanning namespaces through %s\n", libnvme_transport_handle_get_name(hdl)); return err; } @@ -5649,12 +5649,12 @@ static int sanitize_cmd(int argc, char **argv, struct command *acmd, struct plug nvme_init_sanitize_nvm(&cmd, cfg.sanact, cfg.ause, cfg.owpass, cfg.oipbp, cfg.no_dealloc, cfg.emvs, cfg.ovrpat); if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("sanitize", err); return err; @@ -5744,12 +5744,12 @@ static int sanitize_ns_cmd(int argc, char **argv, struct command *acmd, nvme_init_sanitize_ns(&cmd, cfg.sanact, cfg.ause, cfg.emvs); if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_admin_cmd_err("sanitize ns", &cmd, err); return err; @@ -5765,7 +5765,7 @@ static int nvme_get_single_property(struct nvme_transport_handle *hdl, int err; nvme_init_get_property(&cmd, cfg->offset); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err) { *value = cmd.result; return 0; @@ -5836,12 +5836,12 @@ static void *mmap_registers(struct nvme_transport_handle *hdl, bool writable) if (writable) prot |= PROT_WRITE; - sprintf(path, "/sys/class/nvme/%s/device/resource0", nvme_transport_handle_get_name(hdl)); + sprintf(path, "/sys/class/nvme/%s/device/resource0", libnvme_transport_handle_get_name(hdl)); fd = open(path, writable ? O_RDWR : O_RDONLY); if (fd < 0) { if (log_level >= LOG_INFO) nvme_show_error("%s did not find a pci resource, open failed %s", - nvme_transport_handle_get_name(hdl), nvme_strerror(errno)); + libnvme_transport_handle_get_name(hdl), libnvme_strerror(errno)); return NULL; } @@ -5886,7 +5886,7 @@ static int show_registers(int argc, char **argv, struct command *acmd, struct pl if (err) return err; - if (nvme_transport_handle_is_blkdev(hdl)) { + if (libnvme_transport_handle_is_blkdev(hdl)) { nvme_show_error(only_char_dev); return -EINVAL; } @@ -6008,11 +6008,11 @@ static int get_register_properties(struct nvme_transport_handle *hdl, void **pba continue; nvme_init_get_property(&cmd, offset); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (nvme_status_equals(err, NVME_STATUS_TYPE_NVME, NVME_SC_INVALID_FIELD)) { value = -1; } else if (err) { - nvme_show_error("get-property: %s", nvme_strerror(err)); + nvme_show_error("get-property: %s", libnvme_strerror(err)); free(bar); return err; } else { @@ -6163,7 +6163,7 @@ static int get_register(int argc, char **argv, struct command *acmd, struct plug if (err) return err; - if (nvme_transport_handle_is_blkdev(hdl)) { + if (libnvme_transport_handle_is_blkdev(hdl)) { nvme_show_error(only_char_dev); return -EINVAL; } @@ -6208,7 +6208,7 @@ static int nvme_set_single_property(struct nvme_transport_handle *hdl, int offse int err; nvme_init_set_property(&cmd, offset, value); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("set-property", err); return err; @@ -6467,7 +6467,7 @@ static int set_register(int argc, char **argv, struct command *acmd, struct plug if (err) return err; - if (nvme_transport_handle_is_blkdev(hdl)) { + if (libnvme_transport_handle_is_blkdev(hdl)) { nvme_show_error(only_char_dev); return -EINVAL; } @@ -6583,15 +6583,15 @@ static void show_relatives(const char *name, nvme_print_flags_t flags) _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx; int err; - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { nvme_show_error("Failed to create global context"); return; } - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err < 0) { - nvme_show_error("Failed to scan topology: %s", nvme_strerror(-err)); + nvme_show_error("Failed to scan topology: %s", libnvme_strerror(-err)); return; } @@ -6708,7 +6708,7 @@ static int format_cmd(int argc, char **argv, struct command *acmd, struct plugin err = nvme_identify_ctrl(hdl, ctrl); if (err) { - nvme_show_error("identify-ctrl: %s", nvme_strerror(err)); + nvme_show_error("identify-ctrl: %s", libnvme_strerror(err)); return -errno; } @@ -6720,9 +6720,9 @@ static int format_cmd(int argc, char **argv, struct command *acmd, struct plugin */ cfg.namespace_id = NVME_NSID_ALL; } else if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return -errno; } } @@ -6796,9 +6796,9 @@ static int format_cmd(int argc, char **argv, struct command *acmd, struct plugin if (!cfg.force) { fprintf(stderr, "You are about to format %s, namespace %#x%s.\n", - nvme_transport_handle_get_name(hdl), cfg.namespace_id, + libnvme_transport_handle_get_name(hdl), cfg.namespace_id, cfg.namespace_id == NVME_NSID_ALL ? "(ALL namespaces)" : ""); - show_relatives(nvme_transport_handle_get_name(hdl), flags); + show_relatives(libnvme_transport_handle_get_name(hdl), flags); fprintf(stderr, "WARNING: Format may irrevocably delete this device's data.\n" "You have 10 seconds to press Ctrl-C to cancel this operation.\n\n" @@ -6811,21 +6811,21 @@ static int format_cmd(int argc, char **argv, struct command *acmd, struct plugin cfg.pi, cfg.pil, cfg.ses); cmd.timeout_ms = timeout_ms; if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("format", err); return err; } printf("Success formatting namespace:%x\n", cfg.namespace_id); - if (nvme_transport_handle_is_direct(hdl) && cfg.lbaf != prev_lbaf) { - if (nvme_transport_handle_is_chardev(hdl)) { - if (nvme_rescan_ns(hdl) < 0) { + if (libnvme_transport_handle_is_direct(hdl) && cfg.lbaf != prev_lbaf) { + if (libnvme_transport_handle_is_chardev(hdl)) { + if (libnvme_rescan_ns(hdl) < 0) { nvme_show_error("failed to rescan namespaces"); return -errno; } @@ -6839,7 +6839,7 @@ static int format_cmd(int argc, char **argv, struct command *acmd, struct plugin * to the given one because blkdev will not * update by itself without re-opening fd. */ - if (ioctl(nvme_transport_handle_get_fd(hdl), BLKBSZSET, + if (ioctl(libnvme_transport_handle_get_fd(hdl), BLKBSZSET, &block_size) < 0) { nvme_show_error( "failed to set block size to %d", @@ -6847,7 +6847,7 @@ static int format_cmd(int argc, char **argv, struct command *acmd, struct plugin return -errno; } - if (ioctl(nvme_transport_handle_get_fd(hdl), + if (ioctl(libnvme_transport_handle_get_fd(hdl), BLKRRPART) < 0) { nvme_show_error( "failed to re-read partition table"); @@ -6855,9 +6855,9 @@ static int format_cmd(int argc, char **argv, struct command *acmd, struct plugin } } } - if (nvme_transport_handle_is_direct(hdl) && cfg.reset && - nvme_transport_handle_is_chardev(hdl)) - nvme_reset_ctrl(hdl); + if (libnvme_transport_handle_is_direct(hdl) && cfg.reset && + libnvme_transport_handle_is_chardev(hdl)) + libnvme_reset_ctrl(hdl); return err; } @@ -6932,10 +6932,10 @@ static int set_feature(int argc, char **argv, struct command *acmd, struct plugi } if (!argconfig_parse_seen(opts, "namespace-id")) { - err = nvme_get_nsid(hdl, &cfg.nsid); + err = libnvme_get_nsid(hdl, &cfg.nsid); if (err < 0) { if (errno != ENOTTY) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return -errno; } cfg.nsid = NVME_NSID_ALL; @@ -6979,14 +6979,14 @@ static int set_feature(int argc, char **argv, struct command *acmd, struct plugi if (ffd < 0) { nvme_show_error("Failed to open file %s: %s", - cfg.file, nvme_strerror(errno)); + cfg.file, libnvme_strerror(errno)); return -EINVAL; } err = read(ffd, buf, cfg.data_len); if (err < 0) { nvme_show_error("failed to read data buffer from input file: %s", - nvme_strerror(errno)); + libnvme_strerror(errno)); return -errno; } } @@ -7088,7 +7088,7 @@ static int sec_send(int argc, char **argv, struct command *acmd, struct plugin * } else { sec_fd = open(cfg.file, O_RDONLY); if (sec_fd < 0) { - nvme_show_error("Failed to open %s: %s", cfg.file, nvme_strerror(errno)); + nvme_show_error("Failed to open %s: %s", cfg.file, libnvme_strerror(errno)); return -EINVAL; } @@ -7108,19 +7108,19 @@ static int sec_send(int argc, char **argv, struct command *acmd, struct plugin * err = read(sec_fd, sec_buf, sec_size); if (err < 0) { nvme_show_error("Failed to read data from security file %s with %s", cfg.file, - nvme_strerror(errno)); + libnvme_strerror(errno)); return -errno; } nvme_init_security_send(&cmd, cfg.namespace_id, cfg.nssf, cfg.spsp, cfg.secp, cfg.tl, sec_buf, cfg.tl); if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("security-send", err); return err; @@ -7229,7 +7229,7 @@ static int dir_send(int argc, char **argv, struct command *acmd, struct plugin * ffd = open(cfg.file, O_RDONLY); if (ffd <= 0) { nvme_show_error("Failed to open file %s: %s", - cfg.file, nvme_strerror(errno)); + cfg.file, libnvme_strerror(errno)); return -EINVAL; } } @@ -7237,7 +7237,7 @@ static int dir_send(int argc, char **argv, struct command *acmd, struct plugin * if (err < 0) { nvme_show_error( "failed to read data buffer from input file %s", - nvme_strerror(errno)); + libnvme_strerror(errno)); return -errno; } } @@ -7245,7 +7245,7 @@ static int dir_send(int argc, char **argv, struct command *acmd, struct plugin * nvme_init_directive_send(&cmd, cfg.namespace_id, cfg.doper, cfg.dtype, cfg.dspec, buf, cfg.data_len); cmd.cdw12 = dw12; - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("dir-send", err); return err; @@ -7304,9 +7304,9 @@ static int write_uncor(int argc, char **argv, struct command *acmd, struct plugi return err; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -7318,7 +7318,7 @@ static int write_uncor(int argc, char **argv, struct command *acmd, struct plugi nvme_init_write_uncorrectable(&cmd, cfg.namespace_id, cfg.start_block, cfg.block_count, cfg.dtype << 4, cfg.dspec); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_err("write uncorrectable", err); return err; @@ -7577,9 +7577,9 @@ static int write_zeroes(int argc, char **argv, control |= NVME_IO_NSZ; control |= (cfg.dtype << 4); if (!cfg.nsid) { - err = nvme_get_nsid(hdl, &cfg.nsid); + err = libnvme_get_nsid(hdl, &cfg.nsid); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -7592,7 +7592,7 @@ static int write_zeroes(int argc, char **argv, if (err && err != -ENAVAIL) return err; - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_err("write-zeroes", err); return err; @@ -7697,9 +7697,9 @@ static int dsm(int argc, char **argv, struct command *acmd, struct plugin *plugi } if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -7716,7 +7716,7 @@ static int dsm(int argc, char **argv, struct command *acmd, struct plugin *plugi nvme_init_dsm_range(dsm, ctx_attrs, nlbs, slbas, nb); nvme_init_dsm(&cmd, cfg.namespace_id, nb, cfg.idr, cfg.idw, cfg.ad, dsm, sizeof(*dsm) * nb); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_err("data-set management", err); return err; @@ -7897,9 +7897,9 @@ static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin * } if (!cfg.nsid) { - err = nvme_get_nsid(hdl, &cfg.nsid); + err = libnvme_get_nsid(hdl, &cfg.nsid); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -7934,7 +7934,7 @@ static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin * cfg.lbatm); if (err != 0 && err != -ENAVAIL) return err; - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_err("NVMe Copy", err); return err; @@ -7977,9 +7977,9 @@ static int flush_cmd(int argc, char **argv, struct command *acmd, struct plugin return err; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -8049,9 +8049,9 @@ static int resv_acquire(int argc, char **argv, struct command *acmd, struct plug } if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -8062,7 +8062,7 @@ static int resv_acquire(int argc, char **argv, struct command *acmd, struct plug nvme_init_resv_acquire(&cmd, cfg.namespace_id, cfg.racqa, cfg.iekey, false, cfg.rtype, cfg.crkey, cfg.prkey, payload); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_err("reservation acquire", err); return err; @@ -8125,9 +8125,9 @@ static int resv_register(int argc, char **argv, struct command *acmd, struct plu } if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -8144,7 +8144,7 @@ static int resv_register(int argc, char **argv, struct command *acmd, struct plu nvme_init_resv_register(&cmd, cfg.namespace_id, cfg.rrega, cfg.iekey, false, cfg.cptpl, cfg.crkey, cfg.nrkey, payload); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_err("reservation register", err); return err; @@ -8208,9 +8208,9 @@ static int resv_release(int argc, char **argv, struct command *acmd, struct plug } if (!cfg.nsid) { - err = nvme_get_nsid(hdl, &cfg.nsid); + err = libnvme_get_nsid(hdl, &cfg.nsid); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -8221,7 +8221,7 @@ static int resv_release(int argc, char **argv, struct command *acmd, struct plug nvme_init_resv_release(&cmd, cfg.nsid, cfg.rrela, cfg.iekey, false, cfg.rtype, cfg.crkey, payload); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_err("reservation release", err); return err; @@ -8283,9 +8283,9 @@ static int resv_report(int argc, char **argv, struct command *acmd, struct plugi flags = BINARY; if (!cfg.nsid) { - err = nvme_get_nsid(hdl, &cfg.nsid); + err = libnvme_get_nsid(hdl, &cfg.nsid); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -8303,7 +8303,7 @@ static int resv_report(int argc, char **argv, struct command *acmd, struct plugi err = nvme_identify_ctrl(hdl, ctrl); if (err) { - nvme_show_error("identify-ctrl: %s", nvme_strerror(err)); + nvme_show_error("identify-ctrl: %s", libnvme_strerror(err)); return -errno; } @@ -8315,7 +8315,7 @@ static int resv_report(int argc, char **argv, struct command *acmd, struct plugi return -ENOMEM; nvme_init_resv_report(&cmd, cfg.nsid, cfg.eds, false, status, size); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_err("reservation report", err); return err; @@ -8469,9 +8469,9 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char } if (!cfg.nsid) { - err = nvme_get_nsid(hdl, &cfg.nsid); + err = libnvme_get_nsid(hdl, &cfg.nsid); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -8576,7 +8576,7 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char err = read(dfd, (void *)buffer, cfg.data_size); if (err < 0) { err = -errno; - nvme_show_error("failed to read data buffer from input file %s", nvme_strerror(errno)); + nvme_show_error("failed to read data buffer from input file %s", libnvme_strerror(errno)); return err; } } @@ -8585,7 +8585,7 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char err = read(mfd, (void *)mbuffer, mbuffer_size); if (err < 0) { err = -errno; - nvme_show_error("failed to read meta-data buffer from input file %s", nvme_strerror(errno)); + nvme_show_error("failed to read meta-data buffer from input file %s", libnvme_strerror(errno)); return err; } } @@ -8632,7 +8632,7 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char return err; } gettimeofday(&start_time, NULL); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); gettimeofday(&end_time, NULL); if (cfg.latency) printf(" latency: %s: %llu us\n", command, elapsed_utime(start_time, end_time)); @@ -8644,13 +8644,13 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char if (!(opcode & 1) && write(dfd, (void *)buffer, buffer_size) < 0) { nvme_show_error( "write: %s: failed to write buffer to output file", - nvme_strerror(errno)); + libnvme_strerror(errno)); err = -EINVAL; } else if (!(opcode & 1) && cfg.metadata_size && write(mfd, (void *)mbuffer, mbuffer_size) < 0) { nvme_show_error( "write: %s: failed to write meta-data buffer to output file", - nvme_strerror(errno)); + libnvme_strerror(errno)); err = -EINVAL; } else { fprintf(stderr, "%s: Success\n", command); @@ -8760,9 +8760,9 @@ static int verify_cmd(int argc, char **argv, struct command *acmd, struct plugin control |= NVME_IO_STC; if (!cfg.nsid) { - err = nvme_get_nsid(hdl, &cfg.nsid); + err = libnvme_get_nsid(hdl, &cfg.nsid); if (err < 0) { - nvme_show_error("get-namespace-id: %s", nvme_strerror(-err)); + nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err)); return err; } } @@ -8773,7 +8773,7 @@ static int verify_cmd(int argc, char **argv, struct command *acmd, struct plugin cfg.lbat, cfg.lbatm); if (err != 0 && err != -ENAVAIL) return err; - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_err("verify", err); return err; @@ -8851,7 +8851,7 @@ static int sec_recv(int argc, char **argv, struct command *acmd, struct plugin * } if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); @@ -8859,7 +8859,7 @@ static int sec_recv(int argc, char **argv, struct command *acmd, struct plugin * nvme_init_security_receive(&cmd, cfg.namespace_id, cfg.nssf, cfg.spsp, cfg.secp, cfg.al, sec_buf, cfg.size); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("security receive", err); return err; @@ -8944,12 +8944,12 @@ static int get_lba_status(int argc, char **argv, struct command *acmd, nvme_init_get_lba_status(&cmd, cfg.namespace_id, cfg.slba, cfg.mndw, cfg.atype, cfg.rl, buf); if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("get lba status", err); return err; @@ -9021,12 +9021,12 @@ static int capacity_mgmt(int argc, char **argv, struct command *acmd, struct plu nvme_init_capacity_mgmt(&cmd, cfg.operation, cfg.element_id, (__u64)cfg.dw12 << 32 | cfg.dw11); if (cfg.ish) { - if (nvme_transport_handle_is_mi(hdl)) + if (libnvme_transport_handle_is_mi(hdl)) nvme_init_mi_cmd_flags(&cmd, ish); else printf("ISH is supported only for NVMe-MI\n"); } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("capacity management", err); return err; @@ -9143,7 +9143,7 @@ static int dir_receive(int argc, char **argv, struct command *acmd, struct plugi nvme_init_directive_recv(&cmd, cfg.namespace_id, cfg.doper, cfg.dtype, cfg.dspec, buf, cfg.data_len); cmd.cdw12 = dw12; - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("dir-receive", err); return err; @@ -9235,7 +9235,7 @@ static int lockdown_cmd(int argc, char **argv, struct command *acmd, struct plug nvme_init_lockdown(&cmd, cfg.scp, cfg.prhbt, cfg.ifc, cfg.ofi, cfg.uuid); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("lockdown", err); return err; @@ -9429,7 +9429,7 @@ static int passthru(int argc, char **argv, bool admin, } else if (cfg.write) { if (read(dfd, data, cfg.data_len) < 0) { err = -errno; - nvme_show_error("failed to read write buffer %s", nvme_strerror(errno)); + nvme_show_error("failed to read write buffer %s", libnvme_strerror(errno)); return err; } } @@ -9478,9 +9478,9 @@ static int passthru(int argc, char **argv, bool admin, .timeout_ms = nvme_args.timeout, }; if (admin) - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); else - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); gettimeofday(&end_time, NULL); cmd_name = nvme_cmd_to_string(admin, cfg.opcode); @@ -9524,7 +9524,7 @@ static int gen_hostnqn_cmd(int argc, char **argv, struct command *acmd, struct p { char *hostnqn; - hostnqn = nvme_generate_hostnqn(); + hostnqn = libnvme_generate_hostnqn(); if (!hostnqn) { nvme_show_error("\"%s\" not supported. Install lib uuid and rebuild.", acmd->name); @@ -9539,9 +9539,9 @@ static int show_hostnqn_cmd(int argc, char **argv, struct command *acmd, struct { char *hostnqn; - hostnqn = nvme_read_hostnqn(); + hostnqn = libnvme_read_hostnqn(); if (!hostnqn) - hostnqn = nvme_generate_hostnqn(); + hostnqn = libnvme_generate_hostnqn(); if (!hostnqn) { nvme_show_error("hostnqn is not available -- use nvme gen-hostnqn"); @@ -9598,7 +9598,7 @@ static int gen_dhchap_key(int argc, char **argv, struct command *acmd, struct pl if (err) return err; - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { nvme_show_error("Failed to create global context"); return -ENOMEM; @@ -9669,14 +9669,14 @@ static int gen_dhchap_key(int argc, char **argv, struct command *acmd, struct pl } if (!cfg.nqn) { - cfg.nqn = hnqn = nvme_read_hostnqn(); + cfg.nqn = hnqn = libnvme_read_hostnqn(); if (!cfg.nqn) { nvme_show_error("Could not read host NQN"); return -ENOENT; } } - err = nvme_gen_dhchap_key(ctx, cfg.nqn, cfg.hmac, + err = libnvme_gen_dhchap_key(ctx, cfg.nqn, cfg.hmac, cfg.key_len, raw_secret, key); if (err) return err; @@ -9795,14 +9795,14 @@ static int append_keyfile(struct nvme_global_ctx *ctx, const char *keyring, long kr_id; char type; - err = nvme_lookup_keyring(ctx, keyring, &kr_id); + err = libnvme_lookup_keyring(ctx, keyring, &kr_id); if (err) { nvme_show_error("Failed to lookup keyring '%s', %s", - keyring, nvme_strerror(-err)); + keyring, libnvme_strerror(-err)); return err; } - identity = nvme_describe_key_serial(ctx, id); + identity = libnvme_describe_key_serial(ctx, id); if (!identity) { nvme_show_error("Failed to get identity info"); return -EINVAL; @@ -9813,18 +9813,18 @@ static int append_keyfile(struct nvme_global_ctx *ctx, const char *keyring, return -EINVAL; } - err = nvme_read_key(ctx, kr_id, id, &key_len, &key_data); + err = libnvme_read_key(ctx, kr_id, id, &key_len, &key_data); if (err) { nvme_show_error("Failed to read back derive TLS PSK, %s", - nvme_strerror(-err)); + libnvme_strerror(-err)); return err; } - err = nvme_export_tls_key_versioned(ctx, ver, hmac, key_data, + err = libnvme_export_tls_key_versioned(ctx, ver, hmac, key_data, key_len, &exported_key); if (err) { nvme_show_error("Failed to export key, %s", - nvme_strerror(-err)); + libnvme_strerror(-err)); return err; } @@ -9833,7 +9833,7 @@ static int append_keyfile(struct nvme_global_ctx *ctx, const char *keyring, fd = fopen(keyfile, "a"); if (!fd) { nvme_show_error("Failed to open '%s', %s", - keyfile, nvme_strerror(errno)); + keyfile, libnvme_strerror(errno)); err = -errno; goto out; } @@ -9841,7 +9841,7 @@ static int append_keyfile(struct nvme_global_ctx *ctx, const char *keyring, err = fprintf(fd, "%s %s\n", identity, exported_key); if (err < 0) { nvme_show_error("Failed to append key to '%s', %s", - keyfile, nvme_strerror(errno)); + keyfile, libnvme_strerror(errno)); err = -errno; } else { err = 0; @@ -9933,7 +9933,7 @@ static int gen_tls_key(int argc, char **argv, struct command *acmd, struct plugi return -EINVAL; } if (!cfg.hostnqn) { - cfg.hostnqn = hnqn = nvme_read_hostnqn(); + cfg.hostnqn = hnqn = libnvme_read_hostnqn(); if (!cfg.hostnqn) { nvme_show_error("Failed to read host NQN"); return -EINVAL; @@ -9943,7 +9943,7 @@ static int gen_tls_key(int argc, char **argv, struct command *acmd, struct plugi if (cfg.hmac == 2) key_len = 48; - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { nvme_show_error("Failed to create global context"); return -ENOMEM; @@ -9976,21 +9976,21 @@ static int gen_tls_key(int argc, char **argv, struct command *acmd, struct plugi } } - err = nvme_export_tls_key(ctx, raw_secret, key_len, &encoded_key); + err = libnvme_export_tls_key(ctx, raw_secret, key_len, &encoded_key); if (err) { - nvme_show_error("Failed to export key, %s", nvme_strerror(-err)); + nvme_show_error("Failed to export key, %s", libnvme_strerror(-err)); return err; } printf("%s\n", encoded_key); if (cfg.insert) { if (cfg.compat) - err = nvme_insert_tls_key_compat(ctx, cfg.keyring, + err = libnvme_insert_tls_key_compat(ctx, cfg.keyring, cfg.keytype, cfg.hostnqn, cfg.subsysnqn, cfg.version, cfg.hmac, raw_secret, key_len, &tls_key); else - err = nvme_insert_tls_key_versioned(ctx, cfg.keyring, + err = libnvme_insert_tls_key_versioned(ctx, cfg.keyring, cfg.keytype, cfg.hostnqn, cfg.subsysnqn, cfg.version, cfg.hmac, raw_secret, key_len, &tls_key); @@ -10080,13 +10080,13 @@ static int check_tls_key(int argc, char **argv, struct command *acmd, struct plu return -EINVAL; } - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { nvme_show_error("Failed to create global context"); return -ENOMEM; } - err = nvme_import_tls_key(ctx, cfg.keydata, &decoded_len, + err = libnvme_import_tls_key(ctx, cfg.keydata, &decoded_len, &hmac, &decoded_key); if (err) { nvme_show_error("Key decoding failed, error %d\n", err); @@ -10095,7 +10095,7 @@ static int check_tls_key(int argc, char **argv, struct command *acmd, struct plu if (cfg.subsysnqn) { if (!cfg.hostnqn) { - cfg.hostnqn = hnqn = nvme_read_hostnqn(); + cfg.hostnqn = hnqn = libnvme_read_hostnqn(); if (!cfg.hostnqn) { nvme_show_error("Failed to read host NQN"); return -EINVAL; @@ -10108,13 +10108,13 @@ static int check_tls_key(int argc, char **argv, struct command *acmd, struct plu if (cfg.insert) { if (cfg.compat) - err = nvme_insert_tls_key_compat(ctx, cfg.keyring, + err = libnvme_insert_tls_key_compat(ctx, cfg.keyring, cfg.keytype, cfg.hostnqn, cfg.subsysnqn, cfg.identity, hmac, decoded_key, decoded_len, &tls_key); else - err = nvme_insert_tls_key_versioned(ctx, cfg.keyring, + err = libnvme_insert_tls_key_versioned(ctx, cfg.keyring, cfg.keytype, cfg.hostnqn, cfg.subsysnqn, cfg.identity, hmac, decoded_key, decoded_len, @@ -10135,12 +10135,12 @@ static int check_tls_key(int argc, char **argv, struct command *acmd, struct plu _cleanup_free_ char *tls_id = NULL; if (cfg.compat) - err = nvme_generate_tls_key_identity_compat(ctx, + err = libnvme_generate_tls_key_identity_compat(ctx, cfg.hostnqn, cfg.subsysnqn, cfg.identity, hmac, decoded_key, decoded_len, &tls_id); else - err = nvme_generate_tls_key_identity(ctx, + err = libnvme_generate_tls_key_identity(ctx, cfg.hostnqn, cfg.subsysnqn, cfg.identity, hmac, decoded_key, decoded_len, &tls_id); @@ -10165,14 +10165,14 @@ static void __scan_tls_key(struct nvme_global_ctx *ctx, long keyring_id, char type; int err; - err = nvme_read_key(ctx, keyring_id, key_id, &key_len, &key_data); + err = libnvme_read_key(ctx, keyring_id, key_id, &key_len, &key_data); if (err) return; if (sscanf(desc, "NVMe%01d%c%02d %*s", &ver, &type, &hmac) != 3) return; - err = nvme_export_tls_key_versioned(ctx, ver, hmac, key_data, key_len, + err = libnvme_export_tls_key_versioned(ctx, ver, hmac, key_data, key_len, &encoded_key); if (err) return; @@ -10190,7 +10190,7 @@ static int import_key(struct nvme_global_ctx *ctx, const char *keyring, int linenum = -1, key_len; int err; - err = nvme_lookup_keyring(ctx, keyring, &keyring_id); + err = libnvme_lookup_keyring(ctx, keyring, &keyring_id); if (err) { nvme_show_error("Invalid keyring '%s'", keyring); return err; @@ -10207,13 +10207,13 @@ static int import_key(struct nvme_global_ctx *ctx, const char *keyring, *tls_key = '\0'; tls_key++; tls_key[strcspn(tls_key, "\n")] = 0; - err = nvme_import_tls_key(ctx, tls_key, &key_len, &hmac, &psk); + err = libnvme_import_tls_key(ctx, tls_key, &key_len, &hmac, &psk); if (err) { nvme_show_error("Failed to import key in line %d", linenum); continue; } - err = nvme_update_key(ctx, keyring_id, "psk", tls_str, + err = libnvme_update_key(ctx, keyring_id, "psk", tls_str, psk, key_len, &key); if (err) continue; @@ -10269,7 +10269,7 @@ static int tls_key(int argc, char **argv, struct command *acmd, struct plugin *p if (err) return err; - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { nvme_show_error("Failed to create global context"); return -ENOMEM; @@ -10307,10 +10307,10 @@ static int tls_key(int argc, char **argv, struct command *acmd, struct plugin *p nvme_show_error("Must specify either --import, --export or --revoke"); return -EINVAL; } else if (cfg.export) { - err = nvme_scan_tls_keys(ctx, cfg.keyring, __scan_tls_key, fd); + err = libnvme_scan_tls_keys(ctx, cfg.keyring, __scan_tls_key, fd); if (err < 0) { nvme_show_error("Export of TLS keys failed with '%s'", - nvme_strerror(-err)); + libnvme_strerror(-err)); return err; } @@ -10322,18 +10322,18 @@ static int tls_key(int argc, char **argv, struct command *acmd, struct plugin *p err = import_key(ctx, cfg.keyring, fd); if (err) { nvme_show_error("Import of TLS keys failed with '%s'", - nvme_strerror(err)); + libnvme_strerror(err)); return err; } if (argconfig_parse_seen(opts, "verbose")) printf("importing from %s\n", cfg.keyfile); } else { - err = nvme_revoke_tls_key(ctx, cfg.keyring, cfg.keytype, + err = libnvme_revoke_tls_key(ctx, cfg.keyring, cfg.keytype, cfg.revoke); if (err) { nvme_show_error("Failed to revoke key '%s'", - nvme_strerror(err)); + libnvme_strerror(err)); return err; } @@ -10356,7 +10356,7 @@ static int show_topology_cmd(int argc, char **argv, struct command *acmd, struct nvme_print_flags_t flags; _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; char *devname = NULL; - nvme_scan_filter_t filter = NULL; + libnvme_scan_filter_t filter = NULL; enum nvme_cli_topo_ranking rank; int err; @@ -10395,7 +10395,7 @@ static int show_topology_cmd(int argc, char **argv, struct command *acmd, struct return -EINVAL; } - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { nvme_show_error("Failed to create global context"); return -ENOMEM; @@ -10415,9 +10415,9 @@ static int show_topology_cmd(int argc, char **argv, struct command *acmd, struct filter = nvme_match_device_filter; } - err = nvme_scan_topology(ctx, filter, (void *)devname); + err = libnvme_scan_topology(ctx, filter, (void *)devname); if (err < 0) { - nvme_show_error("Failed to scan topology: %s", nvme_strerror(-err)); + nvme_show_error("Failed to scan topology: %s", libnvme_strerror(-err)); return err; } @@ -10568,7 +10568,7 @@ static int nvme_mi(int argc, char **argv, __u8 admin_opcode, const char *desc) if (send) { if (read(fd, data, cfg.data_len) < 0) { err = -errno; - nvme_show_error("failed to read write buffer %s", nvme_strerror(errno)); + nvme_show_error("failed to read write buffer %s", libnvme_strerror(errno)); return err; } } @@ -10585,7 +10585,7 @@ static int nvme_mi(int argc, char **argv, __u8 admin_opcode, const char *desc) .data_len = cfg.data_len, }; - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { nvme_show_err("nmi_recv", err); return err; @@ -10597,7 +10597,7 @@ static int nvme_mi(int argc, char **argv, __u8 admin_opcode, const char *desc) nvme_cmd_to_string(true, admin_opcode), result, result & 0xff, result >> 8); if (result & 0xff) - printf("status: %s\n", nvme_mi_status_to_string(result & 0xff)); + printf("status: %s\n", libnvme_mi_status_to_string(result & 0xff)); if (!send && strlen(cfg.input_file)) { if (write(fd, (void *)data, cfg.data_len) < 0) perror("failed to write data buffer"); diff --git a/nvme.h b/nvme.h index 7881430d56..1fab99256a 100644 --- a/nvme.h +++ b/nvme.h @@ -93,13 +93,13 @@ struct nvme_args { OPT_END() \ } -static inline bool nvme_is_multipath(nvme_subsystem_t s) +static inline bool nvme_is_multipath(libnvme_subsystem_t s) { - nvme_ns_t n; - nvme_path_t p; + libnvme_ns_t n; + libnvme_path_t p; - nvme_subsystem_for_each_ns(s, n) - nvme_namespace_for_each_path(n, p) + libnvme_subsystem_for_each_ns(s, n) + libnvme_namespace_for_each_path(n, p) return true; return false; @@ -116,7 +116,7 @@ int parse_and_open(struct nvme_global_ctx **ctx, // TODO: unsure if we need a double ptr here static inline DEFINE_CLEANUP_FUNC( - cleanup_nvme_transport_handle, struct nvme_transport_handle *, nvme_close) + cleanup_nvme_transport_handle, struct nvme_transport_handle *, libnvme_close) #define _cleanup_nvme_transport_handle_ __cleanup__(cleanup_nvme_transport_handle) extern const char *uuid_index; @@ -127,7 +127,7 @@ bool nvme_is_output_format_json(void); int __id_ctrl(int argc, char **argv, struct command *acmd, struct plugin *plugin, void (*vs)(uint8_t *vs, struct json_object *root)); -const char *nvme_strerror(int errnum); +const char *libnvme_strerror(int errnum); unsigned long long elapsed_utime(struct timeval start_time, struct timeval end_time); diff --git a/plugin.c b/plugin.c index d0e6ef57f7..e9225c1f1c 100644 --- a/plugin.c +++ b/plugin.c @@ -21,8 +21,8 @@ static int version_cmd(struct plugin *plugin) prog->name, prog->version, GIT_VERSION); } printf("libnvme version %s (git %s)\n", - nvme_get_version(NVME_VERSION_PROJECT), - nvme_get_version(NVME_VERSION_GIT)); + libnvme_get_version(NVME_VERSION_PROJECT), + libnvme_get_version(NVME_VERSION_GIT)); return 0; } diff --git a/plugins/amzn/amzn-nvme.c b/plugins/amzn/amzn-nvme.c index 5613095144..c73e91455e 100644 --- a/plugins/amzn/amzn-nvme.c +++ b/plugins/amzn/amzn-nvme.c @@ -599,7 +599,7 @@ static int get_stats(int argc, char **argv, struct command *acmd, if (!strncmp((char *)ctrl.mn, AMZN_NVME_LOCAL_STORAGE_PREFIX, strlen(AMZN_NVME_LOCAL_STORAGE_PREFIX))) { - if (nvme_get_nsid(hdl, &nsid) < 0) { + if (libnvme_get_nsid(hdl, &nsid) < 0) { struct nvme_id_ctrl test_ctrl; if (nvme_identify_ctrl(hdl, &test_ctrl) == 0) { diff --git a/plugins/dapustor/dapustor-nvme.c b/plugins/dapustor/dapustor-nvme.c index cb88df38f9..bbbbbb8667 100644 --- a/plugins/dapustor/dapustor-nvme.c +++ b/plugins/dapustor/dapustor-nvme.c @@ -550,12 +550,12 @@ static int dapustor_additional_smart_log(int argc, char **argv, struct command * if (flags & JSON || cfg.json) show_dapustor_smart_log_jsn(&smart_log, &ext_smart_log, cfg.namespace_id, - nvme_transport_handle_get_name(hdl), + libnvme_transport_handle_get_name(hdl), has_ext); else if (!cfg.raw_binary) show_dapustor_smart_log(&smart_log, &ext_smart_log, cfg.namespace_id, - nvme_transport_handle_get_name(hdl), has_ext); + libnvme_transport_handle_get_name(hdl), has_ext); else { d_raw((unsigned char *)&smart_log, sizeof(smart_log)); if (has_ext) diff --git a/plugins/dera/dera-nvme.c b/plugins/dera/dera-nvme.c index 0d01060ac9..3d0ee4aaa1 100644 --- a/plugins/dera/dera-nvme.c +++ b/plugins/dera/dera-nvme.c @@ -108,7 +108,7 @@ static int nvme_dera_get_device_status(struct nvme_transport_handle *hdl, enum d .cdw12 = 0x104, }; - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err && result) *result = cmd.result; diff --git a/plugins/fdp/fdp.c b/plugins/fdp/fdp.c index 4c59d6d3f7..4f5e0a9a21 100644 --- a/plugins/fdp/fdp.c +++ b/plugins/fdp/fdp.c @@ -312,7 +312,7 @@ static int fdp_status(int argc, char **argv, struct command *acmd, struct plugin flags = BINARY; if (!cfg.nsid) { - err = nvme_get_nsid(hdl, &cfg.nsid); + err = libnvme_get_nsid(hdl, &cfg.nsid); if (err < 0) { perror("get-namespace-id"); return err; @@ -321,7 +321,7 @@ static int fdp_status(int argc, char **argv, struct command *acmd, struct plugin nvme_init_fdp_reclaim_unit_handle_status(&cmd, cfg.nsid, &hdr, sizeof(hdr)); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_status(err); return err; @@ -334,7 +334,7 @@ static int fdp_status(int argc, char **argv, struct command *acmd, struct plugin return -ENOMEM; nvme_init_fdp_reclaim_unit_handle_status(&cmd, cfg.nsid, buf, len); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_status(err); return err; @@ -386,7 +386,7 @@ static int fdp_update(int argc, char **argv, struct command *acmd, struct plugin } if (!cfg.nsid) { - err = nvme_get_nsid(hdl, &cfg.nsid); + err = libnvme_get_nsid(hdl, &cfg.nsid); if (err < 0) { perror("get-namespace-id"); return err; @@ -397,7 +397,7 @@ static int fdp_update(int argc, char **argv, struct command *acmd, struct plugin buf[i] = cpu_to_le16(pids[i]); nvme_init_fdp_reclaim_unit_handle_status(&cmd, cfg.nsid, buf, npids); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err) { nvme_show_status(err); return err; @@ -461,10 +461,10 @@ static int fdp_set_events(int argc, char **argv, struct command *acmd, struct pl } if (!cfg.nsid) { - err = nvme_get_nsid(hdl, &cfg.nsid); + err = libnvme_get_nsid(hdl, &cfg.nsid); if (err < 0) { if (errno != ENOTTY) { - fprintf(stderr, "get-namespace-id: %s\n", nvme_strerror(errno)); + fprintf(stderr, "get-namespace-id: %s\n", libnvme_strerror(errno)); return err; } diff --git a/plugins/feat/feat-nvme.c b/plugins/feat/feat-nvme.c index 3c37e14312..da1311315d 100644 --- a/plugins/feat/feat-nvme.c +++ b/plugins/feat/feat-nvme.c @@ -86,7 +86,7 @@ static int feat_get(struct nvme_transport_handle *hdl, const __u8 fid, } else if (err > 0) { nvme_show_status(err); } else { - nvme_show_error("Get %s: %s", feat, nvme_strerror(errno)); + nvme_show_error("Get %s: %s", feat, libnvme_strerror(errno)); } nvme_show_finish(); @@ -173,19 +173,19 @@ static int perfc_set(struct nvme_transport_handle *hdl, __u8 fid, __u32 cdw11, data.std_perf->r4karl = cfg->r4karl; break; case NVME_FEAT_PERFC_ATTRI_VS_MIN ... NVME_FEAT_PERFC_ATTRI_VS_MAX: - nvme_uuid_from_string(cfg->paid, data.vs_perf->paid); + libnvme_uuid_from_string(cfg->paid, data.vs_perf->paid); data.vs_perf->attrl = cfg->attrl; if (data.vs_perf->attrl && strlen(cfg->vs_data)) { ffd = open(cfg->vs_data, O_RDONLY); if (ffd < 0) { nvme_show_error("Failed to open file %s: %s", cfg->vs_data, - nvme_strerror(errno)); + libnvme_strerror(errno)); return -EINVAL; } err = read(ffd, data.vs_perf->vs, data.vs_perf->attrl); if (err < 0) { nvme_show_error("failed to read data buffer from input file: %s", - nvme_strerror(errno)); + libnvme_strerror(errno)); return -errno; } } @@ -398,7 +398,7 @@ static int temp_thresh_set(struct nvme_transport_handle *hdl, const __u8 fid, sel = NVME_GET_FEATURES_SEL_SAVED; nvme_init_get_features_temp_thresh(&cmd, sel, cfg->tmpsel, cfg->thsel); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err) { nvme_feature_decode_temp_threshold(cmd.result, &tmpth, &tmpsel, &thsel, &tmpthh); @@ -410,7 +410,7 @@ static int temp_thresh_set(struct nvme_transport_handle *hdl, const __u8 fid, nvme_init_set_features_temp_thresh(&cmd, sv, cfg->tmpth, cfg->tmpsel, cfg->thsel, cfg->tmpthh); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); nvme_show_init(); @@ -481,7 +481,7 @@ static int arbitration_set(struct nvme_transport_handle *hdl, const __u8 fid, sel = NVME_GET_FEATURES_SEL_SAVED; nvme_init_get_features_arbitration(&cmd, sel); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err) { nvme_feature_decode_arbitration(cmd.result, &ab, &lpw, &mpw, &hpw); @@ -497,7 +497,7 @@ static int arbitration_set(struct nvme_transport_handle *hdl, const __u8 fid, nvme_init_set_features_arbitration(&cmd, sv, cfg->ab, cfg->lpw, cfg->mpw, cfg->hpw); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); nvme_show_init(); diff --git a/plugins/huawei/huawei-nvme.c b/plugins/huawei/huawei-nvme.c index dcf4f3dc2b..3b2c8e560e 100644 --- a/plugins/huawei/huawei-nvme.c +++ b/plugins/huawei/huawei-nvme.c @@ -87,12 +87,12 @@ static int huawei_get_nvme_info(struct nvme_transport_handle *hdl, } item->huawei_device = true; - err = nvme_get_nsid(hdl, &item->nsid); + err = libnvme_get_nsid(hdl, &item->nsid); err = nvme_identify_ns(hdl, item->nsid, &item->ns); if (err) return err; - err = fstat(nvme_transport_handle_get_fd(hdl), &nvme_stat_info); + err = fstat(libnvme_transport_handle_get_fd(hdl), &nvme_stat_info); if (err < 0) return err; @@ -297,7 +297,7 @@ static int huawei_list(int argc, char **argv, struct command *acmd, struct plugin *plugin) { _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = - nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); char path[264]; struct dirent **devices; struct huawei_list_item *list_items; @@ -319,7 +319,7 @@ static int huawei_list(int argc, char **argv, struct command *acmd, if (ret < 0 || (fmt != JSON && fmt != NORMAL)) return ret; - n = scandir("/dev", &devices, nvme_filter_namespace, alphasort); + n = scandir("/dev", &devices, libnvme_filter_namespace, alphasort); if (n <= 0) return n; @@ -334,10 +334,10 @@ static int huawei_list(int argc, char **argv, struct command *acmd, _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; snprintf(path, sizeof(path), "/dev/%s", devices[i]->d_name); - ret = nvme_open(ctx, path, &hdl); + ret = libnvme_open(ctx, path, &hdl); if (ret) { fprintf(stderr, "Cannot open device %s: %s\n", - path, nvme_strerror(-ret)); + path, libnvme_strerror(-ret)); continue; } ret = huawei_get_nvme_info(hdl, &list_items[huawei_num], path); diff --git a/plugins/ibm/ibm-nvme.c b/plugins/ibm/ibm-nvme.c index 38f3cf0fe1..0de9f5dfba 100644 --- a/plugins/ibm/ibm-nvme.c +++ b/plugins/ibm/ibm-nvme.c @@ -250,13 +250,13 @@ static int get_ibm_addi_smart_log(int argc, char **argv, struct command *cmd, st if (!err) { if (!cfg.raw_binary) show_ibm_smart_log(&smart_log, - nvme_transport_handle_get_name(hdl)); + libnvme_transport_handle_get_name(hdl)); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } else if (err > 0) nvme_show_status(err); else - nvme_show_error("ibm additional smart log: %s\n", nvme_strerror(errno)); + nvme_show_error("ibm additional smart log: %s\n", libnvme_strerror(errno)); return err; } @@ -381,13 +381,13 @@ static int get_ibm_vpd_log(int argc, char **argv, struct command *cmd, struct pl if (!err) { if (!cfg.raw_binary) show_ibm_vpd_log(&vpd_log, - nvme_transport_handle_get_name(hdl)); + libnvme_transport_handle_get_name(hdl)); else d_raw((unsigned char *)&vpd_log, sizeof(vpd_log)); } else if (err > 0) nvme_show_status(err); else - nvme_show_error("ibm vpd log: %s\n", nvme_strerror(errno)); + nvme_show_error("ibm vpd log: %s\n", libnvme_strerror(errno)); return err; } @@ -590,7 +590,7 @@ static int get_ibm_persistent_event_log(int argc, char **argv, pevent_log_info, log_length); if (!err) { nvme_show_ibm_persistent_event_log(pevent_log_info, cfg.action, - log_length, nvme_transport_handle_get_name(hdl), + log_length, libnvme_transport_handle_get_name(hdl), flags); } diff --git a/plugins/innogrit/innogrit-nvme.c b/plugins/innogrit/innogrit-nvme.c index 2c130c4cd0..e39b8f0bfe 100644 --- a/plugins/innogrit/innogrit-nvme.c +++ b/plugins/innogrit/innogrit-nvme.c @@ -36,7 +36,7 @@ static int nvme_vucmd(struct nvme_transport_handle *hdl, unsigned char opcode, cmd.nsid = 0xffffffff; cmd.addr = (__u64)(__u64)(uintptr_t)data; cmd.data_len = data_len; - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } static int getlogpage(struct nvme_transport_handle *hdl, unsigned char ilogid, diff --git a/plugins/intel/intel-nvme.c b/plugins/intel/intel-nvme.c index 2d1d601b45..2cf4133678 100644 --- a/plugins/intel/intel-nvme.c +++ b/plugins/intel/intel-nvme.c @@ -377,10 +377,10 @@ static int get_additional_smart_log(int argc, char **argv, struct command *acmd, if (!err) { if (flags & JSON || cfg.json) show_intel_smart_log_jsn(&smart_log, cfg.namespace_id, - nvme_transport_handle_get_name(hdl)); + libnvme_transport_handle_get_name(hdl)); else if (!cfg.raw_binary) show_intel_smart_log(&smart_log, cfg.namespace_id, - nvme_transport_handle_get_name(hdl)); + libnvme_transport_handle_get_name(hdl)); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } else if (err > 0) { @@ -1234,7 +1234,7 @@ static int read_entire_cmd(struct nvme_passthru_cmd *cmd, int total_size, dword_tfer = min(max_tfer, total_size); while (total_size > 0) { - err = nvme_submit_admin_passthru(hdl, cmd); + err = libnvme_submit_admin_passthru(hdl, cmd); if (err) { fprintf(stderr, "failed on cmd.data_len %u cmd.cdw13 %u cmd.cdw12 %x cmd.cdw10 %u err %x remaining size %d\n", diff --git a/plugins/lm/lm-nvme.c b/plugins/lm/lm-nvme.c index 423cf2c9f9..3c3115a5ab 100644 --- a/plugins/lm/lm-nvme.c +++ b/plugins/lm/lm-nvme.c @@ -103,15 +103,15 @@ static int lm_create_cdq(int argc, char **argv, struct command *acmd, struct plu queue = nvme_alloc_huge(cfg.sz << 2, &mh); if (!queue) { nvme_show_error("ERROR: nvme_alloc of size %dB failed %s", cfg.sz << 2, - nvme_strerror(errno)); + libnvme_strerror(errno)); return -ENOMEM; } nvme_init_lm_cdq_create(&cmd, NVME_SET(cfg.qt, LM_QT), cfg.cntlid, cfg.sz, queue); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err < 0) - nvme_show_error("ERROR: nvme_lm_cdq() failed: %s", nvme_strerror(errno)); + nvme_show_error("ERROR: nvme_lm_cdq() failed: %s", libnvme_strerror(errno)); else if (err) nvme_show_status(err); else @@ -147,9 +147,9 @@ static int lm_delete_cdq(int argc, char **argv, struct command *acmd, struct plu return err; nvme_init_lm_cdq_delete(&cmd, 0, cfg.cdqid); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err < 0) - nvme_show_error("ERROR: nvme_lm_cdq() failed: %s", nvme_strerror(errno)); + nvme_show_error("ERROR: nvme_lm_cdq() failed: %s", libnvme_strerror(errno)); else if (err > 0) nvme_show_status(err); else @@ -230,9 +230,9 @@ static int lm_track_send(int argc, char **argv, struct command *acmd, struct plu } nvme_init_lm_track_send(&cmd, cfg.sel, cfg.mos, cfg.cdqid); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err < 0) - nvme_show_error("ERROR: nvme_lm_track_send() failed %s", nvme_strerror(errno)); + nvme_show_error("ERROR: nvme_lm_track_send() failed %s", libnvme_strerror(errno)); else if (err) nvme_show_status(err); else @@ -367,7 +367,7 @@ static int lm_migration_send(int argc, char **argv, struct command *acmd, struct fclose(file); if (n_data != (size_t)(cfg.numd << 2)) { - nvme_show_error("failed to read controller state data %s", nvme_strerror(errno)); + nvme_show_error("failed to read controller state data %s", libnvme_strerror(errno)); return -errno; } } @@ -377,9 +377,9 @@ static int lm_migration_send(int argc, char **argv, struct command *acmd, struct cfg.stype, cfg.dudmq, cfg.csvi, cfg.csuuidi, cfg.offset, cfg.uidx, data, (cfg.numd << 2)); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err < 0) - nvme_show_error("ERROR: nvme_lm_migration_send() failed %s", nvme_strerror(errno)); + nvme_show_error("ERROR: nvme_lm_migration_send() failed %s", libnvme_strerror(errno)); else if (err > 0) nvme_show_status(err); else @@ -486,9 +486,9 @@ static int lm_migration_recv(int argc, char **argv, struct command *acmd, struct nvme_init_lm_migration_recv(&cmd, cfg.offset, mos, cfg.cntlid, cfg.csuuidi, cfg.sel, cfg.uidx, 0, data, (cfg.numd + 1) << 2); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err < 0) - nvme_show_error("ERROR: nvme_lm_migration_recv() failed %s", nvme_strerror(errno)); + nvme_show_error("ERROR: nvme_lm_migration_recv() failed %s", libnvme_strerror(errno)); else if (err) nvme_show_status(err); else if (cfg.sel == NVME_LM_SEL_GET_CONTROLLER_STATE) { @@ -501,7 +501,7 @@ static int lm_migration_recv(int argc, char **argv, struct command *acmd, struct if (cfg.output && strlen(cfg.output)) { if (fwrite(data, 1, cfg.numd << 2, fd) != (cfg.numd << 2)) { nvme_show_error("ERROR: %s: failed to write buffer to output file", - nvme_strerror(errno)); + libnvme_strerror(errno)); err = -errno; } } else { @@ -555,7 +555,7 @@ static int lm_set_cdq(int argc, char **argv, struct command *acmd, struct plugin ((cfg.tpt >= 0) ? NVME_SET(1, LM_CTRL_DATA_QUEUE_ETPT) : 0), cfg.hp, cfg.tpt, 0, 0, NULL, 0, NULL); if (err < 0) - nvme_show_error("ERROR: nvme_set_features() failed %s", nvme_strerror(errno)); + nvme_show_error("ERROR: nvme_set_features() failed %s", libnvme_strerror(errno)); else if (err) nvme_show_status(err); else @@ -601,7 +601,7 @@ static int lm_get_cdq(int argc, char **argv, struct command *acmd, struct plugin err = nvme_get_features(hdl, 0, lm_cdq_feature_id, 0, cfg.cdqid, 0, &data, sizeof(data), NULL); if (err < 0) - nvme_show_error("ERROR: nvme_get_features() failed %s", nvme_strerror(errno)); + nvme_show_error("ERROR: nvme_get_features() failed %s", libnvme_strerror(errno)); else if (err) nvme_show_status(err); else diff --git a/plugins/memblaze/memblaze-nvme.c b/plugins/memblaze/memblaze-nvme.c index d1cd761912..e177f9df23 100644 --- a/plugins/memblaze/memblaze-nvme.c +++ b/plugins/memblaze/memblaze-nvme.c @@ -447,7 +447,7 @@ static int mb_get_additional_smart_log(int argc, char **argv, struct command *ac if (!err) { if (!cfg.raw_binary) err = show_memblaze_smart_log(hdl, cfg.namespace_id, - nvme_transport_handle_get_name(hdl), + libnvme_transport_handle_get_name(hdl), &smart_log); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); @@ -737,7 +737,7 @@ static int memblaze_fw_commit(struct nvme_transport_handle *hdl, int select) .cdw12 = select, }; - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } static int mb_selective_download(int argc, char **argv, struct command *acmd, struct plugin *plugin) @@ -841,7 +841,7 @@ static int mb_selective_download(int argc, char **argv, struct command *acmd, st perror("fw-download"); goto out_free; } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err < 0) { perror("fw-download"); goto out_free; @@ -1567,13 +1567,13 @@ static int mb_get_smart_log_add(int argc, char **argv, struct command *acmd, str err = nvme_get_log_simple(hdl, LID_SMART_LOG_ADD, &log, sizeof(struct smart_log_add)); if (!err) { if (!cfg.raw_binary) - smart_log_add_print(&log, nvme_transport_handle_get_name(hdl)); + smart_log_add_print(&log, libnvme_transport_handle_get_name(hdl)); else d_raw((unsigned char *)&log, sizeof(struct smart_log_add)); } else if (err > 0) { nvme_show_status(err); } else { - nvme_show_error("%s: %s", acmd->name, nvme_strerror(errno)); + nvme_show_error("%s: %s", acmd->name, libnvme_strerror(errno)); } return err; @@ -1738,7 +1738,7 @@ static int mb_set_latency_feature(int argc, char **argv, struct command *acmd, s else if (err > 0) nvme_show_status(err); else - nvme_show_error("%s: %s", acmd->name, nvme_strerror(errno)); + nvme_show_error("%s: %s", acmd->name, libnvme_strerror(errno)); return err; } @@ -1781,7 +1781,7 @@ static int mb_get_latency_feature(int argc, char **argv, struct command *acmd, s } else if (err > 0) { nvme_show_status(err); } else { - nvme_show_error("%s: %s", acmd->name, nvme_strerror(errno)); + nvme_show_error("%s: %s", acmd->name, libnvme_strerror(errno)); } return err; @@ -1918,13 +1918,13 @@ static int mb_get_latency_stats(int argc, char **argv, struct command *acmd, str err = nvme_get_log_simple(hdl, LID_LATENCY_STATISTICS, &log, sizeof(struct latency_stats)); if (!err) { if (!cfg.raw_binary) - latency_stats_print(&log, nvme_transport_handle_get_name(hdl)); + latency_stats_print(&log, libnvme_transport_handle_get_name(hdl)); else d_raw((unsigned char *)&log, sizeof(struct latency_stats)); } else if (err > 0) { nvme_show_status(err); } else { - nvme_show_error("%s: %s", acmd->name, nvme_strerror(errno)); + nvme_show_error("%s: %s", acmd->name, libnvme_strerror(errno)); } return err; @@ -2023,13 +2023,13 @@ static int mb_get_high_latency_log(int argc, char **argv, struct command *acmd, &log, sizeof(struct high_latency_log)); if (!err) { if (!cfg.raw_binary) - high_latency_log_print(&log, nvme_transport_handle_get_name(hdl)); + high_latency_log_print(&log, libnvme_transport_handle_get_name(hdl)); else d_raw((unsigned char *)&log, sizeof(struct high_latency_log)); } else if (err > 0) { nvme_show_status(err); } else { - nvme_show_error("%s: %s", acmd->name, nvme_strerror(errno)); + nvme_show_error("%s: %s", acmd->name, libnvme_strerror(errno)); } return err; @@ -2280,13 +2280,13 @@ static int mb_get_performance_stats(int argc, char **argv, struct command *acmd, err = nvme_get_log_simple(hdl, LID_PERFORMANCE_STATISTICS, &log, xfer_size); if (!err) { if (!cfg.raw_binary) - performance_stats_print(&log, nvme_transport_handle_get_name(hdl), cfg.duration); + performance_stats_print(&log, libnvme_transport_handle_get_name(hdl), cfg.duration); else d_raw((unsigned char *)&log, log_size); } else if (err > 0) { nvme_show_status(err); } else { - nvme_show_error("%s: %s", acmd->name, nvme_strerror(errno)); + nvme_show_error("%s: %s", acmd->name, libnvme_strerror(errno)); } return err; diff --git a/plugins/micron/micron-nvme.c b/plugins/micron/micron-nvme.c index 6a88c827f1..051621d0a6 100644 --- a/plugins/micron/micron-nvme.c +++ b/plugins/micron/micron-nvme.c @@ -472,7 +472,7 @@ static int NVMEGetLogPage(struct nvme_transport_handle *hdl, unsigned char ucLog cmd.addr = (__u64) (uintptr_t) pTempPtr; cmd.nsid = 0xFFFFFFFF; cmd.data_len = uiXferDwords * 4; - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); ullBytesRead += uiXferDwords * 4; if (ucLogID == 0x07 || ucLogID == 0x08 || ucLogID == 0xE9) pTempPtr = pBuffer + (ullBytesRead - offset); @@ -561,7 +561,7 @@ static int micron_fw_commit(struct nvme_transport_handle *hdl, int select) .cdw12 = select, }; - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } static int micron_selective_download(int argc, char **argv, @@ -662,7 +662,7 @@ static int micron_selective_download(int argc, char **argv, perror("fw-download"); goto out_free; } - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err < 0) { perror("fw-download"); goto out_free; @@ -969,7 +969,7 @@ static int micron_pcie_stats(int argc, char **argv, admin_cmd.addr = (__u64)(uintptr_t)&pcie_error_counters; admin_cmd.data_len = sizeof(pcie_error_counters); admin_cmd.cdw10 = 1; - err = nvme_submit_admin_passthru(hdl, &admin_cmd); + err = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (!err) { counters = true; correctable_errors = 10; @@ -1137,7 +1137,7 @@ static int micron_clear_pcie_correctable_errors(int argc, char **argv, admin_cmd.opcode = 0xD6; admin_cmd.addr = 0; admin_cmd.cdw10 = 0; - err = nvme_submit_admin_passthru(hdl, &admin_cmd); + err = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (!err) { printf("Device correctable error counters are cleared!\n"); goto out; @@ -2500,7 +2500,7 @@ static int micron_drive_info(int argc, char **argv, struct command *acmd, admin_cmd.addr = (__u64) (uintptr_t) &dinfo; admin_cmd.data_len = (__u32)sizeof(dinfo); admin_cmd.cdw12 = 3; - err = nvme_submit_admin_passthru(hdl, &admin_cmd); + err = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (err) { fprintf(stderr, "ERROR : drive-info opcode failed with 0x%x\n", err); return -1; @@ -4402,7 +4402,7 @@ static int micron_health_info(int argc, char **argv, struct command *acmd, err = nvme_get_log_smart(hdl, NVME_NSID_ALL, &smart_log); if (err) { fprintf(stderr, "Failed to get SMART log: %s\n", - nvme_strerror(err)); + libnvme_strerror(err)); return err; } @@ -4493,7 +4493,7 @@ static int micron_id_ctrl(int argc, char **argv, struct command *acmd, err = nvme_identify_ctrl(hdl, &ctrl); if (err) { fprintf(stderr, "identify controller failed: %s\n", - nvme_strerror(err)); + libnvme_strerror(err)); return err; } diff --git a/plugins/nbft/nbft-plugin.c b/plugins/nbft/nbft-plugin.c index d652d2044e..d30accabb2 100644 --- a/plugins/nbft/nbft-plugin.c +++ b/plugins/nbft/nbft-plugin.c @@ -151,7 +151,7 @@ static json_object *ssns_to_json(struct nbft_info_subsystem_ns *ss) case NBFT_INFO_NID_TYPE_NS_UUID: if (json_object_add_value_string(ss_json, "nid_type", "uuid")) goto fail; - nvme_uuid_to_string(ss->nid, json_str); + libnvme_uuid_to_string(ss->nid, json_str); break; default: @@ -559,7 +559,7 @@ int show_nbft(int argc, char **argv, struct command *acmd, struct plugin *plugin if (ret < 0) return ret; - ctx = nvme_create_global_ctx(stderr, log_level); + ctx = libnvme_create_global_ctx(stderr, log_level); if (!ctx) { nvme_show_error("Failed to create global context"); return -ENOMEM; diff --git a/plugins/netapp/netapp-nvme.c b/plugins/netapp/netapp-nvme.c index a8d1add9f7..c8c2369364 100644 --- a/plugins/netapp/netapp-nvme.c +++ b/plugins/netapp/netapp-nvme.c @@ -578,7 +578,7 @@ static void netapp_ontapdevices_print_verbose(struct ontapdevice_info *devices, &lba, &devices[i].ctrl, &devices[i].ns); ontap_get_subsysname(subnqn, subsysname, &devices[i].ctrl); - nvme_uuid_to_string(devices[i].uuid, uuid_str); + libnvme_uuid_to_string(devices[i].uuid, uuid_str); netapp_get_ontap_labels(vsname, nspath, devices[i].log_data); @@ -595,7 +595,7 @@ static void netapp_ontapdevices_print_verbose(struct ontapdevice_info *devices, &lba, &devices[i].ctrl, &devices[i].ns); ontap_get_subsysname(subnqn, subsysname, &devices[i].ctrl); - nvme_uuid_to_string(devices[i].uuid, uuid_str); + libnvme_uuid_to_string(devices[i].uuid, uuid_str); netapp_get_ontap_labels(vsname, nspath, devices[i].log_data); printf(formatstr, devices[i].dev, vsname, subsysname, @@ -639,7 +639,7 @@ static void netapp_ontapdevices_print_regular(struct ontapdevice_info *devices, if (devname && !strcmp(devname, basename(devices[i].dev))) { /* found the device, fetch and print for that alone */ netapp_get_ns_size(size, &lba, &devices[i].ns); - nvme_uuid_to_string(devices[i].uuid, uuid_str); + libnvme_uuid_to_string(devices[i].uuid, uuid_str); netapp_get_ontap_labels(vsname, nspath, devices[i].log_data); ontap_get_subsysname(subnqn, subsysname, @@ -654,7 +654,7 @@ static void netapp_ontapdevices_print_regular(struct ontapdevice_info *devices, for (i = 0; i < count; i++) { /* fetch info and print for all devices */ netapp_get_ns_size(size, &lba, &devices[i].ns); - nvme_uuid_to_string(devices[i].uuid, uuid_str); + libnvme_uuid_to_string(devices[i].uuid, uuid_str); netapp_get_ontap_labels(vsname, nspath, devices[i].log_data); ontap_get_subsysname(subnqn, subsysname, &devices[i].ctrl); @@ -688,7 +688,7 @@ static void netapp_ontapdevices_print_json(struct ontapdevice_info *devices, &lba, &devices[i].ctrl, &devices[i].ns); ontap_get_subsysname(subnqn, subsysname, &devices[i].ctrl); - nvme_uuid_to_string(devices[i].uuid, uuid_str); + libnvme_uuid_to_string(devices[i].uuid, uuid_str); netapp_get_ontap_labels(vsname, nspath, devices[i].log_data); @@ -707,7 +707,7 @@ static void netapp_ontapdevices_print_json(struct ontapdevice_info *devices, &lba, &devices[i].ctrl, &devices[i].ns); ontap_get_subsysname(subnqn, subsysname, &devices[i].ctrl); - nvme_uuid_to_string(devices[i].uuid, uuid_str); + libnvme_uuid_to_string(devices[i].uuid, uuid_str); netapp_get_ontap_labels(vsname, nspath, devices[i].log_data); netapp_ontapdevice_json(json_devices, devices[i].dev, @@ -746,7 +746,7 @@ static int nvme_get_ontap_c2_log(struct nvme_transport_handle *hdl, __u32 nsid, get_log.cdw10 |= ONTAP_C2_LOG_NSINFO_LSP << 8; get_log.cdw11 = numdu; - err = nvme_submit_admin_passthru(hdl, &get_log); + err = libnvme_submit_admin_passthru(hdl, &get_log); if (err) { fprintf(stderr, "ioctl error %0x\n", err); return 1; @@ -765,15 +765,15 @@ static int netapp_smdevices_get_info(struct nvme_transport_handle *hdl, if (err) { fprintf(stderr, "Identify Controller failed to %s (%s)\n", dev, - err < 0 ? nvme_strerror(-err) : - nvme_status_to_string(err, false)); + err < 0 ? libnvme_strerror(-err) : + libnvme_status_to_string(err, false)); return 0; } if (strncmp("NetApp E-Series", item->ctrl.mn, 15) != 0) return 0; /* not the right model of controller */ - err = nvme_get_nsid(hdl, &item->nsid); + err = libnvme_get_nsid(hdl, &item->nsid); if (err) return err; @@ -781,8 +781,8 @@ static int netapp_smdevices_get_info(struct nvme_transport_handle *hdl, if (err) { fprintf(stderr, "Unable to identify namespace for %s (%s)\n", - dev, err < 0 ? nvme_strerror(-err) : - nvme_status_to_string(err, false)); + dev, err < 0 ? libnvme_strerror(-err) : + libnvme_status_to_string(err, false)); return 0; } strncpy(item->dev, dev, sizeof(item->dev) - 1); @@ -800,8 +800,8 @@ static int netapp_ontapdevices_get_info(struct nvme_transport_handle *hdl, err = nvme_identify_ctrl(hdl, &item->ctrl); if (err) { fprintf(stderr, "Identify Controller failed to %s (%s)\n", - dev, err < 0 ? nvme_strerror(-err) : - nvme_status_to_string(err, false)); + dev, err < 0 ? libnvme_strerror(-err) : + libnvme_status_to_string(err, false)); return 0; } @@ -809,13 +809,13 @@ static int netapp_ontapdevices_get_info(struct nvme_transport_handle *hdl, /* not the right controller model */ return 0; - err = nvme_get_nsid(hdl, &item->nsid); + err = libnvme_get_nsid(hdl, &item->nsid); err = nvme_identify_ns(hdl, item->nsid, &item->ns); if (err) { fprintf(stderr, "Unable to identify namespace for %s (%s)\n", - dev, err < 0 ? nvme_strerror(-err) : - nvme_status_to_string(err, false)); + dev, err < 0 ? libnvme_strerror(-err) : + libnvme_status_to_string(err, false)); return 0; } @@ -829,8 +829,8 @@ static int netapp_ontapdevices_get_info(struct nvme_transport_handle *hdl, err = nvme_identify_ns_descs_list(hdl, item->nsid, nsdescs); if (err) { fprintf(stderr, "Unable to identify namespace descriptor for %s (%s)\n", - dev, err < 0 ? nvme_strerror(-err) : - nvme_status_to_string(err, false)); + dev, err < 0 ? libnvme_strerror(-err) : + libnvme_status_to_string(err, false)); free(nsdescs); return 0; } @@ -841,8 +841,8 @@ static int netapp_ontapdevices_get_info(struct nvme_transport_handle *hdl, err = nvme_get_ontap_c2_log(hdl, item->nsid, item->log_data, ONTAP_C2_LOG_SIZE); if (err) { fprintf(stderr, "Unable to get log page data for %s (%s)\n", - dev, err < 0 ? nvme_strerror(-err) : - nvme_status_to_string(err, false)); + dev, err < 0 ? libnvme_strerror(-err) : + libnvme_status_to_string(err, false)); return 0; } @@ -893,7 +893,7 @@ static int netapp_smdevices(int argc, char **argv, struct command *acmd, struct plugin *plugin) { const char *desc = "Display information about E-Series volumes."; - _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); struct dirent **devices; int num, i, ret, fmt; struct smdevice_info *smdevices; @@ -953,16 +953,16 @@ static int netapp_smdevices(int argc, char **argv, struct command *acmd, for (i = 0; i < num; i++) { snprintf(path, sizeof(path), "%s%s", dev_path, devices[i]->d_name); - ret = nvme_open(ctx, path, &hdl); + ret = libnvme_open(ctx, path, &hdl); if (ret) { fprintf(stderr, "Unable to open %s: %s\n", path, - nvme_strerror(-ret)); + libnvme_strerror(-ret)); continue; } num_smdevices += netapp_smdevices_get_info(hdl, &smdevices[num_smdevices], path); - nvme_close(hdl); + libnvme_close(hdl); } if (num_smdevices) { @@ -991,7 +991,7 @@ static int netapp_smdevices(int argc, char **argv, struct command *acmd, static int netapp_ontapdevices(int argc, char **argv, struct command *acmd, struct plugin *plugin) { - _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); const char *desc = "Display information about ONTAP devices."; struct dirent **devices; int num, i, ret, fmt; @@ -1052,17 +1052,17 @@ static int netapp_ontapdevices(int argc, char **argv, struct command *acmd, for (i = 0; i < num; i++) { snprintf(path, sizeof(path), "%s%s", dev_path, devices[i]->d_name); - ret = nvme_open(ctx, path, &hdl); + ret = libnvme_open(ctx, path, &hdl); if (ret) { fprintf(stderr, "Unable to open %s: %s\n", path, - nvme_strerror(-ret)); + libnvme_strerror(-ret)); continue; } num_ontapdevices += netapp_ontapdevices_get_info(hdl, &ontapdevices[num_ontapdevices], path); - nvme_close(hdl); + libnvme_close(hdl); } if (num_ontapdevices) { diff --git a/plugins/ocp/ocp-hardware-component-log.c b/plugins/ocp/ocp-hardware-component-log.c index 861ba8940d..a49f3c1711 100644 --- a/plugins/ocp/ocp-hardware-component-log.c +++ b/plugins/ocp/ocp-hardware-component-log.c @@ -217,7 +217,7 @@ static int get_hwcomp_log_data(struct nvme_transport_handle *hdl, struct hwcomp_ log->desc = calloc(1, len); if (!log->desc) { - fprintf(stderr, "error: ocp: calloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "error: ocp: calloc: %s\n", libnvme_strerror(errno)); return -errno; } diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c index 280188558b..7cf08b3d36 100644 --- a/plugins/ocp/ocp-nvme.c +++ b/plugins/ocp/ocp-nvme.c @@ -214,7 +214,7 @@ static int get_c3_log_page(struct nvme_transport_handle *hdl, char *format) data = malloc(sizeof(__u8) * C3_LATENCY_MON_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR : OCP : malloc : %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR : OCP : malloc : %s\n", libnvme_strerror(errno)); return -1; } memset(data, 0, sizeof(__u8) * C3_LATENCY_MON_LOG_BUF_LEN); @@ -222,7 +222,7 @@ static int get_c3_log_page(struct nvme_transport_handle *hdl, char *format) ret = ocp_get_log_simple(hdl, OCP_LID_LMLOG, C3_LATENCY_MON_LOG_BUF_LEN, data); if (strcmp(format, "json")) - fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret, false), ret); + fprintf(stderr, "NVMe Status:%s(%x)\n", libnvme_status_to_string(ret, false), ret); if (!ret) { log_data = (struct ssd_latency_monitor_log *)data; @@ -348,12 +348,12 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *acmd, if (err) return err; - err = fstat(nvme_transport_handle_get_fd(hdl), &nvme_stat); + err = fstat(libnvme_transport_handle_get_fd(hdl), &nvme_stat); if (err < 0) return err; if (S_ISBLK(nvme_stat.st_mode)) { - err = nvme_get_nsid(hdl, &nsid); + err = libnvme_get_nsid(hdl, &nsid); if (err < 0) { perror("invalid-namespace-id"); return err; @@ -394,7 +394,7 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *acmd, printf("discard debug log: 0x%x\n", buf.discard_debug_log); printf("latency monitor feature enable: 0x%x\n", buf.latency_monitor_feature_enable); } else if (err > 0) { - fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err, false), err); + fprintf(stderr, "NVMe Status:%s(%x)\n", libnvme_status_to_string(err, false), err); } return err; @@ -675,7 +675,7 @@ static int get_telemetry_data(struct nvme_transport_handle *hdl, __u32 ns, __u8 cmd.cdw12 = (__u32)(0x00000000FFFFFFFF & offset); cmd.cdw13 = (__u32)((0xFFFFFFFF00000000 & offset) >> 8); cmd.cdw14 = 0; - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } static void print_telemetry_data_area_1(struct telemetry_data_area_1 *da1, @@ -1186,7 +1186,7 @@ static int get_telemetry_log_page_data(struct nvme_transport_handle *hdl, telemetry_log = malloc(bs); if (!hdr || !telemetry_log) { fprintf(stderr, "Failed to allocate %zu bytes for log: %s\n", - bs, nvme_strerror(errno)); + bs, libnvme_strerror(errno)); err = -ENOMEM; goto exit_status; } @@ -1195,7 +1195,7 @@ static int get_telemetry_log_page_data(struct nvme_transport_handle *hdl, fd = open(output_file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (fd < 0) { fprintf(stderr, "Failed to open output file %s: %s!\n", - output_file, nvme_strerror(errno)); + output_file, libnvme_strerror(errno)); err = fd; goto exit_status; } @@ -1284,7 +1284,7 @@ static int get_c9_log_page_data(struct nvme_transport_handle *hdl, header_data = (__u8 *)malloc(sizeof(__u8) * C9_TELEMETRY_STR_LOG_LEN); if (!header_data) { - fprintf(stderr, "ERROR : OCP : malloc : %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR : OCP : malloc : %s\n", libnvme_strerror(errno)); return -1; } memset(header_data, 0, sizeof(__u8) * C9_TELEMETRY_STR_LOG_LEN); @@ -1326,7 +1326,7 @@ static int get_c9_log_page_data(struct nvme_transport_handle *hdl, pC9_string_buffer = (__u8 *)malloc(sizeof(__u8) * total_log_page_sz); if (!pC9_string_buffer) { - fprintf(stderr, "ERROR : OCP : malloc : %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR : OCP : malloc : %s\n", libnvme_strerror(errno)); return -1; } memset(pC9_string_buffer, 0, sizeof(__u8) * total_log_page_sz); @@ -1341,7 +1341,7 @@ static int get_c9_log_page_data(struct nvme_transport_handle *hdl, fd = open(output_file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (fd < 0) { fprintf(stderr, "Failed to open output file %s: %s!\n", output_file, - nvme_strerror(errno)); + libnvme_strerror(errno)); ret = fd; goto free; } @@ -1461,12 +1461,12 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *acmd, struct if (opt.telemetry_type == 0) opt.telemetry_type = "host"; - err = fstat(nvme_transport_handle_get_fd(hdl), &nvme_stat); + err = fstat(libnvme_transport_handle_get_fd(hdl), &nvme_stat); if (err < 0) return err; if (S_ISBLK(nvme_stat.st_mode)) { - err = nvme_get_nsid(hdl, &nsid); + err = libnvme_get_nsid(hdl, &nsid); if (err < 0) return err; } @@ -1595,7 +1595,7 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *acmd, struct err = get_telemetry_dump(hdl, opt.output_file, sn, tele_type, tele_area, true); if (err) - fprintf(stderr, "NVMe Status: %s(%x)\n", nvme_status_to_string(err, false), + fprintf(stderr, "NVMe Status: %s(%x)\n", libnvme_status_to_string(err, false), err); break; } @@ -1642,7 +1642,7 @@ static int get_c5_log_page(struct nvme_transport_handle *hdl, char *format) data = (__u8 *)malloc(sizeof(__u8) * C5_UNSUPPORTED_REQS_LEN); if (!data) { - fprintf(stderr, "ERROR : OCP : malloc : %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR : OCP : malloc : %s\n", libnvme_strerror(errno)); return -1; } memset(data, 0, sizeof(__u8) * C5_UNSUPPORTED_REQS_LEN); @@ -1743,7 +1743,7 @@ static int get_c1_log_page(struct nvme_transport_handle *hdl, char *format) data = (__u8 *)malloc(sizeof(__u8) * C1_ERROR_RECOVERY_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR : OCP : malloc : %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR : OCP : malloc : %s\n", libnvme_strerror(errno)); return -1; } memset(data, 0, sizeof(__u8) * C1_ERROR_RECOVERY_LOG_BUF_LEN); @@ -1843,7 +1843,7 @@ static int get_c4_log_page(struct nvme_transport_handle *hdl, char *format) data = (__u8 *)malloc(sizeof(__u8) * C4_DEV_CAP_REQ_LEN); if (!data) { - fprintf(stderr, "ERROR : OCP : malloc : %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR : OCP : malloc : %s\n", libnvme_strerror(errno)); return -1; } memset(data, 0, sizeof(__u8) * C4_DEV_CAP_REQ_LEN); @@ -2524,7 +2524,7 @@ static int get_c7_log_page(struct nvme_transport_handle *hdl, char *format) data = (__u8 *)malloc(sizeof(__u8) * C7_TCG_CONFIGURATION_LEN); if (!data) { - fprintf(stderr, "ERROR : OCP : malloc : %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR : OCP : malloc : %s\n", libnvme_strerror(errno)); return -1; } memset(data, 0, sizeof(__u8) * C7_TCG_CONFIGURATION_LEN); @@ -2651,7 +2651,7 @@ static int error_injection_get(struct nvme_transport_handle *hdl, const __u8 sel entry = nvme_alloc(data_len); if (!entry) { - nvme_show_error("malloc: %s", nvme_strerror(errno)); + nvme_show_error("malloc: %s", libnvme_strerror(errno)); return -ENOMEM; } @@ -2730,20 +2730,20 @@ static int error_injection_set(struct nvme_transport_handle *hdl, struct erri_co data_len = cfg->number * sizeof(struct erri_entry); entry = nvme_alloc(data_len); if (!entry) { - nvme_show_error("malloc: %s", nvme_strerror(errno)); + nvme_show_error("malloc: %s", libnvme_strerror(errno)); return -ENOMEM; } if (cfg->file && strlen(cfg->file)) { ffd = open(cfg->file, O_RDONLY); if (ffd < 0) { - nvme_show_error("Failed to open file %s: %s", cfg->file, nvme_strerror(errno)); + nvme_show_error("Failed to open file %s: %s", cfg->file, libnvme_strerror(errno)); return -EINVAL; } err = read(ffd, entry, data_len); if (err < 0) { nvme_show_error("failed to read data buffer from input file: %s", - nvme_strerror(errno)); + libnvme_strerror(errno)); return -errno; } } else { @@ -2757,7 +2757,7 @@ static int error_injection_set(struct nvme_transport_handle *hdl, struct erri_co 0, 0, 0, 0, entry, data_len, NULL); if (err) { if (err < 0) - nvme_show_error("set-error-injection: %s", nvme_strerror(errno)); + nvme_show_error("set-error-injection: %s", libnvme_strerror(errno)); else if (err > 0) nvme_show_status(err); return err; @@ -2982,7 +2982,7 @@ static int ocp_get_persistent_event_log(int argc, char **argv, err = nvme_get_log_persistent_event(hdl, cfg.action, pevent, sizeof(*pevent)); if (err < 0) { - nvme_show_error("persistent event log: %s", nvme_strerror(err)); + nvme_show_error("persistent event log: %s", libnvme_strerror(err)); return err; } else if (err) { nvme_show_status(err); @@ -3024,7 +3024,7 @@ static int ocp_get_persistent_event_log(int argc, char **argv, pevent, sizeof(*pevent)); if (err < 0) { - nvme_show_error("persistent event log: %s", nvme_strerror(err)); + nvme_show_error("persistent event log: %s", libnvme_strerror(err)); return err; } else if (err) { nvme_show_status(err); @@ -3038,11 +3038,11 @@ static int ocp_get_persistent_event_log(int argc, char **argv, } ocp_show_persistent_event_log(pevent_log_info, cfg.action, - cfg.log_len, nvme_transport_handle_get_name(hdl), flags); + cfg.log_len, libnvme_transport_handle_get_name(hdl), flags); } else if (err > 0) { nvme_show_status(err); } else { - nvme_show_error("persistent event log: %s", nvme_strerror(err)); + nvme_show_error("persistent event log: %s", libnvme_strerror(err)); } return err; diff --git a/plugins/ocp/ocp-print-stdout.c b/plugins/ocp/ocp-print-stdout.c index 8110f17670..118f4866d6 100644 --- a/plugins/ocp/ocp-print-stdout.c +++ b/plugins/ocp/ocp-print-stdout.c @@ -267,7 +267,7 @@ static void stdout_c3_log(struct nvme_transport_handle *hdl, struct ssd_latency_ printf("-Latency Monitor/C3 Log Page Data-\n"); printf(" Controller : %s\n", - nvme_transport_handle_get_name(hdl)); + libnvme_transport_handle_get_name(hdl)); printf(" Feature Status 0x%x\n", log_data->feature_status); printf(" Active Bucket Timer %d min\n", diff --git a/plugins/ocp/ocp-smart-extended-log.c b/plugins/ocp/ocp-smart-extended-log.c index 0c9c28cac3..90bf17fcb4 100644 --- a/plugins/ocp/ocp-smart-extended-log.c +++ b/plugins/ocp/ocp-smart-extended-log.c @@ -44,7 +44,7 @@ static int get_c0_log_page(struct nvme_transport_handle *hdl, char *format, data = malloc(sizeof(__u8) * C0_SMART_CLOUD_ATTR_LEN); if (!data) { - fprintf(stderr, "ERROR : OCP : malloc : %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR : OCP : malloc : %s\n", libnvme_strerror(errno)); return -1; } memset(data, 0, sizeof(__u8) * C0_SMART_CLOUD_ATTR_LEN); @@ -60,7 +60,7 @@ static int get_c0_log_page(struct nvme_transport_handle *hdl, char *format, if (strcmp(format, "json")) fprintf(stderr, "NVMe Status:%s(%x)\n", - nvme_status_to_string(ret, false), ret); + libnvme_status_to_string(ret, false), ret); if (ret == 0) { /* check log page guid */ diff --git a/plugins/ocp/ocp-utils.c b/plugins/ocp/ocp-utils.c index 966a3e9b62..6e5e3bb05c 100644 --- a/plugins/ocp/ocp-utils.c +++ b/plugins/ocp/ocp-utils.c @@ -20,7 +20,7 @@ const unsigned char ocp_uuid[NVME_UUID_LEN] = { int ocp_find_uuid_index(struct nvme_id_uuid_list *uuid_list, __u8 *index) { - int i = nvme_find_uuid(uuid_list, ocp_uuid); + int i = libnvme_find_uuid(uuid_list, ocp_uuid); *index = 0; if (i > 0) diff --git a/plugins/sandisk/sandisk-nvme.c b/plugins/sandisk/sandisk-nvme.c index 2e1b5e96ae..a75bf24489 100644 --- a/plugins/sandisk/sandisk-nvme.c +++ b/plugins/sandisk/sandisk-nvme.c @@ -62,7 +62,7 @@ static int sndk_do_cap_telemetry_log(struct nvme_global_ctx *ctx, return -EINVAL; } - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err) return err; capabilities = sndk_get_drive_capabilities(ctx, hdl); @@ -110,7 +110,7 @@ static int sndk_do_cap_telemetry_log(struct nvme_global_ctx *ctx, output = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (output < 0) { fprintf(stderr, "%s: Failed to open output file %s: %s!\n", - __func__, file, nvme_strerror(errno)); + __func__, file, libnvme_strerror(errno)); return output; } @@ -160,7 +160,7 @@ static int sndk_do_cap_telemetry_log(struct nvme_global_ctx *ctx, } if (fsync(output) < 0) { - fprintf(stderr, "ERROR: %s: fsync: %s\n", __func__, nvme_strerror(errno)); + fprintf(stderr, "ERROR: %s: fsync: %s\n", __func__, libnvme_strerror(errno)); err = -1; } @@ -267,7 +267,7 @@ static __u32 sndk_dump_udui_data(struct nvme_transport_handle *hdl, admin_cmd.data_len = dataLen; admin_cmd.cdw10 = ((dataLen >> 2) - 1); admin_cmd.cdw12 = offset; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { fprintf(stderr, "ERROR: SNDK: reading DUI data failed\n"); nvme_show_status(ret); @@ -292,7 +292,7 @@ static int sndk_do_cap_udui(struct nvme_transport_handle *hdl, char *file, if (!log) { fprintf(stderr, "%s: ERROR: log header malloc failed : status %s, size 0x%x\n", - __func__, nvme_strerror(errno), udui_log_hdr_size); + __func__, libnvme_strerror(errno), udui_log_hdr_size); return -1; } memset(log, 0, udui_log_hdr_size); @@ -312,7 +312,7 @@ static int sndk_do_cap_udui(struct nvme_transport_handle *hdl, char *file, output = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (output < 0) { fprintf(stderr, "%s: Failed to open output file %s: %s!\n", __func__, file, - nvme_strerror(errno)); + libnvme_strerror(errno)); goto out; } @@ -441,7 +441,7 @@ static int sndk_vs_internal_fw_log(int argc, char **argv, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !sndk_check_device(ctx, hdl)) goto out; @@ -460,7 +460,7 @@ static int sndk_vs_internal_fw_log(int argc, char **argv, /* verify file name and path is valid before getting dump data */ verify_file = open(cfg.file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (verify_file < 0) { - fprintf(stderr, "ERROR: SNDK: open: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: SNDK: open: %s\n", libnvme_strerror(errno)); goto out; } close(verify_file); @@ -631,7 +631,7 @@ static int sndk_do_sn861_drive_resize(struct nvme_transport_handle *hdl, admin_cmd.addr = (__u64)(uintptr_t)buffer; admin_cmd.data_len = SNDK_NVME_SN861_DRIVE_RESIZE_BUFFER_SIZE; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (result) *result = admin_cmd.result; return ret; @@ -665,7 +665,7 @@ static int sndk_drive_resize(int argc, char **argv, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; sndk_check_device(ctx, hdl); @@ -941,7 +941,7 @@ static int sndk_get_fw_act_history_C2(struct nvme_global_ctx *ctx, struct nvme_t data = (__u8 *)malloc(sizeof(__u8) * SNDK_FW_ACT_HISTORY_C2_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: SNDK: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: SNDK: malloc: %s\n", libnvme_strerror(errno)); return -1; } @@ -1013,7 +1013,7 @@ static int sndk_vs_fw_activate_history(int argc, char **argv, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; capabilities = sndk_get_drive_capabilities(ctx, hdl); @@ -1061,7 +1061,7 @@ static int sndk_clear_fw_activate_history(int argc, char **argv, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; capabilities = sndk_get_drive_capabilities(ctx, hdl); @@ -1132,14 +1132,14 @@ static int sndk_capabilities(int argc, char **argv, return ret; /* get capabilities */ - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !sndk_check_device(ctx, hdl)) return -1; capabilities = sndk_get_drive_capabilities(ctx, hdl); /* print command and supported status */ - printf("Sandisk Plugin Capabilities for NVME device:%s\n", nvme_transport_handle_get_name(hdl)); + printf("Sandisk Plugin Capabilities for NVME device:%s\n", libnvme_transport_handle_get_name(hdl)); printf("vs-internal-log : %s\n", capabilities & SNDK_DRIVE_CAP_INTERNAL_LOG_MASK ? "Supported" : "Not Supported"); printf("vs-nand-stats : %s\n", diff --git a/plugins/sandisk/sandisk-utils.c b/plugins/sandisk/sandisk-utils.c index 8b41ade6ca..c799a1674f 100644 --- a/plugins/sandisk/sandisk-utils.c +++ b/plugins/sandisk/sandisk-utils.c @@ -44,31 +44,31 @@ int sndk_get_pci_ids(struct nvme_global_ctx *ctx, struct nvme_transport_handle * uint32_t *device_id, uint32_t *vendor_id) { char vid[256], did[256], id[32]; - nvme_ctrl_t c = NULL; - nvme_ns_t n = NULL; + libnvme_ctrl_t c = NULL; + libnvme_ns_t n = NULL; const char *name; int fd, ret; - name = nvme_transport_handle_get_name(hdl); - ret = nvme_scan_ctrl(ctx, name, &c); + name = libnvme_transport_handle_get_name(hdl); + ret = libnvme_scan_ctrl(ctx, name, &c); if (!ret) { snprintf(vid, sizeof(vid), "%s/device/vendor", - nvme_ctrl_get_sysfs_dir(c)); + libnvme_ctrl_get_sysfs_dir(c)); snprintf(did, sizeof(did), "%s/device/device", - nvme_ctrl_get_sysfs_dir(c)); - nvme_free_ctrl(c); + libnvme_ctrl_get_sysfs_dir(c)); + libnvme_free_ctrl(c); } else { - ret = nvme_scan_namespace(ctx, name, &n); + ret = libnvme_scan_namespace(ctx, name, &n); if (!ret) { fprintf(stderr, "Unable to find %s\n", name); return ret; } snprintf(vid, sizeof(vid), "%s/device/device/vendor", - nvme_ns_get_sysfs_dir(n)); + libnvme_ns_get_sysfs_dir(n)); snprintf(did, sizeof(did), "%s/device/device/device", - nvme_ns_get_sysfs_dir(n)); - nvme_free_ns(n); + libnvme_ns_get_sysfs_dir(n)); + libnvme_free_ns(n); } fd = open(vid, O_RDONLY); @@ -337,16 +337,16 @@ bool sndk_get_dev_mgment_data(struct nvme_global_ctx *ctx, struct nvme_transport memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list)); if (!nvme_get_uuid_list(hdl, &uuid_list)) { /* check for the Sandisk UUID first */ - uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) { /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, WDC_UUID); if (uuid_index < 0) /* Check for the UUID used on SN640 and SN655 drives */ - uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID_SN640_3); + uuid_index = libnvme_find_uuid(&uuid_list, WDC_UUID_SN640_3); } if (uuid_index >= 0) @@ -452,7 +452,7 @@ bool sndk_get_dev_mgmt_log_page_data(struct nvme_transport_handle *hdl, data = (__u8 *)malloc(sizeof(__u8) * SNDK_DEV_MGMNT_LOG_PAGE_LEN); if (!data) { - fprintf(stderr, "ERROR: SNDK: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: SNDK: malloc: %s\n", libnvme_strerror(errno)); return false; } @@ -481,7 +481,7 @@ bool sndk_get_dev_mgmt_log_page_data(struct nvme_transport_handle *hdl, free(data); data = calloc(length, sizeof(__u8)); if (!data) { - fprintf(stderr, "ERROR: SNDK: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: SNDK: malloc: %s\n", libnvme_strerror(errno)); goto end; } @@ -506,7 +506,7 @@ bool sndk_get_dev_mgmt_log_page_data(struct nvme_transport_handle *hdl, /* Ensure size of log data matches length in log header */ *log_data = calloc(length, sizeof(__u8)); if (!*log_data) { - fprintf(stderr, "ERROR: SNDK: calloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: SNDK: calloc: %s\n", libnvme_strerror(errno)); valid = false; goto end; } @@ -684,16 +684,16 @@ __u64 sndk_get_enc_drive_capabilities(struct nvme_global_ctx *ctx, memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list)); if (!nvme_get_uuid_list(hdl, &uuid_list)) { /* check for the Sandisk UUID first */ - uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) { /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, WDC_UUID); if (uuid_index < 0) /* Check for the UUID used on SN640 and SN655 drives */ - uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID_SN640_3); + uuid_index = libnvme_find_uuid(&uuid_list, WDC_UUID_SN640_3); } } else { /* UUID Lists not supported, Use default uuid index - 0 */ diff --git a/plugins/scaleflux/sfx-nvme.c b/plugins/scaleflux/sfx-nvme.c index 6de7e36c79..8fd118e1cb 100644 --- a/plugins/scaleflux/sfx-nvme.c +++ b/plugins/scaleflux/sfx-nvme.c @@ -58,8 +58,8 @@ int nvme_query_cap(struct nvme_transport_handle *hdl, __u32 nsid, __u32 data_len .data_len = data_len, }; - rc = ioctl(nvme_transport_handle_get_fd(hdl), SFX_GET_FREESPACE, data); - return rc ? nvme_submit_admin_passthru(hdl, &cmd) : 0; + rc = ioctl(libnvme_transport_handle_get_fd(hdl), SFX_GET_FREESPACE, data); + return rc ? libnvme_submit_admin_passthru(hdl, &cmd) : 0; } int nvme_change_cap(struct nvme_transport_handle *hdl, __u32 nsid, __u64 capacity) @@ -71,7 +71,7 @@ int nvme_change_cap(struct nvme_transport_handle *hdl, __u32 nsid, __u64 capacit .cdw11 = (capacity >> 32), }; - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } int nvme_sfx_set_features(struct nvme_transport_handle *hdl, __u32 nsid, __u32 fid, __u32 value) @@ -83,7 +83,7 @@ int nvme_sfx_set_features(struct nvme_transport_handle *hdl, __u32 nsid, __u32 f .cdw11 = value, }; - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } int nvme_sfx_get_features(struct nvme_transport_handle *hdl, __u32 nsid, __u32 fid, __u32 *result) @@ -95,7 +95,7 @@ int nvme_sfx_get_features(struct nvme_transport_handle *hdl, __u32 nsid, __u32 f .cdw10 = fid, }; - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err && result) *result = cmd.result; @@ -370,10 +370,10 @@ static int get_additional_smart_log(int argc, char **argv, struct command *acmd, if (!err) { if (flags & JSON || cfg.json) show_sfx_smart_log_jsn(&smart_log, cfg.namespace_id, - nvme_transport_handle_get_name(hdl)); + libnvme_transport_handle_get_name(hdl)); else if (!cfg.raw_binary) show_sfx_smart_log(&smart_log, cfg.namespace_id, - nvme_transport_handle_get_name(hdl)); + libnvme_transport_handle_get_name(hdl)); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } else if (err > 0) { @@ -565,7 +565,7 @@ int sfx_nvme_get_log(struct nvme_transport_handle *hdl, __u32 nsid, __u8 log_id, cmd.cdw10 = log_id | (numdl << 16); cmd.cdw11 = numdu; - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } /** @@ -579,7 +579,7 @@ int sfx_nvme_get_log(struct nvme_transport_handle *hdl, __u32 nsid, __u8 log_id, */ static int get_bb_table(struct nvme_transport_handle *hdl, __u32 nsid, unsigned char *buf, __u64 size) { - if (nvme_transport_handle_get_fd(hdl) < 0 || !buf || size != 256*4096*sizeof(unsigned char)) { + if (libnvme_transport_handle_get_fd(hdl) < 0 || !buf || size != 256*4096*sizeof(unsigned char)) { fprintf(stderr, "Invalid Param \r\n"); return -EINVAL; } @@ -873,7 +873,7 @@ static int change_cap(int argc, char **argv, struct command *acmd, struct plugin nvme_show_status(err); } else { printf("ScaleFlux change-capacity: success\n"); - ioctl(nvme_transport_handle_get_fd(hdl), BLKRRPART); + ioctl(libnvme_transport_handle_get_fd(hdl), BLKRRPART); } return err; } @@ -881,7 +881,7 @@ static int change_cap(int argc, char **argv, struct command *acmd, struct plugin static int sfx_verify_chr(struct nvme_transport_handle *hdl) { static struct stat nvme_stat; - int err = fstat(nvme_transport_handle_get_fd(hdl), &nvme_stat); + int err = fstat(libnvme_transport_handle_get_fd(hdl), &nvme_stat); if (err < 0) { perror("fstat"); @@ -902,7 +902,7 @@ static int sfx_clean_card(struct nvme_transport_handle *hdl) ret = sfx_verify_chr(hdl); if (ret) return ret; - ret = ioctl(nvme_transport_handle_get_fd(hdl), NVME_IOCTL_CLR_CARD); + ret = ioctl(libnvme_transport_handle_get_fd(hdl), NVME_IOCTL_CLR_CARD); if (ret) perror("Ioctl Fail."); else @@ -1417,12 +1417,12 @@ static int nvme_expand_cap(struct nvme_transport_handle *hdl, __u32 namespace_id __u8 reserve1[5]; } __packed; - if (nvme_transport_handle_is_chardev(hdl)) - snprintf(dev_name, 32, "%sn%u", nvme_transport_handle_get_name(hdl), namespace_id); + if (libnvme_transport_handle_is_chardev(hdl)) + snprintf(dev_name, 32, "%sn%u", libnvme_transport_handle_get_name(hdl), namespace_id); else - strcpy(dev_name, nvme_transport_handle_get_name(hdl)); + strcpy(dev_name, libnvme_transport_handle_get_name(hdl)); - num = scandir("/dev", &devices, nvme_filter_namespace, alphasort); + num = scandir("/dev", &devices, libnvme_filter_namespace, alphasort); if (num <= 0) { err = num; goto ret; @@ -1453,7 +1453,7 @@ static int nvme_expand_cap(struct nvme_transport_handle *hdl, __u32 namespace_id .cdw10 = 0x0e, }; - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (err) { fprintf(stderr, "Create ns failed\n"); nvme_show_status(err); @@ -1507,11 +1507,11 @@ static int sfx_expand_cap(int argc, char **argv, struct command *acmd, struct pl return err; if (cfg.namespace_id == NVME_NSID_ALL) { - if (nvme_transport_handle_is_chardev(hdl)) { + if (libnvme_transport_handle_is_chardev(hdl)) { fprintf(stderr, "namespace_id or blk device required\n"); return -EINVAL; } else { - cfg.namespace_id = atoi(&nvme_transport_handle_get_name(hdl)[strlen(nvme_transport_handle_get_name(hdl)) - 1]); + cfg.namespace_id = atoi(&libnvme_transport_handle_get_name(hdl)[strlen(libnvme_transport_handle_get_name(hdl)) - 1]); } } @@ -1579,7 +1579,7 @@ static int sfx_status(int argc, char **argv, struct command *acmd, struct plugin //Calculate formatted capacity, not concerned with errors, we may have a char device memset(&path, 0, 512); - snprintf(path, 512, "/dev/%s", nvme_transport_handle_get_name(hdl)); + snprintf(path, 512, "/dev/%s", libnvme_transport_handle_get_name(hdl)); fd = open(path, O_RDONLY | O_NONBLOCK); if (fd >= 0) { err = ioctl(fd, BLKSSZGET, §or_size); @@ -1596,7 +1596,7 @@ static int sfx_status(int argc, char **argv, struct command *acmd, struct plugin capacity = capacity / (1000 * 1000 * 1000); //B --> GB memset(&chr_dev, 0, 8); - strcpy(chr_dev, nvme_transport_handle_get_name(hdl)); + strcpy(chr_dev, libnvme_transport_handle_get_name(hdl)); for (len = 2; len < 8; len++) { if (chr_dev[len] == 'n') chr_dev[len] = '\0'; @@ -1903,7 +1903,7 @@ static int sfx_status(int argc, char **argv, struct command *acmd, struct plugin if (flags & JSON || cfg.json) { root = json_create_object(); - json_object_add_value_string(root, "ScaleFlux Status", nvme_transport_handle_get_name(hdl)); + json_object_add_value_string(root, "ScaleFlux Status", libnvme_transport_handle_get_name(hdl)); dev_stats = json_create_object(); link_stats = json_create_object(); @@ -1983,7 +1983,7 @@ static int sfx_status(int argc, char **argv, struct command *acmd, struct plugin if (len < 11) strcpy(path, "None"); - printf("%-35s%s%s\n", "ScaleFlux Drive:", "/dev/", nvme_transport_handle_get_name(hdl)); + printf("%-35s%s%s\n", "ScaleFlux Drive:", "/dev/", libnvme_transport_handle_get_name(hdl)); printf("%-35s%s\n", "PCIe Vendor ID:", pci_vid); printf("%-35s%s\n", "PCIe Subsystem Vendor ID:", pci_ssvid); printf("%-35s%s\n", "Manufacturer:", vendor); diff --git a/plugins/seagate/seagate-nvme.c b/plugins/seagate/seagate-nvme.c index be61e55e7f..c63ff68ecc 100644 --- a/plugins/seagate/seagate-nvme.c +++ b/plugins/seagate/seagate-nvme.c @@ -1570,7 +1570,7 @@ static int get_host_tele(int argc, char **argv, struct command *acmd, struct plu if (!cfg.raw_binary) { printf("Device:%s log-id:%d namespace-id:%#x\n", - nvme_transport_handle_get_name(hdl), cfg.log_id, + libnvme_transport_handle_get_name(hdl), cfg.log_id, cfg.namespace_id); printf("Data Block 1 Last Block:%d Data Block 2 Last Block:%d Data Block 3 Last Block:%d\n", tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3); @@ -1678,7 +1678,7 @@ static int get_ctrl_tele(int argc, char **argv, struct command *acmd, struct plu if (!cfg.raw_binary) { printf("Device:%s namespace-id:%#x\n", - nvme_transport_handle_get_name(hdl), cfg.namespace_id); + libnvme_transport_handle_get_name(hdl), cfg.namespace_id); printf("Data Block 1 Last Block:%d Data Block 2 Last Block:%d Data Block 3 Last Block:%d\n", tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3); diff --git a/plugins/sed/sed.c b/plugins/sed/sed.c index fee0636362..5a2c25ed24 100644 --- a/plugins/sed/sed.c +++ b/plugins/sed/sed.c @@ -74,7 +74,7 @@ static int sed_opal_open_device(struct nvme_global_ctx **ctx, struct nvme_transp if (err) return err; - if (!nvme_transport_handle_is_blkdev(*hdl)) { + if (!libnvme_transport_handle_is_blkdev(*hdl)) { fprintf(stderr, "ERROR : The NVMe block device must be specified\n"); err = -EINVAL; @@ -95,7 +95,7 @@ static int sed_opal_discover(int argc, char **argv, struct command *acmd, if (err) return err; - err = sedopal_cmd_discover(nvme_transport_handle_get_fd(hdl)); + err = sedopal_cmd_discover(libnvme_transport_handle_get_fd(hdl)); return err; } @@ -112,7 +112,7 @@ static int sed_opal_initialize(int argc, char **argv, struct command *acmd, if (err) return err; - err = sedopal_cmd_initialize(nvme_transport_handle_get_fd(hdl)); + err = sedopal_cmd_initialize(libnvme_transport_handle_get_fd(hdl)); if ((err != 0) && (err != -EOPNOTSUPP)) fprintf(stderr, "initialize: SED error - %s\n", sedopal_error_to_text(err)); @@ -132,7 +132,7 @@ static int sed_opal_revert(int argc, char **argv, struct command *acmd, if (err) return err; - err = sedopal_cmd_revert(nvme_transport_handle_get_fd(hdl)); + err = sedopal_cmd_revert(libnvme_transport_handle_get_fd(hdl)); if ((err != 0) && (err != -EOPNOTSUPP) && (err != EPERM)) fprintf(stderr, "revert: SED error - %s\n", sedopal_error_to_text(err)); @@ -152,7 +152,7 @@ static int sed_opal_lock(int argc, char **argv, struct command *acmd, if (err) return err; - err = sedopal_cmd_lock(nvme_transport_handle_get_fd(hdl)); + err = sedopal_cmd_lock(libnvme_transport_handle_get_fd(hdl)); if ((err != 0) && (err != -EOPNOTSUPP)) fprintf(stderr, "lock: SED error - %s\n", sedopal_error_to_text(err)); @@ -172,7 +172,7 @@ static int sed_opal_unlock(int argc, char **argv, struct command *acmd, if (err) return err; - err = sedopal_cmd_unlock(nvme_transport_handle_get_fd(hdl)); + err = sedopal_cmd_unlock(libnvme_transport_handle_get_fd(hdl)); if ((err != 0) && (err != -EOPNOTSUPP)) fprintf(stderr, "unlock: SED error - %s\n", sedopal_error_to_text(err)); @@ -192,7 +192,7 @@ static int sed_opal_password(int argc, char **argv, struct command *acmd, if (err) return err; - err = sedopal_cmd_password(nvme_transport_handle_get_fd(hdl)); + err = sedopal_cmd_password(libnvme_transport_handle_get_fd(hdl)); if ((err != 0) && (err != EPERM)) fprintf(stderr, "password: SED error - %s\n", sedopal_error_to_text(err)); diff --git a/plugins/shannon/shannon-nvme.c b/plugins/shannon/shannon-nvme.c index 490617bb86..46d7aa1a02 100644 --- a/plugins/shannon/shannon-nvme.c +++ b/plugins/shannon/shannon-nvme.c @@ -145,7 +145,7 @@ static int get_additional_smart_log(int argc, char **argv, struct command *acmd, if (!cfg.raw_binary) show_shannon_smart_log( &smart_log, cfg.namespace_id, - nvme_transport_handle_get_name(hdl)); + libnvme_transport_handle_get_name(hdl)); else d_raw((unsigned char *)&smart_log, sizeof(smart_log)); } else if (err > 0) { diff --git a/plugins/solidigm/solidigm-garbage-collection.c b/plugins/solidigm/solidigm-garbage-collection.c index 5d9c7b8f5c..3657844ac0 100644 --- a/plugins/solidigm/solidigm-garbage-collection.c +++ b/plugins/solidigm/solidigm-garbage-collection.c @@ -104,9 +104,9 @@ int solidigm_get_garbage_collection_log(int argc, char **argv, struct command *a if (flags & BINARY) d_raw((unsigned char *)&gc_log, sizeof(gc_log)); else if (flags & JSON) - vu_gc_log_show_json(&gc_log, nvme_transport_handle_get_name(hdl)); + vu_gc_log_show_json(&gc_log, libnvme_transport_handle_get_name(hdl)); else - vu_gc_log_show(&gc_log, nvme_transport_handle_get_name(hdl), uuid_index); + vu_gc_log_show(&gc_log, libnvme_transport_handle_get_name(hdl), uuid_index); } else if (err > 0) { nvme_show_status(err); } diff --git a/plugins/solidigm/solidigm-get-drive-info.c b/plugins/solidigm/solidigm-get-drive-info.c index 729904578e..3050482d94 100644 --- a/plugins/solidigm/solidigm-get-drive-info.c +++ b/plugins/solidigm/solidigm-get-drive-info.c @@ -16,8 +16,8 @@ int sldgm_get_drive_info(int argc, char **argv, struct command *acmd, struct plu _cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL; _cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL; nvme_print_flags_t flags; - nvme_ctrl_t c; - nvme_ns_t n; + libnvme_ctrl_t c; + libnvme_ns_t n; struct nvme_id_ns ns = { 0 }; __u8 flbaf_inUse; __u16 lba_size; @@ -36,25 +36,25 @@ int sldgm_get_drive_info(int argc, char **argv, struct command *acmd, struct plu return err; } - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err) return err; - err = nvme_scan_ctrl(ctx, nvme_transport_handle_get_name(hdl), &c); + err = libnvme_scan_ctrl(ctx, libnvme_transport_handle_get_name(hdl), &c); if (!err) - n = nvme_ctrl_first_ns(c); + n = libnvme_ctrl_first_ns(c); else { - err = nvme_scan_namespace(ctx, - nvme_transport_handle_get_name(hdl), &n); + err = libnvme_scan_namespace(ctx, + libnvme_transport_handle_get_name(hdl), &n); if (err) { nvme_show_error("solidigm-vs-drive-info: drive missing namespace"); return err; } } - err = nvme_ns_identify(n, &ns); + err = libnvme_ns_identify(n, &ns); if (err) { - nvme_show_error("identify namespace: %s", nvme_strerror(errno)); + nvme_show_error("identify namespace: %s", libnvme_strerror(errno)); return err; } diff --git a/plugins/solidigm/solidigm-internal-logs.c b/plugins/solidigm/solidigm-internal-logs.c index e26e8bfcc0..917cf888f8 100644 --- a/plugins/solidigm/solidigm-internal-logs.c +++ b/plugins/solidigm/solidigm-internal-logs.c @@ -185,7 +185,7 @@ static int cmd_dump_repeat(struct nvme_passthru_cmd *cmd, __u32 total_dw_size, cmd->cdw10 = force_max_transfer ? INTERNAL_LOG_MAX_DWORD_TRANSFER : dword_tfer; cmd->data_len = dword_tfer * 4; - err = nvme_submit_admin_passthru(hdl, cmd); + err = libnvme_submit_admin_passthru(hdl, cmd); if (err) return err; @@ -577,14 +577,14 @@ static int ilog_dump_telemetry(struct nvme_transport_handle *hdl, struct ilog *i if (da == 4) { nvme_init_get_features_host_behavior(&cmd, 0, &prev); - int err = nvme_submit_admin_passthru(hdl, &cmd); + int err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err && !prev.etdas) { struct nvme_feat_host_behavior da4_enable = prev; da4_enable.etdas = 1; nvme_init_set_features_host_behavior(&cmd, 0, &da4_enable); - nvme_submit_admin_passthru(hdl, &cmd); + libnvme_submit_admin_passthru(hdl, &cmd); host_behavior_changed = true; } } @@ -612,7 +612,7 @@ static int ilog_dump_telemetry(struct nvme_transport_handle *hdl, struct ilog *i if (host_behavior_changed) { nvme_init_set_features_host_behavior(&cmd, 0, &prev); - nvme_submit_admin_passthru(hdl, &cmd); + libnvme_submit_admin_passthru(hdl, &cmd); } if (err) diff --git a/plugins/solidigm/solidigm-smart.c b/plugins/solidigm/solidigm-smart.c index d8e5fa7e82..f90327251c 100644 --- a/plugins/solidigm/solidigm-smart.c +++ b/plugins/solidigm/solidigm-smart.c @@ -271,12 +271,12 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *acm if (!err) { if (flags & JSON) vu_smart_log_show_json(&smart_log_payload, - cfg.namespace_id, nvme_transport_handle_get_name(hdl)); + cfg.namespace_id, libnvme_transport_handle_get_name(hdl)); else if (flags & BINARY) d_raw((unsigned char *)&smart_log_payload, sizeof(smart_log_payload)); else vu_smart_log_show(&smart_log_payload, cfg.namespace_id, - nvme_transport_handle_get_name(hdl), uuid_index); + libnvme_transport_handle_get_name(hdl), uuid_index); } else if (err > 0) { nvme_show_status(err); } diff --git a/plugins/solidigm/solidigm-util.c b/plugins/solidigm/solidigm-util.c index 5a9009da77..df348beee5 100644 --- a/plugins/solidigm/solidigm-util.c +++ b/plugins/solidigm/solidigm-util.c @@ -18,7 +18,7 @@ const unsigned char solidigm_uuid[NVME_UUID_LEN] = { int sldgm_find_uuid_index(struct nvme_id_uuid_list *uuid_list, __u8 *index) { - int i = nvme_find_uuid(uuid_list, solidigm_uuid); + int i = libnvme_find_uuid(uuid_list, solidigm_uuid); *index = 0; if (i > 0) diff --git a/plugins/solidigm/solidigm-workload-tracker.c b/plugins/solidigm/solidigm-workload-tracker.c index 5c408f6930..ce05625379 100644 --- a/plugins/solidigm/solidigm-workload-tracker.c +++ b/plugins/solidigm/solidigm-workload-tracker.c @@ -605,7 +605,7 @@ int sldgm_get_workload_tracker(int argc, char **argv, struct command *acmd, stru err = nvme_set_features(wlt.hdl, 0, 0xf5, 0, cfg.trigger_treshold, 0, 0, wlt.uuid_index, 0, NULL, 0, NULL); if (err < 0) { - nvme_show_error("Trigger Threshold set-feature: %s", nvme_strerror(errno)); + nvme_show_error("Trigger Threshold set-feature: %s", libnvme_strerror(errno)); return err; } else if (err > 0) { nvme_show_status(err); @@ -623,7 +623,7 @@ int sldgm_get_workload_tracker(int argc, char **argv, struct command *acmd, stru we.trackerEnable = true; err = wltracker_config(&wlt, &we); if (err < 0) { - nvme_show_error("tracker set-feature: %s", nvme_strerror(errno)); + nvme_show_error("tracker set-feature: %s", libnvme_strerror(errno)); return err; } else if (err > 0) { nvme_show_status(err); @@ -677,7 +677,7 @@ int sldgm_get_workload_tracker(int argc, char **argv, struct command *acmd, stru we2.triggerEnable = false; err = wltracker_config(&wlt, &we2); if (err < 0) { - nvme_show_error("tracker set-feature: %s", nvme_strerror(errno)); + nvme_show_error("tracker set-feature: %s", libnvme_strerror(errno)); return err; } else if (err > 0) { nvme_show_status(err); diff --git a/plugins/ssstc/ssstc-nvme.c b/plugins/ssstc/ssstc-nvme.c index 95c3b2c266..7f0fd0d381 100644 --- a/plugins/ssstc/ssstc-nvme.c +++ b/plugins/ssstc/ssstc-nvme.c @@ -417,11 +417,11 @@ int ssstc_get_add_smart_log(int argc, char **argv, struct command *acmd, struct if (cfg.json) show_ssstc_add_smart_log_jsn( &smart_log_add, cfg.namespace_id, - nvme_transport_handle_get_name(hdl)); + libnvme_transport_handle_get_name(hdl)); else if (!cfg.raw_binary) show_ssstc_add_smart_log( &smart_log_add, cfg.namespace_id, - nvme_transport_handle_get_name(hdl)); + libnvme_transport_handle_get_name(hdl)); else d_raw((unsigned char *)&smart_log_add, sizeof(smart_log_add)); } else if (err > 0) { diff --git a/plugins/toshiba/toshiba-nvme.c b/plugins/toshiba/toshiba-nvme.c index 3c0e46f926..c7f357bb23 100644 --- a/plugins/toshiba/toshiba-nvme.c +++ b/plugins/toshiba/toshiba-nvme.c @@ -59,7 +59,7 @@ static int nvme_sct_op(struct nvme_transport_handle *hdl, __u32 opcode, .data_len = data_len, .addr = (__u64)(uintptr_t)data, }; - return nvme_submit_admin_passthru(hdl, &cmd); + return libnvme_submit_admin_passthru(hdl, &cmd); } static int nvme_get_sct_status(struct nvme_transport_handle *hdl, __u32 device_mask) @@ -351,7 +351,7 @@ static void default_show_vendor_log_c0(struct nvme_transport_handle *hdl, struct nvme_xdn_smart_log_c0 *smart) { printf("Vendor Log Page Directory 0xC0 for NVME device:%s namespace-id:%x\n", - nvme_transport_handle_get_name(hdl), nsid); + libnvme_transport_handle_get_name(hdl), nsid); printf("Error Log : %u\n", smart->items[ERROR_LOG_C0]); printf("SMART Health Log : %u\n", smart->items[SMART_HEALTH_LOG_C0]); printf("Firmware Slot Info : %u\n", smart->items[FIRMWARE_SLOT_INFO_C0]); diff --git a/plugins/transcend/transcend-nvme.c b/plugins/transcend/transcend-nvme.c index 425fc4cc2a..fcdf4914d8 100644 --- a/plugins/transcend/transcend-nvme.c +++ b/plugins/transcend/transcend-nvme.c @@ -76,7 +76,7 @@ static int getBadblock(int argc, char **argv, struct command *acmd, struct plugi nvmecmd.addr = (__u64)(uintptr_t)data; nvmecmd.data_len = 0x1; - result = nvme_submit_admin_passthru(hdl, &nvmecmd); + result = libnvme_submit_admin_passthru(hdl, &nvmecmd); if (!result) { int badblock = data[0]; diff --git a/plugins/virtium/virtium-nvme.c b/plugins/virtium/virtium-nvme.c index 20367db310..d69932df1b 100644 --- a/plugins/virtium/virtium-nvme.c +++ b/plugins/virtium/virtium-nvme.c @@ -281,7 +281,7 @@ static int vt_add_entry_to_log(struct nvme_transport_handle *hdl, filename = cfg->output_file; smart.time_stamp = time(NULL); - ret = nvme_get_nsid(hdl, &nsid); + ret = libnvme_get_nsid(hdl, &nsid); if (ret < 0) { printf("Cannot read namespace-id\n"); diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index 3b55b6a2cb..693ca04511 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -1477,31 +1477,31 @@ static double calc_percent(uint64_t numerator, uint64_t denominator) static int wdc_get_pci_ids(struct nvme_global_ctx *ctx, struct nvme_transport_handle *hdl, uint32_t *device_id, uint32_t *vendor_id) { - const char *name = nvme_transport_handle_get_name(hdl); + const char *name = libnvme_transport_handle_get_name(hdl); char vid[256], did[256], id[32]; - nvme_ctrl_t c = NULL; - nvme_ns_t n = NULL; + libnvme_ctrl_t c = NULL; + libnvme_ns_t n = NULL; int fd, ret; - ret = nvme_scan_ctrl(ctx, name, &c); + ret = libnvme_scan_ctrl(ctx, name, &c); if (!ret) { snprintf(vid, sizeof(vid), "%s/device/vendor", - nvme_ctrl_get_sysfs_dir(c)); + libnvme_ctrl_get_sysfs_dir(c)); snprintf(did, sizeof(did), "%s/device/device", - nvme_ctrl_get_sysfs_dir(c)); - nvme_free_ctrl(c); + libnvme_ctrl_get_sysfs_dir(c)); + libnvme_free_ctrl(c); } else { - ret = nvme_scan_namespace(ctx, name, &n); + ret = libnvme_scan_namespace(ctx, name, &n); if (ret) { fprintf(stderr, "Unable to find %s\n", name); return ret; } snprintf(vid, sizeof(vid), "%s/device/device/vendor", - nvme_ns_get_sysfs_dir(n)); + libnvme_ns_get_sysfs_dir(n)); snprintf(did, sizeof(did), "%s/device/device/device", - nvme_ns_get_sysfs_dir(n)); - nvme_free_ns(n); + libnvme_ns_get_sysfs_dir(n)); + libnvme_free_ns(n); } fd = open(vid, O_RDONLY); @@ -2121,13 +2121,13 @@ static __u64 wdc_get_enc_drive_capabilities(struct nvme_global_ctx *ctx, memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list)); if (wdc_CheckUuidListSupport(hdl, &uuid_list)) { /* check for the Sandisk UUID first */ - uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, WDC_UUID); } /* WD UUID not found, use default uuid index - 0 */ @@ -2259,14 +2259,14 @@ static int wdc_create_log_file(const char *file, const __u8 *drive_log_data, fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (fd < 0) { - fprintf(stderr, "ERROR: WDC: open: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: open: %s\n", libnvme_strerror(errno)); return -1; } while (drive_log_length > WRITE_SIZE) { ret = write(fd, drive_log_data, WRITE_SIZE); if (ret < 0) { - fprintf(stderr, "ERROR: WDC: write: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: write: %s\n", libnvme_strerror(errno)); close(fd); return -1; } @@ -2276,13 +2276,13 @@ static int wdc_create_log_file(const char *file, const __u8 *drive_log_data, ret = write(fd, drive_log_data, drive_log_length); if (ret < 0) { - fprintf(stderr, "ERROR: WDC: write: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: write: %s\n", libnvme_strerror(errno)); close(fd); return -1; } if (fsync(fd) < 0) { - fprintf(stderr, "ERROR: WDC: fsync: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: fsync: %s\n", libnvme_strerror(errno)); close(fd); return -1; } @@ -2558,7 +2558,7 @@ static bool get_dev_mgmt_log_page_data(struct nvme_transport_handle *hdl, void * data = (__u8 *)malloc(sizeof(__u8) * WDC_C2_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return false; } @@ -2587,7 +2587,7 @@ static bool get_dev_mgmt_log_page_data(struct nvme_transport_handle *hdl, void * free(data); data = calloc(length, sizeof(__u8)); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); goto end; } @@ -2612,7 +2612,7 @@ static bool get_dev_mgmt_log_page_data(struct nvme_transport_handle *hdl, void * /* Ensure size of log data matches length in log header */ *log_data = calloc(length, sizeof(__u8)); if (!*log_data) { - fprintf(stderr, "ERROR: WDC: calloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: calloc: %s\n", libnvme_strerror(errno)); valid = false; goto end; } @@ -2643,7 +2643,7 @@ static bool get_dev_mgmt_log_page_lid_data(struct nvme_transport_handle *hdl, data = (__u8 *)malloc(sizeof(__u8) * WDC_C2_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return false; } @@ -2671,7 +2671,7 @@ static bool get_dev_mgmt_log_page_lid_data(struct nvme_transport_handle *hdl, free(data); data = calloc(length, sizeof(__u8)); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); goto end; } @@ -2698,7 +2698,7 @@ static bool get_dev_mgmt_log_page_lid_data(struct nvme_transport_handle *hdl, if (found) { *cbs_data = calloc(le32_to_cpu(sph->length), sizeof(__u8)); if (!*cbs_data) { - fprintf(stderr, "ERROR: WDC: calloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: calloc: %s\n", libnvme_strerror(errno)); found = false; goto end; } @@ -2734,15 +2734,15 @@ static bool get_dev_mgment_data(struct nvme_global_ctx *ctx, struct nvme_transpo memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list)); if (wdc_CheckUuidListSupport(hdl, &uuid_list)) { /* check for the Sandisk UUID first */ - uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) { /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, WDC_UUID); if (uuid_index < 0) - uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID_SN640_3); + uuid_index = libnvme_find_uuid(&uuid_list, WDC_UUID_SN640_3); } if (uuid_index >= 0) @@ -2803,15 +2803,15 @@ static bool get_dev_mgment_cbs_data(struct nvme_global_ctx *ctx, struct nvme_tra memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list)); if (wdc_CheckUuidListSupport(hdl, &uuid_list)) { /* check for the Sandisk UUID first */ - uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) { /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, WDC_UUID); if (uuid_index < 0) - uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID_SN640_3); + uuid_index = libnvme_find_uuid(&uuid_list, WDC_UUID_SN640_3); } if (uuid_index >= 0) @@ -2995,7 +2995,7 @@ static int wdc_do_clear_dump(struct nvme_transport_handle *hdl, __u8 opcode, __u memset(&admin_cmd, 0, sizeof(struct nvme_passthru_cmd)); admin_cmd.opcode = opcode; admin_cmd.cdw12 = cdw12; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) fprintf(stdout, "ERROR: WDC: Crash dump erase failed\n"); nvme_show_status(ret); @@ -3017,7 +3017,7 @@ static __u32 wdc_dump_length(struct nvme_transport_handle *link, __u32 opcode, _ admin_cmd.cdw10 = cdw10; admin_cmd.cdw12 = cdw12; - ret = nvme_submit_admin_passthru(link, &admin_cmd); + ret = libnvme_submit_admin_passthru(link, &admin_cmd); if (ret) { l->log_size = 0; ret = -1; @@ -3045,7 +3045,7 @@ static __u32 wdc_dump_length_e6(struct nvme_transport_handle *hdl, __u32 opcode, admin_cmd.cdw10 = cdw10; admin_cmd.cdw12 = cdw12; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { fprintf(stderr, "ERROR: WDC: reading dump length failed\n"); nvme_show_status(ret); @@ -3072,7 +3072,7 @@ static __u32 wdc_dump_dui_data(struct nvme_transport_handle *hdl, __u32 dataLen, admin_cmd.cdw14 = WDC_NVME_CAP_DUI_DISABLE_IO; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { fprintf(stderr, "ERROR: WDC: reading DUI data failed\n"); nvme_show_status(ret); @@ -3103,7 +3103,7 @@ static __u32 wdc_dump_dui_data_v2(struct nvme_transport_handle *hdl, __u32 dataL else admin_cmd.cdw14 = WDC_NVME_CAP_DUI_DISABLE_IO; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { fprintf(stderr, "ERROR: WDC: reading DUI data V2 failed\n"); nvme_show_status(ret); @@ -3124,7 +3124,7 @@ static int wdc_do_dump(struct nvme_transport_handle *hdl, __u32 opcode, __u32 da dump_data = (__u8 *)malloc(sizeof(__u8) * dump_length); if (!dump_data) { - fprintf(stderr, "%s: ERROR: malloc: %s\n", __func__, nvme_strerror(errno)); + fprintf(stderr, "%s: ERROR: malloc: %s\n", __func__, libnvme_strerror(errno)); return -1; } memset(dump_data, 0, sizeof(__u8) * dump_length); @@ -3141,7 +3141,7 @@ static int wdc_do_dump(struct nvme_transport_handle *hdl, __u32 opcode, __u32 da admin_cmd.cdw13 = curr_data_offset; while (curr_data_offset < data_len) { - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { nvme_show_status(ret); fprintf(stderr, "%s: ERROR: WDC: Get chunk %d, size = 0x%x, offset = 0x%x, addr = 0x%lx\n", @@ -3192,7 +3192,7 @@ static int wdc_do_dump_e6(struct nvme_transport_handle *hdl, __u32 opcode, __u32 dump_data = (__u8 *)malloc(sizeof(__u8) * data_len); if (!dump_data) { - fprintf(stderr, "%s: ERROR: malloc: %s\n", __func__, nvme_strerror(errno)); + fprintf(stderr, "%s: ERROR: malloc: %s\n", __func__, libnvme_strerror(errno)); return -1; } memset(dump_data, 0, sizeof(__u8) * data_len); @@ -3216,7 +3216,7 @@ static int wdc_do_dump_e6(struct nvme_transport_handle *hdl, __u32 opcode, __u32 admin_cmd.cdw10 = xfer_size >> 2; admin_cmd.cdw13 = curr_data_offset >> 2; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { nvme_show_status(ret); fprintf(stderr, "%s: ERROR: WDC: Get chunk %d, size = 0x%x, offset = 0x%x, addr = 0x%lx\n", @@ -3273,7 +3273,7 @@ static int wdc_do_cap_telemetry_log(struct nvme_global_ctx *ctx, return -EINVAL; } - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err) { fprintf(stderr, "Failed to scan nvme subsystems\n"); return err; @@ -3322,7 +3322,7 @@ static int wdc_do_cap_telemetry_log(struct nvme_global_ctx *ctx, output = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (output < 0) { fprintf(stderr, "%s: Failed to open output file %s: %s!\n", - __func__, file, nvme_strerror(errno)); + __func__, file, libnvme_strerror(errno)); return output; } @@ -3371,7 +3371,7 @@ static int wdc_do_cap_telemetry_log(struct nvme_global_ctx *ctx, } if (fsync(output) < 0) { - fprintf(stderr, "ERROR: %s: fsync: %s\n", __func__, nvme_strerror(errno)); + fprintf(stderr, "ERROR: %s: fsync: %s\n", __func__, libnvme_strerror(errno)); err = -1; } @@ -3391,7 +3391,7 @@ static int wdc_do_cap_diag(struct nvme_global_ctx *ctx, struct nvme_transport_ha log_hdr = (struct wdc_e6_log_hdr *)malloc(e6_log_hdr_size); if (!log_hdr) { - fprintf(stderr, "%s: ERROR: malloc: %s\n", __func__, nvme_strerror(errno)); + fprintf(stderr, "%s: ERROR: malloc: %s\n", __func__, libnvme_strerror(errno)); ret = -1; goto out; } @@ -3492,7 +3492,7 @@ static int wdc_do_cap_dui_v1(struct nvme_transport_handle *hdl, char *file, __u3 dump_data = (__u8 *)malloc(sizeof(__u8) * xfer_size); if (!dump_data) { fprintf(stderr, "%s: ERROR: dump data V1 malloc failed : status %s, size = 0x%x\n", - __func__, nvme_strerror(errno), (unsigned int)xfer_size); + __func__, libnvme_strerror(errno), (unsigned int)xfer_size); return -1; } memset(dump_data, 0, sizeof(__u8) * xfer_size); @@ -3500,7 +3500,7 @@ static int wdc_do_cap_dui_v1(struct nvme_transport_handle *hdl, char *file, __u3 output = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (output < 0) { fprintf(stderr, "%s: Failed to open output file %s: %s!\n", __func__, file, - nvme_strerror(errno)); + libnvme_strerror(errno)); free(dump_data); return output; } @@ -3626,7 +3626,7 @@ static int wdc_do_cap_dui_v2_v3(struct nvme_transport_handle *hdl, char *file, _ if (!dump_data) { fprintf(stderr, "%s: ERROR: dump data v3 malloc failed : status %s, size = 0x%"PRIx64"\n", - __func__, nvme_strerror(errno), (uint64_t)xfer_size_long); + __func__, libnvme_strerror(errno), (uint64_t)xfer_size_long); return -1; } memset(dump_data, 0, sizeof(__u8) * xfer_size_long); @@ -3634,7 +3634,7 @@ static int wdc_do_cap_dui_v2_v3(struct nvme_transport_handle *hdl, char *file, _ output = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (output < 0) { fprintf(stderr, "%s: Failed to open output file %s: %s!\n", - __func__, file, nvme_strerror(errno)); + __func__, file, libnvme_strerror(errno)); free(dump_data); return output; } @@ -3767,7 +3767,7 @@ static int wdc_do_cap_dui_v4(struct nvme_transport_handle *hdl, char *file, __u3 dump_data = (__u8 *)malloc(sizeof(__u8) * xfer_size_long); if (!dump_data) { fprintf(stderr, "%s: ERROR: dump data V4 malloc failed : status %s, size = 0x%x\n", - __func__, nvme_strerror(errno), (unsigned int)xfer_size_long); + __func__, libnvme_strerror(errno), (unsigned int)xfer_size_long); return -1; } memset(dump_data, 0, sizeof(__u8) * xfer_size_long); @@ -3775,7 +3775,7 @@ static int wdc_do_cap_dui_v4(struct nvme_transport_handle *hdl, char *file, __u3 output = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (output < 0) { fprintf(stderr, "%s: Failed to open output file %s: %s!\n", __func__, file, - nvme_strerror(errno)); + libnvme_strerror(errno)); free(dump_data); return output; } @@ -3850,7 +3850,7 @@ static int wdc_do_cap_dui(struct nvme_transport_handle *hdl, char *file, __u32 x log_hdr = (struct wdc_dui_log_hdr *)malloc(dui_log_hdr_size); if (!log_hdr) { fprintf(stderr, "%s: ERROR: log header malloc failed : status %s, size 0x%x\n", - __func__, nvme_strerror(errno), dui_log_hdr_size); + __func__, libnvme_strerror(errno), dui_log_hdr_size); return -1; } memset(log_hdr, 0, dui_log_hdr_size); @@ -3929,7 +3929,7 @@ static int wdc_cap_diag(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -3966,7 +3966,7 @@ static int wdc_do_get_sn730_log_len(struct nvme_transport_handle *hdl, uint32_t output = (uint32_t *)malloc(sizeof(uint32_t)); if (!output) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } memset(output, 0, sizeof(uint32_t)); @@ -3978,7 +3978,7 @@ static int wdc_do_get_sn730_log_len(struct nvme_transport_handle *hdl, uint32_t admin_cmd.cdw12 = subopcode; admin_cmd.cdw10 = SN730_LOG_CHUNK_SIZE / 4; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (!ret) *len_buf = *output; free(output); @@ -3993,7 +3993,7 @@ static int wdc_do_get_sn730_log(struct nvme_transport_handle *hdl, void *log_buf output = (uint8_t *)calloc(SN730_LOG_CHUNK_SIZE, sizeof(uint8_t)); if (!output) { - fprintf(stderr, "ERROR: WDC: calloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: calloc: %s\n", libnvme_strerror(errno)); return -1; } memset(&admin_cmd, 0, sizeof(struct nvme_passthru_cmd)); @@ -4004,7 +4004,7 @@ static int wdc_do_get_sn730_log(struct nvme_transport_handle *hdl, void *log_buf admin_cmd.cdw13 = offset; admin_cmd.cdw10 = SN730_LOG_CHUNK_SIZE / 4; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (!ret) memcpy(log_buf, output, SN730_LOG_CHUNK_SIZE); return ret; @@ -4019,7 +4019,7 @@ static int get_sn730_log_chunks(struct nvme_transport_handle *hdl, uint8_t *log_ chunk_buf = (uint8_t *)malloc(sizeof(uint8_t) * SN730_LOG_CHUNK_SIZE); if (!chunk_buf) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); ret = -1; goto out; } @@ -4062,7 +4062,7 @@ static int wdc_do_sn730_get_and_tar(struct nvme_transport_handle *hdl, char *out tarInfo = (struct tarfile_metadata *)malloc(sizeof(struct tarfile_metadata)); if (!tarInfo) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); ret = -1; goto free_buf; } @@ -4122,7 +4122,7 @@ static int wdc_do_sn730_get_and_tar(struct nvme_transport_handle *hdl, char *out extended_log_buf = (uint8_t *) calloc(extended_log_len, sizeof(uint8_t)); if (!full_log_buf || !key_log_buf || !core_dump_log_buf || !extended_log_buf) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); ret = -1; goto free_buf; } @@ -4207,7 +4207,7 @@ static int dump_internal_logs(struct nvme_transport_handle *hdl, const char *dir hdr = malloc(bs); telemetry_log = malloc(bs); if (!hdr || !telemetry_log) { - fprintf(stderr, "Failed to allocate %zu bytes for log: %s\n", bs, nvme_strerror(errno)); + fprintf(stderr, "Failed to allocate %zu bytes for log: %s\n", bs, libnvme_strerror(errno)); err = -ENOMEM; goto free_mem; } @@ -4216,7 +4216,7 @@ static int dump_internal_logs(struct nvme_transport_handle *hdl, const char *dir sprintf(file_path, "%s/telemetry.bin", dir_name); output = open(file_path, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (output < 0) { - fprintf(stderr, "Failed to open output file %s: %s!\n", file_path, nvme_strerror(errno)); + fprintf(stderr, "Failed to open output file %s: %s!\n", file_path, libnvme_strerror(errno)); err = output; goto free_mem; } @@ -4363,7 +4363,7 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) goto out; @@ -4383,7 +4383,7 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *acmd, /* verify file name and path is valid before getting dump data */ verify_file = open(cfg.file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (verify_file < 0) { - fprintf(stderr, "ERROR: WDC: open: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: open: %s\n", libnvme_strerror(errno)); goto out; } close(verify_file); @@ -4687,7 +4687,7 @@ static int wdc_do_drive_log(struct nvme_transport_handle *hdl, const char *file) drive_log_data = (__u8 *)malloc(sizeof(__u8) * drive_log_length); if (!drive_log_data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } @@ -4700,7 +4700,7 @@ static int wdc_do_drive_log(struct nvme_transport_handle *hdl, const char *file) admin_cmd.cdw12 = ((WDC_NVME_DRIVE_LOG_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_DRIVE_LOG_SIZE_CMD); - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); nvme_show_status(ret); if (!ret) ret = wdc_create_log_file(file, drive_log_data, drive_log_length); @@ -4733,7 +4733,7 @@ static int wdc_drive_log(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return ret; @@ -4779,7 +4779,7 @@ static int wdc_get_crash_dump(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return ret; @@ -4820,7 +4820,7 @@ static int wdc_get_pfail_dump(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return ret; @@ -4899,7 +4899,7 @@ static int wdc_purge(int argc, char **argv, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return ret; @@ -4912,7 +4912,7 @@ static int wdc_purge(int argc, char **argv, memset(&admin_cmd, 0, sizeof(admin_cmd)); admin_cmd.opcode = WDC_NVME_PURGE_CMD_OPCODE; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (ret > 0) { switch (ret) { case WDC_NVME_PURGE_CMD_SEQ_ERR: @@ -4951,7 +4951,7 @@ static int wdc_purge_monitor(int argc, char **argv, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return ret; @@ -4968,7 +4968,7 @@ static int wdc_purge_monitor(int argc, char **argv, admin_cmd.cdw10 = WDC_NVME_PURGE_MONITOR_CMD_CDW10; admin_cmd.timeout_ms = WDC_NVME_PURGE_MONITOR_TIMEOUT; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (!ret) { mon = (struct wdc_nvme_purge_monitor_data *) output; printf("Purge state = 0x%0"PRIx64"\n", @@ -5120,7 +5120,7 @@ static int wdc_print_latency_monitor_log_normal(struct nvme_transport_handle *hd struct wdc_ssd_latency_monitor_log *log_data) { printf("Latency Monitor/C3 Log Page Data\n"); - printf(" Controller : %s\n", nvme_transport_handle_get_name(hdl)); + printf(" Controller : %s\n", libnvme_transport_handle_get_name(hdl)); int err = -1, i, j; struct nvme_id_ctrl ctrl; char ts_buf[128]; @@ -5620,7 +5620,7 @@ static void wdc_print_bd_ca_log_normal(struct nvme_transport_handle *hdl, void * switch (bd_data->field_id) { case 0x0: printf("Additional Smart Log for NVME device:%s namespace-id:%x\n", - nvme_transport_handle_get_name(hdl), WDC_DE_GLOBAL_NSID); + libnvme_transport_handle_get_name(hdl), WDC_DE_GLOBAL_NSID); printf("key normalized raw\n"); printf("program_fail_count : %3"PRIu8"%% %"PRIu64"\n", bd_data->normalized_value, (uint64_t)rawSwapped); @@ -6326,12 +6326,12 @@ static int nvme_get_print_ocp_cloud_smart_log(struct nvme_transport_handle *hdl, log_ptr = (struct ocp_cloud_smart_log *)malloc(sizeof(__u8) * length); if (!log_ptr) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } if (namespace_id == NVME_NSID_ALL) { - ret = nvme_get_nsid(hdl, &namespace_id); + ret = libnvme_get_nsid(hdl, &namespace_id); if (ret < 0) namespace_id = NVME_NSID_ALL; } @@ -6391,12 +6391,12 @@ static int nvme_get_print_c0_eol_log(struct nvme_transport_handle *hdl, log_ptr = (void *)malloc(sizeof(__u8) * length); if (!log_ptr) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } if (namespace_id == NVME_NSID_ALL) { - ret = nvme_get_nsid(hdl, &namespace_id); + ret = libnvme_get_nsid(hdl, &namespace_id); if (ret < 0) namespace_id = NVME_NSID_ALL; } @@ -6433,7 +6433,7 @@ static int nvme_get_ext_smart_cloud_log(struct nvme_transport_handle *hdl, __u8 log_ptr = (__u8 *)malloc(sizeof(__u8) * WDC_NVME_SMART_CLOUD_ATTR_LEN); if (!log_ptr) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } @@ -6480,7 +6480,7 @@ static int nvme_get_hw_rev_log(struct nvme_transport_handle *hdl, __u8 **data, i log_ptr = (struct wdc_nvme_hw_rev_log *)malloc(sizeof(__u8) * WDC_NVME_HW_REV_LOG_PAGE_LEN); if (!log_ptr) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } @@ -7523,7 +7523,7 @@ static int wdc_get_ca_log_page(struct nvme_global_ctx *ctx, struct nvme_transpor if (cust_id == WDC_CUSTOMER_ID_0x1005) { data = (__u8 *)malloc(sizeof(__u8) * WDC_FB_CA_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } @@ -7559,7 +7559,7 @@ static int wdc_get_ca_log_page(struct nvme_global_ctx *ctx, struct nvme_transpor if (cust_id == WDC_CUSTOMER_ID_0x1005) { data = (__u8 *)malloc(sizeof(__u8) * WDC_FB_CA_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } @@ -7583,7 +7583,7 @@ static int wdc_get_ca_log_page(struct nvme_global_ctx *ctx, struct nvme_transpor (cust_id == WDC_CUSTOMER_ID_BD)) { data = (__u8 *)malloc(sizeof(__u8) * WDC_BD_CA_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } @@ -7646,7 +7646,7 @@ static int wdc_get_c1_log_page(struct nvme_global_ctx *ctx, data = (__u8 *)malloc(sizeof(__u8) * WDC_ADD_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } memset(data, 0, sizeof(__u8) * WDC_ADD_LOG_BUF_LEN); @@ -7695,7 +7695,7 @@ static int wdc_get_c3_log_page(struct nvme_global_ctx *ctx, struct nvme_transpor data = (__u8 *)malloc(sizeof(__u8) * WDC_LATENCY_MON_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } memset(data, 0, sizeof(__u8) * WDC_LATENCY_MON_LOG_BUF_LEN); @@ -7704,7 +7704,7 @@ static int wdc_get_c3_log_page(struct nvme_global_ctx *ctx, struct nvme_transpor data, WDC_LATENCY_MON_LOG_BUF_LEN); if (strcmp(format, "json")) - fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret, false), ret); + fprintf(stderr, "NVMe Status:%s(%x)\n", libnvme_status_to_string(ret, false), ret); if (!ret) { log_data = (struct wdc_ssd_latency_monitor_log *)data; @@ -7767,7 +7767,7 @@ static int wdc_get_ocp_c1_log_page(struct nvme_global_ctx *ctx, struct nvme_tran data = (__u8 *)malloc(sizeof(__u8) * WDC_ERROR_REC_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } memset(data, 0, sizeof(__u8) * WDC_ERROR_REC_LOG_BUF_LEN); @@ -7776,7 +7776,7 @@ static int wdc_get_ocp_c1_log_page(struct nvme_global_ctx *ctx, struct nvme_tran data, WDC_ERROR_REC_LOG_BUF_LEN); if (strcmp(format, "json")) - fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret, false), ret); + fprintf(stderr, "NVMe Status:%s(%x)\n", libnvme_status_to_string(ret, false), ret); if (!ret) { log_data = (struct wdc_ocp_c1_error_recovery_log *)data; @@ -7839,7 +7839,7 @@ static int wdc_get_ocp_c4_log_page(struct nvme_global_ctx *ctx, struct nvme_tran data = (__u8 *)malloc(sizeof(__u8) * WDC_DEV_CAP_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } memset(data, 0, sizeof(__u8) * WDC_DEV_CAP_LOG_BUF_LEN); @@ -7848,7 +7848,7 @@ static int wdc_get_ocp_c4_log_page(struct nvme_global_ctx *ctx, struct nvme_tran data, WDC_DEV_CAP_LOG_BUF_LEN); if (strcmp(format, "json")) - fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret, false), ret); + fprintf(stderr, "NVMe Status:%s(%x)\n", libnvme_status_to_string(ret, false), ret); if (!ret) { log_data = (struct wdc_ocp_C4_dev_cap_log *)data; @@ -7909,7 +7909,7 @@ static int wdc_get_ocp_c5_log_page(struct nvme_global_ctx *ctx, struct nvme_tran data = (__u8 *)malloc(sizeof(__u8) * WDC_UNSUPPORTED_REQS_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } memset(data, 0, sizeof(__u8) * WDC_UNSUPPORTED_REQS_LOG_BUF_LEN); @@ -7918,7 +7918,7 @@ static int wdc_get_ocp_c5_log_page(struct nvme_global_ctx *ctx, struct nvme_tran data, WDC_UNSUPPORTED_REQS_LOG_BUF_LEN); if (strcmp(format, "json")) - fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret, false), ret); + fprintf(stderr, "NVMe Status:%s(%x)\n", libnvme_status_to_string(ret, false), ret); if (!ret) { log_data = (struct wdc_ocp_C5_unsupported_reqs *)data; @@ -7987,7 +7987,7 @@ static int wdc_get_d0_log_page(struct nvme_global_ctx *ctx, struct nvme_transpor data = (__u8 *)malloc(sizeof(__u8) * WDC_NVME_VU_SMART_LOG_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } memset(data, 0, sizeof(__u8) * WDC_NVME_VU_SMART_LOG_LEN); @@ -8192,7 +8192,7 @@ static void wdc_show_cloud_smart_log_normal(struct ocp_cloud_smart_log *log, uint16_t smart_log_ver = (uint16_t)le16_to_cpu(log->log_page_version); printf("SMART Cloud Attributes for NVMe device : %s\n", - nvme_transport_handle_get_name(hdl)); + libnvme_transport_handle_get_name(hdl)); printf("Physical Media Units Written : %'.0Lf\n", le_to_float(log->physical_media_units_written, 16)); printf("Physical Media Units Read : %'.0Lf\n", @@ -8329,7 +8329,7 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -8461,7 +8461,7 @@ static int wdc_cu_smart_log(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -8497,7 +8497,7 @@ static int wdc_cu_smart_log(int argc, char **argv, struct command *acmd, case WDC_NVME_SN861_DEV_ID_1: data = (__u8 *)malloc(WDC_BD_CA_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); ret = -1; break; } @@ -8569,7 +8569,7 @@ static int wdc_vs_cloud_log(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -8636,7 +8636,7 @@ static int wdc_vs_hw_rev_log(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -8724,7 +8724,7 @@ static int wdc_vs_device_waf(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -8745,7 +8745,7 @@ static int wdc_vs_device_waf(int argc, char **argv, struct command *acmd, ret = -1; goto out; } else { - fprintf(stderr, "smart log: %s\n", nvme_strerror(errno)); + fprintf(stderr, "smart log: %s\n", libnvme_strerror(errno)); ret = -1; goto out; } @@ -8828,7 +8828,7 @@ static int wdc_get_latency_monitor_log(int argc, char **argv, struct command *ac if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; capabilities = wdc_get_drive_capabilities(ctx, hdl); @@ -8870,7 +8870,7 @@ static int wdc_get_error_recovery_log(int argc, char **argv, struct command *acm if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -8913,7 +8913,7 @@ static int wdc_get_dev_capabilities_log(int argc, char **argv, struct command *a if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -8956,7 +8956,7 @@ static int wdc_get_unsupported_reqs_log(int argc, char **argv, struct command *a if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -8986,7 +8986,7 @@ static int wdc_do_clear_pcie_correctable_errors(struct nvme_transport_handle *hd admin_cmd.cdw12 = ((WDC_NVME_CLEAR_PCIE_CORR_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_CLEAR_PCIE_CORR_CMD); - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); nvme_show_status(ret); return ret; } @@ -8999,7 +8999,7 @@ static int wdc_do_clear_pcie_correctable_errors_vuc(struct nvme_transport_handle memset(&admin_cmd, 0, sizeof(admin_cmd)); admin_cmd.opcode = WDC_NVME_CLEAR_PCIE_CORR_OPCODE_VUC; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); nvme_show_status(ret); return ret; } @@ -9032,7 +9032,7 @@ static int wdc_clear_pcie_correctable_errors(int argc, char **argv, struct comma if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return -1; @@ -9078,7 +9078,7 @@ static int wdc_drive_status(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -9096,13 +9096,13 @@ static int wdc_drive_status(int argc, char **argv, struct command *acmd, memset(&uuid_list, 0, sizeof(struct nvme_id_uuid_list)); if (wdc_CheckUuidListSupport(hdl, &uuid_list)) { /* check for the Sandisk UUID first */ - uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, WDC_UUID); } /* WD UUID not found, use default uuid index - 0 */ @@ -9222,7 +9222,7 @@ static int wdc_clear_assert_dump(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -9247,7 +9247,7 @@ static int wdc_clear_assert_dump(int argc, char **argv, struct command *acmd, admin_cmd.cdw12 = ((WDC_NVME_CLEAR_ASSERT_DUMP_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_CLEAR_ASSERT_DUMP_CMD); - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); nvme_show_status(ret); } else fprintf(stderr, "INFO: WDC: No Assert Dump Present\n"); @@ -9283,7 +9283,7 @@ static int wdc_get_fw_act_history(struct nvme_global_ctx *ctx, struct nvme_trans data = (__u8 *)malloc(sizeof(__u8) * WDC_FW_ACT_HISTORY_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } @@ -9363,7 +9363,7 @@ static int wdc_get_fw_act_history_C2(struct nvme_global_ctx *ctx, struct nvme_tr data = (__u8 *)malloc(sizeof(__u8) * WDC_FW_ACT_HISTORY_C2_LOG_BUF_LEN); if (!data) { - fprintf(stderr, "ERROR: WDC: malloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: malloc: %s\n", libnvme_strerror(errno)); return -1; } @@ -9445,7 +9445,7 @@ static int wdc_vs_fw_activate_history(int argc, char **argv, struct command *acm if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -9494,7 +9494,7 @@ static int wdc_do_clear_fw_activate_history_vuc(struct nvme_transport_handle *hd admin_cmd.cdw12 = ((WDC_NVME_CLEAR_FW_ACT_HIST_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_CLEAR_FW_ACT_HIST_CMD); - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); nvme_show_status(ret); return ret; @@ -9528,7 +9528,7 @@ static int wdc_clear_fw_activate_history(int argc, char **argv, struct command * if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -9584,7 +9584,7 @@ static int wdc_vs_telemetry_controller_option(int argc, char **argv, struct comm if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -9703,7 +9703,7 @@ static int wdc_de_VU_read_size(struct nvme_transport_handle *hdl, __u32 fileId, cmd.cdw13 = fileId << 16; cmd.cdw14 = spiDestn; - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret && logSize) *logSize = cmd.result; @@ -9740,7 +9740,7 @@ static int wdc_de_VU_read_buffer(struct nvme_transport_handle *hdl, __u32 fileId cmd.addr = (__u64)(__u64)(uintptr_t)dataBuffer; cmd.data_len = *bufferSize; - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (ret != WDC_STATUS_SUCCESS) { fprintf(stderr, "ERROR: WDC: VUReadBuffer() failed, "); @@ -10374,7 +10374,7 @@ static int wdc_drive_essentials(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -10409,7 +10409,7 @@ static int wdc_do_drive_resize(struct nvme_transport_handle *hdl, uint64_t new_s WDC_NVME_DRIVE_RESIZE_CMD); admin_cmd.cdw13 = new_size; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); return ret; } @@ -10423,7 +10423,7 @@ static int wdc_do_namespace_resize(struct nvme_transport_handle *hdl, __u32 nsid admin_cmd.nsid = nsid; admin_cmd.cdw10 = op_option; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); return ret; } @@ -10437,7 +10437,7 @@ static int wdc_do_drive_info(struct nvme_transport_handle *hdl, __u32 *result) admin_cmd.cdw12 = ((WDC_NVME_DRIVE_INFO_SUBCMD << WDC_NVME_SUBCMD_SHIFT) | WDC_NVME_DRIVE_INFO_CMD); - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (!ret && result) *result = admin_cmd.result; @@ -10470,7 +10470,7 @@ static int wdc_drive_resize(int argc, char **argv, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return -1; @@ -10525,7 +10525,7 @@ static int wdc_namespace_resize(int argc, char **argv, return -1; } - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return -1; @@ -10580,7 +10580,7 @@ static int wdc_reason_identifier(int argc, char **argv, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -10596,7 +10596,7 @@ static int wdc_reason_identifier(int argc, char **argv, /* verify the passed in file name and path is valid before getting the dump data */ verify_file = open(cfg.file, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (verify_file < 0) { - fprintf(stderr, "ERROR: WDC: open: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: open: %s\n", libnvme_strerror(errno)); return -1; } close(verify_file); @@ -10843,7 +10843,7 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *acmd, return ret; } - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -10871,13 +10871,13 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *acmd, if (!wdc_is_sn861(device_id)) { if (uuid_supported) { /* check for the Sandisk UUID first */ - uuid_index = nvme_find_uuid(&uuid_list, SNDK_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, SNDK_UUID); if (uuid_index < 0) /* The Sandisk UUID is not found; * check for the WDC UUID second. */ - uuid_index = nvme_find_uuid(&uuid_list, WDC_UUID); + uuid_index = libnvme_find_uuid(&uuid_list, WDC_UUID); } /* WD UUID not found, use default uuid index - 0 */ @@ -10954,7 +10954,7 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *acmd, .data_len = 32, }; - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) { switch (fmt) { case BINARY: @@ -10968,7 +10968,7 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *acmd, } } else { fprintf(stderr, "NVMe Status:%s(%x)\n", - nvme_status_to_string(ret, false), ret); + libnvme_status_to_string(ret, false), ret); } } } @@ -11032,7 +11032,7 @@ static int wdc_save_reason_id(struct nvme_transport_handle *hdl, __u8 *rsn_ident if (stat(reason_id_path, &st) == -1) { if (mkdir(reason_id_path, 0700) < 0) { fprintf(stderr, "%s: ERROR: failed to mkdir %s: %s\n", - __func__, reason_id_path, nvme_strerror(errno)); + __func__, reason_id_path, libnvme_strerror(errno)); return -1; } } @@ -11111,7 +11111,7 @@ static int wdc_do_get_reason_id(struct nvme_transport_handle *hdl, const char *f log_hdr = (struct nvme_telemetry_log *)malloc(log_hdr_size); if (!log_hdr) { - fprintf(stderr, "%s: ERROR: malloc failed, size : 0x%x, status: %s\n", __func__, log_hdr_size, nvme_strerror(errno)); + fprintf(stderr, "%s: ERROR: malloc failed, size : 0x%x, status: %s\n", __func__, log_hdr_size, libnvme_strerror(errno)); ret = -1; goto out; } @@ -11526,7 +11526,7 @@ static int wdc_do_vs_nand_stats(struct nvme_transport_handle *hdl, char *format) output = (uint8_t *)calloc(WDC_NVME_NAND_STATS_SIZE, sizeof(uint8_t)); if (!output) { - fprintf(stderr, "ERROR: WDC: calloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: calloc: %s\n", libnvme_strerror(errno)); ret = -1; goto out; } @@ -11587,7 +11587,7 @@ static int wdc_vs_nand_stats(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -11632,7 +11632,7 @@ static int wdc_do_vs_pcie_stats(struct nvme_transport_handle *hdl, admin_cmd.addr = (__u64)(uintptr_t)pcieStatsPtr; admin_cmd.data_len = pcie_stats_size; - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); return ret; } @@ -11664,7 +11664,7 @@ static int wdc_vs_pcie_stats(int argc, char **argv, struct command *acmd, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -11676,7 +11676,7 @@ static int wdc_vs_pcie_stats(int argc, char **argv, struct command *acmd, pcieStatsPtr = nvme_alloc_huge(pcie_stats_size, &mh); if (!pcieStatsPtr) { - fprintf(stderr, "ERROR: WDC: PCIE Stats alloc: %s\n", nvme_strerror(errno)); + fprintf(stderr, "ERROR: WDC: PCIE Stats alloc: %s\n", libnvme_strerror(errno)); ret = -1; goto out; } @@ -11764,7 +11764,7 @@ static int wdc_vs_drive_info(int argc, char **argv, return ret; } - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return -1; @@ -11926,7 +11926,7 @@ static int wdc_vs_drive_info(int argc, char **argv, .addr = (__u64)(uintptr_t)&info, .data_len = data_len, }; - ret = nvme_submit_admin_passthru(hdl, &cmd); + ret = libnvme_submit_admin_passthru(hdl, &cmd); if (!ret) { __u16 hw_rev_major, hw_rev_minor; @@ -12001,7 +12001,7 @@ static int wdc_vs_temperature_stats(int argc, char **argv, if (ret) return ret; - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret) return ret; @@ -12040,7 +12040,7 @@ static int wdc_vs_temperature_stats(int argc, char **argv, if (fmt == NORMAL) { /* print the temperature stats */ printf("Temperature Stats for NVME device:%s namespace-id:%x\n", - nvme_transport_handle_get_name(hdl), WDC_DE_GLOBAL_NSID); + libnvme_transport_handle_get_name(hdl), WDC_DE_GLOBAL_NSID); printf("Current Composite Temperature : %d °C\n", temperature); printf("WCTEMP : %"PRIu16" °C\n", id_ctrl.wctemp - 273); @@ -12104,14 +12104,14 @@ static int wdc_capabilities(int argc, char **argv, struct command *acmd, struct return ret; /* get capabilities */ - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return -1; capabilities = wdc_get_drive_capabilities(ctx, hdl); /* print command and supported status */ - printf("WDC Plugin Capabilities for NVME device:%s\n", nvme_transport_handle_get_name(hdl)); + printf("WDC Plugin Capabilities for NVME device:%s\n", libnvme_transport_handle_get_name(hdl)); printf("cap-diag : %s\n", capabilities & WDC_DRIVE_CAP_CAP_DIAG ? "Supported" : "Not Supported"); printf("drive-log : %s\n", @@ -12209,7 +12209,7 @@ static int wdc_cloud_ssd_plugin_version(int argc, char **argv, struct command *a return ret; /* get capabilities */ - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return -1; @@ -12254,7 +12254,7 @@ static int wdc_cloud_boot_SSD_version(int argc, char **argv, struct command *acm return ret; /* get capabilities */ - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return -1; @@ -12346,7 +12346,7 @@ static int wdc_enc_get_log(int argc, char **argv, struct command *acmd, struct p output_fd = fopen(cfg.file, "wb"); if (!output_fd) { fprintf(stderr, "%s: ERROR: opening:%s: %s\n", __func__, cfg.file, - nvme_strerror(errno)); + libnvme_strerror(errno)); return -EINVAL; } } else { @@ -12391,7 +12391,7 @@ static int wdc_enc_submit_move_data(struct nvme_transport_handle *hdl, char *cmd buf = (char *)malloc(sizeof(__u8) * xfer_size); if (!buf) { - fprintf(stderr, "%s: ERROR: malloc: %s\n", __func__, nvme_strerror(errno)); + fprintf(stderr, "%s: ERROR: malloc: %s\n", __func__, libnvme_strerror(errno)); return -1; } /* send something no matter what */ @@ -12430,7 +12430,7 @@ static int wdc_enc_submit_move_data(struct nvme_transport_handle *hdl, char *cmd nvme_cmd.timeout_ms, nvme_cmd.result, md, d); #endif nvme_cmd.result = 0; - err = nvme_submit_admin_passthru(hdl, &nvme_cmd); + err = libnvme_submit_admin_passthru(hdl, &nvme_cmd); if (nvme_status_equals(err, NVME_STATUS_TYPE_NVME, NVME_SC_INTERNAL)) { fprintf(stderr, "%s: WARNING : WDC: No log ID:x%x available\n", __func__, log_id); } else if (err) { @@ -12455,7 +12455,7 @@ static int wdc_enc_submit_move_data(struct nvme_transport_handle *hdl, char *cmd nvme_cmd.cdw14 = cdw14; nvme_cmd.cdw15 = cdw15; nvme_cmd.result = 0; /* returned result !=0 indicates more data available */ - err = nvme_submit_admin_passthru(hdl, &nvme_cmd); + err = libnvme_submit_admin_passthru(hdl, &nvme_cmd); if (err) { more = 0; fprintf(stderr, "%s: ERROR: WDC: NVMe Rcv Mgmt ", __func__); @@ -12489,7 +12489,7 @@ static int wdc_enc_get_nic_log(struct nvme_transport_handle *hdl, __u8 log_id, _ dump_data = (__u8 *)malloc(sizeof(__u8) * dump_length); if (!dump_data) { - fprintf(stderr, "%s: ERROR: malloc: %s\n", __func__, nvme_strerror(errno)); + fprintf(stderr, "%s: ERROR: malloc: %s\n", __func__, libnvme_strerror(errno)); return -1; } memset(dump_data, 0, sizeof(__u8) * dump_length); @@ -12515,7 +12515,7 @@ static int wdc_enc_get_nic_log(struct nvme_transport_handle *hdl, __u8 log_id, _ admin_cmd.nsid, admin_cmd.addr, admin_cmd.data_len, admin_cmd.cdw10, admin_cmd.cdw11, admin_cmd.cdw12, admin_cmd.cdw13, admin_cmd.cdw14); #endif - ret = nvme_submit_admin_passthru(hdl, &admin_cmd); + ret = libnvme_submit_admin_passthru(hdl, &admin_cmd); if (ret) { nvme_show_status(ret); fprintf(stderr, "%s: ERROR: WDC: Get chunk %d, size = 0x%x, offset = 0x%x, addr = 0x%lx\n", @@ -12635,7 +12635,7 @@ int wdc_set_latency_monitor_feature(int argc, char **argv, struct command *acmd, return ret; /* get capabilities */ - ret = nvme_scan_topology(ctx, NULL, NULL); + ret = libnvme_scan_topology(ctx, NULL, NULL); if (ret || !wdc_check_device(ctx, hdl)) return -1; @@ -12683,7 +12683,7 @@ int wdc_set_latency_monitor_feature(int argc, char **argv, struct command *acmd, buf.latency_monitor_feature_enable); } else if (ret > 0) fprintf(stderr, "NVMe Status:%s(%x)\n", - nvme_status_to_string(ret, false), ret); + libnvme_status_to_string(ret, false), ret); return ret; } diff --git a/plugins/wdc/wdc-utils.c b/plugins/wdc/wdc-utils.c index 7e6afaf014..1f34563cb5 100644 --- a/plugins/wdc/wdc-utils.c +++ b/plugins/wdc/wdc-utils.c @@ -189,7 +189,7 @@ bool wdc_CheckUuidListSupport(struct nvme_transport_handle *hdl, else if (err > 0) nvme_show_status(err); else - nvme_show_error("identify UUID list: %s", nvme_strerror(errno)); + nvme_show_error("identify UUID list: %s", libnvme_strerror(errno)); } return false; diff --git a/plugins/ymtc/ymtc-nvme.c b/plugins/ymtc/ymtc-nvme.c index 6f4a5e5d1d..d393807b62 100644 --- a/plugins/ymtc/ymtc-nvme.c +++ b/plugins/ymtc/ymtc-nvme.c @@ -53,7 +53,7 @@ static int show_ymtc_smart_log(struct nvme_transport_handle *hdl, __u32 nsid, /* Table Title */ printf("Additional Smart Log for NVME device:%s namespace-id:%x\n", - nvme_transport_handle_get_name(hdl), nsid); + libnvme_transport_handle_get_name(hdl), nsid); /* Column Name*/ printf("key normalized raw\n"); /* 00 SI_VD_PROGRAM_FAIL */ diff --git a/plugins/zns/zns.c b/plugins/zns/zns.c index 9a988e01dc..b51571878f 100644 --- a/plugins/zns/zns.c +++ b/plugins/zns/zns.c @@ -24,14 +24,14 @@ static const char *namespace_id = "Namespace identifier to use"; -static int detect_zns(nvme_ns_t ns, int *out_supported) +static int detect_zns(libnvme_ns_t ns, int *out_supported) { int err = 0; char *zoned; *out_supported = 0; - zoned = nvme_get_attr(nvme_ns_get_sysfs_dir(ns), "queue/zoned"); + zoned = libnvme_get_attr(libnvme_ns_get_sysfs_dir(ns), "queue/zoned"); if (!zoned) { *out_supported = 0; return err; @@ -43,7 +43,7 @@ static int detect_zns(nvme_ns_t ns, int *out_supported) return err; } -static int print_zns_list_ns(nvme_ns_t ns, struct table *t) +static int print_zns_list_ns(libnvme_ns_t ns, struct table *t) { int supported; int err = 0; @@ -63,21 +63,21 @@ static int print_zns_list_ns(nvme_ns_t ns, struct table *t) static int print_zns_list(struct nvme_global_ctx *ctx, struct table *t) { int err = 0; - nvme_host_t h; - nvme_subsystem_t s; - nvme_ctrl_t c; - nvme_ns_t n; - - nvme_for_each_host(ctx, h) { - nvme_for_each_subsystem(h, s) { - nvme_subsystem_for_each_ns(s, n) { + libnvme_host_t h; + libnvme_subsystem_t s; + libnvme_ctrl_t c; + libnvme_ns_t n; + + libnvme_for_each_host(ctx, h) { + libnvme_for_each_subsystem(h, s) { + libnvme_subsystem_for_each_ns(s, n) { err = print_zns_list_ns(n, t); if (err) return err; } - nvme_subsystem_for_each_ctrl(s, c) { - nvme_ctrl_for_each_ns(c, n) { + libnvme_subsystem_for_each_ctrl(s, c) { + libnvme_ctrl_for_each_ns(c, n) { err = print_zns_list_ns(n, t); if (err) return err; @@ -106,13 +106,13 @@ static int list(int argc, char **argv, struct command *acmd, }; struct table *t = table_init_with_columns(columns, ARRAY_SIZE(columns)); - ctx = nvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); + ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); if (ctx) { fprintf(stderr, "Failed to create root object\n"); return -ENOMEM; } - err = nvme_scan_topology(ctx, NULL, NULL); + err = libnvme_scan_topology(ctx, NULL, NULL); if (err) { fprintf(stderr, "Failed to scan nvme subsystems\n"); return err; @@ -151,7 +151,7 @@ static int id_ctrl(int argc, char **argv, struct command *acmd, struct plugin *p return err; nvme_init_zns_identify_ctrl(&cmd, &ctrl); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err) nvme_show_zns_id_ctrl(&ctrl, flags); else if (err > 0) @@ -203,7 +203,7 @@ static int id_ns(int argc, char **argv, struct command *acmd, struct plugin *plu flags |= VERBOSE; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); return err; @@ -260,7 +260,7 @@ static int zns_mgmt_send(int argc, char **argv, struct command *acmd, struct plu return err; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); goto free; @@ -269,7 +269,7 @@ static int zns_mgmt_send(int argc, char **argv, struct command *acmd, struct plu nvme_init_zns_mgmt_send(&cmd, cfg.namespace_id, cfg.zslba, zsa, cfg.select_all, 0, 0, NULL, 0); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err) { if (zsa == NVME_ZNS_ZSA_RESET) zcapc = cmd.result & 0x1; @@ -359,7 +359,7 @@ static int zone_mgmt_send(int argc, char **argv, struct command *acmd, struct pl return errno; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); return err; @@ -413,7 +413,7 @@ static int zone_mgmt_send(int argc, char **argv, struct command *acmd, struct pl nvme_init_zns_mgmt_send(&cmd, cfg.namespace_id, cfg.zslba, cfg.zsa, cfg.select_all, cfg.zsaso, 0, buf, cfg.data_len); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err) printf("zone-mgmt-send: Success, action:%d zone:%"PRIx64" all:%d nsid:%d\n", cfg.zsa, (uint64_t)cfg.zslba, (int)cfg.select_all, cfg.namespace_id); @@ -476,7 +476,7 @@ static int open_zone(int argc, char **argv, struct command *acmd, struct plugin return errno; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); return err; @@ -486,7 +486,7 @@ static int open_zone(int argc, char **argv, struct command *acmd, struct plugin nvme_init_zns_mgmt_send(&cmd, cfg.namespace_id, cfg.zslba, NVME_ZNS_ZSA_OPEN, cfg.select_all, cfg.zrwaa, 0, NULL, 0); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err) printf("zns-open-zone: Success zone slba:%"PRIx64" nsid:%d\n", (uint64_t)cfg.zslba, cfg.namespace_id); @@ -546,7 +546,7 @@ static int set_zone_desc(int argc, char **argv, struct command *acmd, struct plu return errno; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); return err; @@ -585,7 +585,7 @@ static int set_zone_desc(int argc, char **argv, struct command *acmd, struct plu nvme_init_zns_mgmt_send(&cmd, cfg.namespace_id, cfg.zslba, NVME_ZNS_ZSA_SET_DESC_EXT, 0, cfg.zrwaa, 0, buf, data_len); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err) printf("set-zone-desc: Success, zone:%"PRIx64" nsid:%d\n", (uint64_t)cfg.zslba, cfg.namespace_id); @@ -628,7 +628,7 @@ static int zrwa_flush_zone(int argc, char **argv, struct command *acmd, struct p return errno; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); return err; @@ -637,7 +637,7 @@ static int zrwa_flush_zone(int argc, char **argv, struct command *acmd, struct p nvme_init_zns_mgmt_send(&cmd, cfg.namespace_id, cfg.lba, NVME_ZNS_ZSA_ZRWA_FLUSH, 0, 0, 0, NULL, 0); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err) printf("zrwa-flush-zone: Success, lba:%"PRIx64" nsid:%d\n", (uint64_t)cfg.lba, cfg.namespace_id); @@ -693,7 +693,7 @@ static int zone_mgmt_recv(int argc, char **argv, struct command *acmd, struct pl return err; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); return err; @@ -714,7 +714,7 @@ static int zone_mgmt_recv(int argc, char **argv, struct command *acmd, struct pl nvme_init_zns_mgmt_recv(&cmd, cfg.namespace_id, cfg.zslba, cfg.zra, cfg.zrasf, cfg.partial, data, cfg.data_len); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); if (!err) printf("zone-mgmt-recv: Success, action:%d zone:%"PRIx64" nsid:%d\n", cfg.zra, (uint64_t)cfg.zslba, cfg.namespace_id); @@ -793,7 +793,7 @@ static int report_zones(int argc, char **argv, struct command *acmd, struct plug flags |= VERBOSE; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); return err; @@ -830,7 +830,7 @@ static int report_zones(int argc, char **argv, struct command *acmd, struct plug nvme_init_zns_report_zones(&cmd, cfg.namespace_id, 0, cfg.state, false, false, buff, log_len); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err > 0) { nvme_show_status(err); goto free_buff; @@ -873,7 +873,7 @@ static int report_zones(int argc, char **argv, struct command *acmd, struct plug nvme_init_zns_report_zones(&cmd, cfg.namespace_id, offset, cfg.state, cfg.extended, cfg.partial, report, log_len); - err = nvme_submit_io_passthru(hdl, &cmd); + err = libnvme_submit_io_passthru(hdl, &cmd); if (err > 0) { nvme_show_status(err); break; @@ -966,7 +966,7 @@ static int zone_append(int argc, char **argv, struct command *acmd, struct plugi } if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); return err;; @@ -1061,7 +1061,7 @@ static int zone_append(int argc, char **argv, struct command *acmd, struct plugi nvme_init_zns_append(&cmd, cfg.namespace_id, cfg.zslba, nblocks, control, cev, dspec, buf, cfg.data_size, mbuf, cfg.metadata_size); - err = nvme_submit_admin_passthru(hdl, &cmd); + err = libnvme_submit_admin_passthru(hdl, &cmd); gettimeofday(&end_time, NULL); if (cfg.latency) printf(" latency: zone append: %llu us\n", @@ -1120,7 +1120,7 @@ static int changed_zone_list(int argc, char **argv, struct command *acmd, struct return err; if (!cfg.namespace_id) { - err = nvme_get_nsid(hdl, &cfg.namespace_id); + err = libnvme_get_nsid(hdl, &cfg.namespace_id); if (err < 0) { perror("get-namespace-id"); return err; diff --git a/unit/test-argconfig-parse.c b/unit/test-argconfig-parse.c index 29ab6907a8..5db83d7af1 100644 --- a/unit/test-argconfig-parse.c +++ b/unit/test-argconfig-parse.c @@ -11,7 +11,7 @@ #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) -const char *nvme_strerror(int errnum); +const char *libnvme_strerror(int errnum); static int test_rc; @@ -221,7 +221,7 @@ int main(void) setlocale(LC_NUMERIC, "C"); f = freopen("/dev/null", "w", stderr); if (!f) - printf("ERROR: reopening stderr failed: %s\n", nvme_strerror(errno)); + printf("ERROR: reopening stderr failed: %s\n", libnvme_strerror(errno)); for (i = 0; i < ARRAY_SIZE(toval_tests); i++) toval_test(&toval_tests[i]); diff --git a/util/argconfig.c b/util/argconfig.c index dded73c876..8557c82ae7 100644 --- a/util/argconfig.c +++ b/util/argconfig.c @@ -44,7 +44,7 @@ #include "cleanup.h" #include "suffix.h" -const char *nvme_strerror(int errnum); +const char *libnvme_strerror(int errnum); static bool is_null_or_empty(const char *s) { @@ -317,7 +317,7 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc, short_opts = calloc(options_count * 3 + 3, sizeof(*short_opts)); if (!long_opts || !short_opts) { - fprintf(stderr, "failed to allocate memory for opts: %s\n", nvme_strerror(errno)); + fprintf(stderr, "failed to allocate memory for opts: %s\n", libnvme_strerror(errno)); return -errno; } diff --git a/util/cleanup.h b/util/cleanup.h index 6ef3e87673..a163c5cc84 100644 --- a/util/cleanup.h +++ b/util/cleanup.h @@ -38,11 +38,11 @@ static inline void cleanup_fd(int *fd) static inline void cleanup_nvme_global_ctx(struct nvme_global_ctx **ctx) { - nvme_free_global_ctx(*ctx); + libnvme_free_global_ctx(*ctx); } #define _cleanup_nvme_global_ctx_ __cleanup__(cleanup_nvme_global_ctx) -static inline DEFINE_CLEANUP_FUNC(cleanup_nvme_ctrl, nvme_ctrl_t, nvme_free_ctrl) +static inline DEFINE_CLEANUP_FUNC(cleanup_nvme_ctrl, libnvme_ctrl_t, libnvme_free_ctrl) #define _cleanup_nvme_ctrl_ __cleanup__(cleanup_nvme_ctrl) #ifdef CONFIG_FABRICS diff --git a/util/types.c b/util/types.c index 0c58f175dd..5d17af48c1 100644 --- a/util/types.c +++ b/util/types.c @@ -151,7 +151,7 @@ const char *util_uuid_to_string(unsigned char uuid[NVME_UUID_LEN]) { static char uuid_str[NVME_UUID_LEN_STRING]; - nvme_uuid_to_string(uuid, uuid_str); + libnvme_uuid_to_string(uuid, uuid_str); return uuid_str; }