diff --git a/include/spdk/nvmf.h b/include/spdk/nvmf.h index 9a19bf039..d2c2f0050 100644 --- a/include/spdk/nvmf.h +++ b/include/spdk/nvmf.h @@ -134,9 +134,10 @@ struct spdk_nvmf_subsystem { bool is_removed; union { struct { - struct spdk_nvme_ctrlr *ctrlr; - struct spdk_nvme_qpair *io_qpair; - struct spdk_pci_addr pci_addr; + struct spdk_nvme_ctrlr *ctrlr; + struct spdk_nvme_qpair *io_qpair; + struct spdk_pci_addr pci_addr; + struct spdk_poller *admin_poller; } direct; struct { @@ -160,7 +161,7 @@ struct spdk_nvmf_subsystem { TAILQ_HEAD(, spdk_nvmf_subsystem_allowed_listener) allowed_listeners; - TAILQ_ENTRY(spdk_nvmf_subsystem) entries; + TAILQ_ENTRY(spdk_nvmf_subsystem) entries; }; struct spdk_nvmf_subsystem *spdk_nvmf_create_subsystem(const char *nqn, diff --git a/lib/nvmf/direct.c b/lib/nvmf/direct.c index e76c6d8a7..1b4f8b64b 100644 --- a/lib/nvmf/direct.c +++ b/lib/nvmf/direct.c @@ -39,6 +39,7 @@ #include "spdk/nvmf_spec.h" #include "spdk/trace.h" #include "spdk/util.h" +#include "spdk/event.h" #include "spdk_internal/log.h" @@ -51,10 +52,27 @@ nvmf_direct_ctrlr_get_data(struct spdk_nvmf_session *session) memcpy(&session->vcdata, cdata, sizeof(struct spdk_nvme_ctrlr_data)); } +static void +nvmf_direct_ctrlr_poll_for_admin_completions(void *arg) +{ + struct spdk_nvmf_subsystem *subsystem = arg; + + spdk_nvme_ctrlr_process_admin_completions(subsystem->dev.direct.ctrlr); +} + static void nvmf_direct_ctrlr_poll_for_completions(struct spdk_nvmf_subsystem *subsystem) { - spdk_nvme_ctrlr_process_admin_completions(subsystem->dev.direct.ctrlr); + if (subsystem->dev.direct.admin_poller == NULL) { + int lcore = spdk_app_get_current_core(); + + spdk_poller_register(&subsystem->dev.direct.admin_poller, + nvmf_direct_ctrlr_poll_for_admin_completions, + subsystem, lcore, 10000); + } + + nvmf_direct_ctrlr_poll_for_admin_completions(subsystem); + spdk_nvme_qpair_process_completions(subsystem->dev.direct.io_qpair, 0); } @@ -244,6 +262,10 @@ static void nvmf_direct_ctrlr_detach(struct spdk_nvmf_subsystem *subsystem) { if (subsystem->dev.direct.ctrlr) { + if (subsystem->dev.direct.admin_poller != NULL) { + spdk_poller_unregister(&subsystem->dev.direct.admin_poller, NULL); + } + spdk_nvme_detach(subsystem->dev.direct.ctrlr); } } diff --git a/test/lib/nvmf/direct/direct_ut.c b/test/lib/nvmf/direct/direct_ut.c index 6c33fc250..2021bfa94 100644 --- a/test/lib/nvmf/direct/direct_ut.c +++ b/test/lib/nvmf/direct/direct_ut.c @@ -42,6 +42,25 @@ SPDK_LOG_REGISTER_TRACE_FLAG("nvmf", SPDK_TRACE_NVMF) +uint32_t +spdk_app_get_current_core(void) +{ + return 0; +} + +void +spdk_poller_register(struct spdk_poller **ppoller, spdk_poller_fn fn, void *arg, + uint32_t lcore, uint64_t period_microseconds) +{ + return; +} + +void +spdk_poller_unregister(struct spdk_poller **ppoller, struct spdk_event *complete) +{ + return; +} + int32_t spdk_nvme_ctrlr_process_admin_completions(struct spdk_nvme_ctrlr *ctrlr) {