From 2653cb49a73b45f9e53423a10c3c4ab2cc23fa51 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 15 Jul 2016 09:34:25 -0700 Subject: [PATCH] nvmf: define transport-specific address union For now, it just contains RDMA, plus a raw byte array to allow generic copying. Change-Id: I02fe11f99dd8b49000de0dba991cd34c99fd7a4a Signed-off-by: Daniel Verkamp --- include/spdk/nvmf_spec.h | 10 +++++++--- lib/nvmf/port.c | 6 +++--- lib/nvmf/port.h | 2 +- lib/nvmf/subsystem.c | 4 +--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/spdk/nvmf_spec.h b/include/spdk/nvmf_spec.h index ea0743064..60098e294 100644 --- a/include/spdk/nvmf_spec.h +++ b/include/spdk/nvmf_spec.h @@ -364,6 +364,12 @@ struct spdk_nvmf_rdma_transport_specific_address { SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_rdma_transport_specific_address) == 256, "Incorrect size"); +union spdk_nvmf_transport_specific_address { + uint8_t raw[256]; + struct spdk_nvmf_rdma_transport_specific_address rdma; +}; +SPDK_STATIC_ASSERT(sizeof(union spdk_nvmf_transport_specific_address) == 256, "Incorrect size"); + struct spdk_nvmf_discovery_log_page_entry { uint8_t trtype; /* transport type */ uint8_t adrfam; /* address family */ @@ -376,9 +382,7 @@ struct spdk_nvmf_discovery_log_page_entry { uint8_t reserved1[192]; uint8_t subnqn[256]; uint8_t traddr[256]; - union { - struct spdk_nvmf_rdma_transport_specific_address rdma; - } tsas; + union spdk_nvmf_transport_specific_address tsas; }; SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_discovery_log_page_entry) == 1024, "Incorrect size"); diff --git a/lib/nvmf/port.c b/lib/nvmf/port.c index f02a74806..e0bf42eab 100644 --- a/lib/nvmf/port.c +++ b/lib/nvmf/port.c @@ -127,10 +127,10 @@ spdk_nvmf_port_create(int tag) port->state = GROUP_INIT; port->tag = tag; port->type = FABRIC_RDMA; - port->rdma.rdma_qptype = SPDK_NVMF_QP_TYPE_RELIABLE_CONNECTED; + port->tsas.rdma.rdma_qptype = SPDK_NVMF_QP_TYPE_RELIABLE_CONNECTED; /* No provider specified */ - port->rdma.rdma_prtype = SPDK_NVMF_RDMA_NO_PROVIDER; - port->rdma.rdma_cms = SPDK_NVMF_RDMA_CMS_RDMA_CM; + port->tsas.rdma.rdma_prtype = SPDK_NVMF_RDMA_NO_PROVIDER; + port->tsas.rdma.rdma_cms = SPDK_NVMF_RDMA_CMS_RDMA_CM; TAILQ_INIT(&port->head); diff --git a/lib/nvmf/port.h b/lib/nvmf/port.h index 8a2b73905..c5a038d4b 100644 --- a/lib/nvmf/port.h +++ b/lib/nvmf/port.h @@ -77,7 +77,7 @@ struct spdk_nvmf_port { int tag; enum group_state state; enum fabric_type type; - struct spdk_nvmf_rdma_transport_specific_address rdma; + union spdk_nvmf_transport_specific_address tsas; TAILQ_HEAD(, spdk_nvmf_fabric_intf) head; TAILQ_ENTRY(spdk_nvmf_port) tailq; }; diff --git a/lib/nvmf/subsystem.c b/lib/nvmf/subsystem.c index 78226c490..a54078b5c 100644 --- a/lib/nvmf/subsystem.c +++ b/lib/nvmf/subsystem.c @@ -224,9 +224,7 @@ spdk_format_discovery_log(struct spdk_nvmf_discovery_log_page *disc_log, uint32_ 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.rdma.rdma_qptype = port->rdma.rdma_qptype; - entry->tsas.rdma.rdma_prtype = port->rdma.rdma_prtype; - entry->tsas.rdma.rdma_cms = port->rdma.rdma_cms; + entry->tsas = port->tsas; } numrec++; }