public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH librdmacm 1/3] cmatose: Allow user to specify address format
@ 2013-07-18 19:52 sean.hefty-ral2JQCrhuEAvxtiuMwx3w
       [not found] ` <1374177133-802-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2013-07-18 19:52 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Sean Hefty

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Provide an option for the user to indicate the type of
addresses used as input.  Support hostname, IPv4, IPv6,
and GIDs.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 examples/cmatose.c |   44 +++++++++++++++++++++++++++++++-------------
 examples/common.c  |    4 ++--
 examples/common.h  |    1 +
 man/ucmatose.1     |   22 ++++++++++++++++++----
 4 files changed, 52 insertions(+), 19 deletions(-)

diff --git a/examples/cmatose.c b/examples/cmatose.c
index 2b6b2b1..ab3e746 100644
--- a/examples/cmatose.c
+++ b/examples/cmatose.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005-2006,2011 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2005-2006,2011-2012 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -81,6 +81,7 @@ static uint8_t tos;
 static uint8_t migrate = 0;
 static char *dst_addr;
 static char *src_addr;
+static struct rdma_addrinfo hints;
 
 static int create_message(struct cmatest_node *node)
 {
@@ -385,7 +386,7 @@ static int alloc_nodes(void)
 		if (dst_addr) {
 			ret = rdma_create_id(test.channel,
 					     &test.nodes[i].cma_id,
-					     &test.nodes[i], RDMA_PS_TCP);
+					     &test.nodes[i], hints.ai_port_space);
 			if (ret)
 				goto err;
 		}
@@ -497,19 +498,15 @@ static int migrate_channel(struct rdma_cm_id *listen_id)
 static int run_server(void)
 {
 	struct rdma_cm_id *listen_id;
-	struct rdma_addrinfo hints;
 	int i, ret;
 
 	printf("cmatose: starting server\n");
-	ret = rdma_create_id(test.channel, &listen_id, &test, RDMA_PS_TCP);
+	ret = rdma_create_id(test.channel, &listen_id, &test, hints.ai_port_space);
 	if (ret) {
 		perror("cmatose: listen request failed");
 		return ret;
 	}
 
-	memset(&hints, 0, sizeof hints);
-	hints.ai_flags = RAI_PASSIVE;
-	hints.ai_port_space = RDMA_PS_TCP;
 	ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
 	if (ret) {
 		perror("cmatose: getrdmaaddr error");
@@ -579,13 +576,10 @@ out:
 
 static int run_client(void)
 {
-	struct rdma_addrinfo hints;
 	int i, ret, ret2;
 
 	printf("cmatose: starting client\n");
 
-	memset(&hints, 0, sizeof hints);
-	hints.ai_port_space = RDMA_PS_TCP;
 	ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
 	if (ret) {
 		perror("cmatose: getaddrinfo error");
@@ -642,7 +636,8 @@ int main(int argc, char **argv)
 {
 	int op, ret;
 
-	while ((op = getopt(argc, argv, "s:b:c:C:S:t:p:m")) != -1) {
+	hints.ai_port_space = RDMA_PS_TCP;
+	while ((op = getopt(argc, argv, "s:b:f:P:c:C:S:t:p:m")) != -1) {
 		switch (op) {
 		case 's':
 			dst_addr = optarg;
@@ -650,6 +645,23 @@ int main(int argc, char **argv)
 		case 'b':
 			src_addr = optarg;
 			break;
+		case 'f':
+			if (!strncasecmp("ip", optarg, 2)) {
+				hints.ai_flags = RAI_NUMERICHOST;
+			} else if (!strncasecmp("gid", optarg, 3)) {
+				hints.ai_flags = RAI_NUMERICHOST | RAI_FAMILY;
+				hints.ai_family = AF_IB;
+			} else if (strncasecmp("name", optarg, 4)) {
+				fprintf(stderr, "Warning: unknown address format\n");
+			}
+			break;
+		case 'P':
+			if (!strncasecmp("ib", optarg, 2)) {
+				hints.ai_port_space = RDMA_PS_IB;
+			} else if (strncasecmp("tcp", optarg, 3)) {
+				fprintf(stderr, "Warning: unknown port space format\n");
+			}
+			break;
 		case 'c':
 			connections = atoi(optarg);
 			break;
@@ -673,6 +685,10 @@ int main(int argc, char **argv)
 			printf("usage: %s\n", argv[0]);
 			printf("\t[-s server_address]\n");
 			printf("\t[-b bind_address]\n");
+			printf("\t[-f address_format]\n");
+			printf("\t    name, ip, ipv6, or gid\n");
+			printf("\t[-P port_space]\n");
+			printf("\t    tcp or ib\n");
 			printf("\t[-c connections]\n");
 			printf("\t[-C message_count]\n");
 			printf("\t[-S message_size]\n");
@@ -694,10 +710,12 @@ int main(int argc, char **argv)
 	if (alloc_nodes())
 		exit(1);
 
-	if (dst_addr)
+	if (dst_addr) {
 		ret = run_client();
-	else
+	} else {
+		hints.ai_flags |= RAI_PASSIVE;
 		ret = run_server();
+	}
 
 	printf("test complete\n");
 	destroy_nodes();
diff --git a/examples/common.c b/examples/common.c
index 4eb5bbe..0b6428c 100644
--- a/examples/common.c
+++ b/examples/common.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005-2006 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2005-2006,2012 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -58,7 +58,7 @@ int get_rdma_addr(char *src, char *dst, char *port,
 
 	rai_hints = *hints;
 	if (src) {
-		rai_hints.ai_flags = RAI_PASSIVE;
+		rai_hints.ai_flags |= RAI_PASSIVE;
 		ret = rdma_getaddrinfo(src, NULL, &rai_hints, &res);
 		if (ret)
 			return ret;
diff --git a/examples/common.h b/examples/common.h
index 7cf16d2..f7511f0 100644
--- a/examples/common.h
+++ b/examples/common.h
@@ -39,6 +39,7 @@
 
 #include <rdma/rdma_cma.h>
 #include <rdma/rsocket.h>
+#include <infiniband/ib.h>
 
 #if __BYTE_ORDER == __BIG_ENDIAN
 static inline uint64_t cpu_to_be64(uint64_t x) { return x; }
diff --git a/man/ucmatose.1 b/man/ucmatose.1
index 73477ea..95dc2d6 100644
--- a/man/ucmatose.1
+++ b/man/ucmatose.1
@@ -4,10 +4,12 @@ ucmatose \- RDMA CM connection and simple ping-pong test.
 .SH SYNOPSIS
 .sp
 .nf
-\fIucmatose\fR [-s server_address] [-b bind_address] [-c connections]
-		[-C message_count] [-S message_size]
-\fIucmatose\fR -s server_address [-b bind_address] [-c connections]
-		[-C message_count] [-S message_size] [-t tos]
+\fIucmatose\fR [-s server_address] [-b bind_address]
+		[-f address_format] [-P port_space]
+		[-c connections] [-C message_count] [-S message_size]
+\fIucmatose\fR -s server_address [-b bind_address]
+		[-f address_format] [-P port_space]
+		[-c connections] [-C message_count] [-S message_size] [-t tos]
 .fi
 .SH "DESCRIPTION"
 Establishes a set of reliable RDMA connections between two nodes using the
@@ -22,6 +24,18 @@ This option must be specified by the client.
 \-b bind_address
 The local network address to bind to.
 .TP
+\-f address_format
+Specifies the format of the server and bind address.  Be default, the
+format is determined by getaddrinfo() as either being a hostname, an IPv4
+address, or an IPv6 address.  This option may be used to indicate that
+a specific address format has been provided.  Supported address_format
+values are: name, ip, ipv6, and gid.
+.TP
+\-P port_space
+Specifies the port space for the connection.  Be default, the port space
+is the RDMA TCP port space. (Note that the RDMA port space may be separate
+from that used for IP.)  Supported port_space values are: tcp and ib.
+.TP
 \-c connections
 The number of connections to establish between the client and server.
 (default 1)
-- 
1.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH librdmacm 2/3] acm: Define needed ACM protocol messages
       [not found] ` <1374177133-802-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2013-07-18 19:52   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  2013-07-18 19:52   ` [PATCH librdmacm 3/3] init: Remove USE_IB_ACM configuration option sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  1 sibling, 0 replies; 3+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2013-07-18 19:52 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Sean Hefty

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

The librdmacm needs message definitions used to communicate
with the ibacm.  It currently pulls these from infiniband/acm.h,
which is installed by ibacm.  This creates an install order
dependency on ibacm.  However, work on the scalable SA has
the ibacm using the librdmacm (via rsockets) for communication
between the different SSA components.

To resolve this issue, have the librdmacm define the message
structures that it needs to communicate with ibacm.  The
librdmacm already defines some ACM messages through configuration
checks.  We just expand that capability, which isolates the librdmacm
package from the ibacm package.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 configure.ac |    7 +-----
 src/acm.c    |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 62 insertions(+), 15 deletions(-)

diff --git a/configure.ac b/configure.ac
index 31b1a0e..b4303c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,12 +71,7 @@ fi
 fi
 
 AC_CHECK_HEADER(infiniband/acm.h, 
-	AC_DEFINE([USE_IB_ACM], 1, [setting IBACM support]), [])
-
-AC_CHECK_HEADER(infiniband/acm.h,
-	AC_CHECK_MEMBER(struct acm_msg.resolve_data, [],
-		AC_DEFINE(DEFINE_ACM_MSG, 1, [adding ACM message definition]),
-			[#include <infiniband/acm.h>]), [])
+      AC_DEFINE([USE_IB_ACM], 1, [setting IBACM support]), [])
 
 dnl Checks close on exec support
 AC_CHECK_HEADERS([fcntl.h sys/socket.h])
diff --git a/src/acm.c b/src/acm.c
index 6e8e173..09c5d4e 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -46,19 +46,71 @@
 #include <infiniband/sa.h>
 
 #ifdef USE_IB_ACM
-#include <infiniband/acm.h>
+#define ACM_VERSION             1
+
+#define ACM_OP_RESOLVE          0x01
+#define ACM_OP_ACK              0x80
+
+#define ACM_STATUS_SUCCESS      0
+#define ACM_STATUS_ENOMEM       1
+#define ACM_STATUS_EINVAL       2
+#define ACM_STATUS_ENODATA      3
+#define ACM_STATUS_ENOTCONN     5
+#define ACM_STATUS_ETIMEDOUT    6
+#define ACM_STATUS_ESRCADDR     7
+#define ACM_STATUS_ESRCTYPE     8
+#define ACM_STATUS_EDESTADDR    9
+#define ACM_STATUS_EDESTTYPE    10
+
+#define ACM_FLAGS_NODELAY	(1<<30)
+
+#define ACM_MSG_HDR_LENGTH      16
+#define ACM_MAX_ADDRESS         64
+#define ACM_MSG_EP_LENGTH       72
+#define ACM_MSG_DATA_LENGTH     (ACM_MSG_EP_LENGTH * 8)
+
+struct acm_hdr {
+	uint8_t                 version;
+	uint8_t                 opcode;
+	uint8_t                 status;
+	uint8_t		        data[3];
+	uint16_t                length;
+	uint64_t                tid;
+};
+
+#define ACM_EP_INFO_NAME        0x0001
+#define ACM_EP_INFO_ADDRESS_IP  0x0002
+#define ACM_EP_INFO_ADDRESS_IP6 0x0003
+#define ACM_EP_INFO_PATH        0x0010
+
+union acm_ep_info {
+	uint8_t                 addr[ACM_MAX_ADDRESS];
+	uint8_t                 name[ACM_MAX_ADDRESS];
+	struct ibv_path_record  path;
+};
+
+#define ACM_EP_FLAG_SOURCE      (1<<0)
+#define ACM_EP_FLAG_DEST        (1<<1)
 
-#if DEFINE_ACM_MSG
-typedef struct cma_acm_msg {
+struct acm_ep_addr_data {
+	uint32_t                flags;
+	uint16_t                type;
+	uint16_t                reserved;
+	union acm_ep_info       info;
+};
+
+struct acm_resolve_msg {
+	struct acm_hdr          hdr;
+	struct acm_ep_addr_data data[0];
+};
+
+struct acm_msg {
 	struct acm_hdr                  hdr;
 	union{
 		uint8_t                 data[ACM_MSG_DATA_LENGTH];
 		struct acm_ep_addr_data resolve_data[0];
 	};
-} cma_acm_msg_t;
-#else
-typedef struct acm_msg cma_acm_msg_t;
-#endif
+};
 
 static pthread_mutex_t acm_lock = PTHREAD_MUTEX_INITIALIZER;
 static int sock = -1;
@@ -242,7 +294,7 @@ err:
 	rdma_freeaddrinfo(ib_rai);
 }
 
-static void ucma_ib_save_resp(struct rdma_addrinfo *rai, cma_acm_msg_t *msg)
+static void ucma_ib_save_resp(struct rdma_addrinfo *rai, struct acm_msg *msg)
 {
 	struct acm_ep_addr_data *ep_data;
 	struct ibv_path_data *path_data = NULL;
@@ -326,7 +378,7 @@ static int ucma_ib_addr(struct sockaddr *addr, socklen_t len)
 
 void ucma_ib_resolve(struct rdma_addrinfo **rai, struct rdma_addrinfo *hints)
 {
-	cma_acm_msg_t msg;
+	struct acm_msg msg;
 	struct acm_ep_addr_data *data;
 	int ret;
 
-- 
1.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH librdmacm 3/3] init: Remove USE_IB_ACM configuration option
       [not found] ` <1374177133-802-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  2013-07-18 19:52   ` [PATCH librdmacm 2/3] acm: Define needed ACM protocol messages sean.hefty-ral2JQCrhuEAvxtiuMwx3w
@ 2013-07-18 19:52   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w
  1 sibling, 0 replies; 3+ messages in thread
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w @ 2013-07-18 19:52 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA; +Cc: Sean Hefty

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

When the librdmacm is configured, it sets the USE_IB_ACM option
if infininband/acm.h is found.  We can remove this option with
very little overhead, which would allow a user to install
ACM after installing the librdmacm, and the librdmacm would be
able to make use of ACM.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 configure.ac |    3 ---
 src/acm.c    |    3 ---
 src/cma.h    |    6 ------
 3 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/configure.ac b/configure.ac
index b4303c6..59c5eb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,9 +70,6 @@ AC_CHECK_HEADER(valgrind/memcheck.h, [],
 fi
 fi
 
-AC_CHECK_HEADER(infiniband/acm.h, 
-      AC_DEFINE([USE_IB_ACM], 1, [setting IBACM support]), [])
-
 dnl Checks close on exec support
 AC_CHECK_HEADERS([fcntl.h sys/socket.h])
 
diff --git a/src/acm.c b/src/acm.c
index 09c5d4e..04cddee 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -45,7 +45,6 @@
 #include <infiniband/ib.h>
 #include <infiniband/sa.h>
 
-#ifdef USE_IB_ACM
 #define ACM_VERSION             1
 
 #define ACM_OP_RESOLVE          0x01
@@ -453,5 +452,3 @@ void ucma_ib_resolve(struct rdma_addrinfo **rai, struct rdma_addrinfo *hints)
 	if (af_ib_support && !(hints->ai_flags & RAI_ROUTEONLY) && (*rai)->ai_route_len)
 		ucma_resolve_af_ib(rai);
 }
-
-#endif /* USE_IB_ACM */
diff --git a/src/cma.h b/src/cma.h
index b575b9b..e6fba8b 100644
--- a/src/cma.h
+++ b/src/cma.h
@@ -162,15 +162,9 @@ extern int af_ib_support;
 
 #define RAI_ROUTEONLY		0x01000000
 
-#ifdef USE_IB_ACM
 void ucma_ib_init();
 void ucma_ib_cleanup();
 void ucma_ib_resolve(struct rdma_addrinfo **rai, struct rdma_addrinfo *hints);
-#else
-#define ucma_ib_init()
-#define ucma_ib_cleanup()
-#define ucma_ib_resolve(x, y)
-#endif
 
 /* Define path record definition if using older version of libibverbs */
 #ifdef DEFINE_PATH_RECORD
-- 
1.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-18 19:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-18 19:52 [PATCH librdmacm 1/3] cmatose: Allow user to specify address format sean.hefty-ral2JQCrhuEAvxtiuMwx3w
     [not found] ` <1374177133-802-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-07-18 19:52   ` [PATCH librdmacm 2/3] acm: Define needed ACM protocol messages sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2013-07-18 19:52   ` [PATCH librdmacm 3/3] init: Remove USE_IB_ACM configuration option sean.hefty-ral2JQCrhuEAvxtiuMwx3w

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox