From 23622693d5459a9d51a6175a3e83060e0829f8d8 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 19 Jan 2023 09:21:45 +0100 Subject: [PATCH] fabrics: Handle DUPRETINFO and EPCSD when doing discovery 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 --- fabrics.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/fabrics.c b/fabrics.c index 533cecee..a17ef2a1 100644 --- 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); } -- 2.50.1