]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
fabrics: Handle DUPRETINFO and EPCSD when doing discovery
authorDaniel Wagner <dwagner@suse.de>
Thu, 19 Jan 2023 08:21:45 +0000 (09:21 +0100)
committerDaniel Wagner <dwagner@suse.de>
Fri, 20 Jan 2023 08:59:20 +0000 (09:59 +0100)
The TP8014 adds two new flags for providing information to the host
which discovery controller is returning the same information we already
know or if the discovery controller doesn't support explicit
persistency.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
fabrics.c

index 533cecee0d3ce30f2d72ae4d355941f439a4b046..a17ef2a139adca85e40cf253bf19db0d2bee9f34 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -477,6 +477,7 @@ static int __discover(nvme_ctrl_t c, struct nvme_fabrics_config *defcfg,
                for (i = 0; i < numrec; i++) {
                        struct nvmf_disc_log_entry *e = &log->entries[i];
                        bool discover = false;
+                       bool disconnect;
                        nvme_ctrl_t child;
                        int tmo = defcfg->keep_alive_tmo;
 
@@ -494,12 +495,38 @@ static int __discover(nvme_ctrl_t c, struct nvme_fabrics_config *defcfg,
                                continue;
 
                        /* Skip connect if the transport types don't match */
-                       if (strcmp(nvme_ctrl_get_transport(c), nvmf_trtype_str(e->trtype)))
+                       if (strcmp(nvme_ctrl_get_transport(c),
+                                  nvmf_trtype_str(e->trtype)))
                                continue;
 
                        if (e->subtype == NVME_NQN_DISC ||
-                           e->subtype == NVME_NQN_CURR)
+                           e->subtype == NVME_NQN_CURR) {
+                               __u16 eflags = le16_to_cpu(e->eflags);
+                               /*
+                                * Does this discovery controller return the
+                                * same information?
+                                */
+                               if (eflags & NVMF_DISC_EFLAGS_DUPRETINFO)
+                                       continue;
+
+                               /* Are we supposed to keep the discovery
+                                * controller around? */
+                               disconnect = !persistent;
+
+                               if (strcmp(e->subnqn, NVME_DISC_SUBSYS_NAME)) {
+                                       /*
+                                        * Does this discovery controller doesn't
+                                        * support explicit persistent connection?
+                                        */
+                                       if (!(eflags & NVMF_DISC_EFLAGS_EPCSD))
+                                               disconnect = true;
+                               }
+
                                set_discovery_kato(defcfg);
+                       } else {
+                               /* NVME_NQN_NVME */
+                               disconnect = false;
+                       }
 
                        errno = 0;
                        child = nvmf_connect_disc_entry(h, e, defcfg,
@@ -511,8 +538,7 @@ static int __discover(nvme_ctrl_t c, struct nvme_fabrics_config *defcfg,
                                if (discover)
                                        __discover(child, defcfg, raw,
                                                   true, persistent, flags);
-                               if (e->subtype != NVME_NQN_NVME &&
-                                   !persistent) {
+                               if (disconnect) {
                                        nvme_disconnect_ctrl(child);
                                        nvme_free_ctrl(child);
                                }