Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nbft: Discovery support #2315

Merged
merged 5 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ static nvme_ctrl_t __create_discover_ctrl(nvme_root_t r, nvme_host_t h,
return c;
}

static nvme_ctrl_t create_discover_ctrl(nvme_root_t r, nvme_host_t h,
struct nvme_fabrics_config *cfg,
struct tr_config *trcfg)
nvme_ctrl_t nvmf_create_discover_ctrl(nvme_root_t r, nvme_host_t h,
struct nvme_fabrics_config *cfg,
struct tr_config *trcfg)
{
_cleanup_free_ struct nvme_id_ctrl *id = NULL;
nvme_ctrl_t c;
Expand Down Expand Up @@ -378,8 +378,7 @@ static int __discover(nvme_ctrl_t c, struct nvme_fabrics_config *defcfg,
return 0;
}

static char *get_default_trsvcid(const char *transport,
bool discovery_ctrl)
char *nvmf_get_default_trsvcid(const char *transport, bool discovery_ctrl)
{
if (!transport)
return NULL;
Expand Down Expand Up @@ -465,7 +464,7 @@ static int discover_from_conf_file(nvme_root_t r, nvme_host_t h,
goto next;

if (!trsvcid)
trsvcid = get_default_trsvcid(transport, true);
trsvcid = nvmf_get_default_trsvcid(transport, true);

struct tr_config trcfg = {
.subsysnqn = subsysnqn,
Expand All @@ -485,7 +484,7 @@ static int discover_from_conf_file(nvme_root_t r, nvme_host_t h,
}
}

c = create_discover_ctrl(r, h, &cfg, &trcfg);
c = nvmf_create_discover_ctrl(r, h, &cfg, &trcfg);
if (!c)
goto next;

Expand Down Expand Up @@ -549,7 +548,8 @@ static int discover_from_json_config_file(nvme_root_t r, nvme_host_t h,

trsvcid = nvme_ctrl_get_trsvcid(c);
if (!trsvcid || !strcmp(trsvcid, ""))
trsvcid = get_default_trsvcid(transport, true);
trsvcid = nvmf_get_default_trsvcid(transport,
true);

if (force)
subsysnqn = nvme_ctrl_get_subsysnqn(c);
Expand Down Expand Up @@ -579,7 +579,7 @@ static int discover_from_json_config_file(nvme_root_t r, nvme_host_t h,
}
}

cn = create_discover_ctrl(r, h, &cfg, &trcfg);
cn = nvmf_create_discover_ctrl(r, h, &cfg, &trcfg);
if (!cn)
continue;

Expand Down Expand Up @@ -806,7 +806,7 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect)
}

if (!trsvcid)
trsvcid = get_default_trsvcid(transport, true);
trsvcid = nvmf_get_default_trsvcid(transport, true);

struct tr_config trcfg = {
.subsysnqn = subsysnqn,
Expand Down Expand Up @@ -876,7 +876,7 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect)
}
if (!c) {
/* No device or non-matching device, create a new controller */
c = create_discover_ctrl(r, h, &cfg, &trcfg);
c = nvmf_create_discover_ctrl(r, h, &cfg, &trcfg);
if (!c) {
if (errno != ENVME_CONNECT_IGNORED)
fprintf(stderr,
Expand Down Expand Up @@ -1005,7 +1005,7 @@ int nvmf_connect(const char *desc, int argc, char **argv)
if (hostkey)
nvme_host_set_dhchap_key(h, hostkey);
if (!trsvcid)
trsvcid = get_default_trsvcid(transport, false);
trsvcid = nvmf_get_default_trsvcid(transport, false);

struct tr_config trcfg = {
.subsysnqn = subsysnqn,
Expand Down
6 changes: 6 additions & 0 deletions fabrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@ extern int nvmf_disconnect(const char *desc, int argc, char **argv);
extern int nvmf_disconnect_all(const char *desc, int argc, char **argv);
extern int nvmf_config(const char *desc, int argc, char **argv);
extern int nvmf_dim(const char *desc, int argc, char **argv);
extern nvme_ctrl_t nvmf_create_discover_ctrl(nvme_root_t r, nvme_host_t h,
struct nvme_fabrics_config *cfg,
struct tr_config *trcfg);
extern char *nvmf_get_default_trsvcid(const char *transport,
bool discovery_ctrl);


#endif
Loading