From 5d2d15764811a93271f7c7b6c20551aa4bb7b43a Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Tue, 16 Nov 2021 09:46:57 +0100 Subject: [PATCH] fabrics: allow 'nqn' as argument to connect and discover With TP8013 a discovery controller can provide a unique subsystem NQN, so we should be able to pass in that NQN when calling 'nvme discover'. Signed-off-by: Hannes Reinecke --- Documentation/nvme-connect-all.txt | 5 +++++ Documentation/nvme-discover.txt | 5 +++++ fabrics.c | 12 +++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Documentation/nvme-connect-all.txt b/Documentation/nvme-connect-all.txt index e673ede5..3d3587ff 100644 --- a/Documentation/nvme-connect-all.txt +++ b/Documentation/nvme-connect-all.txt @@ -10,6 +10,7 @@ SYNOPSIS [verse] 'nvme connect-all' [--transport= | -t ] + [--nqn= | -n ] [--traddr= | -a ] [--trsvcid= | -s ] [--host-traddr= | -w ] @@ -65,6 +66,10 @@ OPTIONS |loop|Connect to a NVMe over Fabrics target on the local host |================= +-n :: +--nqn :: + This field specifies the name for the NVMe subsystem to connect to. + -a :: --traddr=:: This field specifies the network address of the Discovery Controller. diff --git a/Documentation/nvme-discover.txt b/Documentation/nvme-discover.txt index cb81a674..b7311aa9 100644 --- a/Documentation/nvme-discover.txt +++ b/Documentation/nvme-discover.txt @@ -10,6 +10,7 @@ SYNOPSIS [verse] 'nvme discover' [--transport= | -t ] + [--nqn= | -n ] [--traddr= | -a ] [--trsvcid= | -s ] [--host-traddr= | -w ] @@ -87,6 +88,10 @@ OPTIONS |loop|Connect to a NVMe over Fabrics target on the local host |================= +-n :: +--nqn :: + This field specifies the name for the NVMe subsystem to connect to. + -a :: --traddr=:: This field specifies the network address of the Discovery Controller. diff --git a/fabrics.c b/fabrics.c index 02071c2e..e947ced5 100644 --- a/fabrics.c +++ b/fabrics.c @@ -83,6 +83,7 @@ static const char *nvmf_config_file = "Use specified JSON configuration file or OPT_STRING("host-iface", 'f', "STR", &host_iface, nvmf_hiface), \ OPT_STRING("hostnqn", 'q', "STR", &hostnqn, nvmf_hostnqn), \ OPT_STRING("hostid", 'I', "STR", &hostid, nvmf_hostid), \ + OPT_STRING("nqn", 'n', "STR", &subsysnqn, nvmf_nqn), \ OPT_INT("nr-io-queues", 'i', &c.nr_io_queues, nvmf_nr_io_queues), \ OPT_INT("nr-write-queues", 'W', &c.nr_write_queues, nvmf_nr_write_queues),\ OPT_INT("nr-poll-queues", 'P', &c.nr_poll_queues, nvmf_nr_poll_queues), \ @@ -302,6 +303,7 @@ static int discover_from_conf_file(nvme_host_t h, const char *desc, char *transport = NULL, *traddr = NULL, *trsvcid = NULL; char *host_traddr = NULL, *host_iface = NULL; char *hostnqn = NULL, *hostid = NULL; + char *subsysnqn = NULL; char *ptr, **argv, *p, line[4096]; int argc, ret = 0; unsigned int verbose = 0; @@ -353,6 +355,7 @@ static int discover_from_conf_file(nvme_host_t h, const char *desc, argv[argc] = NULL; memcpy(&cfg, defcfg, sizeof(cfg)); + subsysnqn = NVME_DISC_SUBSYS_NAME; ret = argconfig_parse(argc, argv, desc, opts); if (ret) goto next; @@ -361,7 +364,7 @@ static int discover_from_conf_file(nvme_host_t h, const char *desc, if (!transport && !traddr) goto next; - c = nvme_create_ctrl(NVME_DISC_SUBSYS_NAME, transport, + c = nvme_create_ctrl(subsysnqn, transport, traddr, host_traddr, host_iface, trsvcid); if (!c) goto next; @@ -385,7 +388,7 @@ out: int nvmf_discover(const char *desc, int argc, char **argv, bool connect) { - char *nqn = NVME_DISC_SUBSYS_NAME; + char *subsysnqn = NVME_DISC_SUBSYS_NAME; char *hostnqn = NULL, *hostid = NULL; char *host_traddr = NULL, *host_iface = NULL; char *transport = NULL, *traddr = NULL, *trsvcid = NULL; @@ -472,7 +475,7 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) c = nvme_scan_ctrl(r, device); if (c) { /* Check if device matches command-line options */ - if (strcmp(nvme_ctrl_get_subsysnqn(c), nqn) || + if (strcmp(nvme_ctrl_get_subsysnqn(c), subsysnqn) || strcmp(nvme_ctrl_get_transport(c), transport) || strcmp(nvme_ctrl_get_traddr(c), traddr) || (host_traddr && nvme_ctrl_get_host_traddr(c) && @@ -510,7 +513,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 = nvme_create_ctrl(nqn, transport, traddr, + c = nvme_create_ctrl(subsysnqn, transport, traddr, host_traddr, host_iface, trsvcid); if (!c) { ret = errno; @@ -560,7 +563,6 @@ int nvmf_connect(const char *desc, int argc, char **argv) struct nvme_fabrics_config cfg; OPT_ARGS(opts) = { - OPT_STRING("nqn", 'n', "NAME", &subsysnqn, nvmf_nqn), NVMF_OPTS(cfg), OPT_STRING("config", 'C', "FILE", &config_file, nvmf_config_file), OPT_INCR("verbose", 'v', &verbose, "Increase logging verbosity"), -- 2.50.1