From 40d4ca2fad30d9b1422d6ddd3dc630e9effc863d Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Fri, 10 Apr 2026 12:05:44 +0000 Subject: [PATCH] libnvme: rename nvmf_ API prefix to libnvmf_ Use the libnvme_ prefix for the library fabrics API. This makes this part of the library consistent with the other parts. The spec API uses nvme_, the rest libnvme_. Signed-off-by: Daniel Wagner --- README.md | 2 +- fabrics.c | 88 ++++---- libnvme/README.md | 6 +- libnvme/examples/discover-loop.c | 14 +- libnvme/libnvme/nvme.i | 18 +- ...nvmf-accessors.ld => accessors-fabrics.ld} | 8 +- libnvme/src/libnvmf.ld | 80 +++---- libnvme/src/meson.build | 8 +- .../{nvmf-accessors.c => accessors-fabrics.c} | 18 +- .../{nvmf-accessors.h => accessors-fabrics.h} | 36 +-- libnvme/src/nvme/cleanup.h | 2 +- libnvme/src/nvme/fabrics.c | 204 ++++++++--------- libnvme/src/nvme/fabrics.h | 206 +++++++++--------- libnvme/src/nvme/json.c | 2 +- libnvme/src/nvme/private-fabrics.h | 4 +- libnvme/src/nvme/private.h | 24 +- libnvme/src/nvme/tree.c | 22 +- libnvme/src/nvme/util.c | 2 +- libnvme/src/nvme/util.h | 4 +- libnvme/test/ioctl/discovery.c | 10 +- libnvme/test/tree.c | 10 +- libnvme/test/uriparser.c | 2 +- libnvme/tools/check-public-symbols.py | 2 +- libnvme/tools/generator/meson.build | 6 +- nvme-print-json.c | 38 ++-- nvme-print-stdout.c | 38 ++-- plugins/nbft/nbft-plugin.c | 4 +- util/cleanup.h | 6 +- 28 files changed, 432 insertions(+), 432 deletions(-) rename libnvme/src/{nvmf-accessors.ld => accessors-fabrics.ld} (62%) rename libnvme/src/nvme/{nvmf-accessors.c => accessors-fabrics.c} (72%) rename libnvme/src/nvme/{nvmf-accessors.h => accessors-fabrics.h} (58%) diff --git a/README.md b/README.md index 1d6153717c..bf1cdadbc9 100644 --- a/README.md +++ b/README.md @@ -309,7 +309,7 @@ ABI-stable opaque structs. Two sets of accessors are maintained: | Set | Input header | Generated files | |-----|-------------|-----------------| | Common NVMe | `libnvme/src/nvme/private.h` | `src/nvme/accessors.{h,c}`, `src/accessors.ld` | -| NVMe-oF | `libnvme/src/nvme/private-fabrics.h` | `src/nvme/nvmf-accessors.{h,c}`, `src/nvmf-accessors.ld` | +| NVMe-oF | `libnvme/src/nvme/private-fabrics.h` | `src/nvme/accessors-fabrics.{h,c}`, `src/accessors-fabrics.ld` | The generated `.h` and `.c` files are committed to the source tree and are **not** regenerated during a normal build. To regenerate after modifying a diff --git a/fabrics.c b/fabrics.c index 34a71a30cd..14e7abfaaf 100644 --- a/fabrics.c +++ b/fabrics.c @@ -169,7 +169,7 @@ static void save_discovery_log(char *raw, struct nvmf_discovery_log *log) close(fd); } -static int setup_common_context(struct nvmf_context *fctx, +static int setup_common_context(struct libnvmf_context *fctx, struct nvmf_args *fa); struct cb_fabrics_data { @@ -181,18 +181,18 @@ struct cb_fabrics_data { FILE *f; }; -static bool cb_decide_retry(struct nvmf_context *fctx, int err, +static bool cb_decide_retry(struct libnvmf_context *fctx, int err, void *user_data) { if (err == -EAGAIN || (err == -EINTR && !nvme_sigint_received)) { - print_debug("nvmf_add_ctrl returned '%s'\n", libnvme_strerror(-err)); + print_debug("libnvmf_add_ctrl returned '%s'\n", libnvme_strerror(-err)); return true; } return false; } -static void cb_connected(struct nvmf_context *fctx, +static void cb_connected(struct libnvmf_context *fctx, struct libnvme_ctrl *c, void *user_data) { struct cb_fabrics_data *cfd = user_data; @@ -221,7 +221,7 @@ static void cb_connected(struct nvmf_context *fctx, #endif } -static void cb_already_connected(struct nvmf_context *fctx, +static void cb_already_connected(struct libnvmf_context *fctx, struct libnvme_host *host, const char *subsysnqn, const char *transport, const char *traddr, const char *trsvcid, void *user_data) @@ -234,7 +234,7 @@ static void cb_already_connected(struct nvmf_context *fctx, transport, traddr, trsvcid); } -static void cb_discovery_log(struct nvmf_context *fctx, +static void cb_discovery_log(struct libnvmf_context *fctx, bool connect, struct nvmf_discovery_log *log, uint64_t numrec, void *user_data) { @@ -246,7 +246,7 @@ static void cb_discovery_log(struct nvmf_context *fctx, nvme_show_discovery_log(log, numrec, cfd->flags); } -static int cb_parser_init(struct nvmf_context *dctx, void *user_data) +static int cb_parser_init(struct libnvmf_context *dctx, void *user_data) { struct cb_fabrics_data *cfd = user_data; @@ -265,7 +265,7 @@ static int cb_parser_init(struct nvmf_context *dctx, void *user_data) return 0; } -static void cb_parser_cleanup(struct nvmf_context *fctx, void *user_data) +static void cb_parser_cleanup(struct libnvmf_context *fctx, void *user_data) { struct cb_fabrics_data *cfd = user_data; @@ -273,7 +273,7 @@ static void cb_parser_cleanup(struct nvmf_context *fctx, void *user_data) fclose(cfd->f); } -static int cb_parser_next_line(struct nvmf_context *fctx, void *user_data) +static int cb_parser_next_line(struct libnvmf_context *fctx, void *user_data) { struct cb_fabrics_data *cfd = user_data; struct libnvme_fabrics_config cfg; @@ -308,37 +308,37 @@ static int cb_parser_next_line(struct nvmf_context *fctx, void *user_data) goto next; if (!fa.trsvcid) - fa.trsvcid = nvmf_get_default_trsvcid(fa.transport, true); + fa.trsvcid = libnvmf_get_default_trsvcid(fa.transport, true); ret = setup_common_context(fctx, &fa); if (ret) return ret; - ret = nvmf_context_set_fabrics_config(fctx, &cfg); + ret = libnvmf_context_set_fabrics_config(fctx, &cfg); if (ret) return ret; return 0; } -static int setup_common_context(struct nvmf_context *fctx, +static int setup_common_context(struct libnvmf_context *fctx, struct nvmf_args *fa) { int err; - err = nvmf_context_set_connection(fctx, + err = libnvmf_context_set_connection(fctx, fa->subsysnqn, fa->transport, fa->traddr, fa->trsvcid, fa->host_traddr, fa->host_iface); if (err) return err; - err = nvmf_context_set_hostnqn(fctx, + err = libnvmf_context_set_hostnqn(fctx, fa->hostnqn, fa->hostid); if (err) return err; - err = nvmf_context_set_crypto(fctx, + err = libnvmf_context_set_crypto(fctx, fa->hostkey, fa->ctrlkey, fa->keyring, fa->tls_key, fa->tls_key_identity); @@ -351,36 +351,36 @@ static int setup_common_context(struct nvmf_context *fctx, static int create_common_context(struct libnvme_global_ctx *ctx, bool persistent, struct nvmf_args *fa, struct libnvme_fabrics_config *cfg, - void *user_data, struct nvmf_context **fctxp) + void *user_data, struct libnvmf_context **fctxp) { - struct nvmf_context *fctx; + struct libnvmf_context *fctx; int err; - err = nvmf_context_create(ctx, cb_decide_retry, cb_connected, + err = libnvmf_context_create(ctx, cb_decide_retry, cb_connected, cb_already_connected, user_data, &fctx); if (err) return err; - err = nvmf_context_set_connection(fctx, fa->subsysnqn, + err = libnvmf_context_set_connection(fctx, fa->subsysnqn, fa->transport, fa->traddr, fa->trsvcid, fa->host_traddr, fa->host_iface); if (err) goto err; - err = nvmf_context_set_hostnqn(fctx, fa->hostnqn, fa->hostid); + err = libnvmf_context_set_hostnqn(fctx, fa->hostnqn, fa->hostid); if (err) goto err; - err = nvmf_context_set_fabrics_config(fctx, cfg); + err = libnvmf_context_set_fabrics_config(fctx, cfg); if (err) goto err; - err = nvmf_context_set_crypto(fctx, fa->hostkey, fa->ctrlkey, + err = libnvmf_context_set_crypto(fctx, fa->hostkey, fa->ctrlkey, fa->keyring, fa->tls_key, fa->tls_key_identity); if (err) goto err; - err = nvmf_context_set_persistent(fctx, persistent); + err = libnvmf_context_set_persistent(fctx, persistent); if (err) goto err; @@ -389,7 +389,7 @@ static int create_common_context(struct libnvme_global_ctx *ctx, return 0; err: - nvmf_context_free(fctx); + libnvmf_context_free(fctx); return err; } @@ -397,9 +397,9 @@ static int create_discovery_context(struct libnvme_global_ctx *ctx, bool persistent, const char *device, struct nvmf_args *fa, struct libnvme_fabrics_config *cfg, - void *user_data, struct nvmf_context **fctxp) + void *user_data, struct libnvmf_context **fctxp) { - struct nvmf_context *fctx; + struct libnvmf_context *fctx; int err; err = create_common_context(ctx, persistent, fa, cfg, user_data, @@ -407,17 +407,17 @@ static int create_discovery_context(struct libnvme_global_ctx *ctx, if (err) return err; - err = nvmf_context_set_discovery_cbs(fctx, cb_discovery_log, + err = libnvmf_context_set_discovery_cbs(fctx, cb_discovery_log, cb_parser_init, cb_parser_cleanup, cb_parser_next_line); if (err) goto err; - err = nvmf_context_set_discovery_defaults(fctx, MAX_DISC_RETRIES, + err = libnvmf_context_set_discovery_defaults(fctx, MAX_DISC_RETRIES, NVMF_DEF_DISC_TMO); if (err) goto err; - err = nvmf_context_set_device(fctx, device); + err = libnvmf_context_set_device(fctx, device); if (err) goto err; @@ -425,7 +425,7 @@ static int create_discovery_context(struct libnvme_global_ctx *ctx, return 0; err: - nvmf_context_free(fctx); + libnvmf_context_free(fctx); return err; } @@ -480,7 +480,7 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect) char *context = NULL; nvme_print_flags_t flags; _cleanup_nvme_global_ctx_ struct libnvme_global_ctx *ctx = NULL; - _cleanup_nvmf_context_ struct nvmf_context *fctx = NULL; + _cleanup_nvmf_context_ struct libnvmf_context *fctx = NULL; int ret; struct libnvme_fabrics_config cfg; struct nvmf_args fa = { .subsysnqn = NVME_DISC_SUBSYS_NAME }; @@ -503,7 +503,7 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect) OPT_STRING("nbft-path", 0, "STR", &nbft_path, "user-defined path for NBFT tables"), OPT_STRING("context", 0, "STR", &context, nvmf_context)); - nvmf_default_config(&cfg); + libnvmf_default_config(&cfg); ret = argconfig_parse(argc, argv, desc, opts); if (ret) @@ -561,22 +561,22 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect) if (!device && !fa.transport && !fa.traddr) { if (!nonbft) - ret = nvmf_discovery_nbft(ctx, fctx, + ret = libnvmf_discovery_nbft(ctx, fctx, connect, nbft_path); if (nbft) goto out_free; if (json_config) - ret = nvmf_discovery_config_json(ctx, fctx, + ret = libnvmf_discovery_config_json(ctx, fctx, connect, force); if (ret || access(PATH_NVMF_DISC, F_OK)) goto out_free; - ret = nvmf_discovery_config_file(ctx, fctx, connect, force); + ret = libnvmf_discovery_config_file(ctx, fctx, connect, force); goto out_free; } - ret = nvmf_discovery(ctx, fctx, connect, force); + ret = libnvmf_discovery(ctx, fctx, connect, force); out_free: if (dump_config) @@ -592,7 +592,7 @@ int fabrics_connect(const char *desc, int argc, char **argv) char *config_file = NULL; char *context = NULL; _cleanup_nvme_global_ctx_ struct libnvme_global_ctx *ctx = NULL; - _cleanup_nvmf_context_ struct nvmf_context *fctx = NULL; + _cleanup_nvmf_context_ struct libnvmf_context *fctx = NULL; _cleanup_nvme_ctrl_ libnvme_ctrl_t c = NULL; int ret; nvme_print_flags_t flags; @@ -604,7 +604,7 @@ int fabrics_connect(const char *desc, int argc, char **argv) OPT_FLAG("dump-config", 'O', &dump_config, "Dump JSON configuration to stdout"), OPT_STRING("context", 0, "STR", &context, nvmf_context)); - nvmf_default_config(&cfg); + libnvmf_default_config(&cfg); ret = argconfig_parse(argc, argv, desc, opts); if (ret) @@ -674,9 +674,9 @@ int fabrics_connect(const char *desc, int argc, char **argv) return ret; if (config_file) - return nvmf_connect_config_json(ctx, fctx); + return libnvmf_connect_config_json(ctx, fctx); - ret = nvmf_connect(ctx, fctx); + ret = libnvmf_connect(ctx, fctx); if (ret) { fprintf(stderr, "failed to connect: %s\n", libnvme_strerror(-ret)); @@ -900,7 +900,7 @@ int fabrics_config(const char *desc, int argc, char **argv) OPT_FLAG("dump", 'O', &dump_config, "Dump JSON configuration to stdout"), OPT_FLAG("update", 'U', &update_config, "Update JSON configuration file")); - nvmf_default_config(&cfg); + libnvmf_default_config(&cfg); ret = argconfig_parse(argc, argv, desc, opts); if (ret) @@ -931,7 +931,7 @@ int fabrics_config(const char *desc, int argc, char **argv) } if (modify_config) { - _cleanup_nvmf_context_ struct nvmf_context *fctx = NULL; + _cleanup_nvmf_context_ struct libnvmf_context *fctx = NULL; if (!fa.subsysnqn) { fprintf(stderr, @@ -950,7 +950,7 @@ int fabrics_config(const char *desc, int argc, char **argv) if (ret) return ret; - ret = nvmf_config_modify(ctx, fctx); + ret = libnvmf_config_modify(ctx, fctx); if (ret) { fprintf(stderr, "failed to update config\n"); return ret; @@ -982,7 +982,7 @@ static int dim_operation(libnvme_ctrl_t c, enum nvmf_dim_tas tas, const char *na __u32 result; t = (tas > NVMF_DIM_TAS_DEREGISTER || !task[tas]) ? "reserved" : task[tas]; - status = nvmf_register_ctrl(c, tas, &result); + status = libnvmf_register_ctrl(c, tas, &result); if (status == NVME_SC_SUCCESS) { printf("%s DIM %s command success\n", name, t); } else if (status < NVME_SC_SUCCESS) { diff --git a/libnvme/README.md b/libnvme/README.md index df77397abb..4b09cfc2a3 100644 --- a/libnvme/README.md +++ b/libnvme/README.md @@ -201,7 +201,7 @@ or PCIe-only) builds can exclude all fabrics code entirely. | Meson target | Input header | Generated files | |---|---|---| | `update-common-accessors` | `src/nvme/private.h` | `src/nvme/accessors.{h,c}`, `src/accessors.ld` | -| `update-fabrics-accessors` | `src/nvme/private-fabrics.h` | `src/nvme/nvmf-accessors.{h,c}`, `src/nvmf-accessors.ld` | +| `update-fabrics-accessors` | `src/nvme/private-fabrics.h` | `src/nvme/accessors-fabrics.{h,c}`, `src/accessors-fabrics.ld` | ### When to regenerate @@ -228,13 +228,13 @@ changes. Commit the updated files afterward: ```bash git add libnvme/src/nvme/accessors.h libnvme/src/nvme/accessors.c -git add libnvme/src/nvme/nvmf-accessors.h libnvme/src/nvme/nvmf-accessors.c +git add libnvme/src/nvme/accessors-fabrics.h libnvme/src/nvme/accessors-fabrics.c git commit -m "libnvme: regenerate accessors following changes" ``` ### Maintaining the .ld version-script files -The `.ld` files (`src/accessors.ld` and `src/nvmf-accessors.ld`) are GNU +The `.ld` files (`src/accessors.ld` and `src/accessors-fabrics.ld`) are GNU linker version scripts that control which accessor symbols are exported from the shared library and under which ABI version label they were introduced (e.g. `LIBNVME_ACCESSORS_3`, `LIBNVMF_ACCESSORS_3`). diff --git a/libnvme/examples/discover-loop.c b/libnvme/examples/discover-loop.c index 37702a22d2..e43232d77d 100644 --- a/libnvme/examples/discover-loop.c +++ b/libnvme/examples/discover-loop.c @@ -57,9 +57,9 @@ int main() libnvme_ctrl_t c; int ret; struct libnvme_fabrics_config cfg; - struct nvmf_discovery_args *args; + struct libnvmf_discovery_args *args; - nvmf_default_config(&cfg); + libnvmf_default_config(&cfg); ctx = libnvme_create_global_ctx(stdout, DEFAULT_LOGLEVEL); if (!ctx) @@ -81,17 +81,17 @@ int main() fprintf(stderr, "Failed to allocate memory\n"); return 1; } - ret = nvmf_add_ctrl(h, c, &cfg); + ret = libnvmf_add_ctrl(h, c, &cfg); if (ret) { fprintf(stderr, "no controller found\n"); return 1; } - ret = nvmf_discovery_args_create(&args); + ret = libnvmf_discovery_args_create(&args); if (!ret) { - nvmf_discovery_args_set_max_retries(args, 4); - ret = nvmf_get_discovery_log(c, args, &log); - nvmf_discovery_args_free(args); + libnvmf_discovery_args_set_max_retries(args, 4); + ret = libnvmf_get_discovery_log(c, args, &log); + libnvmf_discovery_args_free(args); } libnvme_disconnect_ctrl(c); diff --git a/libnvme/libnvme/nvme.i b/libnvme/libnvme/nvme.i index 11c3507481..49da2384fc 100644 --- a/libnvme/libnvme/nvme.i +++ b/libnvme/libnvme/nvme.i @@ -720,7 +720,7 @@ struct libnvme_ns { } Py_BEGIN_ALLOW_THREADS /* Release Python GIL */ - ret = nvmf_add_ctrl(h, $self, cfg); + ret = libnvmf_add_ctrl(h, $self, cfg); Py_END_ALLOW_THREADS /* Reacquire Python GIL */ if (ret) { @@ -752,7 +752,7 @@ struct libnvme_ns { %feature("autodoc", "@return: True if controller supports explicit registration. False otherwise.") is_registration_supported; bool is_registration_supported() { - return nvmf_is_registration_supported($self); + return libnvmf_is_registration_supported($self); } %feature("autodoc", "@return None on success or Error string on error.") registration_ctlr; @@ -761,7 +761,7 @@ struct libnvme_ns { int status; Py_BEGIN_ALLOW_THREADS /* Release Python GIL */ - status = nvmf_register_ctrl($self, NVMF_DIM_TAS_REGISTER, &result); + status = libnvmf_register_ctrl($self, NVMF_DIM_TAS_REGISTER, &result); Py_END_ALLOW_THREADS /* Reacquire Python GIL */ if (status != NVME_SC_SUCCESS) { @@ -778,21 +778,21 @@ struct libnvme_ns { %newobject discover; struct nvmf_discovery_log *discover(int lsp = 0, int max_retries = 6) { struct nvmf_discovery_log *logp = NULL; - struct nvmf_discovery_args *args = NULL; + struct libnvmf_discovery_args *args = NULL; if (!libnvme_ctrl_get_name($self)) { discover_err = 1; return NULL; } - discover_err = nvmf_discovery_args_create(&args); + discover_err = libnvmf_discovery_args_create(&args); if (discover_err) return NULL; - nvmf_discovery_args_set_lsp(args, lsp); - nvmf_discovery_args_set_max_retries(args, max_retries); + libnvmf_discovery_args_set_lsp(args, lsp); + libnvmf_discovery_args_set_max_retries(args, max_retries); Py_BEGIN_ALLOW_THREADS /* Release Python GIL */ - discover_err = nvmf_get_discovery_log($self, args, &logp); + discover_err = libnvmf_get_discovery_log($self, args, &logp); Py_END_ALLOW_THREADS /* Reacquire Python GIL */ - nvmf_discovery_args_free(args); + libnvmf_discovery_args_free(args); if (logp == NULL) discover_err = 2; return logp; diff --git a/libnvme/src/nvmf-accessors.ld b/libnvme/src/accessors-fabrics.ld similarity index 62% rename from libnvme/src/nvmf-accessors.ld rename to libnvme/src/accessors-fabrics.ld index b7aaf57c17..a5a7155721 100644 --- a/libnvme/src/nvmf-accessors.ld +++ b/libnvme/src/accessors-fabrics.ld @@ -10,8 +10,8 @@ LIBNVMF_ACCESSORS_3 { global: - nvmf_discovery_args_get_lsp; - nvmf_discovery_args_set_lsp; - nvmf_discovery_args_get_max_retries; - nvmf_discovery_args_set_max_retries; + libnvmf_discovery_args_get_lsp; + libnvmf_discovery_args_set_lsp; + libnvmf_discovery_args_get_max_retries; + libnvmf_discovery_args_set_max_retries; }; diff --git a/libnvme/src/libnvmf.ld b/libnvme/src/libnvmf.ld index 45b91f9224..c271e4fb15 100644 --- a/libnvme/src/libnvmf.ld +++ b/libnvme/src/libnvmf.ld @@ -2,46 +2,46 @@ LIBNVMF_3 { global: - nvmf_add_ctrl; - nvmf_adrfam_str; - nvmf_cms_str; - nvmf_config_modify; - nvmf_connect; - nvmf_connect_config_json; - nvmf_connect_ctrl; - nvmf_context_create; - nvmf_context_free; - nvmf_context_set_connection; - nvmf_context_set_crypto; - nvmf_context_set_device; - nvmf_context_set_discovery_cbs; - nvmf_context_set_discovery_defaults; - nvmf_context_set_fabrics_config; - nvmf_context_set_hostnqn; - nvmf_context_set_persistent; - nvmf_default_config; - nvmf_discovery; - nvmf_discovery_config_file; - nvmf_discovery_config_json; - nvmf_discovery_nbft; - nvmf_eflags_str; - nvmf_exat_ptr_next; - nvmf_free_uri; - nvmf_get_default_trsvcid; - nvmf_discovery_args_create; - nvmf_discovery_args_free; - nvmf_get_discovery_log; - nvmf_is_registration_supported; - nvmf_nbft_free; - nvmf_nbft_read_files; - nvmf_prtype_str; - nvmf_qptype_str; - nvmf_register_ctrl; - nvmf_sectype_str; - nvmf_subtype_str; - nvmf_treq_str; - nvmf_trtype_str; - nvmf_update_config; + libnvmf_add_ctrl; + libnvmf_adrfam_str; + libnvmf_cms_str; + libnvmf_config_modify; + libnvmf_connect; + libnvmf_connect_config_json; + libnvmf_connect_ctrl; + libnvmf_context_create; + libnvmf_context_free; + libnvmf_context_set_connection; + libnvmf_context_set_crypto; + libnvmf_context_set_device; + libnvmf_context_set_discovery_cbs; + libnvmf_context_set_discovery_defaults; + libnvmf_context_set_fabrics_config; + libnvmf_context_set_hostnqn; + libnvmf_context_set_persistent; + libnvmf_default_config; + libnvmf_discovery; + libnvmf_discovery_config_file; + libnvmf_discovery_config_json; + libnvmf_discovery_nbft; + libnvmf_eflags_str; + libnvmf_exat_ptr_next; + libnvmf_free_uri; + libnvmf_get_default_trsvcid; + libnvmf_discovery_args_create; + libnvmf_discovery_args_free; + libnvmf_get_discovery_log; + libnvmf_is_registration_supported; + libnvmf_nbft_free; + libnvmf_nbft_read_files; + libnvmf_prtype_str; + libnvmf_qptype_str; + libnvmf_register_ctrl; + libnvmf_sectype_str; + libnvmf_subtype_str; + libnvmf_treq_str; + libnvmf_trtype_str; + libnvmf_update_config; local: *; }; diff --git a/libnvme/src/meson.build b/libnvme/src/meson.build index d06873d718..5e7ec5b33c 100644 --- a/libnvme/src/meson.build +++ b/libnvme/src/meson.build @@ -45,12 +45,12 @@ if want_fabrics sources += [ 'nvme/fabrics.c', 'nvme/nbft.c', - 'nvme/nvmf-accessors.c', + 'nvme/accessors-fabrics.c', ] headers += [ 'nvme/fabrics.h', 'nvme/nbft.h', - 'nvme/nvmf-accessors.h', + 'nvme/accessors-fabrics.h', ] endif @@ -87,7 +87,7 @@ endif nvme_ld = meson.current_source_dir() / 'libnvme.ld' nvmf_ld = meson.current_source_dir() / 'libnvmf.ld' accessors_ld = meson.current_source_dir() / 'accessors.ld' -nvmf_accessors_ld = meson.current_source_dir() / 'nvmf-accessors.ld' +nvmf_accessors_ld = meson.current_source_dir() / 'accessors-fabrics.ld' link_args = [ '-Wl,--version-script=@0@'.format(nvme_ld), @@ -101,7 +101,7 @@ if want_fabrics '-Wl,--version-script=@0@'.format(nvmf_accessors_ld), ] libconf.set('FABRICS_INCLUDE', - '#include \n#include \n#include ') + '#include \n#include \n#include ') else libconf.set('FABRICS_INCLUDE', '') endif diff --git a/libnvme/src/nvme/nvmf-accessors.c b/libnvme/src/nvme/accessors-fabrics.c similarity index 72% rename from libnvme/src/nvme/nvmf-accessors.c rename to libnvme/src/nvme/accessors-fabrics.c index a021d551c5..e442ce6950 100644 --- a/libnvme/src/nvme/nvmf-accessors.c +++ b/libnvme/src/nvme/accessors-fabrics.c @@ -19,36 +19,36 @@ */ #include #include -#include "nvmf-accessors.h" +#include "accessors-fabrics.h" #include "private-fabrics.h" #include "compiler_attributes.h" /**************************************************************************** - * Accessors for: struct nvmf_discovery_args + * Accessors for: struct libnvmf_discovery_args ****************************************************************************/ -__public void nvmf_discovery_args_set_max_retries( - struct nvmf_discovery_args *p, +__public void libnvmf_discovery_args_set_max_retries( + struct libnvmf_discovery_args *p, int max_retries) { p->max_retries = max_retries; } -__public int nvmf_discovery_args_get_max_retries( - const struct nvmf_discovery_args *p) +__public int libnvmf_discovery_args_get_max_retries( + const struct libnvmf_discovery_args *p) { return p->max_retries; } -__public void nvmf_discovery_args_set_lsp( - struct nvmf_discovery_args *p, +__public void libnvmf_discovery_args_set_lsp( + struct libnvmf_discovery_args *p, __u8 lsp) { p->lsp = lsp; } -__public __u8 nvmf_discovery_args_get_lsp(const struct nvmf_discovery_args *p) +__public __u8 libnvmf_discovery_args_get_lsp(const struct libnvmf_discovery_args *p) { return p->lsp; } diff --git a/libnvme/src/nvme/nvmf-accessors.h b/libnvme/src/nvme/accessors-fabrics.h similarity index 58% rename from libnvme/src/nvme/nvmf-accessors.h rename to libnvme/src/nvme/accessors-fabrics.h index 25a0558802..4c628f1bbf 100644 --- a/libnvme/src/nvme/nvmf-accessors.h +++ b/libnvme/src/nvme/accessors-fabrics.h @@ -17,8 +17,8 @@ * To update run: meson compile -C [BUILD-DIR] update-accessors * Or: make update-accessors */ -#ifndef _NVMF_ACCESSORS_H_ -#define _NVMF_ACCESSORS_H_ +#ifndef _ACCESSORS_FABRICS_H_ +#define _ACCESSORS_FABRICS_H_ #include #include @@ -27,42 +27,42 @@ #include /* __u32, __u64, etc. */ /* Forward declarations. These are internal (opaque) structs. */ -struct nvmf_discovery_args; +struct libnvmf_discovery_args; /**************************************************************************** - * Accessors for: struct nvmf_discovery_args + * Accessors for: struct libnvmf_discovery_args ****************************************************************************/ /** - * nvmf_discovery_args_set_max_retries() - Set max_retries. - * @p: The &struct nvmf_discovery_args instance to update. + * libnvmf_discovery_args_set_max_retries() - Set max_retries. + * @p: The &struct libnvmf_discovery_args instance to update. * @max_retries: Value to assign to the max_retries field. */ -void nvmf_discovery_args_set_max_retries( - struct nvmf_discovery_args *p, +void libnvmf_discovery_args_set_max_retries( + struct libnvmf_discovery_args *p, int max_retries); /** - * nvmf_discovery_args_get_max_retries() - Get max_retries. - * @p: The &struct nvmf_discovery_args instance to query. + * libnvmf_discovery_args_get_max_retries() - Get max_retries. + * @p: The &struct libnvmf_discovery_args instance to query. * * Return: The value of the max_retries field. */ -int nvmf_discovery_args_get_max_retries(const struct nvmf_discovery_args *p); +int libnvmf_discovery_args_get_max_retries(const struct libnvmf_discovery_args *p); /** - * nvmf_discovery_args_set_lsp() - Set lsp. - * @p: The &struct nvmf_discovery_args instance to update. + * libnvmf_discovery_args_set_lsp() - Set lsp. + * @p: The &struct libnvmf_discovery_args instance to update. * @lsp: Value to assign to the lsp field. */ -void nvmf_discovery_args_set_lsp(struct nvmf_discovery_args *p, __u8 lsp); +void libnvmf_discovery_args_set_lsp(struct libnvmf_discovery_args *p, __u8 lsp); /** - * nvmf_discovery_args_get_lsp() - Get lsp. - * @p: The &struct nvmf_discovery_args instance to query. + * libnvmf_discovery_args_get_lsp() - Get lsp. + * @p: The &struct libnvmf_discovery_args instance to query. * * Return: The value of the lsp field. */ -__u8 nvmf_discovery_args_get_lsp(const struct nvmf_discovery_args *p); +__u8 libnvmf_discovery_args_get_lsp(const struct libnvmf_discovery_args *p); -#endif /* _NVMF_ACCESSORS_H_ */ +#endif /* _ACCESSORS_FABRICS_H_ */ diff --git a/libnvme/src/nvme/cleanup.h b/libnvme/src/nvme/cleanup.h index d4ee5705ba..61ff57d958 100644 --- a/libnvme/src/nvme/cleanup.h +++ b/libnvme/src/nvme/cleanup.h @@ -50,7 +50,7 @@ static inline DEFINE_CLEANUP_FUNC(cleanup_addrinfo, struct addrinfo *, freeaddri static inline void free_uri(struct libnvme_fabrics_uri **uri) { if (*uri) - nvmf_free_uri(*uri); + libnvmf_free_uri(*uri); } #define _cleanup_uri_ __cleanup__(free_uri) diff --git a/libnvme/src/nvme/fabrics.c b/libnvme/src/nvme/fabrics.c index 659bc3615f..6b7ec50430 100644 --- a/libnvme/src/nvme/fabrics.c +++ b/libnvme/src/nvme/fabrics.c @@ -70,7 +70,7 @@ const char * const trtypes[] = { [NVMF_TRTYPE_LOOP] = "loop", }; -__public const char *nvmf_trtype_str(__u8 trtype) +__public const char *libnvmf_trtype_str(__u8 trtype) { return arg_str(trtypes, ARRAY_SIZE(trtypes), trtype); } @@ -83,7 +83,7 @@ static const char * const adrfams[] = { [NVMF_ADDR_FAMILY_FC] = "fibre-channel", }; -__public const char *nvmf_adrfam_str(__u8 adrfam) +__public const char *libnvmf_adrfam_str(__u8 adrfam) { return arg_str(adrfams, ARRAY_SIZE(adrfams), adrfam); } @@ -94,7 +94,7 @@ static const char * const subtypes[] = { [NVME_NQN_CURR] = "current discovery subsystem", }; -__public const char *nvmf_subtype_str(__u8 subtype) +__public const char *libnvmf_subtype_str(__u8 subtype) { return arg_str(subtypes, ARRAY_SIZE(subtypes), subtype); } @@ -114,7 +114,7 @@ static const char * const treqs[] = { "sq flow control disable supported", }; -__public const char *nvmf_treq_str(__u8 treq) +__public const char *libnvmf_treq_str(__u8 treq) { return arg_str(treqs, ARRAY_SIZE(treqs), treq); } @@ -140,7 +140,7 @@ static const char * const eflags_strings[] = { "no cdc connectivity", }; -__public const char *nvmf_eflags_str(__u16 eflags) +__public const char *libnvmf_eflags_str(__u16 eflags) { return arg_str(eflags_strings, ARRAY_SIZE(eflags_strings), eflags); } @@ -151,7 +151,7 @@ static const char * const sectypes[] = { [NVMF_TCP_SECTYPE_TLS13] = "tls13", }; -__public const char *nvmf_sectype_str(__u8 sectype) +__public const char *libnvmf_sectype_str(__u8 sectype) { return arg_str(sectypes, ARRAY_SIZE(sectypes), sectype); } @@ -164,7 +164,7 @@ static const char * const prtypes[] = { [NVMF_RDMA_PRTYPE_IWARP] = "iwarp", }; -__public const char *nvmf_prtype_str(__u8 prtype) +__public const char *libnvmf_prtype_str(__u8 prtype) { return arg_str(prtypes, ARRAY_SIZE(prtypes), prtype); } @@ -174,7 +174,7 @@ static const char * const qptypes[] = { [NVMF_RDMA_QPTYPE_DATAGRAM] = "datagram", }; -__public const char *nvmf_qptype_str(__u8 qptype) +__public const char *libnvmf_qptype_str(__u8 qptype) { return arg_str(qptypes, ARRAY_SIZE(qptypes), qptype); } @@ -183,23 +183,23 @@ static const char * const cms[] = { [NVMF_RDMA_CMS_RDMA_CM] = "rdma-cm", }; -__public const char *nvmf_cms_str(__u8 cm) +__public const char *libnvmf_cms_str(__u8 cm) { return arg_str(cms, ARRAY_SIZE(cms), cm); } -__public int nvmf_context_create(struct libnvme_global_ctx *ctx, - bool (*decide_retry)(struct nvmf_context *fctx, int err, +__public int libnvmf_context_create(struct libnvme_global_ctx *ctx, + bool (*decide_retry)(struct libnvmf_context *fctx, int err, void *user_data), - void (*connected)(struct nvmf_context *fctx, + void (*connected)(struct libnvmf_context *fctx, struct libnvme_ctrl *c, void *user_data), - void (*already_connected)(struct nvmf_context *fctx, + void (*already_connected)(struct libnvmf_context *fctx, 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) + void *user_data, struct libnvmf_context **fctxp) { - struct nvmf_context *fctx; + struct libnvmf_context *fctx; fctx = calloc(1, sizeof(*fctx)); if (!fctx) @@ -217,22 +217,22 @@ __public int nvmf_context_create(struct libnvme_global_ctx *ctx, return 0; } -__public void nvmf_context_free(struct nvmf_context *fctx) +__public void libnvmf_context_free(struct libnvmf_context *fctx) { free(fctx->tls_key); free(fctx); } -__public int nvmf_context_set_discovery_cbs(struct nvmf_context *fctx, - void (*discovery_log)(struct nvmf_context *fctx, +__public int libnvmf_context_set_discovery_cbs(struct libnvmf_context *fctx, + void (*discovery_log)(struct libnvmf_context *fctx, bool connect, struct nvmf_discovery_log *log, uint64_t numrec, void *user_data), - int (*parser_init)(struct nvmf_context *fctx, + int (*parser_init)(struct libnvmf_context *fctx, void *user_data), - void (*parser_cleanup)(struct nvmf_context *fctx, + void (*parser_cleanup)(struct libnvmf_context *fctx, void *user_data), - int (*parser_next_line)(struct nvmf_context *fctx, + int (*parser_next_line)(struct libnvmf_context *fctx, void *user_data)) { fctx->discovery_log = discovery_log; @@ -243,7 +243,7 @@ __public int nvmf_context_set_discovery_cbs(struct nvmf_context *fctx, return 0; } -__public int nvmf_context_set_discovery_defaults(struct nvmf_context *fctx, +__public int libnvmf_context_set_discovery_defaults(struct libnvmf_context *fctx, int max_discovery_retries, int keep_alive_timeout) { fctx->default_max_discovery_retries = max_discovery_retries; @@ -252,7 +252,7 @@ __public int nvmf_context_set_discovery_defaults(struct nvmf_context *fctx, return 0; } -__public int nvmf_context_set_fabrics_config(struct nvmf_context *fctx, +__public int libnvmf_context_set_fabrics_config(struct libnvmf_context *fctx, struct libnvme_fabrics_config *cfg) { fctx->cfg = cfg; @@ -260,7 +260,7 @@ __public int nvmf_context_set_fabrics_config(struct nvmf_context *fctx, return 0; } -__public int nvmf_context_set_connection(struct nvmf_context *fctx, +__public int libnvmf_context_set_connection(struct libnvmf_context *fctx, const char *subsysnqn, const char *transport, const char *traddr, const char *trsvcid, const char *host_traddr, const char *host_iface) @@ -289,7 +289,7 @@ static const char *hostid_from_hostnqn(const char *hostnqn) return match + strlen("uuid:"); } -__public int nvmf_context_set_hostnqn(struct nvmf_context *fctx, +__public int libnvmf_context_set_hostnqn(struct libnvmf_context *fctx, const char *hostnqn, const char *hostid) { fctx->hostnqn = hostnqn; @@ -300,7 +300,7 @@ __public int nvmf_context_set_hostnqn(struct nvmf_context *fctx, return 0; } -__public int nvmf_context_set_crypto(struct nvmf_context *fctx, +__public int libnvmf_context_set_crypto(struct libnvmf_context *fctx, const char *hostkey, const char *ctrlkey, const char *keyring, const char *tls_key, const char *tls_key_identity) @@ -339,14 +339,14 @@ __public int nvmf_context_set_crypto(struct nvmf_context *fctx, return 0; } -__public int nvmf_context_set_persistent(struct nvmf_context *fctx, bool persistent) +__public int libnvmf_context_set_persistent(struct libnvmf_context *fctx, bool persistent) { fctx->persistent = persistent; return 0; } -__public int nvmf_context_set_device(struct nvmf_context *fctx, const char *device) +__public int libnvmf_context_set_device(struct libnvmf_context *fctx, const char *device) { fctx->device = device; @@ -415,7 +415,7 @@ static struct libnvme_fabrics_config *merge_config(libnvme_ctrl_t c, #define UPDATE_CFG_OPTION(c, n, o, d) \ if ((n)->o != d) (c)->o = (n)->o -__public void nvmf_update_config(libnvme_ctrl_t c, const struct libnvme_fabrics_config *cfg) +__public void libnvmf_update_config(libnvme_ctrl_t c, const struct libnvme_fabrics_config *cfg) { struct libnvme_fabrics_config *ctrl_cfg = libnvme_ctrl_get_config(c); @@ -1018,7 +1018,7 @@ static const char *lookup_context(struct libnvme_global_ctx *ctx, libnvme_ctrl_t libnvme_for_each_host(ctx, h) { libnvme_for_each_subsystem(h, s) { - struct nvmf_context fctx = { + struct libnvmf_context fctx = { .transport = libnvme_ctrl_get_transport(c), .traddr = libnvme_ctrl_get_traddr(c), .host_traddr = NULL, @@ -1034,7 +1034,7 @@ static const char *lookup_context(struct libnvme_global_ctx *ctx, libnvme_ctrl_t return NULL; } -__public int nvmf_add_ctrl(libnvme_host_t h, libnvme_ctrl_t c, +__public int libnvmf_add_ctrl(libnvme_host_t h, libnvme_ctrl_t c, const struct libnvme_fabrics_config *cfg) { libnvme_subsystem_t s; @@ -1049,7 +1049,7 @@ __public int nvmf_add_ctrl(libnvme_host_t h, libnvme_ctrl_t c, s = libnvme_lookup_subsystem(h, NULL, libnvme_ctrl_get_subsysnqn(c)); if (s) { libnvme_ctrl_t fc; - struct nvmf_context fctx = { + struct libnvmf_context fctx = { .transport = libnvme_ctrl_get_transport(c), .traddr = libnvme_ctrl_get_traddr(c), .host_traddr = libnvme_ctrl_get_host_traddr(c), @@ -1130,7 +1130,7 @@ __public int nvmf_add_ctrl(libnvme_host_t h, libnvme_ctrl_t c, return libnvme_init_ctrl(h, c, ret); } -__public int nvmf_connect_ctrl(libnvme_ctrl_t c) +__public int libnvmf_connect_ctrl(libnvme_ctrl_t c) { _cleanup_free_ char *argstr = NULL; int ret; @@ -1156,8 +1156,8 @@ static void nvmf_update_tls_concat(struct nvmf_disc_log_entry *e, if (e->treq & NVMF_TREQ_REQUIRED) { libnvme_msg(h->ctx, LOG_DEBUG, "setting --tls due to treq %s and sectype %s\n", - nvmf_treq_str(e->treq), - nvmf_sectype_str(e->tsas.tcp.sectype)); + libnvmf_treq_str(e->treq), + libnvmf_sectype_str(e->tsas.tcp.sectype)); c->cfg.tls = true; return; @@ -1166,8 +1166,8 @@ static void nvmf_update_tls_concat(struct nvmf_disc_log_entry *e, if (e->treq & NVMF_TREQ_NOT_REQUIRED) { libnvme_msg(h->ctx, LOG_DEBUG, "setting --concat due to treq %s and sectype %s\n", - nvmf_treq_str(e->treq), - nvmf_sectype_str(e->tsas.tcp.sectype)); + libnvmf_treq_str(e->treq), + libnvmf_sectype_str(e->tsas.tcp.sectype)); c->cfg.concat = true; return; @@ -1176,7 +1176,7 @@ static void nvmf_update_tls_concat(struct nvmf_disc_log_entry *e, static int nvmf_connect_disc_entry(libnvme_host_t h, struct nvmf_disc_log_entry *e, - struct nvmf_context *fctx, + struct libnvmf_context *fctx, const struct libnvme_fabrics_config *cfg, bool *discover, libnvme_ctrl_t *cp) { @@ -1220,7 +1220,7 @@ static int nvmf_connect_disc_entry(libnvme_host_t h, return -EINVAL; } - fctx->transport = nvmf_trtype_str(e->trtype); + fctx->transport = libnvmf_trtype_str(e->trtype); fctx->subsysnqn = e->subnqn; libnvme_msg(h->ctx, LOG_DEBUG, "lookup ctrl " @@ -1270,7 +1270,7 @@ static int nvmf_connect_disc_entry(libnvme_host_t h, /* update tls or concat */ nvmf_update_tls_concat(e, c, h); - ret = nvmf_add_ctrl(h, c, cfg); + ret = libnvmf_add_ctrl(h, c, cfg); if (!ret) { *cp = c; return 0; @@ -1281,7 +1281,7 @@ static int nvmf_connect_disc_entry(libnvme_host_t h, libnvme_msg(h->ctx, LOG_INFO, "failed to connect controller, " "retry with disabling SQ flow control\n"); c->cfg.disable_sqflow = false; - ret = nvmf_add_ctrl(h, c, cfg); + ret = libnvmf_add_ctrl(h, c, cfg); if (!ret) { *cp = c; return 0; @@ -1299,7 +1299,7 @@ static int nvmf_connect_disc_entry(libnvme_host_t h, #define DISCOVERY_HEADER_LEN 20 static int nvme_discovery_log(libnvme_ctrl_t ctrl, - const struct nvmf_discovery_args *args, + const struct libnvmf_discovery_args *args, struct nvmf_discovery_log **logp) { struct libnvme_global_ctx *ctx = ctrl->ctx; @@ -1422,9 +1422,9 @@ static void sanitize_discovery_log_entry(struct libnvme_global_ctx *ctx, } } -__public int nvmf_discovery_args_create(struct nvmf_discovery_args **argsp) +__public int libnvmf_discovery_args_create(struct libnvmf_discovery_args **argsp) { - struct nvmf_discovery_args *args; + struct libnvmf_discovery_args *args; if (!argsp) return -EINVAL; @@ -1440,16 +1440,16 @@ __public int nvmf_discovery_args_create(struct nvmf_discovery_args **argsp) return 0; } -__public void nvmf_discovery_args_free(struct nvmf_discovery_args *args) +__public void libnvmf_discovery_args_free(struct libnvmf_discovery_args *args) { free(args); } -__public int nvmf_get_discovery_log(libnvme_ctrl_t ctrl, - const struct nvmf_discovery_args *args, +__public int libnvmf_get_discovery_log(libnvme_ctrl_t ctrl, + const struct libnvmf_discovery_args *args, struct nvmf_discovery_log **logp) { - static const struct nvmf_discovery_args defaults = { + static const struct libnvmf_discovery_args defaults = { .max_retries = 6, .lsp = NVMF_LOG_DISC_LSP_NONE, }; @@ -1540,7 +1540,7 @@ static void nvmf_fill_die(struct nvmf_ext_die *die, struct libnvme_host *h, __u16 exatlen = nvmf_exat_len(symname_len); numexat++; - exat = nvmf_exat_ptr_next(exat); + exat = libnvmf_exat_ptr_next(exat); exat->exattype = cpu_to_le16(NVMF_EXATTYPE_SYMNAME); exat->exatlen = cpu_to_le16(exatlen); memcpy(exat->exatval, h->hostsymname, symname_len); @@ -1736,7 +1736,7 @@ static int nvme_fetch_cntrltype_dctype_from_id(libnvme_ctrl_t c) return 0; } -__public bool nvmf_is_registration_supported(libnvme_ctrl_t c) +__public bool libnvmf_is_registration_supported(libnvme_ctrl_t c) { if (!c->cntrltype || !c->dctype) if (nvme_fetch_cntrltype_dctype_from_id(c)) @@ -1745,9 +1745,9 @@ __public bool nvmf_is_registration_supported(libnvme_ctrl_t c) return !strcmp(c->dctype, "ddc") || !strcmp(c->dctype, "cdc"); } -__public int nvmf_register_ctrl(libnvme_ctrl_t c, enum nvmf_dim_tas tas, __u32 *result) +__public int libnvmf_register_ctrl(libnvme_ctrl_t c, enum nvmf_dim_tas tas, __u32 *result) { - if (!nvmf_is_registration_supported(c)) + if (!libnvmf_is_registration_supported(c)) return -ENOTSUP; /* We're registering our source address with the DC. To do @@ -1815,13 +1815,13 @@ __public int libnvme_parse_uri(const char *str, struct libnvme_fabrics_uri **uri if (sscanf(str, "%m[^:/]://%m[^/?#]%ms", &scheme, &authority, &path) < 2) { - nvmf_free_uri(uri); + libnvmf_free_uri(uri); return -EINVAL; } if (sscanf(scheme, "%m[^+]+%ms", &uri->scheme, &uri->protocol) < 1) { - nvmf_free_uri(uri); + libnvmf_free_uri(uri); return -EINVAL; } @@ -1839,7 +1839,7 @@ __public int libnvme_parse_uri(const char *str, struct libnvme_fabrics_uri **uri /* treat it as IPv4/hostname */ if (sscanf(host, "%m[^:]:%d", &h, &uri->port) < 1) { - nvmf_free_uri(uri); + libnvmf_free_uri(uri); return -EINVAL; } uri->host = unescape_uri(h, 0); @@ -1883,7 +1883,7 @@ __public int libnvme_parse_uri(const char *str, struct libnvme_fabrics_uri **uri return 0; } -__public void nvmf_free_uri(struct libnvme_fabrics_uri *uri) +__public void libnvmf_free_uri(struct libnvme_fabrics_uri *uri) { char **s; @@ -1901,7 +1901,7 @@ __public void nvmf_free_uri(struct libnvme_fabrics_uri *uri) free(uri); } -static libnvme_ctrl_t lookup_ctrl(libnvme_host_t h, struct nvmf_context *fctx) +static libnvme_ctrl_t lookup_ctrl(libnvme_host_t h, struct libnvmf_context *fctx) { libnvme_subsystem_t s; libnvme_ctrl_t c; @@ -1916,7 +1916,7 @@ static libnvme_ctrl_t lookup_ctrl(libnvme_host_t h, struct nvmf_context *fctx) } static int lookup_host(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, struct libnvme_host **host) + struct libnvmf_context *fctx, struct libnvme_host **host) { _cleanup_free_ char *hnqn = NULL; _cleanup_free_ char *hid = NULL; @@ -1936,21 +1936,21 @@ static int lookup_host(struct libnvme_global_ctx *ctx, return 0; } -static int setup_connection(struct nvmf_context *fctx, struct libnvme_host *h, +static int setup_connection(struct libnvmf_context *fctx, struct libnvme_host *h, bool discovery) { if (fctx->hostkey) libnvme_host_set_dhchap_host_key(h, fctx->hostkey); if (!fctx->trsvcid) - fctx->trsvcid = nvmf_get_default_trsvcid(fctx->transport, + fctx->trsvcid = libnvmf_get_default_trsvcid(fctx->transport, discovery); return 0; } -static int set_discovery_kato(struct nvmf_context *fctx, +static int set_discovery_kato(struct libnvmf_context *fctx, struct libnvme_fabrics_config *cfg) { int tmo = cfg->keep_alive_tmo; @@ -1995,7 +1995,7 @@ static void nvme_parse_tls_args(const char *keyring, const char *tls_key, static int _nvmf_discovery(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, bool connect, + struct libnvmf_context *fctx, bool connect, struct libnvme_ctrl *c) { _cleanup_free_ struct nvmf_discovery_log *log = NULL; @@ -2004,7 +2004,7 @@ static int _nvmf_discovery(struct libnvme_global_ctx *ctx, uint64_t numrec; int err; - struct nvmf_discovery_args args = { + struct libnvmf_discovery_args args = { .max_retries = fctx->default_max_discovery_retries, .lsp = NVMF_LOG_DISC_LSP_NONE, }; @@ -2031,10 +2031,10 @@ static int _nvmf_discovery(struct libnvme_global_ctx *ctx, bool disconnect; libnvme_ctrl_t child = { 0 }; int tmo = fctx->cfg->keep_alive_tmo; - struct nvmf_context nfctx = *fctx; + struct libnvmf_context nfctx = *fctx; nfctx.subsysnqn = e->subnqn; - nfctx.transport = nvmf_trtype_str(e->trtype); + nfctx.transport = libnvmf_trtype_str(e->trtype); nfctx.traddr = e->traddr; nfctx.trsvcid = e->trsvcid; nfctx.cfg = fctx->cfg; @@ -2099,7 +2099,7 @@ static int _nvmf_discovery(struct libnvme_global_ctx *ctx, struct nvmf_disc_log_entry *e = &log->entries[i]; nfctx.already_connected(&nfctx, h, e->subnqn, - nvmf_trtype_str(e->trtype), e->traddr, + libnvmf_trtype_str(e->trtype), e->traddr, e->trsvcid, nfctx.user_data); } } @@ -2107,7 +2107,7 @@ static int _nvmf_discovery(struct libnvme_global_ctx *ctx, return 0; } -__public const char *nvmf_get_default_trsvcid(const char *transport, +__public const char *libnvmf_get_default_trsvcid(const char *transport, bool discovery_ctrl) { if (!transport) @@ -2134,14 +2134,14 @@ static bool is_persistent_discovery_ctrl(libnvme_host_t h, libnvme_ctrl_t c) return false; } -static int libnvme_add_ctrl(struct nvmf_context *fctx, +static int libnvme_add_ctrl(struct libnvmf_context *fctx, struct libnvme_host *h, struct libnvme_ctrl *c, struct libnvme_fabrics_config *cfg) { int err; retry: - err = nvmf_add_ctrl(h, c, cfg); + err = libnvmf_add_ctrl(h, c, cfg); if (!err) return 0; if (fctx->decide_retry(fctx, err, fctx->user_data)) @@ -2151,7 +2151,7 @@ static int libnvme_add_ctrl(struct nvmf_context *fctx, } static int __create_discovery_ctrl(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, libnvme_host_t h, + struct libnvmf_context *fctx, libnvme_host_t h, struct libnvme_fabrics_config *cfg, struct libnvme_ctrl **ctrl) { libnvme_ctrl_t c; @@ -2184,7 +2184,7 @@ static int __create_discovery_ctrl(struct libnvme_global_ctx *ctx, } static int nvmf_create_discovery_ctrl(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, libnvme_host_t h, + struct libnvmf_context *fctx, libnvme_host_t h, struct libnvme_fabrics_config *cfg, struct libnvme_ctrl **ctrl) { @@ -2246,10 +2246,10 @@ static int nvmf_create_discovery_ctrl(struct libnvme_global_ctx *ctx, } int _discovery_config_json(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, libnvme_host_t h, libnvme_ctrl_t c, + struct libnvmf_context *fctx, libnvme_host_t h, libnvme_ctrl_t c, bool connect, bool force) { - struct nvmf_context nfctx = *fctx; + struct libnvmf_context nfctx = *fctx; struct libnvme_fabrics_config cfg; libnvme_ctrl_t cn; int ret = 0; @@ -2290,7 +2290,7 @@ int _discovery_config_json(struct libnvme_global_ctx *ctx, nfctx.trsvcid = libnvme_ctrl_get_trsvcid(c); if (!nfctx.trsvcid || !strcmp(nfctx.trsvcid, "")) nfctx.trsvcid = - nvmf_get_default_trsvcid(nfctx.transport, true); + libnvmf_get_default_trsvcid(nfctx.transport, true); if (force) nfctx.subsysnqn = libnvme_ctrl_get_subsysnqn(c); @@ -2323,8 +2323,8 @@ int _discovery_config_json(struct libnvme_global_ctx *ctx, return ret; } -__public int nvmf_discovery_config_json(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, bool connect, bool force) +__public int libnvmf_discovery_config_json(struct libnvme_global_ctx *ctx, + struct libnvmf_context *fctx, bool connect, bool force) { const char *hnqn, *hid; struct libnvme_subsystem *s; @@ -2371,8 +2371,8 @@ __public int nvmf_discovery_config_json(struct libnvme_global_ctx *ctx, return ret; } -__public int nvmf_connect_config_json(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx) +__public int libnvmf_connect_config_json(struct libnvme_global_ctx *ctx, + struct libnvmf_context *fctx) { const char *hnqn, *hid; const char *transport; @@ -2409,7 +2409,7 @@ __public int nvmf_connect_config_json(struct libnvme_global_ctx *ctx, strcmp(transport, "fc")) continue; - err = nvmf_connect_ctrl(c); + err = libnvmf_connect_ctrl(c); if (err) { if (err == -ENVME_CONNECT_ALREADY) continue; @@ -2430,8 +2430,8 @@ __public int nvmf_connect_config_json(struct libnvme_global_ctx *ctx, return ret; } -__public int nvmf_discovery_config_file(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, bool connect, bool force) +__public int libnvmf_discovery_config_file(struct libnvme_global_ctx *ctx, + struct libnvmf_context *fctx, bool connect, bool force) { struct libnvme_host *h; struct libnvme_ctrl *c; @@ -2454,7 +2454,7 @@ __public int nvmf_discovery_config_file(struct libnvme_global_ctx *ctx, if (err) break; - struct nvmf_context nfctx = *fctx; + struct libnvmf_context nfctx = *fctx; if (!force) { c = lookup_ctrl(h, &nfctx); @@ -2484,8 +2484,8 @@ __public int nvmf_discovery_config_file(struct libnvme_global_ctx *ctx, return 0; } -__public int nvmf_config_modify(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx) +__public int libnvmf_config_modify(struct libnvme_global_ctx *ctx, + struct libnvmf_context *fctx) { _cleanup_free_ char *hnqn = NULL; _cleanup_free_ char *hid = NULL; @@ -2526,7 +2526,7 @@ __public int nvmf_config_modify(struct libnvme_global_ctx *ctx, nvme_parse_tls_args(fctx->keyring, fctx->tls_key, fctx->tls_key_identity, fctx->cfg, c); - nvmf_update_config(c, fctx->cfg); + libnvmf_update_config(c, fctx->cfg); return 0; } @@ -2538,7 +2538,7 @@ static int nbft_filter(const struct dirent *dent) return !fnmatch(NBFT_SYSFS_FILENAME, dent->d_name, FNM_PATHNAME); } -__public int nvmf_nbft_read_files(struct libnvme_global_ctx *ctx, char *path, +__public int libnvmf_nbft_read_files(struct libnvme_global_ctx *ctx, char *path, struct nbft_file_entry **head) { struct nbft_file_entry *entry = NULL; @@ -2577,7 +2577,7 @@ __public int nvmf_nbft_read_files(struct libnvme_global_ctx *ctx, char *path, return 0; } -__public void nvmf_nbft_free(struct libnvme_global_ctx *ctx, struct nbft_file_entry *head) +__public void libnvmf_nbft_free(struct libnvme_global_ctx *ctx, struct nbft_file_entry *head) { while (head) { struct nbft_file_entry *next = head->next; @@ -2616,7 +2616,7 @@ static bool validate_uri(struct libnvme_global_ctx *ctx, } static int nbft_connect(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, struct libnvme_host *h, + struct libnvmf_context *fctx, struct libnvme_host *h, struct nvmf_disc_log_entry *e, struct nbft_info_subsystem_ns *ss, struct libnvme_fabrics_config *cfg) @@ -2645,7 +2645,7 @@ static int nbft_connect(struct libnvme_global_ctx *ctx, /* Update tls or concat */ nvmf_update_tls_concat(e, c, h); - ret = nvmf_add_ctrl(h, c, cfg); + ret = libnvmf_add_ctrl(h, c, cfg); /* Resume logging */ if (ss && ss->unavailable && saved_log_level < 1) @@ -2676,7 +2676,7 @@ static int nbft_connect(struct libnvme_global_ctx *ctx, } static int nbft_discovery(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, struct nbft_info_discovery *dd, + struct libnvmf_context *fctx, struct nbft_info_discovery *dd, struct libnvme_host *h, struct libnvme_ctrl *c, struct libnvme_fabrics_config *defcfg) { @@ -2684,7 +2684,7 @@ static int nbft_discovery(struct libnvme_global_ctx *ctx, int ret; int i; - struct nvmf_discovery_args args = { + struct libnvmf_discovery_args args = { .max_retries = 10 /* MAX_DISC_RETRIES */, .lsp = NVMF_LOG_DISC_LSP_NONE, }; @@ -2699,12 +2699,12 @@ static int nbft_discovery(struct libnvme_global_ctx *ctx, for (i = 0; i < le64_to_cpu(log->numrec); i++) { struct nvmf_disc_log_entry *e = &log->entries[i]; - struct nvmf_context nfctx = *fctx; + struct libnvmf_context nfctx = *fctx; libnvme_ctrl_t cl; int tmo = defcfg->keep_alive_tmo; nfctx.subsysnqn = e->subnqn; - nfctx.transport = nvmf_trtype_str(e->trtype); + nfctx.transport = libnvmf_trtype_str(e->trtype); nfctx.traddr = e->traddr; nfctx.trsvcid = e->trsvcid; @@ -2771,8 +2771,8 @@ static int nbft_discovery(struct libnvme_global_ctx *ctx, return 0; } -__public int nvmf_discovery_nbft(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, bool connect, char *nbft_path) +__public int libnvmf_discovery_nbft(struct libnvme_global_ctx *ctx, + struct libnvmf_context *fctx, bool connect, char *nbft_path) { const char *hostnqn = NULL, *hostid = NULL, *host_traddr = NULL; char uuid[NVME_UUID_LEN_STRING]; @@ -2795,7 +2795,7 @@ __public int nvmf_discovery_nbft(struct libnvme_global_ctx *ctx, /* TODO: print discovery-type info from NBFT tables */ return 0; - ret = nvmf_nbft_read_files(ctx, nbft_path, &entry); + ret = libnvmf_nbft_read_files(ctx, nbft_path, &entry); if (ret) { if (ret != -ENOENT) libnvme_msg(ctx, LOG_ERR, @@ -2833,7 +2833,7 @@ __public int nvmf_discovery_nbft(struct libnvme_global_ctx *ctx, /* Subsystem Namespace Descriptor List */ for (ss = entry->nbft->subsystem_ns_list; ss && *ss; ss++) for (i = 0; i < (*ss)->num_hfis; i++) { - struct nvmf_context nfctx = *fctx; + struct libnvmf_context nfctx = *fctx; hfi = (*ss)->hfis[i]; @@ -2897,7 +2897,7 @@ __public int nvmf_discovery_nbft(struct libnvme_global_ctx *ctx, for (dd = entry->nbft->discovery_list; dd && *dd; dd++) { _cleanup_uri_ struct libnvme_fabrics_uri *uri = NULL; _cleanup_free_ char *trsvcid = NULL; - struct nvmf_context nfctx = *fctx; + struct libnvmf_context nfctx = *fctx; bool persistent = false; bool linked = false; libnvme_ctrl_t c; @@ -2937,7 +2937,7 @@ __public int nvmf_discovery_nbft(struct libnvme_global_ctx *ctx, } } else trsvcid = - strdup(nvmf_get_default_trsvcid( + strdup(libnvmf_get_default_trsvcid( uri->protocol, true)); nfctx.subsysnqn = NVME_DISC_SUBSYS_NAME; @@ -2983,11 +2983,11 @@ __public int nvmf_discovery_nbft(struct libnvme_global_ctx *ctx, } } out_free: - nvmf_nbft_free(ctx, entry); + libnvmf_nbft_free(ctx, entry); return ret; } -__public int nvmf_discovery(struct libnvme_global_ctx *ctx, struct nvmf_context *fctx, +__public int libnvmf_discovery(struct libnvme_global_ctx *ctx, struct libnvmf_context *fctx, bool connect, bool force) { struct libnvme_ctrl *c = NULL; @@ -3082,7 +3082,7 @@ __public int nvmf_discovery(struct libnvme_global_ctx *ctx, struct nvmf_context return ret; } -__public int nvmf_connect(struct libnvme_global_ctx *ctx, struct nvmf_context *fctx) +__public int libnvmf_connect(struct libnvme_global_ctx *ctx, struct libnvmf_context *fctx) { struct libnvme_host *h; struct libnvme_ctrl *c; diff --git a/libnvme/src/nvme/fabrics.h b/libnvme/src/nvme/fabrics.h index 572ef07bcc..302e0a971e 100644 --- a/libnvme/src/nvme/fabrics.h +++ b/libnvme/src/nvme/fabrics.h @@ -89,7 +89,7 @@ struct libnvme_fabrics_uri { }; /** - * nvmf_trtype_str() - Decode TRTYPE field + * libnvmf_trtype_str() - Decode TRTYPE field * @trtype: value to be decoded * * Decode the transport type field in the discovery @@ -97,10 +97,10 @@ struct libnvme_fabrics_uri { * * Return: decoded string */ -const char *nvmf_trtype_str(__u8 trtype); +const char *libnvmf_trtype_str(__u8 trtype); /** - * nvmf_adrfam_str() - Decode ADRFAM field + * libnvmf_adrfam_str() - Decode ADRFAM field * @adrfam: value to be decoded * * Decode the address family field in the discovery @@ -108,10 +108,10 @@ const char *nvmf_trtype_str(__u8 trtype); * * Return: decoded string */ -const char *nvmf_adrfam_str(__u8 adrfam); +const char *libnvmf_adrfam_str(__u8 adrfam); /** - * nvmf_subtype_str() - Decode SUBTYPE field + * libnvmf_subtype_str() - Decode SUBTYPE field * @subtype: value to be decoded * * Decode the subsystem type field in the discovery @@ -119,10 +119,10 @@ const char *nvmf_adrfam_str(__u8 adrfam); * * Return: decoded string */ -const char *nvmf_subtype_str(__u8 subtype); +const char *libnvmf_subtype_str(__u8 subtype); /** - * nvmf_treq_str() - Decode TREQ field + * libnvmf_treq_str() - Decode TREQ field * @treq: value to be decoded * * Decode the transport requirements field in the @@ -130,10 +130,10 @@ const char *nvmf_subtype_str(__u8 subtype); * * Return: decoded string */ -const char *nvmf_treq_str(__u8 treq); +const char *libnvmf_treq_str(__u8 treq); /** - * nvmf_eflags_str() - Decode EFLAGS field + * libnvmf_eflags_str() - Decode EFLAGS field * @eflags: value to be decoded * * Decode the EFLAGS field in the discovery log page @@ -141,10 +141,10 @@ const char *nvmf_treq_str(__u8 treq); * * Return: decoded string */ -const char *nvmf_eflags_str(__u16 eflags); +const char *libnvmf_eflags_str(__u16 eflags); /** - * nvmf_sectype_str() - Decode SECTYPE field + * libnvmf_sectype_str() - Decode SECTYPE field * @sectype: value to be decoded * * Decode the SECTYPE field in the discovery log page @@ -152,10 +152,10 @@ const char *nvmf_eflags_str(__u16 eflags); * * Return: decoded string */ -const char *nvmf_sectype_str(__u8 sectype); +const char *libnvmf_sectype_str(__u8 sectype); /** - * nvmf_prtype_str() - Decode RDMA Provider type field + * libnvmf_prtype_str() - Decode RDMA Provider type field * @prtype: value to be decoded * * Decode the RDMA Provider type field in the discovery @@ -163,10 +163,10 @@ const char *nvmf_sectype_str(__u8 sectype); * * Return: decoded string */ -const char *nvmf_prtype_str(__u8 prtype); +const char *libnvmf_prtype_str(__u8 prtype); /** - * nvmf_qptype_str() - Decode RDMA QP Service type field + * libnvmf_qptype_str() - Decode RDMA QP Service type field * @qptype: value to be decoded * * Decode the RDMA QP Service type field in the discovery log page @@ -174,10 +174,10 @@ const char *nvmf_prtype_str(__u8 prtype); * * Return: decoded string */ -const char *nvmf_qptype_str(__u8 qptype); +const char *libnvmf_qptype_str(__u8 qptype); /** - * nvmf_cms_str() - Decode RDMA connection management service field + * libnvmf_cms_str() - Decode RDMA connection management service field * @cms: value to be decoded * * Decode the RDMA connection management service field in the discovery @@ -185,29 +185,29 @@ const char *nvmf_qptype_str(__u8 qptype); * * Return: decoded string */ -const char *nvmf_cms_str(__u8 cms); +const char *libnvmf_cms_str(__u8 cms); /** - * nvmf_default_config() - Default values for fabrics configuration + * libnvmf_default_config() - Default values for fabrics configuration * @cfg: config values to set * * Initializes @cfg with default values. */ -void nvmf_default_config(struct libnvme_fabrics_config *cfg); +void libnvmf_default_config(struct libnvme_fabrics_config *cfg); /** - * nvmf_update_config() - Update fabrics configuration values + * libnvmf_update_config() - Update fabrics configuration values * @c: Controller to be modified * @cfg: Updated configuration values * * 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(libnvme_ctrl_t c, +void libnvmf_update_config(libnvme_ctrl_t c, const struct libnvme_fabrics_config *cfg); /** - * nvmf_add_ctrl() - Connect a controller and update topology + * libnvmf_add_ctrl() - Connect a controller and update topology * @h: Host to which the controller should be attached * @c: Controller to be connected * @cfg: Default configuration for the controller @@ -218,11 +218,11 @@ void nvmf_update_config(libnvme_ctrl_t c, * * Return: 0 on success, or an error code on failure. */ -int nvmf_add_ctrl(libnvme_host_t h, libnvme_ctrl_t c, +int libnvmf_add_ctrl(libnvme_host_t h, libnvme_ctrl_t c, const struct libnvme_fabrics_config *cfg); /** - * nvmf_connect_ctrl() - Connect a controller + * libnvmf_connect_ctrl() - Connect a controller * @c: Controller to be connected * * Issues a 'connect' command to the NVMe-oF controller. @@ -230,36 +230,36 @@ int nvmf_add_ctrl(libnvme_host_t h, libnvme_ctrl_t c, * * Return: 0 on success, or an error code on failure. */ -int nvmf_connect_ctrl(libnvme_ctrl_t c); +int libnvmf_connect_ctrl(libnvme_ctrl_t c); /* - * struct nvmf_discovery_args - Opaque arguments for nvmf_get_discovery_log() + * struct libnvmf_discovery_args - Opaque arguments for libnvmf_get_discovery_log() * - * Allocate with nvmf_discovery_args_create() and release with - * nvmf_discovery_args_free(). Use the setter/getter accessors to configure + * Allocate with libnvmf_discovery_args_create() and release with + * libnvmf_discovery_args_free(). Use the setter/getter accessors to configure * fields; do not access members directly. */ -struct nvmf_discovery_args; +struct libnvmf_discovery_args; /** - * nvmf_discovery_args_create() - Allocate a discovery args object + * libnvmf_discovery_args_create() - Allocate a discovery args object * @argsp: On success, set to the newly allocated object * - * Allocates and initialises a &struct nvmf_discovery_args with sensible - * defaults. The caller must release it with nvmf_discovery_args_free(). + * Allocates and initialises a &struct libnvmf_discovery_args with sensible + * defaults. The caller must release it with libnvmf_discovery_args_free(). * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_discovery_args_create(struct nvmf_discovery_args **argsp); +int libnvmf_discovery_args_create(struct libnvmf_discovery_args **argsp); /** - * nvmf_discovery_args_free() - Release a discovery args object - * @args: Object previously returned by nvmf_discovery_args_create() + * libnvmf_discovery_args_free() - Release a discovery args object + * @args: Object previously returned by libnvmf_discovery_args_create() */ -void nvmf_discovery_args_free(struct nvmf_discovery_args *args); +void libnvmf_discovery_args_free(struct libnvmf_discovery_args *args); /** - * nvmf_get_discovery_log() - Fetch the NVMe-oF discovery log page + * libnvmf_get_discovery_log() - Fetch the NVMe-oF discovery log page * @ctrl: Discovery controller * @args: Optional arguments (pass NULL for defaults) * @logp: On success, set to the allocated log page (caller must free()) @@ -269,13 +269,13 @@ void nvmf_discovery_args_free(struct nvmf_discovery_args *args); * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_get_discovery_log(libnvme_ctrl_t ctrl, - const struct nvmf_discovery_args *args, +int libnvmf_get_discovery_log(libnvme_ctrl_t ctrl, + const struct libnvmf_discovery_args *args, struct nvmf_discovery_log **logp); /** - * nvmf_is_registration_supported - check whether registration can be performed. + * libnvmf_is_registration_supported - check whether registration can be performed. * @c: Controller instance * * Only discovery controllers (DC) that comply with TP8010 support @@ -287,10 +287,10 @@ int nvmf_get_discovery_log(libnvme_ctrl_t ctrl, * Return: true if controller supports explicit registration. false * otherwise. */ -bool nvmf_is_registration_supported(libnvme_ctrl_t c); +bool libnvmf_is_registration_supported(libnvme_ctrl_t c); /** - * nvmf_register_ctrl() - Perform registration task with a DC + * libnvmf_register_ctrl() - Perform registration task with a DC * @c: Controller instance * @tas: Task field of the Command Dword 10 (cdw10). Indicates whether to * perform a Registration, Deregistration, or Registration-update. @@ -302,7 +302,7 @@ bool nvmf_is_registration_supported(libnvme_ctrl_t c); * * Return: 0 on success, or an error code on failure. */ -int nvmf_register_ctrl(libnvme_ctrl_t c, enum nvmf_dim_tas tas, __u32 *result); +int libnvmf_register_ctrl(libnvme_ctrl_t c, enum nvmf_dim_tas tas, __u32 *result); /** * libnvme_parse_uri() - Parse the URI string @@ -320,15 +320,15 @@ int nvmf_register_ctrl(libnvme_ctrl_t c, enum nvmf_dim_tas tas, __u32 *result); int libnvme_parse_uri(const char *str, struct libnvme_fabrics_uri **uri); /** - * nvmf_free_uri() - Free the URI structure + * libnvmf_free_uri() - Free the URI structure * @uri: &libnvme_fabrics_uri structure * * Free an &libnvme_fabrics_uri structure. */ -void nvmf_free_uri(struct libnvme_fabrics_uri *uri); +void libnvmf_free_uri(struct libnvme_fabrics_uri *uri); /** - * nvmf_get_default_trsvcid() - Get default transport service ID + * libnvmf_get_default_trsvcid() - Get default transport service ID * @transport: Transport type string (e.g., "tcp", "rdma") * @discovery_ctrl: True if for discovery controller, false otherwise * @@ -337,18 +337,18 @@ void nvmf_free_uri(struct libnvme_fabrics_uri *uri); * * Return: Allocated string with default trsvcid, or NULL on failure. */ -const char *nvmf_get_default_trsvcid(const char *transport, +const char *libnvmf_get_default_trsvcid(const char *transport, bool discovery_ctrl); /* - * struct nvmf_context - Opaque context for fabrics operations + * struct libnvmf_context - Opaque context for fabrics operations * * Used to manage state and configuration for fabrics discovery and connect * operations. */ -struct nvmf_context; +struct libnvmf_context; /** - * nvmf_context_create() - Create a new fabrics context for discovery/connect + * libnvmf_context_create() - Create a new fabrics context for discovery/connect * @ctx: Global context * @decide_retry: Callback to decide if a retry should be attempted * @connected: Callback invoked when a connection is established @@ -361,30 +361,30 @@ struct nvmf_context; * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_context_create(struct libnvme_global_ctx *ctx, - bool (*decide_retry)(struct nvmf_context *fctx, int err, +int libnvmf_context_create(struct libnvme_global_ctx *ctx, + bool (*decide_retry)(struct libnvmf_context *fctx, int err, void *user_data), - void (*connected)(struct nvmf_context *fctx, + void (*connected)(struct libnvmf_context *fctx, struct libnvme_ctrl *c, void *user_data), - void (*already_connected)(struct nvmf_context *fctx, + void (*already_connected)(struct libnvmf_context *fctx, 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); + void *user_data, struct libnvmf_context **fctxp); /** - * nvmf_context_free() - Free a fabrics context + * libnvmf_context_free() - Free a fabrics context * @fctx: Fabrics context to free * * Releases all resources associated with @fctx. The context must have - * been previously created with nvmf_context_create(). + * been previously created with libnvmf_context_create(). * * After this call, @fctx must not be used. */ -void nvmf_context_free(struct nvmf_context *fctx); +void libnvmf_context_free(struct libnvmf_context *fctx); /** - * nvmf_context_set_discovery_cbs() - Set discovery callbacks for context + * libnvmf_context_set_discovery_cbs() - Set discovery callbacks for context * @fctx: Fabrics context * @discovery_log: Callback for discovery log events * @parser_init: Callback to initialize parser @@ -395,19 +395,19 @@ void nvmf_context_free(struct nvmf_context *fctx); * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_context_set_discovery_cbs(struct nvmf_context *fctx, - void (*discovery_log)(struct nvmf_context *fctx, +int libnvmf_context_set_discovery_cbs(struct libnvmf_context *fctx, + void (*discovery_log)(struct libnvmf_context *fctx, bool connect, struct nvmf_discovery_log *log, uint64_t numrec, void *user_data), - int (*parser_init)(struct nvmf_context *fctx, + int (*parser_init)(struct libnvmf_context *fctx, void *user_data), - void (*parser_cleanup)(struct nvmf_context *fctx, + void (*parser_cleanup)(struct libnvmf_context *fctx, void *user_data), - int (*parser_next_line)(struct nvmf_context *fctx, + int (*parser_next_line)(struct libnvmf_context *fctx, void *user_data)); /** - * nvmf_context_set_discovery_defaults() - Set default discovery parameters + * libnvmf_context_set_discovery_defaults() - Set default discovery parameters * @fctx: Fabrics context * @max_discovery_retries: Maximum number of discovery retries * @keep_alive_timeout: Keep-alive timeout in seconds @@ -416,11 +416,11 @@ int nvmf_context_set_discovery_cbs(struct nvmf_context *fctx, * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_context_set_discovery_defaults(struct nvmf_context *fctx, +int libnvmf_context_set_discovery_defaults(struct libnvmf_context *fctx, int max_discovery_retries, int keep_alive_timeout); /** - * nvmf_context_set_fabrics_config() - Set fabrics configuration for context + * libnvmf_context_set_fabrics_config() - Set fabrics configuration for context * @fctx: Fabrics context * @cfg: Fabrics configuration to apply * @@ -428,11 +428,11 @@ int nvmf_context_set_discovery_defaults(struct nvmf_context *fctx, * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_context_set_fabrics_config(struct nvmf_context *fctx, +int libnvmf_context_set_fabrics_config(struct libnvmf_context *fctx, struct libnvme_fabrics_config *cfg); /** - * nvmf_context_set_connection() - Set connection parameters for context + * libnvmf_context_set_connection() - Set connection parameters for context * @fctx: Fabrics context * @subsysnqn: Subsystem NQN * @transport: Transport type @@ -445,13 +445,13 @@ int nvmf_context_set_fabrics_config(struct nvmf_context *fctx, * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_context_set_connection(struct nvmf_context *fctx, +int libnvmf_context_set_connection(struct libnvmf_context *fctx, const char *subsysnqn, const char *transport, const char *traddr, const char *trsvcid, const char *host_traddr, const char *host_iface); /** - * nvmf_context_set_hostnqn() - Set host NQN and host ID for context + * libnvmf_context_set_hostnqn() - Set host NQN and host ID for context * @fctx: Fabrics context * @hostnqn: Host NQN * @hostid: Host identifier @@ -460,11 +460,11 @@ int nvmf_context_set_connection(struct nvmf_context *fctx, * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_context_set_hostnqn(struct nvmf_context *fctx, +int libnvmf_context_set_hostnqn(struct libnvmf_context *fctx, const char *hostnqn, const char *hostid); /** - * nvmf_context_set_crypto() - Set cryptographic parameters for context + * libnvmf_context_set_crypto() - Set cryptographic parameters for context * @fctx: Fabrics context * @hostkey: Host key * @ctrlkey: Controller key @@ -476,13 +476,13 @@ int nvmf_context_set_hostnqn(struct nvmf_context *fctx, * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_context_set_crypto(struct nvmf_context *fctx, +int libnvmf_context_set_crypto(struct libnvmf_context *fctx, const char *hostkey, const char *ctrlkey, const char *keyring, const char *tls_key, const char *tls_key_identity); /** - * nvmf_context_set_persistent() - Set persistence for context + * libnvmf_context_set_persistent() - Set persistence for context * @fctx: Fabrics context * @persistent: Whether to enable persistent connections * @@ -491,10 +491,10 @@ int nvmf_context_set_crypto(struct nvmf_context *fctx, * Return: 0 on success, or a negative error code on failure. */ -int nvmf_context_set_persistent(struct nvmf_context *fctx, bool persistent); +int libnvmf_context_set_persistent(struct libnvmf_context *fctx, bool persistent); /** - * nvmf_context_set_device() - Set device for context + * libnvmf_context_set_device() - Set device for context * @fctx: Fabrics context * @device: Device path or identifier * @@ -502,10 +502,10 @@ int nvmf_context_set_persistent(struct nvmf_context *fctx, bool persistent); * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_context_set_device(struct nvmf_context *fctx, const char *device); +int libnvmf_context_set_device(struct libnvmf_context *fctx, const char *device); /** - * nvmf_discovery() - Perform fabrics discovery + * libnvmf_discovery() - Perform fabrics discovery * @ctx: Global context * @fctx: Fabrics context * @connect: Whether to connect discovered subsystems @@ -515,11 +515,11 @@ int nvmf_context_set_device(struct nvmf_context *fctx, const char *device); * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_discovery(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, bool connect, bool force); +int libnvmf_discovery(struct libnvme_global_ctx *ctx, + struct libnvmf_context *fctx, bool connect, bool force); /** - * nvmf_discovery_config_json() - Perform discovery using JSON config + * libnvmf_discovery_config_json() - Perform discovery using JSON config * @ctx: Global context * @fctx: Fabrics context * @connect: Whether to connect discovered subsystems @@ -529,11 +529,11 @@ int nvmf_discovery(struct libnvme_global_ctx *ctx, * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_discovery_config_json(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, bool connect, bool force); +int libnvmf_discovery_config_json(struct libnvme_global_ctx *ctx, + struct libnvmf_context *fctx, bool connect, bool force); /** - * nvmf_discovery_config_file() - Perform discovery using config file + * libnvmf_discovery_config_file() - Perform discovery using config file * @ctx: Global context * @fctx: Fabrics context * @connect: Whether to connect discovered subsystems @@ -543,11 +543,11 @@ int nvmf_discovery_config_json(struct libnvme_global_ctx *ctx, * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_discovery_config_file(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, bool connect, bool force); +int libnvmf_discovery_config_file(struct libnvme_global_ctx *ctx, + struct libnvmf_context *fctx, bool connect, bool force); /** - * nvmf_discovery_nbft() - Perform discovery using NBFT + * libnvmf_discovery_nbft() - Perform discovery using NBFT * @ctx: Global context * @fctx: Fabrics context * @connect: Whether to connect discovered subsystems @@ -557,11 +557,11 @@ int nvmf_discovery_config_file(struct libnvme_global_ctx *ctx, * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_discovery_nbft(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, bool connect, char *nbft_path); +int libnvmf_discovery_nbft(struct libnvme_global_ctx *ctx, + struct libnvmf_context *fctx, bool connect, char *nbft_path); /** - * nvmf_connect() - Connect to fabrics subsystem + * libnvmf_connect() - Connect to fabrics subsystem * @ctx: Global context * @fctx: Fabrics context * @@ -569,10 +569,10 @@ int nvmf_discovery_nbft(struct libnvme_global_ctx *ctx, * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_connect(struct libnvme_global_ctx *ctx, struct nvmf_context *fctx); +int libnvmf_connect(struct libnvme_global_ctx *ctx, struct libnvmf_context *fctx); /** - * nvmf_connect_config_json() - Connect using JSON config + * libnvmf_connect_config_json() - Connect using JSON config * @ctx: Global context * @fctx: Fabrics context * @@ -580,11 +580,11 @@ int nvmf_connect(struct libnvme_global_ctx *ctx, struct nvmf_context *fctx); * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_connect_config_json(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx); +int libnvmf_connect_config_json(struct libnvme_global_ctx *ctx, + struct libnvmf_context *fctx); /** - * nvmf_config_modify() - Modify and update the configurtion + * libnvmf_config_modify() - Modify and update the configurtion * @ctx: Global context * @fctx: Fabrics context * @@ -593,13 +593,13 @@ int nvmf_connect_config_json(struct libnvme_global_ctx *ctx, * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_config_modify(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx); +int libnvmf_config_modify(struct libnvme_global_ctx *ctx, + struct libnvmf_context *fctx); struct nbft_file_entry; /** - * nvmf_nbft_read_files() - Read NBFT files from path + * libnvmf_nbft_read_files() - Read NBFT files from path * @ctx: struct libnvme_global_ctx object * @path: Path to NBFT files * @head: Pointer to store linked list of NBFT file entries @@ -608,17 +608,17 @@ struct nbft_file_entry; * * Return: 0 on success, or a negative error code on failure. */ -int nvmf_nbft_read_files(struct libnvme_global_ctx *ctx, char *path, +int libnvmf_nbft_read_files(struct libnvme_global_ctx *ctx, char *path, struct nbft_file_entry **head); /** - * nvmf_nbft_free() - Free NBFT file entry list + * libnvmf_nbft_free() - Free NBFT file entry list * @ctx: struct libnvme_global_ctx object * @head: Head of the NBFT file entry list * * Frees all memory associated with the NBFT file entry list. */ -void nvmf_nbft_free(struct libnvme_global_ctx *ctx, +void libnvmf_nbft_free(struct libnvme_global_ctx *ctx, struct nbft_file_entry *head); #endif /* _LIBNVME_FABRICS_H */ diff --git a/libnvme/src/nvme/json.c b/libnvme/src/nvme/json.c index cd81545308..c59ab96a3f 100644 --- a/libnvme/src/nvme/json.c +++ b/libnvme/src/nvme/json.c @@ -83,7 +83,7 @@ static void json_parse_port(libnvme_subsystem_t s, struct json_object *port_obj) { libnvme_ctrl_t c; struct json_object *attr_obj; - struct nvmf_context fctx = {}; + struct libnvmf_context fctx = {}; attr_obj = json_object_object_get(port_obj, "transport"); if (!attr_obj) diff --git a/libnvme/src/nvme/private-fabrics.h b/libnvme/src/nvme/private-fabrics.h index 936cca45f9..dd0a69957f 100644 --- a/libnvme/src/nvme/private-fabrics.h +++ b/libnvme/src/nvme/private-fabrics.h @@ -16,11 +16,11 @@ * * Structs in this file are NVMe-oF-specific (fabrics layer). They are kept * separate from private.h so that PCIe-only builds can exclude this entire - * file and its generated accessors (nvmf-accessors.{h,c}) along with the + * file and its generated accessors (accessors-fabrics.{h,c}) along with the * rest of the fabrics layer. */ -struct nvmf_discovery_args { /*!generate-accessors*/ +struct libnvmf_discovery_args { /*!generate-accessors*/ int max_retries; __u8 lsp; }; diff --git a/libnvme/src/nvme/private.h b/libnvme/src/nvme/private.h index b392c8ccd6..eaf20eb2a9 100644 --- a/libnvme/src/nvme/private.h +++ b/libnvme/src/nvme/private.h @@ -306,29 +306,29 @@ struct libnvme_global_ctx { #endif }; -struct nvmf_context { +struct libnvmf_context { struct libnvme_global_ctx *ctx; /* common callbacks */ - bool (*decide_retry)(struct nvmf_context *fctx, int err, + bool (*decide_retry)(struct libnvmf_context *fctx, int err, void *user_data); - void (*connected)(struct nvmf_context *fctx, struct libnvme_ctrl *c, + void (*connected)(struct libnvmf_context *fctx, struct libnvme_ctrl *c, void *user_data); - void (*already_connected)(struct nvmf_context *fctx, + void (*already_connected)(struct libnvmf_context *fctx, struct libnvme_host *host, const char *subsysnqn, const char *transport, const char *traddr, const char *trsvcid, void *user_data); /* discovery callbacks */ - void (*discovery_log)(struct nvmf_context *fctx, + void (*discovery_log)(struct libnvmf_context *fctx, bool connect, struct nvmf_discovery_log *log, uint64_t numrec, void *user_data); - int (*parser_init)(struct nvmf_context *fctx, + int (*parser_init)(struct libnvmf_context *fctx, void *user_data); - void (*parser_cleanup)(struct nvmf_context *fctx, + void (*parser_cleanup)(struct libnvmf_context *fctx, void *user_data); - int (*parser_next_line)(struct nvmf_context *fctx, + int (*parser_next_line)(struct libnvmf_context *fctx, void *user_data); /* discovery defaults */ @@ -387,10 +387,10 @@ int __libnvme_transport_handle_init_mi(struct libnvme_transport_handle *hdl); void __libnvme_transport_handle_close_mi(struct libnvme_transport_handle *hdl); int _libnvme_create_ctrl(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, + struct libnvmf_context *fctx, libnvme_ctrl_t *cp); bool _libnvme_ctrl_match_config(struct libnvme_ctrl *c, - struct nvmf_context *fctx); + struct libnvmf_context *fctx); void *__libnvme_alloc(size_t len); @@ -401,9 +401,9 @@ libnvme_host_t libnvme_lookup_host(struct libnvme_global_ctx *ctx, libnvme_subsystem_t libnvme_lookup_subsystem(struct libnvme_host *h, const char *name, const char *subsysnqn); libnvme_ctrl_t libnvme_lookup_ctrl(libnvme_subsystem_t s, - struct nvmf_context *fctx, libnvme_ctrl_t p); + struct libnvmf_context *fctx, libnvme_ctrl_t p); libnvme_ctrl_t libnvme_ctrl_find(libnvme_subsystem_t s, - struct nvmf_context *fctx); + struct libnvmf_context *fctx); void __libnvme_free_host(libnvme_host_t h); diff --git a/libnvme/src/nvme/tree.c b/libnvme/src/nvme/tree.c index 2a05b1e6ec..a3a2f38fad 100644 --- a/libnvme/src/nvme/tree.c +++ b/libnvme/src/nvme/tree.c @@ -1081,7 +1081,7 @@ static bool traddr_is_hostname(const char *transport, const char *traddr) return true; } -__public void nvmf_default_config(struct libnvme_fabrics_config *cfg) +__public void libnvmf_default_config(struct libnvme_fabrics_config *cfg) { memset(cfg, 0, sizeof(*cfg)); cfg->tos = -1; @@ -1089,7 +1089,7 @@ __public void nvmf_default_config(struct libnvme_fabrics_config *cfg) } int _libnvme_create_ctrl(struct libnvme_global_ctx *ctx, - struct nvmf_context *fctx, libnvme_ctrl_t *cp) + struct libnvmf_context *fctx, libnvme_ctrl_t *cp) { struct libnvme_ctrl *c; @@ -1114,7 +1114,7 @@ int _libnvme_create_ctrl(struct libnvme_global_ctx *ctx, c->ctx = ctx; c->hdl = NULL; - nvmf_default_config(&c->cfg); + libnvmf_default_config(&c->cfg); list_head_init(&c->namespaces); list_head_init(&c->paths); list_node_init(&c->entry); @@ -1144,7 +1144,7 @@ __public int libnvme_create_ctrl(struct libnvme_global_ctx *ctx, const char *host_iface, const char *trsvcid, libnvme_ctrl_t *cp) { - struct nvmf_context fctx = { + struct libnvmf_context fctx = { .transport = transport, .traddr = traddr, .host_traddr = host_traddr, @@ -1443,7 +1443,7 @@ static bool _match_ctrl(struct libnvme_ctrl *c, * controller to the candidate controller. */ static ctrl_match_t _candidate_init(struct libnvme_global_ctx *ctx, - struct candidate_args *candidate, struct nvmf_context *fctx) + struct candidate_args *candidate, struct libnvmf_context *fctx) { memset(candidate, 0, sizeof(*candidate)); @@ -1485,7 +1485,7 @@ static ctrl_match_t _candidate_init(struct libnvme_global_ctx *ctx, } static libnvme_ctrl_t __nvme_ctrl_find(libnvme_subsystem_t s, - struct nvmf_context *fctx, libnvme_ctrl_t p) + struct libnvmf_context *fctx, libnvme_ctrl_t p) { struct candidate_args candidate = {}; struct libnvme_ctrl *c, *matching_c = NULL; @@ -1506,7 +1506,7 @@ static libnvme_ctrl_t __nvme_ctrl_find(libnvme_subsystem_t s, } bool _libnvme_ctrl_match_config(struct libnvme_ctrl *c, - struct nvmf_context *fctx) + struct libnvmf_context *fctx) { struct candidate_args candidate = {}; ctrl_match_t ctrl_match; @@ -1522,7 +1522,7 @@ __public bool libnvme_ctrl_match_config(struct libnvme_ctrl *c, const char *subsysnqn, const char *host_traddr, const char *host_iface) { - struct nvmf_context fctx = { + struct libnvmf_context fctx = { .transport = transport, .traddr = traddr, .host_traddr = host_traddr, @@ -1535,13 +1535,13 @@ __public bool libnvme_ctrl_match_config(struct libnvme_ctrl *c, } libnvme_ctrl_t libnvme_ctrl_find(libnvme_subsystem_t s, - struct nvmf_context *fctx) + struct libnvmf_context *fctx) { return __nvme_ctrl_find(s, fctx, NULL/*p*/); } libnvme_ctrl_t libnvme_lookup_ctrl(libnvme_subsystem_t s, - struct nvmf_context *fctx, + struct libnvmf_context *fctx, libnvme_ctrl_t p) { struct libnvme_global_ctx *ctx; @@ -1942,7 +1942,7 @@ int libnvme_ctrl_alloc(struct libnvme_global_ctx *ctx, libnvme_subsystem_t s, skip_address: p = NULL; do { - struct nvmf_context fctx = { + struct libnvmf_context fctx = { .transport = transport, .traddr = traddr, .host_traddr = host_traddr, diff --git a/libnvme/src/nvme/util.c b/libnvme/src/nvme/util.c index 25d1847e5a..47138d8064 100644 --- a/libnvme/src/nvme/util.c +++ b/libnvme/src/nvme/util.c @@ -706,7 +706,7 @@ size_t get_entity_version(char *buffer, size_t bufsz) return num_bytes; } -__public struct nvmf_ext_attr *nvmf_exat_ptr_next(struct nvmf_ext_attr *p) +__public struct nvmf_ext_attr *libnvmf_exat_ptr_next(struct nvmf_ext_attr *p) { return (struct nvmf_ext_attr *) ((uintptr_t)p + (ptrdiff_t)nvmf_exat_size(le16_to_cpu(p->exatlen))); diff --git a/libnvme/src/nvme/util.h b/libnvme/src/nvme/util.h index abd515171f..5ff0a655d6 100644 --- a/libnvme/src/nvme/util.h +++ b/libnvme/src/nvme/util.h @@ -187,7 +187,7 @@ const char *libnvme_errno_to_string(int err); const char *libnvme_strerror(int err); /** - * nvmf_exat_ptr_next - Increment @p to the next element in the array. + * libnvmf_exat_ptr_next - Increment @p to the next element in the array. * @p: Pointer to an element of an array of "struct nvmf_ext_attr". * * Extended attributes are saved to an array of "struct nvmf_ext_attr" @@ -198,7 +198,7 @@ const char *libnvme_strerror(int err); * * Return: Pointer to the next element in the array. */ -struct nvmf_ext_attr *nvmf_exat_ptr_next(struct nvmf_ext_attr *p); +struct nvmf_ext_attr *libnvmf_exat_ptr_next(struct nvmf_ext_attr *p); /** * enum libnvme_version - Selector for version to be returned by diff --git a/libnvme/test/ioctl/discovery.c b/libnvme/test/ioctl/discovery.c index a408c41046..452cb9d5ab 100644 --- a/libnvme/test/ioctl/discovery.c +++ b/libnvme/test/ioctl/discovery.c @@ -42,15 +42,15 @@ static int fetch_discovery_log(libnvme_ctrl_t c, struct nvmf_discovery_log **logp, int max_retries) { - struct nvmf_discovery_args *args; + struct libnvmf_discovery_args *args; int err; - err = nvmf_discovery_args_create(&args); + err = libnvmf_discovery_args_create(&args); if (err) return err; - nvmf_discovery_args_set_max_retries(args, max_retries); - err = nvmf_get_discovery_log(c, args, logp); - nvmf_discovery_args_free(args); + libnvmf_discovery_args_set_max_retries(args, max_retries); + err = libnvmf_get_discovery_log(c, args, logp); + libnvmf_discovery_args_free(args); return err; } diff --git a/libnvme/test/tree.c b/libnvme/test/tree.c index 71143bafee..3a739dc0f8 100644 --- a/libnvme/test/tree.c +++ b/libnvme/test/tree.c @@ -17,7 +17,7 @@ struct test_data { /* input data */ - struct nvmf_context f; + struct libnvmf_context f; const char *subsysname; /* track controller generated by input data */ @@ -173,7 +173,7 @@ static bool tcp_ctrl_lookup(libnvme_subsystem_t s, struct test_data *d) { libnvme_ctrl_t c; bool pass = true; - struct nvmf_context f = d->f; + struct libnvmf_context f = d->f; f.host_traddr = NULL; f.host_iface = NULL; @@ -220,7 +220,7 @@ static bool default_ctrl_lookup(libnvme_subsystem_t s, struct test_data *d) { libnvme_ctrl_t c; bool pass = true; - struct nvmf_context f = d->f; + struct libnvmf_context f = d->f; f.host_iface = NULL; f.trsvcid = NULL; @@ -280,7 +280,7 @@ static bool test_lookup(void) static bool test_src_addr() { struct libnvme_global_ctx *ctx; - struct nvmf_context fctx = { + struct libnvmf_context fctx = { .transport = "tcp", .traddr = "192.168.56.1", .host_traddr = NULL, @@ -431,7 +431,7 @@ static bool test_src_addr() } struct ctrl_args { - struct nvmf_context f; + struct libnvmf_context f; const char *address; }; diff --git a/libnvme/test/uriparser.c b/libnvme/test/uriparser.c index 664c35a8c0..25077cab99 100644 --- a/libnvme/test/uriparser.c +++ b/libnvme/test/uriparser.c @@ -191,7 +191,7 @@ static void test_uriparser(void) assert(strcmp(d->frag, parsed_data->fragment) == 0); } else assert(d->frag == parsed_data->fragment); - nvmf_free_uri(parsed_data); + libnvmf_free_uri(parsed_data); printf(" OK\n"); } } diff --git a/libnvme/tools/check-public-symbols.py b/libnvme/tools/check-public-symbols.py index ff387ee58a..1efb02b19a 100644 --- a/libnvme/tools/check-public-symbols.py +++ b/libnvme/tools/check-public-symbols.py @@ -38,7 +38,7 @@ ROOT / 'src' / 'libnvme.ld', ROOT / 'src' / 'libnvmf.ld', ROOT / 'src' / 'accessors.ld', - ROOT / 'src' / 'nvmf-accessors.ld', + ROOT / 'src' / 'accessors-fabrics.ld', ] # --------------------------------------------------------------------------- diff --git a/libnvme/tools/generator/meson.build b/libnvme/tools/generator/meson.build index 113d2f318a..e282043f92 100644 --- a/libnvme/tools/generator/meson.build +++ b/libnvme/tools/generator/meson.build @@ -46,9 +46,9 @@ _tgt_fabrics = run_target( 'update-accessors.sh', _py3, files('generate-accessors.py'), - libnvme_src_nvme / 'nvmf-accessors.h', - libnvme_src_nvme / 'nvmf-accessors.c', - libnvme_src / 'nvmf-accessors.ld', + libnvme_src_nvme / 'accessors-fabrics.h', + libnvme_src_nvme / 'accessors-fabrics.c', + libnvme_src / 'accessors-fabrics.ld', libnvme_src_nvme / 'private-fabrics.h', ], ) diff --git a/nvme-print-json.c b/nvme-print-json.c index 57b956fbcb..91a82f3b64 100644 --- a/nvme-print-json.c +++ b/nvme-print-json.c @@ -5203,25 +5203,25 @@ static void json_discovery_log(struct nvmf_discovery_log *log, int numrec) struct nvmf_disc_log_entry *e = &log->entries[i]; struct json_object *entry = json_create_object(); - obj_add_str(entry, "trtype", nvmf_trtype_str(e->trtype)); - obj_add_str(entry, "adrfam", nvmf_adrfam_str(e->adrfam)); - obj_add_str(entry, "subtype", nvmf_subtype_str(e->subtype)); - obj_add_str(entry, "treq", nvmf_treq_str(e->treq)); + obj_add_str(entry, "trtype", libnvmf_trtype_str(e->trtype)); + obj_add_str(entry, "adrfam", libnvmf_adrfam_str(e->adrfam)); + obj_add_str(entry, "subtype", libnvmf_subtype_str(e->subtype)); + obj_add_str(entry, "treq", libnvmf_treq_str(e->treq)); obj_add_uint(entry, "portid", le16_to_cpu(e->portid)); obj_add_str(entry, "trsvcid", e->trsvcid); obj_add_str(entry, "subnqn", e->subnqn); obj_add_str(entry, "traddr", e->traddr); - obj_add_str(entry, "eflags", nvmf_eflags_str(le16_to_cpu(e->eflags))); + obj_add_str(entry, "eflags", libnvmf_eflags_str(le16_to_cpu(e->eflags))); switch (e->trtype) { case NVMF_TRTYPE_RDMA: - obj_add_str(entry, "rdma_prtype", nvmf_prtype_str(e->tsas.rdma.prtype)); - obj_add_str(entry, "rdma_qptype", nvmf_qptype_str(e->tsas.rdma.qptype)); - obj_add_str(entry, "rdma_cms", nvmf_cms_str(e->tsas.rdma.cms)); + obj_add_str(entry, "rdma_prtype", libnvmf_prtype_str(e->tsas.rdma.prtype)); + obj_add_str(entry, "rdma_qptype", libnvmf_qptype_str(e->tsas.rdma.qptype)); + obj_add_str(entry, "rdma_cms", libnvmf_cms_str(e->tsas.rdma.cms)); obj_add_uint(entry, "rdma_pkey", le16_to_cpu(e->tsas.rdma.pkey)); break; case NVMF_TRTYPE_TCP: - obj_add_str(entry, "sectype", nvmf_sectype_str(e->tsas.tcp.sectype)); + obj_add_str(entry, "sectype", libnvmf_sectype_str(e->tsas.tcp.sectype)); break; default: break; @@ -5588,22 +5588,22 @@ static void json_host_discovery_log(struct nvme_host_discover_log *log) hedlpe = (void *)log + i; tel = le32_to_cpu(hedlpe->tel); numexat = le16_to_cpu(hedlpe->numexat); - obj_add_str(hedlpe_o, "trtype", nvmf_trtype_str(hedlpe->trtype)); + obj_add_str(hedlpe_o, "trtype", libnvmf_trtype_str(hedlpe->trtype)); obj_add_str(hedlpe_o, "adrfam", - strlen(hedlpe->traddr) ? nvmf_adrfam_str(hedlpe->adrfam) : ""); - obj_add_str(hedlpe_o, "eflags", nvmf_eflags_str(le16_to_cpu(hedlpe->eflags))); + strlen(hedlpe->traddr) ? libnvmf_adrfam_str(hedlpe->adrfam) : ""); + obj_add_str(hedlpe_o, "eflags", libnvmf_eflags_str(le16_to_cpu(hedlpe->eflags))); obj_add_str(hedlpe_o, "hostnqn", hedlpe->hostnqn); obj_add_str(hedlpe_o, "traddr", hedlpe->traddr); tsas_o = json_create_object(); switch (hedlpe->trtype) { case NVMF_TRTYPE_RDMA: - obj_add_str(tsas_o, "prtype", nvmf_prtype_str(hedlpe->tsas.rdma.prtype)); - obj_add_str(tsas_o, "qptype", nvmf_qptype_str(hedlpe->tsas.rdma.qptype)); - obj_add_str(tsas_o, "cms", nvmf_cms_str(hedlpe->tsas.rdma.cms)); + obj_add_str(tsas_o, "prtype", libnvmf_prtype_str(hedlpe->tsas.rdma.prtype)); + obj_add_str(tsas_o, "qptype", libnvmf_qptype_str(hedlpe->tsas.rdma.qptype)); + obj_add_str(tsas_o, "cms", libnvmf_cms_str(hedlpe->tsas.rdma.cms)); obj_add_uint_0nx(tsas_o, "pkey", le16_to_cpu(hedlpe->tsas.rdma.pkey), 4); break; case NVMF_TRTYPE_TCP: - obj_add_str(tsas_o, "sectype", nvmf_sectype_str(hedlpe->tsas.tcp.sectype)); + obj_add_str(tsas_o, "sectype", libnvmf_sectype_str(hedlpe->tsas.tcp.sectype)); break; default: obj_d(tsas_o, "common", (unsigned char *)hedlpe->tsas.common, @@ -5623,7 +5623,7 @@ static void json_host_discovery_log(struct nvme_host_discover_log *log) obj_d(exat_o, "exatval", (unsigned char *)exat->exatval, le16_to_cpu(exat->exatlen), 16, 1); obj_add_obj(hedlpe_o, json_str, exat_o); - exat = nvmf_exat_ptr_next(exat); + exat = libnvmf_exat_ptr_next(exat); } snprintf(json_str, sizeof(json_str), "hedlpe: %d", n++); obj_add_obj(r, json_str, hedlpe_o); @@ -5641,7 +5641,7 @@ static void obj_add_traddr(struct json_object *o, const char *k, __u8 adrfam, __ size = INET6_ADDRSTRLEN; } - if (inet_ntop(af, nvmf_adrfam_str(adrfam), dst, size)) + if (inet_ntop(af, libnvmf_adrfam_str(adrfam), dst, size)) obj_add_str(o, k, dst); } @@ -5678,7 +5678,7 @@ static void json_ave_discovery_log(struct nvme_ave_discover_log *log) for (j = 0; j < numatr; j++) { atr_o = json_create_object(); snprintf(json_str, sizeof(json_str), "atr: %d", j); - obj_add_str(atr_o, "aveadrfam", nvmf_adrfam_str(atr->aveadrfam)); + obj_add_str(atr_o, "aveadrfam", libnvmf_adrfam_str(atr->aveadrfam)); obj_add_uint(atr_o, "avetrsvcid", le16_to_cpu(atr->avetrsvcid)); obj_add_traddr(atr_o, "avetraddr", atr->aveadrfam, atr->avetraddr); obj_add_obj(adlpe_o, json_str, atr_o); diff --git a/nvme-print-stdout.c b/nvme-print-stdout.c index 13bdc19753..e2152515c3 100644 --- a/nvme-print-stdout.c +++ b/nvme-print-stdout.c @@ -6451,33 +6451,33 @@ static void stdout_discovery_log(struct nvmf_discovery_log *log, int numrec) struct nvmf_disc_log_entry *e = &log->entries[i]; printf("=====Discovery Log Entry %d======\n", i); - printf("trtype: %s\n", nvmf_trtype_str(e->trtype)); + printf("trtype: %s\n", libnvmf_trtype_str(e->trtype)); printf("adrfam: %s\n", strlen(e->traddr) ? - nvmf_adrfam_str(e->adrfam) : ""); - printf("subtype: %s\n", nvmf_subtype_str(e->subtype)); - printf("treq: %s\n", nvmf_treq_str(e->treq)); + libnvmf_adrfam_str(e->adrfam) : ""); + printf("subtype: %s\n", libnvmf_subtype_str(e->subtype)); + printf("treq: %s\n", libnvmf_treq_str(e->treq)); printf("portid: %d\n", le16_to_cpu(e->portid)); printf("trsvcid: %s\n", e->trsvcid); printf("subnqn: %s\n", e->subnqn); printf("traddr: %s\n", e->traddr); printf("eflags: %s\n", - nvmf_eflags_str(le16_to_cpu(e->eflags))); + libnvmf_eflags_str(le16_to_cpu(e->eflags))); switch (e->trtype) { case NVMF_TRTYPE_RDMA: printf("rdma_prtype: %s\n", - nvmf_prtype_str(e->tsas.rdma.prtype)); + libnvmf_prtype_str(e->tsas.rdma.prtype)); printf("rdma_qptype: %s\n", - nvmf_qptype_str(e->tsas.rdma.qptype)); + libnvmf_qptype_str(e->tsas.rdma.qptype)); printf("rdma_cms: %s\n", - nvmf_cms_str(e->tsas.rdma.cms)); + libnvmf_cms_str(e->tsas.rdma.cms)); printf("rdma_pkey: %#04x\n", le16_to_cpu(e->tsas.rdma.pkey)); break; case NVMF_TRTYPE_TCP: printf("sectype: %s\n", - nvmf_sectype_str(e->tsas.tcp.sectype)); + libnvmf_sectype_str(e->tsas.tcp.sectype)); break; } } @@ -6602,23 +6602,23 @@ static void stdout_host_discovery_log(struct nvme_host_discover_log *log) hedlpe = (void *)log + i; tel = le32_to_cpu(hedlpe->tel); numexat = le16_to_cpu(hedlpe->numexat); - printf("trtype: %s\n", nvmf_trtype_str(hedlpe->trtype)); + printf("trtype: %s\n", libnvmf_trtype_str(hedlpe->trtype)); printf("adrfam: %s\n", - strlen(hedlpe->traddr) ? nvmf_adrfam_str(hedlpe->adrfam) : ""); - printf("eflags: %s\n", nvmf_eflags_str(le16_to_cpu(hedlpe->eflags))); + strlen(hedlpe->traddr) ? libnvmf_adrfam_str(hedlpe->adrfam) : ""); + printf("eflags: %s\n", libnvmf_eflags_str(le16_to_cpu(hedlpe->eflags))); printf("hostnqn: %s\n", hedlpe->hostnqn); printf("traddr: %s\n", hedlpe->traddr); printf("tsas: "); switch (hedlpe->trtype) { case NVMF_TRTYPE_RDMA: printf("prtype: %s, qptype: %s, cms: %s, pkey: 0x%04x\n", - nvmf_prtype_str(hedlpe->tsas.rdma.prtype), - nvmf_qptype_str(hedlpe->tsas.rdma.qptype), - nvmf_cms_str(hedlpe->tsas.rdma.cms), + libnvmf_prtype_str(hedlpe->tsas.rdma.prtype), + libnvmf_qptype_str(hedlpe->tsas.rdma.qptype), + libnvmf_cms_str(hedlpe->tsas.rdma.cms), le16_to_cpu(hedlpe->tsas.rdma.pkey)); break; case NVMF_TRTYPE_TCP: - printf("sectype: %s\n", nvmf_sectype_str(hedlpe->tsas.tcp.sectype)); + printf("sectype: %s\n", libnvmf_sectype_str(hedlpe->tsas.tcp.sectype)); break; default: printf("common:\n"); @@ -6635,7 +6635,7 @@ static void stdout_host_discovery_log(struct nvme_host_discover_log *log) printf("exatlen: %u\n", le16_to_cpu(exat->exatlen)); printf("exatval:\n"); d((unsigned char *)exat->exatval, le16_to_cpu(exat->exatlen), 16, 1); - exat = nvmf_exat_ptr_next(exat); + exat = libnvmf_exat_ptr_next(exat); } } } @@ -6651,7 +6651,7 @@ static void print_traddr(char *field, __u8 adrfam, __u8 *traddr) size = INET6_ADDRSTRLEN; } - if (inet_ntop(af, nvmf_adrfam_str(adrfam), dst, size)) + if (inet_ntop(af, libnvmf_adrfam_str(adrfam), dst, size)) printf("%s: %s\n", field, dst); } @@ -6683,7 +6683,7 @@ static void stdout_ave_discovery_log(struct nvme_ave_discover_log *log) atr = adlpe->atr; for (j = 0; j < numatr; j++) { printf("atr: %d\n", j); - printf("aveadrfam: %s\n", nvmf_adrfam_str(atr->aveadrfam)); + printf("aveadrfam: %s\n", libnvmf_adrfam_str(atr->aveadrfam)); printf("avetrsvcid: %u\n", le16_to_cpu(atr->avetrsvcid)); print_traddr("avetraddr", atr->aveadrfam, atr->avetraddr); atr++; diff --git a/plugins/nbft/nbft-plugin.c b/plugins/nbft/nbft-plugin.c index b4f6b294e4..44981ced05 100644 --- a/plugins/nbft/nbft-plugin.c +++ b/plugins/nbft/nbft-plugin.c @@ -569,7 +569,7 @@ int show_nbft(int argc, char **argv, struct command *acmd, struct plugin *plugin show_subsys = show_hfi = show_discovery = true; list_head_init(&nbft_list); - ret = nvmf_nbft_read_files(ctx, nbft_path, &head); + ret = libnvmf_nbft_read_files(ctx, nbft_path, &head); if (!ret && head) { if (flags == NORMAL) normal_show_nbfts(head, show_subsys, @@ -577,7 +577,7 @@ int show_nbft(int argc, char **argv, struct command *acmd, struct plugin *plugin else if (flags == JSON) ret = json_show_nbfts(head, show_subsys, show_hfi, show_discovery); - nvmf_nbft_free(ctx, head); + libnvmf_nbft_free(ctx, head); } return ret; } diff --git a/util/cleanup.h b/util/cleanup.h index 354effca94..1f457bc8be 100644 --- a/util/cleanup.h +++ b/util/cleanup.h @@ -49,13 +49,13 @@ static inline DEFINE_CLEANUP_FUNC(cleanup_nvme_ctrl, libnvme_ctrl_t, libnvme_fre static inline void free_uri(struct libnvme_fabrics_uri **uri) { if (*uri) - nvmf_free_uri(*uri); + libnvmf_free_uri(*uri); } #define _cleanup_uri_ __cleanup__(free_uri) -static inline void cleanup_nvmf_context(struct nvmf_context **fctx) +static inline void cleanup_nvmf_context(struct libnvmf_context **fctx) { - nvmf_context_free(*fctx); + libnvmf_context_free(*fctx); } #define _cleanup_nvmf_context_ __cleanup__(cleanup_nvmf_context) #endif