diff --git a/lib/nvmf/port.c b/lib/nvmf/port.c index 1e537f175..bca1c215c 100644 --- a/lib/nvmf/port.c +++ b/lib/nvmf/port.c @@ -65,12 +65,6 @@ spdk_nvmf_fabric_intf_create(const struct spdk_nvmf_transport *transport, char * fabric_intf->host = host; fabric_intf->sin_port = sin_port; fabric_intf->transport = transport; - fabric_intf->trtype = SPDK_NVMF_TRANS_RDMA; - fabric_intf->adrfam = SPDK_NVMF_ADDR_FAMILY_IPV4; - fabric_intf->treq = SPDK_NVMF_TREQ_NOT_SPECIFIED; - fabric_intf->tsas.rdma.rdma_qptype = SPDK_NVMF_QP_TYPE_RELIABLE_CONNECTED; - fabric_intf->tsas.rdma.rdma_prtype = SPDK_NVMF_RDMA_NO_PROVIDER; - fabric_intf->tsas.rdma.rdma_cms = SPDK_NVMF_RDMA_CMS_RDMA_CM; return fabric_intf; } diff --git a/lib/nvmf/port.h b/lib/nvmf/port.h index c5538d483..8cfd88702 100644 --- a/lib/nvmf/port.h +++ b/lib/nvmf/port.h @@ -63,10 +63,6 @@ struct spdk_nvmf_fabric_intf { char *sin_port; struct spdk_nvmf_port *port; const struct spdk_nvmf_transport *transport; - enum spdk_nvmf_transport_types trtype; - enum spdk_nvmf_address_family_types adrfam; - enum spdk_nvmf_transport_requirements treq; - union spdk_nvmf_transport_specific_address_subtype tsas; uint32_t num_sessions; TAILQ_ENTRY(spdk_nvmf_fabric_intf) tailq; }; diff --git a/lib/nvmf/rdma.c b/lib/nvmf/rdma.c index bdc61f3b3..5125e4d14 100644 --- a/lib/nvmf/rdma.c +++ b/lib/nvmf/rdma.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -54,6 +55,7 @@ #include "transport.h" #include "spdk/assert.h" #include "spdk/log.h" +#include "spdk/nvmf_spec.h" #include "spdk/trace.h" #define ACCEPT_TIMEOUT (rte_get_timer_hz() >> 10) /* ~1ms */ @@ -1175,6 +1177,22 @@ nvmf_check_rdma_completions(struct spdk_nvmf_conn *conn) return cq_count; } +static void +nvmf_rdma_discover(struct spdk_nvmf_fabric_intf *fabric_intf, + struct spdk_nvmf_discovery_log_page_entry *entry) +{ + entry->trtype = SPDK_NVMF_TRANS_RDMA; + entry->adrfam = SPDK_NVMF_ADDR_FAMILY_IPV4; + entry->treq = SPDK_NVMF_TREQ_NOT_SPECIFIED; + + snprintf(entry->trsvcid, sizeof(entry->trsvcid), "%s", fabric_intf->sin_port); + snprintf(entry->traddr, sizeof(entry->traddr), "%s", fabric_intf->host); + + entry->tsas.rdma.rdma_qptype = SPDK_NVMF_QP_TYPE_RELIABLE_CONNECTED; + entry->tsas.rdma.rdma_prtype = SPDK_NVMF_RDMA_NO_PROVIDER; + entry->tsas.rdma.rdma_cms = SPDK_NVMF_RDMA_CMS_RDMA_CM; +} + const struct spdk_nvmf_transport spdk_nvmf_transport_rdma = { .name = "rdma", .transport_init = spdk_nvmf_rdma_init, @@ -1187,6 +1205,8 @@ const struct spdk_nvmf_transport spdk_nvmf_transport_rdma = { .conn_init = spdk_nvmf_rdma_alloc_reqs, .conn_fini = nvmf_rdma_conn_cleanup, .conn_poll = nvmf_check_rdma_completions, + + .fabric_intf_discover = nvmf_rdma_discover, }; SPDK_LOG_REGISTER_TRACE_FLAG("rdma", SPDK_TRACE_RDMA) diff --git a/lib/nvmf/subsystem.c b/lib/nvmf/subsystem.c index 40f7c41ed..f6e90178d 100644 --- a/lib/nvmf/subsystem.c +++ b/lib/nvmf/subsystem.c @@ -39,6 +39,7 @@ #include "nvmf_internal.h" #include "session.h" #include "subsystem.h" +#include "transport.h" #include "spdk/log.h" #include "spdk/string.h" #include "spdk/trace.h" @@ -241,17 +242,13 @@ spdk_format_discovery_log(struct spdk_nvmf_discovery_log_page *disc_log, uint32_ break; } entry = &disc_log->entries[numrec]; - entry->trtype = fabric_intf->trtype; - entry->adrfam = fabric_intf->adrfam; - entry->treq = fabric_intf->treq; entry->portid = port->tag; /* Dynamic controllers */ entry->cntlid = 0xffff; entry->subtype = subsystem->subtype; - snprintf(entry->trsvcid, 32, "%s", fabric_intf->sin_port); - snprintf(entry->traddr, 256, "%s", fabric_intf->host); snprintf(entry->subnqn, 256, "%s", subsystem->subnqn); - entry->tsas = fabric_intf->tsas; + + fabric_intf->transport->fabric_intf_discover(fabric_intf, entry); } numrec++; } diff --git a/lib/nvmf/transport.h b/lib/nvmf/transport.h index 39b508190..3e235f02a 100644 --- a/lib/nvmf/transport.h +++ b/lib/nvmf/transport.h @@ -35,6 +35,8 @@ #define SPDK_NVMF_TRANSPORT_H struct spdk_nvmf_conn; +struct spdk_nvmf_discovery_log_page_entry; +struct spdk_nvmf_fabric_intf; struct spdk_nvmf_request; struct spdk_nvmf_transport { @@ -82,6 +84,12 @@ struct spdk_nvmf_transport { * Poll a connection for events. */ int (*conn_poll)(struct spdk_nvmf_conn *conn); + + /** + * Fill out a discovery log entry for a specific fabric interface. + */ + void (*fabric_intf_discover)(struct spdk_nvmf_fabric_intf *fabric_intf, + struct spdk_nvmf_discovery_log_page_entry *entry); }; int spdk_nvmf_transport_init(void);