All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] [PATCH 0/22] [for 2.6.36] rdma/cm: add support for native IB addressing
@ 2010-03-23 17:48 Sean Hefty
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 17:48 UTC (permalink / raw)
  To: linux-rdma, Hefty, Sean

The following patch series extends the rdma_cm to support native
Infiniband addressing through the use of a new AF_IB address family.
It defines a new struct sockaddr_ib that may be used to specify an
IB GID, along with other IB address attributes, such as the pkey and
service ID.

The higher level intent is to support a user space call, rdma_getaddrinfo,
which can return AF_IB addresses to an application.  This allows the
rdma_cm to support transport specific features, such as failover and
non-reversible paths.  (An implementation of rdma_getaddrinfo is included
in a separate patch set to the librdmacm.)

This set is very lightly tested, but I wanted to start soliciting feedback
with more extensive testing ongoing in parallel.  For more casual reviewers
of patches, the first patch in the series is probably the most important,
as it defines struct sockaddr_ib.

I think a reasonable kernel target for these patches would be 2.6.36.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

--
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	[flat|nested] 41+ messages in thread

* [RFC] [PATCH 1/22] [for 2.6.36] rdma/cm: define native IB address
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2010-03-23 17:52   ` Sean Hefty
  2010-03-23 17:54   ` [RFC] [PATCH 2/22] [for 2.6.36] rdma/cm: fix handling of ipv6 addressing in cma_use_port Sean Hefty
                     ` (22 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 17:52 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Define AF_IB and sockaddr_ib to allow the rdma_cm to use native IB
addressing.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 include/linux/socket.h |    2 +
 include/rdma/ib.h      |   89 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 0 deletions(-)

diff --git a/include/linux/socket.h b/include/linux/socket.h
index 7b3aae2..966e268 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -181,6 +181,7 @@ struct ucred {
 #define AF_PPPOX	24	/* PPPoX sockets		*/
 #define AF_WANPIPE	25	/* Wanpipe API Sockets */
 #define AF_LLC		26	/* Linux LLC			*/
+#define AF_IB		27	/* Native InfiniBand address	*/
 #define AF_CAN		29	/* Controller Area Network      */
 #define AF_TIPC		30	/* TIPC sockets			*/
 #define AF_BLUETOOTH	31	/* Bluetooth sockets 		*/
@@ -221,6 +222,7 @@ struct ucred {
 #define PF_PPPOX	AF_PPPOX
 #define PF_WANPIPE	AF_WANPIPE
 #define PF_LLC		AF_LLC
+#define PF_IB		AF_IB
 #define PF_CAN		AF_CAN
 #define PF_TIPC		AF_TIPC
 #define PF_BLUETOOTH	AF_BLUETOOTH
diff --git a/include/rdma/ib.h b/include/rdma/ib.h
new file mode 100644
index 0000000..cf8f9e7
--- /dev/null
+++ b/include/rdma/ib.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2010 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
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined(_RDMA_IB_H)
+#define _RDMA_IB_H
+
+#include <linux/types.h>
+
+struct ib_addr {
+	union {
+		__u8		uib_addr8[16];
+		__be16		uib_addr16[8];
+		__be32		uib_addr32[4];
+		__be64		uib_addr64[2];
+	} ib_u;
+#define sib_addr8		ib_u.uib_addr8
+#define sib_addr16		ib_u.uib_addr16
+#define sib_addr32		ib_u.uib_addr32
+#define sib_addr64		ib_u.uib_addr64
+#define sib_raw			ib_u.uib_addr8
+#define sib_subnet_prefix	ib_u.uib_addr64[0]
+#define sib_interface_id	ib_u.uib_addr64[1]
+};
+
+static inline int ib_addr_any(const struct ib_addr *a)
+{
+	return ((a->sib_addr64[0] | a->sib_addr64[1]) == 0);
+}
+
+static inline int ib_addr_loopback(const struct ib_addr *a)
+{
+	return ((a->sib_addr32[0] | a->sib_addr32[1] |
+		 a->sib_addr32[2] | (a->sib_addr32[3] ^ htonl(1))) == 0);
+}
+
+static inline void ib_addr_set(struct ib_addr *addr,
+			       __be32 w1, __be32 w2, __be32 w3, __be32 w4)
+{
+	addr->sib_addr32[0] = w1;
+	addr->sib_addr32[1] = w2;
+	addr->sib_addr32[2] = w3;
+	addr->sib_addr32[3] = w4;
+}
+
+static inline int ib_addr_cmp(const struct ib_addr *a1, const struct ib_addr *a2)
+{
+	return memcmp(a1, a2, sizeof(struct ib_addr));
+}
+
+struct sockaddr_ib {
+	unsigned short int	sib_family;	/* AF_IB */
+	__be16			sib_pkey;
+	__be32			sib_flowinfo;
+	struct ib_addr		sib_addr;
+	__be64			sib_sid;
+	__be64			sib_sid_mask;
+	__u64			sib_scope_id;
+};
+
+#endif /* _RDMA_IB_H */



--
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] 41+ messages in thread

* [RFC] [PATCH 2/22] [for 2.6.36] rdma/cm: fix handling of ipv6 addressing in cma_use_port
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  2010-03-23 17:52   ` [RFC] [PATCH 1/22] [for 2.6.36] rdma/cm: define native IB address Sean Hefty
@ 2010-03-23 17:54   ` Sean Hefty
  2010-03-23 17:55   ` [RFC] [PATCH 3/22] [for 2.6.36] rdma/cm: include AF_IB in loopback and any address checks Sean Hefty
                     ` (21 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 17:54 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

cma_use_port is coded assuming that the sockaddr is an ipv4 address.
Since ipv6 addressing is supported, and also to support other address
families, make the code more generic in its address handling.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/cma.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 875e34e..9041a2b 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -643,6 +643,21 @@ static inline int cma_any_addr(struct sockaddr *addr)
 	return cma_zero_addr(addr) || cma_loopback_addr(addr);
 }
 
+static int cma_addr_cmp(struct sockaddr *src, struct sockaddr *dst)
+{
+	if (src->sa_family != dst->sa_family)
+		return -1;
+
+	switch (src->sa_family) {
+	case AF_INET:
+		return ((struct sockaddr_in *) src)->sin_addr.s_addr !=
+		       ((struct sockaddr_in *) dst)->sin_addr.s_addr;
+	default:
+		return ipv6_addr_cmp(&((struct sockaddr_in6 *) src)->sin6_addr,
+				     &((struct sockaddr_in6 *) dst)->sin6_addr);
+	}
+}
+
 static inline __be16 cma_port(struct sockaddr *addr)
 {
 	if (addr->sa_family == AF_INET)
@@ -2014,13 +2029,13 @@ err1:
 static int cma_use_port(struct idr *ps, struct rdma_id_private *id_priv)
 {
 	struct rdma_id_private *cur_id;
-	struct sockaddr_in *sin, *cur_sin;
+	struct sockaddr *addr, *cur_addr;
 	struct rdma_bind_list *bind_list;
 	struct hlist_node *node;
 	unsigned short snum;
 
-	sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr;
-	snum = ntohs(sin->sin_port);
+	addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr;
+	snum = ntohs(cma_port(addr));
 	if (snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))
 		return -EACCES;
 
@@ -2032,15 +2047,15 @@ static int cma_use_port(struct idr *ps, struct rdma_id_private *id_priv)
 	 * We don't support binding to any address if anyone is bound to
 	 * a specific address on the same port.
 	 */
-	if (cma_any_addr((struct sockaddr *) &id_priv->id.route.addr.src_addr))
+	if (cma_any_addr(addr))
 		return -EADDRNOTAVAIL;
 
 	hlist_for_each_entry(cur_id, node, &bind_list->owners, node) {
-		if (cma_any_addr((struct sockaddr *) &cur_id->id.route.addr.src_addr))
+		cur_addr = (struct sockaddr *) &cur_id->id.route.addr.src_addr;
+		if (cma_any_addr(cur_addr))
 			return -EADDRNOTAVAIL;
 
-		cur_sin = (struct sockaddr_in *) &cur_id->id.route.addr.src_addr;
-		if (sin->sin_addr.s_addr == cur_sin->sin_addr.s_addr)
+		if (!cma_addr_cmp(addr, cur_addr))
 			return -EADDRINUSE;
 	}
 



--
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] 41+ messages in thread

* [RFC] [PATCH 3/22] [for 2.6.36] rdma/cm: include AF_IB in loopback and any address checks
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  2010-03-23 17:52   ` [RFC] [PATCH 1/22] [for 2.6.36] rdma/cm: define native IB address Sean Hefty
  2010-03-23 17:54   ` [RFC] [PATCH 2/22] [for 2.6.36] rdma/cm: fix handling of ipv6 addressing in cma_use_port Sean Hefty
@ 2010-03-23 17:55   ` Sean Hefty
  2010-03-23 17:57   ` [RFC] [PATCH 4/22] [for 2.6.36] ib/addr: add AF_IB support to ip_addr_size Sean Hefty
                     ` (20 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 17:55 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Enhance checks for loopback and any address to support AF_IB
in addition to AF_INET and AF_INT6.  This will allow future
patches to use AF_IB when binding and resolving addresses.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/cma.c |   35 ++++++++++++++++++++---------------
 1 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 9041a2b..6460fbf 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -46,6 +46,7 @@
 
 #include <rdma/rdma_cm.h>
 #include <rdma/rdma_cm_ib.h>
+#include <rdma/ib.h>
 #include <rdma/ib_cache.h>
 #include <rdma/ib_cm.h>
 #include <rdma/ib_sa.h>
@@ -616,26 +617,30 @@ EXPORT_SYMBOL(rdma_init_qp_attr);
 
 static inline int cma_zero_addr(struct sockaddr *addr)
 {
-	struct in6_addr *ip6;
-
-	if (addr->sa_family == AF_INET)
-		return ipv4_is_zeronet(
-			((struct sockaddr_in *)addr)->sin_addr.s_addr);
-	else {
-		ip6 = &((struct sockaddr_in6 *) addr)->sin6_addr;
-		return (ip6->s6_addr32[0] | ip6->s6_addr32[1] |
-			ip6->s6_addr32[2] | ip6->s6_addr32[3]) == 0;
+	switch (addr->sa_family) {
+	case AF_INET:
+		return ipv4_is_zeronet(((struct sockaddr_in *)addr)->sin_addr.s_addr);
+	case AF_INET6:
+		return ipv6_addr_any(&((struct sockaddr_in6 *) addr)->sin6_addr);
+	case AF_IB:
+		return ib_addr_any(&((struct sockaddr_ib *) addr)->sib_addr);
+	default:
+		return 0;
 	}
 }
 
 static inline int cma_loopback_addr(struct sockaddr *addr)
 {
-	if (addr->sa_family == AF_INET)
-		return ipv4_is_loopback(
-			((struct sockaddr_in *) addr)->sin_addr.s_addr);
-	else
-		return ipv6_addr_loopback(
-			&((struct sockaddr_in6 *) addr)->sin6_addr);
+	switch (addr->sa_family) {
+	case AF_INET:
+		return ipv4_is_loopback(((struct sockaddr_in *) addr)->sin_addr.s_addr);
+	case AF_INET6:
+		return ipv6_addr_loopback(&((struct sockaddr_in6 *) addr)->sin6_addr);
+	case AF_IB:
+		return ib_addr_loopback(&((struct sockaddr_ib *) addr)->sib_addr);
+	default:
+		return 0;
+	}
 }
 
 static inline int cma_any_addr(struct sockaddr *addr)



--
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] 41+ messages in thread

* [RFC] [PATCH 4/22] [for 2.6.36] ib/addr: add AF_IB support to ip_addr_size
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (2 preceding siblings ...)
  2010-03-23 17:55   ` [RFC] [PATCH 3/22] [for 2.6.36] rdma/cm: include AF_IB in loopback and any address checks Sean Hefty
@ 2010-03-23 17:57   ` Sean Hefty
  2010-03-23 17:59   ` [RFC] [PATCH 5/22] [for 2.6.36] rdma/cm: update port reservation to support AF_IB Sean Hefty
                     ` (19 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 17:57 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Add support for AF_IB to ip_addr_size, and rename the function
to account for the change.  Give the compiler more control over
whether the call should be inline or not by moving the definition
into the .c file, removing the static inline, and exporting it.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/addr.c |   20 ++++++++++++++++++--
 drivers/infiniband/core/cma.c  |   12 ++++++------
 include/rdma/ib_addr.h         |    6 +-----
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index abbb069..f73c5de 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -43,6 +43,7 @@
 #include <net/addrconf.h>
 #include <net/ip6_route.h>
 #include <rdma/ib_addr.h>
+#include <rdma/ib.h>
 
 MODULE_AUTHOR("Sean Hefty");
 MODULE_DESCRIPTION("IB Address Translation");
@@ -68,6 +69,21 @@ static LIST_HEAD(req_list);
 static DECLARE_DELAYED_WORK(work, process_req);
 static struct workqueue_struct *addr_wq;
 
+int rdma_addr_size(struct sockaddr *addr)
+{
+	switch (addr->sa_family) {
+	case AF_INET:
+		return sizeof(struct sockaddr_in);
+	case AF_INET6:
+		return sizeof(struct sockaddr_in6);
+	case AF_IB:
+		return sizeof(struct sockaddr_ib);
+	default:
+		return 0;
+	}
+}
+EXPORT_SYMBOL(rdma_addr_size);
+
 void rdma_addr_register_client(struct rdma_addr_client *client)
 {
 	atomic_set(&client->refcount, 1);
@@ -366,12 +382,12 @@ int rdma_resolve_ip(struct rdma_addr_client *client,
 			goto err;
 		}
 
-		memcpy(src_in, src_addr, ip_addr_size(src_addr));
+		memcpy(src_in, src_addr, rdma_addr_size(src_addr));
 	} else {
 		src_in->sa_family = dst_addr->sa_family;
 	}
 
-	memcpy(dst_in, dst_addr, ip_addr_size(dst_addr));
+	memcpy(dst_in, dst_addr, rdma_addr_size(dst_addr));
 	req->addr = addr;
 	req->callback = callback;
 	req->context = context;
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 6460fbf..ac57155 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1468,7 +1468,7 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv,
 
 	dev_id_priv->state = CMA_ADDR_BOUND;
 	memcpy(&id->route.addr.src_addr, &id_priv->id.route.addr.src_addr,
-	       ip_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr));
+	       rdma_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr));
 
 	cma_attach_to_dev(dev_id_priv, cma_dev);
 	list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list);
@@ -1834,7 +1834,7 @@ static void addr_handler(int status, struct sockaddr *src_addr,
 		event.status = status;
 	} else {
 		memcpy(&id_priv->id.route.addr.src_addr, src_addr,
-		       ip_addr_size(src_addr));
+		       rdma_addr_size(src_addr));
 		event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
 	}
 
@@ -1924,7 +1924,7 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
 		return -EINVAL;
 
 	atomic_inc(&id_priv->refcount);
-	memcpy(&id->route.addr.dst_addr, dst_addr, ip_addr_size(dst_addr));
+	memcpy(&id->route.addr.dst_addr, dst_addr, rdma_addr_size(dst_addr));
 	if (cma_any_addr(dst_addr))
 		ret = cma_resolve_loopback(id_priv);
 	else
@@ -2147,7 +2147,7 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
 			goto err1;
 	}
 
-	memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr));
+	memcpy(&id->route.addr.src_addr, addr, rdma_addr_size(addr));
 	ret = cma_get_port(id_priv);
 	if (ret)
 		goto err2;
@@ -2807,7 +2807,7 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
 	if (!mc)
 		return -ENOMEM;
 
-	memcpy(&mc->addr, addr, ip_addr_size(addr));
+	memcpy(&mc->addr, addr, rdma_addr_size(addr));
 	mc->context = context;
 	mc->id_priv = id_priv;
 
@@ -2842,7 +2842,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr)
 	id_priv = container_of(id, struct rdma_id_private, id);
 	spin_lock_irq(&id_priv->lock);
 	list_for_each_entry(mc, &id_priv->mc_list, list) {
-		if (!memcmp(&mc->addr, addr, ip_addr_size(addr))) {
+		if (!memcmp(&mc->addr, addr, rdma_addr_size(addr))) {
 			list_del(&mc->list);
 			spin_unlock_irq(&id_priv->lock);
 
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h
index fa0d52b..9e06769 100644
--- a/include/rdma/ib_addr.h
+++ b/include/rdma/ib_addr.h
@@ -99,11 +99,7 @@ void rdma_addr_cancel(struct rdma_dev_addr *addr);
 int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
 	      const unsigned char *dst_dev_addr);
 
-static inline int ip_addr_size(struct sockaddr *addr)
-{
-	return addr->sa_family == AF_INET6 ?
-	       sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in);
-}
+int rdma_addr_size(struct sockaddr *addr);
 
 static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr)
 {



--
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] 41+ messages in thread

* [RFC] [PATCH 5/22] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (3 preceding siblings ...)
  2010-03-23 17:57   ` [RFC] [PATCH 4/22] [for 2.6.36] ib/addr: add AF_IB support to ip_addr_size Sean Hefty
@ 2010-03-23 17:59   ` Sean Hefty
       [not found]     ` <012F7D9E5E97445E9100EF170212AEE7-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  2010-03-23 18:01   ` [RFC] [PATCH 6/22] [for 2.6.36] rdma/cm: Allow user to specify AF_IB when binding Sean Hefty
                     ` (18 subsequent siblings)
  23 siblings, 1 reply; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 17:59 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Update the port reservation code path to support AF_IB addresses.
AF_IB is limited to the port spaces defined by the RDMA CM IP Annex
which are already supported by the rdma cm.

AF_IB is used with a sockaddr_ib structure, which exposes a 64-bit
service ID, rather than a 16-bit port number used by IP.  As a result,
port numbers must be converted between the two formats as defined by
the above annex.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/cma.c |   38 +++++++++++++++++++++++++++++++-------
 1 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index ac57155..1546236 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -657,18 +657,28 @@ static int cma_addr_cmp(struct sockaddr *src, struct sockaddr *dst)
 	case AF_INET:
 		return ((struct sockaddr_in *) src)->sin_addr.s_addr !=
 		       ((struct sockaddr_in *) dst)->sin_addr.s_addr;
-	default:
+	case AF_INET6:
 		return ipv6_addr_cmp(&((struct sockaddr_in6 *) src)->sin6_addr,
 				     &((struct sockaddr_in6 *) dst)->sin6_addr);
+	default:
+		return ib_addr_cmp(&((struct sockaddr_ib *) src)->sib_addr,
+				   &((struct sockaddr_ib *) dst)->sib_addr);
 	}
 }
 
-static inline __be16 cma_port(struct sockaddr *addr)
+/* AF_IB must be using the RDMA CM IP Annex */
+static __be16 cma_port(struct sockaddr *addr)
 {
-	if (addr->sa_family == AF_INET)
+	switch (addr->sa_family) {
+	case AF_INET:
 		return ((struct sockaddr_in *) addr)->sin_port;
-	else
+	case AF_INET6:
 		return ((struct sockaddr_in6 *) addr)->sin6_port;
+	case AF_IB:
+		return htons((u16) be64_to_cpu(((struct sockaddr_ib *) addr)->sib_sid));
+	default:
+		return 0;
+	}
 }
 
 static inline int cma_any_port(struct sockaddr *addr)
@@ -1945,10 +1955,24 @@ EXPORT_SYMBOL(rdma_resolve_addr);
 static void cma_bind_port(struct rdma_bind_list *bind_list,
 			  struct rdma_id_private *id_priv)
 {
-	struct sockaddr_in *sin;
+	struct sockaddr *addr;
+	__be16 port;
 
-	sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr;
-	sin->sin_port = htons(bind_list->port);
+	addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr;
+	port = htons(bind_list->port);
+
+	switch (addr->sa_family) {
+	case AF_INET:
+		((struct sockaddr_in *) addr)->sin_port = port;
+		break;
+	case AF_INET6:
+		((struct sockaddr_in6 *) addr)->sin6_port = port;
+		break;
+	case AF_IB:
+		((struct sockaddr_ib *) addr)->sib_sid =
+			cpu_to_be64(((u64) bind_list->ps << 16) + ntohs(port));
+		break;
+	}
 	id_priv->bind_list = bind_list;
 	hlist_add_head(&id_priv->node, &bind_list->owners);
 }



--
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] 41+ messages in thread

* [RFC] [PATCH 6/22] [for 2.6.36] rdma/cm: Allow user to specify AF_IB when binding
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (4 preceding siblings ...)
  2010-03-23 17:59   ` [RFC] [PATCH 5/22] [for 2.6.36] rdma/cm: update port reservation to support AF_IB Sean Hefty
@ 2010-03-23 18:01   ` Sean Hefty
  2010-03-23 18:03   ` [RFC] [PATCH 7/22] [for 2.6.36] rdma/cm: do not modify sa_family when setting loopback address Sean Hefty
                     ` (17 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:01 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Modify rdma_bind_addr to allow the user to specify AF_IB when
binding to a device.  AF_IB indicates that the user is not
mapping an IP address to the native IB addressing.  (The mapping
may have already been done, or is not needed.)

The format of the SID is still controlled by the rdma cm,
but is now exported in its entirety, rather than
just the 16 bit port value based on the RDMA CM IP annex.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/cma.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 1546236..0a3bbf9 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -324,6 +324,13 @@ static int cma_set_qkey(struct rdma_id_private *id_priv)
 	return ret;
 }
 
+static void cma_translate_ib(struct sockaddr_ib *addr, struct rdma_dev_addr *dev_addr)
+{
+	dev_addr->dev_type = ARPHRD_INFINIBAND;
+	rdma_addr_set_sgid(dev_addr, (union ib_gid *) &addr->sib_addr);
+	ib_addr_set_pkey(dev_addr, ntohs(addr->sib_pkey));
+}
+
 static int cma_acquire_dev(struct rdma_id_private *id_priv)
 {
 	struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
@@ -2148,7 +2155,8 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
 	struct rdma_id_private *id_priv;
 	int ret;
 
-	if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6)
+	if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6 &&
+	    addr->sa_family != AF_IB)
 		return -EAFNOSUPPORT;
 
 	id_priv = container_of(id, struct rdma_id_private, id);
@@ -2160,9 +2168,14 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
 		goto err1;
 
 	if (!cma_any_addr(addr)) {
-		ret = rdma_translate_ip(addr, &id->route.addr.dev_addr);
-		if (ret)
-			goto err1;
+		if (addr->sa_family == AF_IB) {
+			cma_translate_ib((struct sockaddr_ib *) addr,
+					 &id->route.addr.dev_addr);
+		} else {
+			ret = rdma_translate_ip(addr, &id->route.addr.dev_addr);
+			if (ret)
+				goto err1;
+		}
 
 		mutex_lock(&lock);
 		ret = cma_acquire_dev(id_priv);



--
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] 41+ messages in thread

* [RFC] [PATCH 7/22] [for 2.6.36] rdma/cm: do not modify sa_family when setting loopback address
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (5 preceding siblings ...)
  2010-03-23 18:01   ` [RFC] [PATCH 6/22] [for 2.6.36] rdma/cm: Allow user to specify AF_IB when binding Sean Hefty
@ 2010-03-23 18:03   ` Sean Hefty
  2010-03-23 18:04   ` [RFC] [PATCH 8/22] [for 2.6.36] rdma/cm: restrict AF_IB loopback to binding to IB devices only Sean Hefty
                     ` (16 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:03 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

cma_resolve_loopback is called after an rdma_cm_id has been
bound to a specific sa_family and port.  Once the
source sa_family for the id has been set, do not modify it.
Only the actual IP address portion of the source address
needs to be set.

As part of this fix, we can simplify setting the source address
by moving the loopback address assignment from cma_resolve_loopback
to cma_bind_loopback.  cma_bind_loopback is only invoked when
the source address is the loopback address.

Finally, add loopback support for AF_IB as part of the change.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/cma.c |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 0a3bbf9..7981a85 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1776,6 +1776,23 @@ err:
 }
 EXPORT_SYMBOL(rdma_resolve_route);
 
+static void cma_set_loopback(struct sockaddr *addr)
+{
+	switch (addr->sa_family) {
+	case AF_INET:
+		((struct sockaddr_in *) addr)->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+		break;
+	case AF_INET6:
+		ipv6_addr_set(&((struct sockaddr_in6 *) addr)->sin6_addr,
+			      0, 0, 0, htonl(1));
+		break;
+	default:
+		ib_addr_set(&((struct sockaddr_ib *) addr)->sib_addr,
+			    0, 0, 0, htonl(1));
+		break;
+	}
+}
+
 static int cma_bind_loopback(struct rdma_id_private *id_priv)
 {
 	struct cma_device *cma_dev;
@@ -1816,6 +1833,7 @@ port_found:
 	ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey);
 	id_priv->id.port_num = p;
 	cma_attach_to_dev(id_priv, cma_dev);
+	cma_set_loopback((struct sockaddr *) &id_priv->id.route.addr.src_addr);
 out:
 	mutex_unlock(&lock);
 	return ret;
@@ -1870,7 +1888,6 @@ out:
 static int cma_resolve_loopback(struct rdma_id_private *id_priv)
 {
 	struct cma_work *work;
-	struct sockaddr *src, *dst;
 	union ib_gid gid;
 	int ret;
 
@@ -1887,18 +1904,6 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv)
 	rdma_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid);
 	rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid);
 
-	src = (struct sockaddr *) &id_priv->id.route.addr.src_addr;
-	if (cma_zero_addr(src)) {
-		dst = (struct sockaddr *) &id_priv->id.route.addr.dst_addr;
-		if ((src->sa_family = dst->sa_family) == AF_INET) {
-			((struct sockaddr_in *) src)->sin_addr.s_addr =
-				((struct sockaddr_in *) dst)->sin_addr.s_addr;
-		} else {
-			ipv6_addr_copy(&((struct sockaddr_in6 *) src)->sin6_addr,
-				       &((struct sockaddr_in6 *) dst)->sin6_addr);
-		}
-	}
-
 	work->id = id_priv;
 	INIT_WORK(&work->work, cma_work_handler);
 	work->old_state = CMA_ADDR_QUERY;



--
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] 41+ messages in thread

* [RFC] [PATCH 8/22] [for 2.6.36] rdma/cm: restrict AF_IB loopback to binding to IB devices only
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (6 preceding siblings ...)
  2010-03-23 18:03   ` [RFC] [PATCH 7/22] [for 2.6.36] rdma/cm: do not modify sa_family when setting loopback address Sean Hefty
@ 2010-03-23 18:04   ` Sean Hefty
  2010-03-23 18:06   ` [RFC] [PATCH 9/22] [for 2.6.36] rdma/cm: add support for AF_IB to rdma_resolve_addr Sean Hefty
                     ` (15 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:04 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

If a user specifies AF_IB as the source address for a loopback
connection, limit the resolution to IB devices only.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/cma.c |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 7981a85..0bc33cc 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1795,26 +1795,40 @@ static void cma_set_loopback(struct sockaddr *addr)
 
 static int cma_bind_loopback(struct rdma_id_private *id_priv)
 {
-	struct cma_device *cma_dev;
+	struct cma_device *cma_dev, *cur_dev;
+	struct sockaddr *addr;
 	struct ib_port_attr port_attr;
 	union ib_gid gid;
 	u16 pkey;
 	int ret;
 	u8 p;
 
+	cma_dev = NULL;
+	addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr;
 	mutex_lock(&lock);
-	if (list_empty(&dev_list)) {
+	list_for_each_entry(cur_dev, &dev_list, list) {
+		if (addr->sa_family == AF_IB &&
+		    rdma_node_get_transport(cur_dev->device->node_type) != RDMA_TRANSPORT_IB)
+			continue;
+
+		if (!cma_dev)
+			cma_dev = cur_dev;
+
+		for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
+			if (!ib_query_port(cur_dev->device, p, &port_attr) &&
+			    port_attr.state == IB_PORT_ACTIVE) {
+				cma_dev = cur_dev;
+				goto port_found;
+			}
+		}
+	}
+
+	if (!cma_dev) {
 		ret = -ENODEV;
 		goto out;
 	}
-	list_for_each_entry(cma_dev, &dev_list, list)
-		for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p)
-			if (!ib_query_port(cma_dev->device, p, &port_attr) &&
-			    port_attr.state == IB_PORT_ACTIVE)
-				goto port_found;
 
 	p = 1;
-	cma_dev = list_entry(dev_list.next, struct cma_device, list);
 
 port_found:
 	ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid);



--
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] 41+ messages in thread

* [RFC] [PATCH 9/22] [for 2.6.36] rdma/cm: add support for AF_IB to rdma_resolve_addr
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (7 preceding siblings ...)
  2010-03-23 18:04   ` [RFC] [PATCH 8/22] [for 2.6.36] rdma/cm: restrict AF_IB loopback to binding to IB devices only Sean Hefty
@ 2010-03-23 18:06   ` Sean Hefty
  2010-03-23 18:07   ` [RFC] [PATCH 10/22] [for 2.6.36] rdma/cm: add support for AF_IB to cma_get_service_id Sean Hefty
                     ` (14 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:06 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Allow the user to specify the remote address using AF_IB format.
When AF_IB is used, the remote address simply needs to be recorded,
and no resolution using ARP is done.  The local address may still
need to be resolved however.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/cma.c |  108 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 102 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 0bc33cc..c7b6912 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -350,6 +350,62 @@ static int cma_acquire_dev(struct rdma_id_private *id_priv)
 	return ret;
 }
 
+/*
+ * Select the source IB device and address to reach the destination IB address.
+ */
+static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
+{
+	struct cma_device *cma_dev, *cur_dev;
+	struct sockaddr_ib *addr;
+	union ib_gid gid, sgid, *dgid;
+	u16 pkey, index;
+	u8 port, p;
+	int i;
+
+	cma_dev = NULL;
+	addr = (struct sockaddr_ib *) &id_priv->id.route.addr.dst_addr;
+	dgid = (union ib_gid *) &addr->sib_addr;
+	pkey = ntohs(addr->sib_pkey);
+
+	list_for_each_entry(cur_dev, &dev_list, list) {
+		if (rdma_node_get_transport(cur_dev->device->node_type) != RDMA_TRANSPORT_IB)
+			continue;
+
+		for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
+			if (ib_find_cached_pkey(cur_dev->device, p, pkey, &index))
+				continue;
+
+			for (i = 0; !ib_get_cached_gid(cur_dev->device, p, i, &gid); i++) {
+				if (!memcmp(&gid, dgid, sizeof(gid))) {
+					cma_dev = cur_dev;
+					sgid = gid;
+					port = p;
+					goto found;
+				}
+
+				if (!cma_dev && (gid.global.subnet_prefix ==
+						 dgid->global.subnet_prefix)) {
+					cma_dev = cur_dev;
+					sgid = gid;
+					port = p;
+				}
+			}
+		}
+	}
+
+	if (!cma_dev) {
+		return -ENODEV;
+	}
+
+found:
+	cma_attach_to_dev(id_priv, cma_dev);
+	id_priv->id.port_num = port;
+	addr = (struct sockaddr_ib *) &id_priv->id.route.addr.src_addr;
+	memcpy(&addr->sib_addr, &sgid, sizeof sgid);
+	cma_translate_ib(addr, &id_priv->id.route.addr.dev_addr);
+	return 0;
+}
+
 static void cma_deref_id(struct rdma_id_private *id_priv)
 {
 	if (atomic_dec_and_test(&id_priv->refcount))
@@ -1930,14 +1986,48 @@ err:
 	return ret;
 }
 
+static int cma_resolve_ib_addr(struct rdma_id_private *id_priv)
+{
+	struct cma_work *work;
+	int ret;
+
+	work = kzalloc(sizeof *work, GFP_KERNEL);
+	if (!work)
+		return -ENOMEM;
+
+	if (!id_priv->cma_dev) {
+		ret = cma_resolve_ib_dev(id_priv);
+		if (ret)
+			goto err;
+	}
+
+	rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, (union ib_gid *)
+		&(((struct sockaddr_ib *) &id_priv->id.route.addr.dst_addr)->sib_addr));
+
+	work->id = id_priv;
+	INIT_WORK(&work->work, cma_work_handler);
+	work->old_state = CMA_ADDR_QUERY;
+	work->new_state = CMA_ADDR_RESOLVED;
+	work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
+	queue_work(cma_wq, &work->work);
+	return 0;
+err:
+	kfree(work);
+	return ret;
+}
+
 static int cma_bind_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
 			 struct sockaddr *dst_addr)
 {
 	if (!src_addr || !src_addr->sa_family) {
 		src_addr = (struct sockaddr *) &id->route.addr.src_addr;
-		if ((src_addr->sa_family = dst_addr->sa_family) == AF_INET6) {
+		src_addr->sa_family = dst_addr->sa_family;
+		if (dst_addr->sa_family == AF_INET6) {
 			((struct sockaddr_in6 *) src_addr)->sin6_scope_id =
 				((struct sockaddr_in6 *) dst_addr)->sin6_scope_id;
+		} else if (dst_addr->sa_family == AF_IB) {
+			((struct sockaddr_ib *) src_addr)->sib_pkey =
+				((struct sockaddr_ib *) dst_addr)->sib_pkey;
 		}
 	}
 	return rdma_bind_addr(id, src_addr);
@@ -1961,12 +2051,18 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
 
 	atomic_inc(&id_priv->refcount);
 	memcpy(&id->route.addr.dst_addr, dst_addr, rdma_addr_size(dst_addr));
-	if (cma_any_addr(dst_addr))
+	if (cma_any_addr(dst_addr)) {
 		ret = cma_resolve_loopback(id_priv);
-	else
-		ret = rdma_resolve_ip(&addr_client, (struct sockaddr *) &id->route.addr.src_addr,
-				      dst_addr, &id->route.addr.dev_addr,
-				      timeout_ms, addr_handler, id_priv);
+	} else {
+		if (dst_addr->sa_family == AF_IB) {
+			ret = cma_resolve_ib_addr(id_priv);
+		} else {
+			ret = rdma_resolve_ip(&addr_client,
+					      (struct sockaddr *) &id->route.addr.src_addr,
+					      dst_addr, &id->route.addr.dev_addr,
+					      timeout_ms, addr_handler, id_priv);
+		}
+	}
 	if (ret)
 		goto err;
 



--
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] 41+ messages in thread

* [RFC] [PATCH 10/22] [for 2.6.36] rdma/cm: add support for AF_IB to cma_get_service_id
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (8 preceding siblings ...)
  2010-03-23 18:06   ` [RFC] [PATCH 9/22] [for 2.6.36] rdma/cm: add support for AF_IB to rdma_resolve_addr Sean Hefty
@ 2010-03-23 18:07   ` Sean Hefty
  2010-03-23 18:08   ` [RFC] [PATCH 11/22] [for 2.6.36] rdma/cm: fixup white space Sean Hefty
                     ` (13 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:07 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

cma_get_service_id forms the service ID based on the port space
and port number of the rdma_cm_id.  Extend the call to support
AF_IB, which contains the service ID directly.  This will
be needed to support any arbitrary SID.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/cma.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index c7b6912..326bda6 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1259,6 +1259,9 @@ out:
 
 static __be64 cma_get_service_id(enum rdma_port_space ps, struct sockaddr *addr)
 {
+	if (addr->sa_family == AF_IB)
+		return ((struct sockaddr_ib *) addr)->sib_sid;
+
 	return cpu_to_be64(((u64)ps << 16) + be16_to_cpu(cma_port(addr)));
 }
 



--
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] 41+ messages in thread

* [RFC] [PATCH 11/22] [for 2.6.36] rdma/cm: fixup white space
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (9 preceding siblings ...)
  2010-03-23 18:07   ` [RFC] [PATCH 10/22] [for 2.6.36] rdma/cm: add support for AF_IB to cma_get_service_id Sean Hefty
@ 2010-03-23 18:08   ` Sean Hefty
  2010-03-23 18:11   ` [RFC] [PATCH 12/22] [for 2.6.36] rdma/cm: expose private data when using AF_IB Sean Hefty
                     ` (12 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:08 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Fix white space issue that bugs me.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/cma.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 326bda6..b4adcc6 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1657,7 +1657,7 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms,
 	path_rec.numb_path = 1;
 	path_rec.reversible = 1;
 	path_rec.service_id = cma_get_service_id(id_priv->id.ps,
-							(struct sockaddr *) &addr->dst_addr);
+						 (struct sockaddr *) &addr->dst_addr);
 
 	comp_mask = IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID |
 		    IB_SA_PATH_REC_PKEY | IB_SA_PATH_REC_NUMB_PATH |



--
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] 41+ messages in thread

* [RFC] [PATCH 12/22] [for 2.6.36] rdma/cm: expose private data when using AF_IB
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (10 preceding siblings ...)
  2010-03-23 18:08   ` [RFC] [PATCH 11/22] [for 2.6.36] rdma/cm: fixup white space Sean Hefty
@ 2010-03-23 18:11   ` Sean Hefty
  2010-03-23 18:12   ` [RFC] [PATCH 13/22] [for 2.6.36] rdma/cm: only listen on IB devices " Sean Hefty
                     ` (11 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:11 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

If the source or destination address is AF_IB, then do not
reserve a portion of the private data in the IB CM REQ or SIDR
REQ messages for the cma header.  Instead, all private data
should be exported to the user.  When AF_IB is used, the
rdma cm does not have sufficient information to fill in the
cma header.  Additionally, this will be necessary to support
any IB connection through the rdma cm interface, 

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
rdma_getaddrinfo will end up formatting the private data for the user
if necessary.

 drivers/infiniband/core/cma.c |   46 +++++++++++++++++++++--------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index b4adcc6..0d3c4ef 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -818,14 +818,13 @@ static void cma_save_net_info(struct rdma_addr *addr,
 	}
 }
 
-static inline int cma_user_data_offset(enum rdma_port_space ps)
+static inline int cma_user_data_offset(struct rdma_cm_id *id)
 {
-	switch (ps) {
-	case RDMA_PS_SDP:
+	if (id->ps == RDMA_PS_SDP || id->route.addr.src_addr.ss_family == AF_IB ||
+	    id->route.addr.dst_addr.ss_family == AF_IB)
 		return 0;
-	default:
+	else
 		return sizeof(struct cma_hdr);
-	}
 }
 
 static void cma_cancel_route(struct rdma_id_private *id_priv)
@@ -1201,7 +1200,7 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
 		return -ECONNABORTED;
 
 	memset(&event, 0, sizeof event);
-	offset = cma_user_data_offset(listen_id->id.ps);
+	offset = cma_user_data_offset(&listen_id->id);
 	event.event = RDMA_CM_EVENT_CONNECT_REQUEST;
 	if (cma_is_ud_ps(listen_id->id.ps)) {
 		conn_id = cma_new_udp_id(&listen_id->id, ib_event);
@@ -2320,19 +2319,19 @@ err1:
 }
 EXPORT_SYMBOL(rdma_bind_addr);
 
-static int cma_format_hdr(void *hdr, enum rdma_port_space ps,
-			  struct rdma_route *route)
+static int cma_format_hdr(void *hdr, struct rdma_cm_id *id)
 {
 	struct cma_hdr *cma_hdr;
 	struct sdp_hh *sdp_hdr;
 
-	if (route->addr.src_addr.ss_family == AF_INET) {
+	if (id->route.addr.src_addr.ss_family == AF_INET &&
+	    id->route.addr.dst_addr.ss_family == AF_INET) {
 		struct sockaddr_in *src4, *dst4;
 
-		src4 = (struct sockaddr_in *) &route->addr.src_addr;
-		dst4 = (struct sockaddr_in *) &route->addr.dst_addr;
+		src4 = (struct sockaddr_in *) &id->route.addr.src_addr;
+		dst4 = (struct sockaddr_in *) &id->route.addr.dst_addr;
 
-		switch (ps) {
+		switch (id->ps) {
 		case RDMA_PS_SDP:
 			sdp_hdr = hdr;
 			if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION)
@@ -2351,13 +2350,14 @@ static int cma_format_hdr(void *hdr, enum rdma_port_space ps,
 			cma_hdr->port = src4->sin_port;
 			break;
 		}
-	} else {
+	} else if (id->route.addr.src_addr.ss_family == AF_INET6 &&
+		   id->route.addr.dst_addr.ss_family == AF_INET6) {
 		struct sockaddr_in6 *src6, *dst6;
 
-		src6 = (struct sockaddr_in6 *) &route->addr.src_addr;
-		dst6 = (struct sockaddr_in6 *) &route->addr.dst_addr;
+		src6 = (struct sockaddr_in6 *) &id->route.addr.src_addr;
+		dst6 = (struct sockaddr_in6 *) &id->route.addr.dst_addr;
 
-		switch (ps) {
+		switch (id->ps) {
 		case RDMA_PS_SDP:
 			sdp_hdr = hdr;
 			if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION)
@@ -2449,20 +2449,20 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv,
 {
 	struct ib_cm_sidr_req_param req;
 	struct rdma_route *route;
-	int ret;
+	int offset, ret;
 
-	req.private_data_len = sizeof(struct cma_hdr) +
-			       conn_param->private_data_len;
+	offset = cma_user_data_offset(&id_priv->id);
+	req.private_data_len = offset + conn_param->private_data_len;
 	req.private_data = kzalloc(req.private_data_len, GFP_ATOMIC);
 	if (!req.private_data)
 		return -ENOMEM;
 
 	if (conn_param->private_data && conn_param->private_data_len)
-		memcpy((void *) req.private_data + sizeof(struct cma_hdr),
+		memcpy((void *) req.private_data + offset,
 		       conn_param->private_data, conn_param->private_data_len);
 
 	route = &id_priv->id.route;
-	ret = cma_format_hdr((void *) req.private_data, id_priv->id.ps, route);
+	ret = cma_format_hdr((void *) req.private_data, &id_priv->id);
 	if (ret)
 		goto out;
 
@@ -2498,7 +2498,7 @@ static int cma_connect_ib(struct rdma_id_private *id_priv,
 	int offset, ret;
 
 	memset(&req, 0, sizeof req);
-	offset = cma_user_data_offset(id_priv->id.ps);
+	offset = cma_user_data_offset(&id_priv->id);
 	req.private_data_len = offset + conn_param->private_data_len;
 	private_data = kzalloc(req.private_data_len, GFP_ATOMIC);
 	if (!private_data)
@@ -2516,7 +2516,7 @@ static int cma_connect_ib(struct rdma_id_private *id_priv,
 	}
 
 	route = &id_priv->id.route;
-	ret = cma_format_hdr(private_data, id_priv->id.ps, route);
+	ret = cma_format_hdr(private_data, &id_priv->id);
 	if (ret)
 		goto out;
 	req.private_data = private_data;



--
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] 41+ messages in thread

* [RFC] [PATCH 13/22] [for 2.6.36] rdma/cm: only listen on IB devices when using AF_IB
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (11 preceding siblings ...)
  2010-03-23 18:11   ` [RFC] [PATCH 12/22] [for 2.6.36] rdma/cm: expose private data when using AF_IB Sean Hefty
@ 2010-03-23 18:12   ` Sean Hefty
  2010-03-23 18:14   ` [RFC] [PATCH 14/22] [for 2.6.36] rdma/ucm: support querying for AF_IB addresses Sean Hefty
                     ` (10 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:12 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

If an rdma_cm_id is bound to AF_IB, with a wild card address,
only listen on IB devices.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/cma.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 0d3c4ef..c5bb70c 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1535,6 +1535,10 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv,
 	struct rdma_cm_id *id;
 	int ret;
 
+	if (id_priv->id.route.addr.src_addr.ss_family == AF_IB &&
+	    rdma_node_get_transport(cma_dev->device->node_type) != RDMA_TRANSPORT_IB)
+		return;
+
 	id = rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps);
 	if (IS_ERR(id))
 		return;



--
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] 41+ messages in thread

* [RFC] [PATCH 14/22] [for 2.6.36] rdma/ucm: support querying for AF_IB addresses
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (12 preceding siblings ...)
  2010-03-23 18:12   ` [RFC] [PATCH 13/22] [for 2.6.36] rdma/cm: only listen on IB devices " Sean Hefty
@ 2010-03-23 18:14   ` Sean Hefty
  2010-03-23 18:16   ` [RFC] [PATCH 15/22] [for 2.6.36] ib/sa: export function to pack a path record into wire format Sean Hefty
                     ` (9 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:14 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

The sockaddr structure for AF_IB is larger than sockaddr_in6.
The rdma cm user space ABI uses the latter to exchange address
information between user space and the kernel.

To support querying for larger addresses, define a new query
command that exchanges data using sockaddr_storage, rather
than sockaddr_in6.  Unlike the existing query_route command,
the new command only returns address information.  Route
(i.e. path record) data is separated.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/ucma.c |   76 +++++++++++++++++++++++++++++++++++++++-
 include/rdma/rdma_user_cm.h    |   22 ++++++++++--
 2 files changed, 93 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index b2e16c3..da5a3ec 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -44,6 +44,7 @@
 #include <rdma/ib_marshall.h>
 #include <rdma/rdma_cm.h>
 #include <rdma/rdma_cm_ib.h>
+#include <rdma/ib_addr.h>
 
 MODULE_AUTHOR("Sean Hefty");
 MODULE_DESCRIPTION("RDMA Userspace Connection Manager Access");
@@ -586,7 +587,7 @@ static ssize_t ucma_query_route(struct ucma_file *file,
 				const char __user *inbuf,
 				int in_len, int out_len)
 {
-	struct rdma_ucm_query_route cmd;
+	struct rdma_ucm_query cmd;
 	struct rdma_ucm_query_route_resp resp;
 	struct ucma_context *ctx;
 	struct sockaddr *addr;
@@ -633,6 +634,76 @@ out:
 	return ret;
 }
 
+static void ucma_query_device_addr(struct rdma_cm_id *cm_id,
+				   struct rdma_ucm_query_addr_resp *resp)
+{
+	if (!cm_id->device)
+		return;
+
+	resp->node_guid = (__force __u64) cm_id->device->node_guid;
+	resp->port_num = cm_id->port_num;
+	resp->pkey = (__force __u16) cpu_to_be16(
+		     ib_addr_get_pkey(&cm_id->route.addr.dev_addr));
+}
+
+static ssize_t ucma_query_addr(struct ucma_context *ctx,
+			       void __user *response, int out_len)
+{
+	struct rdma_ucm_query_addr_resp resp;
+	struct sockaddr *addr;
+	int ret = 0;
+
+	if (out_len < sizeof(resp))
+		return -ENOSPC;
+
+	memset(&resp, 0, sizeof resp);
+
+	addr = (struct sockaddr *) &ctx->cm_id->route.addr.src_addr;
+	resp.src_size = rdma_addr_size(addr);
+	memcpy(&resp.src_addr, addr, resp.src_size);
+
+	addr = (struct sockaddr *) &ctx->cm_id->route.addr.dst_addr;
+	resp.dst_size = rdma_addr_size(addr);
+	memcpy(&resp.dst_addr, addr, resp.dst_size);
+
+	ucma_query_device_addr(ctx->cm_id, &resp);
+
+	if (copy_to_user(response, &resp, sizeof(resp)))
+		ret = -EFAULT;
+
+	return ret;
+}
+
+static ssize_t ucma_query(struct ucma_file *file,
+			  const char __user *inbuf,
+			  int in_len, int out_len)
+{
+	struct rdma_ucm_query cmd;
+	struct ucma_context *ctx;
+	void __user *response;
+	int ret;
+
+	if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+		return -EFAULT;
+
+	response = (void __user *)(unsigned long) cmd.response;
+	ctx = ucma_get_ctx(file, cmd.id);
+	if (IS_ERR(ctx))
+		return PTR_ERR(ctx);
+
+	switch (cmd.option) {
+	case RDMA_USER_CM_QUERY_ADDR:
+		ret = ucma_query_addr(ctx, response, out_len);
+		break;
+	default:
+		ret = -ENOSYS;
+		break;
+	}
+
+	ucma_put_ctx(ctx);
+	return ret;
+}
+
 static void ucma_copy_conn_param(struct rdma_conn_param *dst,
 				 struct rdma_ucm_conn_param *src)
 {
@@ -1151,7 +1222,8 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
 	[RDMA_USER_CM_CMD_NOTIFY]	= ucma_notify,
 	[RDMA_USER_CM_CMD_JOIN_MCAST]	= ucma_join_multicast,
 	[RDMA_USER_CM_CMD_LEAVE_MCAST]	= ucma_leave_multicast,
-	[RDMA_USER_CM_CMD_MIGRATE_ID]	= ucma_migrate_id
+	[RDMA_USER_CM_CMD_MIGRATE_ID]	= ucma_migrate_id,
+	[RDMA_USER_CM_CMD_QUERY]	= ucma_query
 };
 
 static ssize_t ucma_write(struct file *filp, const char __user *buf,
diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h
index 1d16502..0d9e984 100644
--- a/include/rdma/rdma_user_cm.h
+++ b/include/rdma/rdma_user_cm.h
@@ -61,7 +61,8 @@ enum {
 	RDMA_USER_CM_CMD_NOTIFY,
 	RDMA_USER_CM_CMD_JOIN_MCAST,
 	RDMA_USER_CM_CMD_LEAVE_MCAST,
-	RDMA_USER_CM_CMD_MIGRATE_ID
+	RDMA_USER_CM_CMD_MIGRATE_ID,
+	RDMA_USER_CM_CMD_QUERY
 };
 
 /*
@@ -112,10 +113,14 @@ struct rdma_ucm_resolve_route {
 	__u32 timeout_ms;
 };
 
-struct rdma_ucm_query_route {
+enum {
+	RDMA_USER_CM_QUERY_ADDR
+};
+
+struct rdma_ucm_query {
 	__u64 response;
 	__u32 id;
-	__u32 reserved;
+	__u32 option;
 };
 
 struct rdma_ucm_query_route_resp {
@@ -128,6 +133,17 @@ struct rdma_ucm_query_route_resp {
 	__u8 reserved[3];
 };
 
+struct rdma_ucm_query_addr_resp {
+	__u64 node_guid;
+	__u8  port_num;
+	__u8  reserved;
+	__u16 pkey;
+	__u16 src_size;
+	__u16 dst_size;
+	struct sockaddr_storage src_addr;
+	struct sockaddr_storage dst_addr;
+};
+
 struct rdma_ucm_conn_param {
 	__u32 qp_num;
 	__u32 reserved;



--
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] 41+ messages in thread

* [RFC] [PATCH 15/22] [for 2.6.36] ib/sa: export function to pack a path record into wire format
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (13 preceding siblings ...)
  2010-03-23 18:14   ` [RFC] [PATCH 14/22] [for 2.6.36] rdma/ucm: support querying for AF_IB addresses Sean Hefty
@ 2010-03-23 18:16   ` Sean Hefty
  2010-03-23 18:18   ` [RFC] [PATCH 16/22] [for 2.6.36] rdma/ucm: support querying when IB paths are not reversible Sean Hefty
                     ` (8 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:16 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Allow converting from struct ib_sa_path_rec to the IB defined
SA path record wire format.  This will be used to report path
data from the rdma cm into user space.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/sa_query.c |    6 ++++++
 include/rdma/ib_sa.h               |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 7e1ffd8..54ec971 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -610,6 +610,12 @@ void ib_sa_unpack_path(void *attribute, struct ib_sa_path_rec *rec)
 }
 EXPORT_SYMBOL(ib_sa_unpack_path);
 
+void ib_sa_pack_path(struct ib_sa_path_rec *rec, void *attribute)
+{
+	ib_pack(path_rec_table, ARRAY_SIZE(path_rec_table), rec, attribute);
+}
+EXPORT_SYMBOL(ib_sa_pack_path);
+
 static void ib_sa_path_rec_callback(struct ib_sa_query *sa_query,
 				    int status,
 				    struct ib_sa_mad *mad)
diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h
index 1082afa..86aa772 100644
--- a/include/rdma/ib_sa.h
+++ b/include/rdma/ib_sa.h
@@ -385,4 +385,10 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
  */
 void ib_sa_unpack_path(void *attribute, struct ib_sa_path_rec *rec);
 
+/**
+ * ib_sa_pack_path - Conert a path record from struct ib_sa_path_rec
+ * to IB MAD wire format.
+ */
+void ib_sa_pack_path(struct ib_sa_path_rec *rec, void *attribute);
+
 #endif /* IB_SA_H */



--
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] 41+ messages in thread

* [RFC] [PATCH 16/22] [for 2.6.36] rdma/ucm: support querying when IB paths are not reversible
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (14 preceding siblings ...)
  2010-03-23 18:16   ` [RFC] [PATCH 15/22] [for 2.6.36] ib/sa: export function to pack a path record into wire format Sean Hefty
@ 2010-03-23 18:18   ` Sean Hefty
  2010-03-23 18:20   ` [RFC] [PATCH 17/22] [for 2.6.36] rdma/cm: export cma_get_service_id Sean Hefty
                     ` (7 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:18 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

The current query_route call can return up to two path records.
The assumption being that one is the primary path, with optional
support for an alternate path.  In both cases, the paths are
assumed to be reversible and are used to send CM MADs.

With the ability to manually set IB path data, the rdma cm
can eventually be capable of using up to 6 paths per
connection:

	forward primary, reverse primary,
	forward alternate, reverse alternate,
	reversible primary path for CM MADs
	reversible alternate path for CM MADs.

(It is unclear at this time if IB routing will complicate this.)
In order to handle more flexible routing topologies, add a new 
command to report any number of paths.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/ucma.c |   35 +++++++++++++++++++++++++++++++++++
 include/rdma/rdma_user_cm.h    |    9 ++++++++-
 2 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index da5a3ec..86115ec 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -674,6 +674,38 @@ static ssize_t ucma_query_addr(struct ucma_context *ctx,
 	return ret;
 }
 
+static ssize_t ucma_query_path(struct ucma_context *ctx,
+			       void __user *response, int out_len)
+{
+	struct rdma_ucm_query_path_resp *resp;
+	int i, ret = 0;
+
+	if (out_len < sizeof(*resp))
+		return -ENOSPC;
+
+	resp = kzalloc(out_len, GFP_KERNEL);
+	if (!resp)
+		return -ENOMEM;
+
+	resp->num_paths = ctx->cm_id->route.num_paths;
+	for (i = 0, out_len -= sizeof(*resp);
+	     i < resp->num_paths && out_len > sizeof(struct ib_path_rec_data);
+	     i++, out_len -= sizeof(struct ib_path_rec_data)) {
+
+		resp->path_data[i].flags = IB_PATH_GMP | IB_PATH_PRIMARY |
+					   IB_PATH_BIDIRECTIONAL;
+		ib_sa_pack_path(&ctx->cm_id->route.path_rec[i],
+				&resp->path_data[i].path_rec);
+	}
+
+	if (copy_to_user(response, resp,
+			 sizeof(*resp) + (i * sizeof(struct ib_path_rec_data))))
+		ret = -EFAULT;
+
+	kfree(resp);
+	return ret;
+}
+
 static ssize_t ucma_query(struct ucma_file *file,
 			  const char __user *inbuf,
 			  int in_len, int out_len)
@@ -695,6 +727,9 @@ static ssize_t ucma_query(struct ucma_file *file,
 	case RDMA_USER_CM_QUERY_ADDR:
 		ret = ucma_query_addr(ctx, response, out_len);
 		break;
+	case RDMA_USER_CM_QUERY_PATH:
+		ret = ucma_query_path(ctx, response, out_len);
+		break;
 	default:
 		ret = -ENOSYS;
 		break;
diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h
index 0d9e984..ee48dde 100644
--- a/include/rdma/rdma_user_cm.h
+++ b/include/rdma/rdma_user_cm.h
@@ -114,7 +114,8 @@ struct rdma_ucm_resolve_route {
 };
 
 enum {
-	RDMA_USER_CM_QUERY_ADDR
+	RDMA_USER_CM_QUERY_ADDR,
+	RDMA_USER_CM_QUERY_PATH
 };
 
 struct rdma_ucm_query {
@@ -144,6 +145,12 @@ struct rdma_ucm_query_addr_resp {
 	struct sockaddr_storage dst_addr;
 };
 
+struct rdma_ucm_query_path_resp {
+	__u32 num_paths;
+	__u32 reserved;
+	struct ib_path_rec_data path_data[0];
+};
+
 struct rdma_ucm_conn_param {
 	__u32 qp_num;
 	__u32 reserved;



--
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] 41+ messages in thread

* [RFC] [PATCH 17/22] [for 2.6.36] rdma/cm: export cma_get_service_id
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (15 preceding siblings ...)
  2010-03-23 18:18   ` [RFC] [PATCH 16/22] [for 2.6.36] rdma/ucm: support querying when IB paths are not reversible Sean Hefty
@ 2010-03-23 18:20   ` Sean Hefty
  2010-03-23 18:23   ` [RFC] [PATCH 18/22] [for 2.6.36] rdma/ucm: add ability to query GID addresses Sean Hefty
                     ` (6 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:20 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Allow the rdma_ucm to query the IB service ID formed or
allocated by the rdma_cm by exporting the cma_get_service_id
functionality.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/cma.c |   19 ++++++++++---------
 include/rdma/rdma_cm.h        |    7 +++++++
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index c5bb70c..1d64342 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1256,13 +1256,14 @@ out:
 	return ret;
 }
 
-static __be64 cma_get_service_id(enum rdma_port_space ps, struct sockaddr *addr)
+__be64 rdma_get_service_id(struct rdma_cm_id *id, struct sockaddr *addr)
 {
 	if (addr->sa_family == AF_IB)
 		return ((struct sockaddr_ib *) addr)->sib_sid;
 
-	return cpu_to_be64(((u64)ps << 16) + be16_to_cpu(cma_port(addr)));
+	return cpu_to_be64(((u64)id->ps << 16) + be16_to_cpu(cma_port(addr)));
 }
+EXPORT_SYMBOL(rdma_get_service_id);
 
 static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr,
 				 struct ib_cm_compare_data *compare)
@@ -1478,7 +1479,7 @@ static int cma_ib_listen(struct rdma_id_private *id_priv)
 		return PTR_ERR(id_priv->cm_id.ib);
 
 	addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr;
-	svc_id = cma_get_service_id(id_priv->id.ps, addr);
+	svc_id = rdma_get_service_id(&id_priv->id, addr);
 	if (cma_any_addr(addr))
 		ret = ib_cm_listen(id_priv->cm_id.ib, svc_id, 0, NULL);
 	else {
@@ -1659,8 +1660,8 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms,
 	path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(&addr->dev_addr));
 	path_rec.numb_path = 1;
 	path_rec.reversible = 1;
-	path_rec.service_id = cma_get_service_id(id_priv->id.ps,
-						 (struct sockaddr *) &addr->dst_addr);
+	path_rec.service_id = rdma_get_service_id(&id_priv->id,
+						  (struct sockaddr *) &addr->dst_addr);
 
 	comp_mask = IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID |
 		    IB_SA_PATH_REC_PKEY | IB_SA_PATH_REC_NUMB_PATH |
@@ -2478,8 +2479,8 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv,
 	}
 
 	req.path = route->path_rec;
-	req.service_id = cma_get_service_id(id_priv->id.ps,
-					    (struct sockaddr *) &route->addr.dst_addr);
+	req.service_id = rdma_get_service_id(&id_priv->id,
+					     (struct sockaddr *) &route->addr.dst_addr);
 	req.timeout_ms = 1 << (CMA_CM_RESPONSE_TIMEOUT - 8);
 	req.max_cm_retries = CMA_MAX_CM_RETRIES;
 
@@ -2529,8 +2530,8 @@ static int cma_connect_ib(struct rdma_id_private *id_priv,
 	if (route->num_paths == 2)
 		req.alternate_path = &route->path_rec[1];
 
-	req.service_id = cma_get_service_id(id_priv->id.ps,
-					    (struct sockaddr *) &route->addr.dst_addr);
+	req.service_id = rdma_get_service_id(&id_priv->id,
+					     (struct sockaddr *) &route->addr.dst_addr);
 	req.qp_num = id_priv->qp_num;
 	req.qp_type = IB_QPT_RC;
 	req.starting_psn = id_priv->seq_num;
diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h
index c6b2962..ffc544f 100644
--- a/include/rdma/rdma_cm.h
+++ b/include/rdma/rdma_cm.h
@@ -330,4 +330,11 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr);
  */
 void rdma_set_service_type(struct rdma_cm_id *id, int tos);
 
+/**
+ * rdma_get_service_id - Return the IB service ID for a specified address.
+ * @id: Communication identifier associated with the address.
+ * @addr: Address for the service ID.
+ */
+__be64 rdma_get_service_id(struct rdma_cm_id *id, struct sockaddr *addr);
+
 #endif /* RDMA_CM_H */



--
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] 41+ messages in thread

* [RFC] [PATCH 18/22] [for 2.6.36] rdma/ucm: add ability to query GID addresses
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (16 preceding siblings ...)
  2010-03-23 18:20   ` [RFC] [PATCH 17/22] [for 2.6.36] rdma/cm: export cma_get_service_id Sean Hefty
@ 2010-03-23 18:23   ` Sean Hefty
  2010-03-23 18:25   ` [RFC] [PATCH 19/22] [for 2.6.36] rdma/ucm: name changes to indicate only IP addresses supported Sean Hefty
                     ` (5 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:23 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Part of address resolution is mapping IP addresses to IB GIDs.
With the changes to support querying larger addresses and more
path records, also provide a way to query IB GIDs after
resolution completes.

This finishes separating the functionality of 'query route' into
the various components: address, route, and device data.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/ucma.c |   50 ++++++++++++++++++++++++++++++++++++++++
 include/rdma/rdma_user_cm.h    |    3 ++
 2 files changed, 52 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 86115ec..1c2083e 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -45,6 +45,7 @@
 #include <rdma/rdma_cm.h>
 #include <rdma/rdma_cm_ib.h>
 #include <rdma/ib_addr.h>
+#include <rdma/ib.h>
 
 MODULE_AUTHOR("Sean Hefty");
 MODULE_DESCRIPTION("RDMA Userspace Connection Manager Access");
@@ -706,6 +707,52 @@ static ssize_t ucma_query_path(struct ucma_context *ctx,
 	return ret;
 }
 
+static ssize_t ucma_query_gid(struct ucma_context *ctx,
+			      void __user *response, int out_len)
+{
+	struct rdma_ucm_query_addr_resp resp;
+	struct sockaddr_ib *addr;
+	int ret = 0;
+
+	if (out_len < sizeof(resp))
+		return -ENOSPC;
+
+	memset(&resp, 0, sizeof resp);
+
+	ucma_query_device_addr(ctx->cm_id, &resp);
+
+	addr = (struct sockaddr_ib *) &resp.src_addr;
+	resp.src_size = sizeof(*addr);
+	if (ctx->cm_id->route.addr.src_addr.ss_family == AF_IB) {
+		memcpy(addr, &ctx->cm_id->route.addr.src_addr, resp.src_size);
+	} else {
+		addr->sib_family = AF_IB;
+		addr->sib_pkey = (__force __be16) resp.pkey;
+		rdma_addr_get_sgid(&ctx->cm_id->route.addr.dev_addr,
+				   (union ib_gid *) &addr->sib_addr);
+		addr->sib_sid = rdma_get_service_id(ctx->cm_id, (struct sockaddr *)
+						    &ctx->cm_id->route.addr.src_addr);
+	}
+
+	addr = (struct sockaddr_ib *) &resp.dst_addr;
+	resp.dst_size = sizeof(*addr);
+	if (ctx->cm_id->route.addr.dst_addr.ss_family == AF_IB) {
+		memcpy(addr, &ctx->cm_id->route.addr.dst_addr, resp.dst_size);
+	} else {
+		addr->sib_family = AF_IB;
+		addr->sib_pkey = (__force __be16) resp.pkey;
+		rdma_addr_get_dgid(&ctx->cm_id->route.addr.dev_addr,
+				   (union ib_gid *) &addr->sib_addr);
+		addr->sib_sid = rdma_get_service_id(ctx->cm_id, (struct sockaddr *)
+						    &ctx->cm_id->route.addr.dst_addr);
+	}
+
+	if (copy_to_user(response, &resp, sizeof(resp)))
+		ret = -EFAULT;
+
+	return ret;
+}
+
 static ssize_t ucma_query(struct ucma_file *file,
 			  const char __user *inbuf,
 			  int in_len, int out_len)
@@ -730,6 +777,9 @@ static ssize_t ucma_query(struct ucma_file *file,
 	case RDMA_USER_CM_QUERY_PATH:
 		ret = ucma_query_path(ctx, response, out_len);
 		break;
+	case RDMA_USER_CM_QUERY_GID:
+		ret = ucma_query_gid(ctx, response, out_len);
+		break;
 	default:
 		ret = -ENOSYS;
 		break;
diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h
index ee48dde..2534598 100644
--- a/include/rdma/rdma_user_cm.h
+++ b/include/rdma/rdma_user_cm.h
@@ -115,7 +115,8 @@ struct rdma_ucm_resolve_route {
 
 enum {
 	RDMA_USER_CM_QUERY_ADDR,
-	RDMA_USER_CM_QUERY_PATH
+	RDMA_USER_CM_QUERY_PATH,
+	RDMA_USER_CM_QUERY_GID
 };
 
 struct rdma_ucm_query {



--
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] 41+ messages in thread

* [RFC] [PATCH 19/22] [for 2.6.36] rdma/ucm: name changes to indicate only IP addresses supported
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (17 preceding siblings ...)
  2010-03-23 18:23   ` [RFC] [PATCH 18/22] [for 2.6.36] rdma/ucm: add ability to query GID addresses Sean Hefty
@ 2010-03-23 18:25   ` Sean Hefty
  2010-03-23 18:27   ` [RFC] [PATCH 20/22] [for 2.6.36] rdma/ucm: allow user space to bind to AF_IB Sean Hefty
                     ` (4 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:25 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Several commands into the RDMA CM from user space are
restricted to supporting addresses which fit into a sockaddr_in6
structure: bind address, resolve address, and join multicast.

With the addition of AF_IB, we need to support addresses
which are larger than sockaddr_in6.  This will be done by
adding new commands that exchange address information using
sockaddr_storage.  However, to support existing applications,
we maintain the current commands and structures, but rename
them to indicate that they only support IPv4 and v6 addresses.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/ucma.c |   26 +++++++++++++-------------
 include/rdma/rdma_user_cm.h    |   12 ++++++------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 1c2083e..950bd35 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -495,10 +495,10 @@ static ssize_t ucma_destroy_id(struct ucma_file *file, const char __user *inbuf,
 	return ret;
 }
 
-static ssize_t ucma_bind_addr(struct ucma_file *file, const char __user *inbuf,
+static ssize_t ucma_bind_ip(struct ucma_file *file, const char __user *inbuf,
 			      int in_len, int out_len)
 {
-	struct rdma_ucm_bind_addr cmd;
+	struct rdma_ucm_bind_ip cmd;
 	struct ucma_context *ctx;
 	int ret;
 
@@ -514,11 +514,11 @@ static ssize_t ucma_bind_addr(struct ucma_file *file, const char __user *inbuf,
 	return ret;
 }
 
-static ssize_t ucma_resolve_addr(struct ucma_file *file,
-				 const char __user *inbuf,
-				 int in_len, int out_len)
+static ssize_t ucma_resolve_ip(struct ucma_file *file,
+			       const char __user *inbuf,
+			       int in_len, int out_len)
 {
-	struct rdma_ucm_resolve_addr cmd;
+	struct rdma_ucm_resolve_ip cmd;
 	struct ucma_context *ctx;
 	int ret;
 
@@ -1088,11 +1088,11 @@ static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf,
 	return ret;
 }
 
-static ssize_t ucma_join_multicast(struct ucma_file *file,
-				   const char __user *inbuf,
-				   int in_len, int out_len)
+static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
+				      const char __user *inbuf,
+				      int in_len, int out_len)
 {
-	struct rdma_ucm_join_mcast cmd;
+	struct rdma_ucm_join_ip_mcast cmd;
 	struct rdma_ucm_create_id_resp resp;
 	struct ucma_context *ctx;
 	struct ucma_multicast *mc;
@@ -1291,8 +1291,8 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
 				   int in_len, int out_len) = {
 	[RDMA_USER_CM_CMD_CREATE_ID]	= ucma_create_id,
 	[RDMA_USER_CM_CMD_DESTROY_ID]	= ucma_destroy_id,
-	[RDMA_USER_CM_CMD_BIND_ADDR]	= ucma_bind_addr,
-	[RDMA_USER_CM_CMD_RESOLVE_ADDR]	= ucma_resolve_addr,
+	[RDMA_USER_CM_CMD_BIND_IP]	= ucma_bind_ip,
+	[RDMA_USER_CM_CMD_RESOLVE_IP]	= ucma_resolve_ip,
 	[RDMA_USER_CM_CMD_RESOLVE_ROUTE]= ucma_resolve_route,
 	[RDMA_USER_CM_CMD_QUERY_ROUTE]	= ucma_query_route,
 	[RDMA_USER_CM_CMD_CONNECT]	= ucma_connect,
@@ -1305,7 +1305,7 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
 	[RDMA_USER_CM_CMD_GET_OPTION]	= NULL,
 	[RDMA_USER_CM_CMD_SET_OPTION]	= ucma_set_option,
 	[RDMA_USER_CM_CMD_NOTIFY]	= ucma_notify,
-	[RDMA_USER_CM_CMD_JOIN_MCAST]	= ucma_join_multicast,
+	[RDMA_USER_CM_CMD_JOIN_IP_MCAST]= ucma_join_ip_multicast,
 	[RDMA_USER_CM_CMD_LEAVE_MCAST]	= ucma_leave_multicast,
 	[RDMA_USER_CM_CMD_MIGRATE_ID]	= ucma_migrate_id,
 	[RDMA_USER_CM_CMD_QUERY]	= ucma_query
diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h
index 2534598..bbb724b 100644
--- a/include/rdma/rdma_user_cm.h
+++ b/include/rdma/rdma_user_cm.h
@@ -45,8 +45,8 @@
 enum {
 	RDMA_USER_CM_CMD_CREATE_ID,
 	RDMA_USER_CM_CMD_DESTROY_ID,
-	RDMA_USER_CM_CMD_BIND_ADDR,
-	RDMA_USER_CM_CMD_RESOLVE_ADDR,
+	RDMA_USER_CM_CMD_BIND_IP,
+	RDMA_USER_CM_CMD_RESOLVE_IP,
 	RDMA_USER_CM_CMD_RESOLVE_ROUTE,
 	RDMA_USER_CM_CMD_QUERY_ROUTE,
 	RDMA_USER_CM_CMD_CONNECT,
@@ -59,7 +59,7 @@ enum {
 	RDMA_USER_CM_CMD_GET_OPTION,
 	RDMA_USER_CM_CMD_SET_OPTION,
 	RDMA_USER_CM_CMD_NOTIFY,
-	RDMA_USER_CM_CMD_JOIN_MCAST,
+	RDMA_USER_CM_CMD_JOIN_IP_MCAST,
 	RDMA_USER_CM_CMD_LEAVE_MCAST,
 	RDMA_USER_CM_CMD_MIGRATE_ID,
 	RDMA_USER_CM_CMD_QUERY
@@ -95,13 +95,13 @@ struct rdma_ucm_destroy_id_resp {
 	__u32 events_reported;
 };
 
-struct rdma_ucm_bind_addr {
+struct rdma_ucm_bind_ip {
 	__u64 response;
 	struct sockaddr_in6 addr;
 	__u32 id;
 };
 
-struct rdma_ucm_resolve_addr {
+struct rdma_ucm_resolve_ip {
 	struct sockaddr_in6 src_addr;
 	struct sockaddr_in6 dst_addr;
 	__u32 id;
@@ -215,7 +215,7 @@ struct rdma_ucm_notify {
 	__u32 event;
 };
 
-struct rdma_ucm_join_mcast {
+struct rdma_ucm_join_ip_mcast {
 	__u64 response;		/* rdma_ucm_create_id_resp */
 	__u64 uid;
 	struct sockaddr_in6 addr;



--
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] 41+ messages in thread

* [RFC] [PATCH 20/22] [for 2.6.36] rdma/ucm: allow user space to bind to AF_IB
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (18 preceding siblings ...)
  2010-03-23 18:25   ` [RFC] [PATCH 19/22] [for 2.6.36] rdma/ucm: name changes to indicate only IP addresses supported Sean Hefty
@ 2010-03-23 18:27   ` Sean Hefty
  2010-03-23 18:28   ` [RFC] [PATCH 21/22] [for 2.6.36] rdma/ucm: allow user space to pass AF_IB into resolve Sean Hefty
                     ` (3 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:27 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Support user space binding to addresses using AF_IB.  Since
sockaddr_ib is larger than sockaddr_in6, we need to define
a larger structure when binding using AF_IB.  This time we
use sockaddr_storage to cover future cases.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/ucma.c |   27 ++++++++++++++++++++++++++-
 include/rdma/rdma_user_cm.h    |   10 +++++++++-
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 950bd35..e2d8dcf 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -514,6 +514,30 @@ static ssize_t ucma_bind_ip(struct ucma_file *file, const char __user *inbuf,
 	return ret;
 }
 
+static ssize_t ucma_bind(struct ucma_file *file, const char __user *inbuf,
+			 int in_len, int out_len)
+{
+	struct rdma_ucm_bind cmd;
+	struct sockaddr *addr;
+	struct ucma_context *ctx;
+	int ret;
+
+	if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+		return -EFAULT;
+
+	addr = (struct sockaddr *) &cmd.addr;
+	if (cmd.reserved || !cmd.addr_size || (cmd.addr_size != rdma_addr_size(addr)))
+		return -EINVAL;
+
+	ctx = ucma_get_ctx(file, cmd.id);
+	if (IS_ERR(ctx))
+		return PTR_ERR(ctx);
+
+	ret = rdma_bind_addr(ctx->cm_id, addr);
+	ucma_put_ctx(ctx);
+	return ret;
+}
+
 static ssize_t ucma_resolve_ip(struct ucma_file *file,
 			       const char __user *inbuf,
 			       int in_len, int out_len)
@@ -1308,7 +1332,8 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
 	[RDMA_USER_CM_CMD_JOIN_IP_MCAST]= ucma_join_ip_multicast,
 	[RDMA_USER_CM_CMD_LEAVE_MCAST]	= ucma_leave_multicast,
 	[RDMA_USER_CM_CMD_MIGRATE_ID]	= ucma_migrate_id,
-	[RDMA_USER_CM_CMD_QUERY]	= ucma_query
+	[RDMA_USER_CM_CMD_QUERY]	= ucma_query,
+	[RDMA_USER_CM_CMD_BIND]		= ucma_bind
 };
 
 static ssize_t ucma_write(struct file *filp, const char __user *buf,
diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h
index bbb724b..009b8da 100644
--- a/include/rdma/rdma_user_cm.h
+++ b/include/rdma/rdma_user_cm.h
@@ -62,7 +62,8 @@ enum {
 	RDMA_USER_CM_CMD_JOIN_IP_MCAST,
 	RDMA_USER_CM_CMD_LEAVE_MCAST,
 	RDMA_USER_CM_CMD_MIGRATE_ID,
-	RDMA_USER_CM_CMD_QUERY
+	RDMA_USER_CM_CMD_QUERY,
+	RDMA_USER_CM_CMD_BIND
 };
 
 /*
@@ -101,6 +102,13 @@ struct rdma_ucm_bind_ip {
 	__u32 id;
 };
 
+struct rdma_ucm_bind {
+	__u32 id;
+	__u16 addr_size;
+	__u16 reserved;
+	struct sockaddr_storage addr;
+};
+
 struct rdma_ucm_resolve_ip {
 	struct sockaddr_in6 src_addr;
 	struct sockaddr_in6 dst_addr;



--
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] 41+ messages in thread

* [RFC] [PATCH 21/22] [for 2.6.36] rdma/ucm: allow user space to pass AF_IB into resolve
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (19 preceding siblings ...)
  2010-03-23 18:27   ` [RFC] [PATCH 20/22] [for 2.6.36] rdma/ucm: allow user space to bind to AF_IB Sean Hefty
@ 2010-03-23 18:28   ` Sean Hefty
  2010-03-23 18:30   ` [RFC] [PATCH 22/22] [for 2.6.36] rdma/ucm: allow user space to specify AF_IB when joining multicast Sean Hefty
                     ` (2 subsequent siblings)
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:28 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Allow user space applications to call resolve_addr using
AF_IB.  To support sockaddr_ib, we need to define a new
structure capable of handling the larger address size.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/ucma.c |   30 +++++++++++++++++++++++++++++-
 include/rdma/rdma_user_cm.h    |   13 ++++++++++++-
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index e2d8dcf..2224a05 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -560,6 +560,33 @@ static ssize_t ucma_resolve_ip(struct ucma_file *file,
 	return ret;
 }
 
+static ssize_t ucma_resolve_addr(struct ucma_file *file,
+				 const char __user *inbuf,
+				 int in_len, int out_len)
+{
+	struct rdma_ucm_resolve_addr cmd;
+	struct sockaddr *src, *dst;
+	struct ucma_context *ctx;
+	int ret;
+
+	if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+		return -EFAULT;
+
+	src = (struct sockaddr *) &cmd.src_addr;
+	dst = (struct sockaddr *) &cmd.dst_addr;
+	if (cmd.reserved || (cmd.src_size && (cmd.src_size != rdma_addr_size(src))) ||
+	    !cmd.dst_size || (cmd.dst_size != rdma_addr_size(dst)))
+		return -EINVAL;
+
+	ctx = ucma_get_ctx(file, cmd.id);
+	if (IS_ERR(ctx))
+		return PTR_ERR(ctx);
+
+	ret = rdma_resolve_addr(ctx->cm_id, src, dst, cmd.timeout_ms);
+	ucma_put_ctx(ctx);
+	return ret;
+}
+
 static ssize_t ucma_resolve_route(struct ucma_file *file,
 				  const char __user *inbuf,
 				  int in_len, int out_len)
@@ -1333,7 +1360,8 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
 	[RDMA_USER_CM_CMD_LEAVE_MCAST]	= ucma_leave_multicast,
 	[RDMA_USER_CM_CMD_MIGRATE_ID]	= ucma_migrate_id,
 	[RDMA_USER_CM_CMD_QUERY]	= ucma_query,
-	[RDMA_USER_CM_CMD_BIND]		= ucma_bind
+	[RDMA_USER_CM_CMD_BIND]		= ucma_bind,
+	[RDMA_USER_CM_CMD_RESOLVE_ADDR]	= ucma_resolve_addr
 };
 
 static ssize_t ucma_write(struct file *filp, const char __user *buf,
diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h
index 009b8da..c546e18 100644
--- a/include/rdma/rdma_user_cm.h
+++ b/include/rdma/rdma_user_cm.h
@@ -63,7 +63,8 @@ enum {
 	RDMA_USER_CM_CMD_LEAVE_MCAST,
 	RDMA_USER_CM_CMD_MIGRATE_ID,
 	RDMA_USER_CM_CMD_QUERY,
-	RDMA_USER_CM_CMD_BIND
+	RDMA_USER_CM_CMD_BIND,
+	RDMA_USER_CM_CMD_RESOLVE_ADDR
 };
 
 /*
@@ -116,6 +117,16 @@ struct rdma_ucm_resolve_ip {
 	__u32 timeout_ms;
 };
 
+struct rdma_ucm_resolve_addr {
+	__u32 id;
+	__u32 timeout_ms;
+	__u16 src_size;
+	__u16 dst_size;
+	__u32 reserved;
+	struct sockaddr_storage src_addr;
+	struct sockaddr_storage dst_addr;
+};
+
 struct rdma_ucm_resolve_route {
 	__u32 id;
 	__u32 timeout_ms;



--
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] 41+ messages in thread

* [RFC] [PATCH 22/22] [for 2.6.36] rdma/ucm: allow user space to specify AF_IB when joining multicast
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (20 preceding siblings ...)
  2010-03-23 18:28   ` [RFC] [PATCH 21/22] [for 2.6.36] rdma/ucm: allow user space to pass AF_IB into resolve Sean Hefty
@ 2010-03-23 18:30   ` Sean Hefty
       [not found]     ` <48F1FC4C2F114E928EB38D690091185E-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  2010-03-23 19:22   ` [RFC] [PATCH 0/22] [for 2.6.36] rdma/cm: add support for native IB addressing Sean Hefty
  2010-03-26 17:33   ` Sean Hefty
  23 siblings, 1 reply; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 18:30 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Allow user space applications to join multicast groups using MGIDs
directly.  MGIDs may be passed using AF_IB addresses.  Since the
current multicast join command only supports addresses as large as
sockaddr_in6, define a new structure for joining addresses specified
using sockaddr_ib.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---

 drivers/infiniband/core/ucma.c |   55 ++++++++++++++++++++++++++++++++--------
 include/rdma/rdma_user_cm.h    |   12 ++++++++-
 2 files changed, 55 insertions(+), 12 deletions(-)

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 2224a05..a9b917a 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -1139,23 +1139,23 @@ static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf,
 	return ret;
 }
 
-static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
-				      const char __user *inbuf,
-				      int in_len, int out_len)
+static ssize_t ucma_process_join(struct ucma_file *file,
+				 struct rdma_ucm_join_mcast *cmd,  int out_len)
 {
-	struct rdma_ucm_join_ip_mcast cmd;
 	struct rdma_ucm_create_id_resp resp;
 	struct ucma_context *ctx;
 	struct ucma_multicast *mc;
+	struct sockaddr *addr;
 	int ret;
 
 	if (out_len < sizeof(resp))
 		return -ENOSPC;
 
-	if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
-		return -EFAULT;
+	addr = (struct sockaddr *) &cmd->addr;
+	if (cmd->reserved || !cmd->addr_size || (cmd->addr_size != rdma_addr_size(addr)))
+		return -EINVAL;
 
-	ctx = ucma_get_ctx(file, cmd.id);
+	ctx = ucma_get_ctx(file, cmd->id);
 	if (IS_ERR(ctx))
 		return PTR_ERR(ctx);
 
@@ -1166,14 +1166,14 @@ static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
 		goto err1;
 	}
 
-	mc->uid = cmd.uid;
-	memcpy(&mc->addr, &cmd.addr, sizeof cmd.addr);
+	mc->uid = cmd->uid;
+	memcpy(&mc->addr, addr, cmd->addr_size);
 	ret = rdma_join_multicast(ctx->cm_id, (struct sockaddr *) &mc->addr, mc);
 	if (ret)
 		goto err2;
 
 	resp.id = mc->id;
-	if (copy_to_user((void __user *)(unsigned long)cmd.response,
+	if (copy_to_user((void __user *)(unsigned long) cmd->response,
 			 &resp, sizeof(resp))) {
 		ret = -EFAULT;
 		goto err3;
@@ -1198,6 +1198,38 @@ err1:
 	return ret;
 }
 
+static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
+				      const char __user *inbuf,
+				      int in_len, int out_len)
+{
+	struct rdma_ucm_join_ip_mcast cmd;
+	struct rdma_ucm_join_mcast join_cmd;
+
+	if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+		return -EFAULT;
+
+	join_cmd.response = cmd.response;
+	join_cmd.uid = cmd.uid;
+	join_cmd.id = cmd.id;
+	join_cmd.addr_size = rdma_addr_size((struct sockaddr *) &cmd.addr);
+	join_cmd.reserved = 0;
+	memcpy(&join_cmd.addr, &cmd.addr, join_cmd.addr_size);
+
+	return ucma_process_join(file, &join_cmd, out_len);
+}
+
+static ssize_t ucma_join_multicast(struct ucma_file *file,
+				   const char __user *inbuf,
+				   int in_len, int out_len)
+{
+	struct rdma_ucm_join_mcast cmd;
+
+	if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+		return -EFAULT;
+
+	return ucma_process_join(file, &cmd, out_len);
+}
+
 static ssize_t ucma_leave_multicast(struct ucma_file *file,
 				    const char __user *inbuf,
 				    int in_len, int out_len)
@@ -1361,7 +1393,8 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
 	[RDMA_USER_CM_CMD_MIGRATE_ID]	= ucma_migrate_id,
 	[RDMA_USER_CM_CMD_QUERY]	= ucma_query,
 	[RDMA_USER_CM_CMD_BIND]		= ucma_bind,
-	[RDMA_USER_CM_CMD_RESOLVE_ADDR]	= ucma_resolve_addr
+	[RDMA_USER_CM_CMD_RESOLVE_ADDR]	= ucma_resolve_addr,
+	[RDMA_USER_CM_CMD_JOIN_MCAST]	= ucma_join_multicast
 };
 
 static ssize_t ucma_write(struct file *filp, const char __user *buf,
diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h
index c546e18..9f14ca8 100644
--- a/include/rdma/rdma_user_cm.h
+++ b/include/rdma/rdma_user_cm.h
@@ -64,7 +64,8 @@ enum {
 	RDMA_USER_CM_CMD_MIGRATE_ID,
 	RDMA_USER_CM_CMD_QUERY,
 	RDMA_USER_CM_CMD_BIND,
-	RDMA_USER_CM_CMD_RESOLVE_ADDR
+	RDMA_USER_CM_CMD_RESOLVE_ADDR,
+	RDMA_USER_CM_CMD_JOIN_MCAST
 };
 
 /*
@@ -241,6 +242,15 @@ struct rdma_ucm_join_ip_mcast {
 	__u32 id;
 };
 
+struct rdma_ucm_join_mcast {
+	__u64 response;		/* rdma_ucma_create_id_resp */
+	__u64 uid;
+	__u32 id;
+	__u16 addr_size;
+	__u16 reserved;
+	struct sockaddr_storage addr;
+};
+
 struct rdma_ucm_get_event {
 	__u64 response;
 };



--
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] 41+ messages in thread

* RE: [RFC] [PATCH 0/22] [for 2.6.36] rdma/cm: add support for native IB addressing
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (21 preceding siblings ...)
  2010-03-23 18:30   ` [RFC] [PATCH 22/22] [for 2.6.36] rdma/ucm: allow user space to specify AF_IB when joining multicast Sean Hefty
@ 2010-03-23 19:22   ` Sean Hefty
  2010-03-26 17:33   ` Sean Hefty
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-23 19:22 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

>The following patch series extends the rdma_cm to support native
>Infiniband addressing through the use of a new AF_IB address family.
>It defines a new struct sockaddr_ib that may be used to specify an
>IB GID, along with other IB address attributes, such as the pkey and
>service ID.

The kernel patches are also available from:

	git://git.openfabrics.org/~shefty/rdma-dev.git af_ib

>The higher level intent is to support a user space call, rdma_getaddrinfo,
>which can return AF_IB addresses to an application.  This allows the
>rdma_cm to support transport specific features, such as failover and
>non-reversible paths.  (An implementation of rdma_getaddrinfo is included
>in a separate patch set to the librdmacm.)

User space patches are available from:

	git://git.openfabrics.org/~shefty/librdmacm.git af_ib

Since there are 33 user space patches to the librdmacm, including new
functionality to simplify establishing connections, I will wait a day or
so before posting them.

Updates to ib_acm are at:

	git://git.openfabrics.org/~shefty/ibacm.git

- Sean

--
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	[flat|nested] 41+ messages in thread

* [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]     ` <012F7D9E5E97445E9100EF170212AEE7-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2010-03-25 19:05       ` Sean Hefty
       [not found]         ` <7451BD1514874F3E987E55040776EECC-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 41+ messages in thread
From: Sean Hefty @ 2010-03-25 19:05 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Update the port reservation code path to support AF_IB addresses.
AF_IB is limited to the port spaces defined by the RDMA CM IP Annex
which are already supported by the rdma cm.

AF_IB is used with a sockaddr_ib structure, which exposes a 64-bit
service ID, rather than a 16-bit port number used by IP.  As a result,
port numbers must be converted between the two formats as defined by
the above annex.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
changes from v1:
SID calculation in cma_bind_port for AF_IB was incorrect.

 drivers/infiniband/core/cma.c |   38 +++++++++++++++++++++++++++++++-------
 1 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index ac57155..57f1521 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -657,18 +657,28 @@ static int cma_addr_cmp(struct sockaddr *src, struct sockaddr *dst)
 	case AF_INET:
 		return ((struct sockaddr_in *) src)->sin_addr.s_addr !=
 		       ((struct sockaddr_in *) dst)->sin_addr.s_addr;
-	default:
+	case AF_INET6:
 		return ipv6_addr_cmp(&((struct sockaddr_in6 *) src)->sin6_addr,
 				     &((struct sockaddr_in6 *) dst)->sin6_addr);
+	default:
+		return ib_addr_cmp(&((struct sockaddr_ib *) src)->sib_addr,
+				   &((struct sockaddr_ib *) dst)->sib_addr);
 	}
 }
 
-static inline __be16 cma_port(struct sockaddr *addr)
+/* AF_IB must be using the RDMA CM IP Annex */
+static __be16 cma_port(struct sockaddr *addr)
 {
-	if (addr->sa_family == AF_INET)
+	switch (addr->sa_family) {
+	case AF_INET:
 		return ((struct sockaddr_in *) addr)->sin_port;
-	else
+	case AF_INET6:
 		return ((struct sockaddr_in6 *) addr)->sin6_port;
+	case AF_IB:
+		return htons((u16) be64_to_cpu(((struct sockaddr_ib *) addr)->sib_sid));
+	default:
+		return 0;
+	}
 }
 
 static inline int cma_any_port(struct sockaddr *addr)
@@ -1945,10 +1955,24 @@ EXPORT_SYMBOL(rdma_resolve_addr);
 static void cma_bind_port(struct rdma_bind_list *bind_list,
 			  struct rdma_id_private *id_priv)
 {
-	struct sockaddr_in *sin;
+	struct sockaddr *addr;
+	__be16 port;
 
-	sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr;
-	sin->sin_port = htons(bind_list->port);
+	addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr;
+	port = htons(bind_list->port);
+
+	switch (addr->sa_family) {
+	case AF_INET:
+		((struct sockaddr_in *) addr)->sin_port = port;
+		break;
+	case AF_INET6:
+		((struct sockaddr_in6 *) addr)->sin6_port = port;
+		break;
+	case AF_IB:
+		((struct sockaddr_ib *) addr)->sib_sid =
+			cpu_to_be64(((u64) id_priv->id.ps << 16) + ntohs(port));
+		break;
+	}
 	id_priv->bind_list = bind_list;
 	hlist_add_head(&id_priv->node, &bind_list->owners);
 }



--
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] 41+ messages in thread

* [RFC] [PATCH 22/22 v2] [for 2.6.36] rdma/ucm: allow user space to specify AF_IB when joining multicast
       [not found]     ` <48F1FC4C2F114E928EB38D690091185E-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2010-03-25 19:08       ` Sean Hefty
  0 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-25 19:08 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

Allow user space applications to join multicast groups using MGIDs
directly.  MGIDs may be passed using AF_IB addresses.  Since the
current multicast join command only supports addresses as large as
sockaddr_in6, define a new structure for joining addresses specified
using sockaddr_ib.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
changes from v1:
Forgot to include the changes to the cma.c module to support
AF_IB as part of a join request.

 drivers/infiniband/core/cma.c  |    2 +
 drivers/infiniband/core/ucma.c |   55 ++++++++++++++++++++++++++++++++--------
 include/rdma/rdma_user_cm.h    |   12 ++++++++-
 3 files changed, 57 insertions(+), 12 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 9e9a473..42d51b5 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -2897,6 +2897,8 @@ static void cma_set_mgid(struct rdma_id_private *id_priv,
 								 0xFF10A01B)) {
 		/* IPv6 address is an SA assigned MGID. */
 		memcpy(mgid, &sin6->sin6_addr, sizeof *mgid);
+	} else if (addr->sa_family == AF_IB) {
+		memcpy(mgid, &((struct sockaddr_ib *) addr)->sib_addr, sizeof *mgid);
 	} else if ((addr->sa_family == AF_INET6)) {
 		ipv6_ib_mc_map(&sin6->sin6_addr, dev_addr->broadcast, mc_map);
 		if (id_priv->id.ps == RDMA_PS_UDP)
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 2224a05..a9b917a 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -1139,23 +1139,23 @@ static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf,
 	return ret;
 }
 
-static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
-				      const char __user *inbuf,
-				      int in_len, int out_len)
+static ssize_t ucma_process_join(struct ucma_file *file,
+				 struct rdma_ucm_join_mcast *cmd,  int out_len)
 {
-	struct rdma_ucm_join_ip_mcast cmd;
 	struct rdma_ucm_create_id_resp resp;
 	struct ucma_context *ctx;
 	struct ucma_multicast *mc;
+	struct sockaddr *addr;
 	int ret;
 
 	if (out_len < sizeof(resp))
 		return -ENOSPC;
 
-	if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
-		return -EFAULT;
+	addr = (struct sockaddr *) &cmd->addr;
+	if (cmd->reserved || !cmd->addr_size || (cmd->addr_size != rdma_addr_size(addr)))
+		return -EINVAL;
 
-	ctx = ucma_get_ctx(file, cmd.id);
+	ctx = ucma_get_ctx(file, cmd->id);
 	if (IS_ERR(ctx))
 		return PTR_ERR(ctx);
 
@@ -1166,14 +1166,14 @@ static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
 		goto err1;
 	}
 
-	mc->uid = cmd.uid;
-	memcpy(&mc->addr, &cmd.addr, sizeof cmd.addr);
+	mc->uid = cmd->uid;
+	memcpy(&mc->addr, addr, cmd->addr_size);
 	ret = rdma_join_multicast(ctx->cm_id, (struct sockaddr *) &mc->addr, mc);
 	if (ret)
 		goto err2;
 
 	resp.id = mc->id;
-	if (copy_to_user((void __user *)(unsigned long)cmd.response,
+	if (copy_to_user((void __user *)(unsigned long) cmd->response,
 			 &resp, sizeof(resp))) {
 		ret = -EFAULT;
 		goto err3;
@@ -1198,6 +1198,38 @@ err1:
 	return ret;
 }
 
+static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
+				      const char __user *inbuf,
+				      int in_len, int out_len)
+{
+	struct rdma_ucm_join_ip_mcast cmd;
+	struct rdma_ucm_join_mcast join_cmd;
+
+	if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+		return -EFAULT;
+
+	join_cmd.response = cmd.response;
+	join_cmd.uid = cmd.uid;
+	join_cmd.id = cmd.id;
+	join_cmd.addr_size = rdma_addr_size((struct sockaddr *) &cmd.addr);
+	join_cmd.reserved = 0;
+	memcpy(&join_cmd.addr, &cmd.addr, join_cmd.addr_size);
+
+	return ucma_process_join(file, &join_cmd, out_len);
+}
+
+static ssize_t ucma_join_multicast(struct ucma_file *file,
+				   const char __user *inbuf,
+				   int in_len, int out_len)
+{
+	struct rdma_ucm_join_mcast cmd;
+
+	if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+		return -EFAULT;
+
+	return ucma_process_join(file, &cmd, out_len);
+}
+
 static ssize_t ucma_leave_multicast(struct ucma_file *file,
 				    const char __user *inbuf,
 				    int in_len, int out_len)
@@ -1361,7 +1393,8 @@ static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
 	[RDMA_USER_CM_CMD_MIGRATE_ID]	= ucma_migrate_id,
 	[RDMA_USER_CM_CMD_QUERY]	= ucma_query,
 	[RDMA_USER_CM_CMD_BIND]		= ucma_bind,
-	[RDMA_USER_CM_CMD_RESOLVE_ADDR]	= ucma_resolve_addr
+	[RDMA_USER_CM_CMD_RESOLVE_ADDR]	= ucma_resolve_addr,
+	[RDMA_USER_CM_CMD_JOIN_MCAST]	= ucma_join_multicast
 };
 
 static ssize_t ucma_write(struct file *filp, const char __user *buf,
diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h
index c546e18..9f14ca8 100644
--- a/include/rdma/rdma_user_cm.h
+++ b/include/rdma/rdma_user_cm.h
@@ -64,7 +64,8 @@ enum {
 	RDMA_USER_CM_CMD_MIGRATE_ID,
 	RDMA_USER_CM_CMD_QUERY,
 	RDMA_USER_CM_CMD_BIND,
-	RDMA_USER_CM_CMD_RESOLVE_ADDR
+	RDMA_USER_CM_CMD_RESOLVE_ADDR,
+	RDMA_USER_CM_CMD_JOIN_MCAST
 };
 
 /*
@@ -241,6 +242,15 @@ struct rdma_ucm_join_ip_mcast {
 	__u32 id;
 };
 
+struct rdma_ucm_join_mcast {
+	__u64 response;		/* rdma_ucma_create_id_resp */
+	__u64 uid;
+	__u32 id;
+	__u16 addr_size;
+	__u16 reserved;
+	struct sockaddr_storage addr;
+};
+
 struct rdma_ucm_get_event {
 	__u64 response;
 };



--
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] 41+ messages in thread

* Re: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]         ` <7451BD1514874F3E987E55040776EECC-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2010-03-25 20:29           ` Jason Gunthorpe
       [not found]             ` <20100325202924.GO29129-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 41+ messages in thread
From: Jason Gunthorpe @ 2010-03-25 20:29 UTC (permalink / raw)
  To: Sean Hefty; +Cc: linux-rdma

On Thu, Mar 25, 2010 at 12:05:33PM -0700, Sean Hefty wrote:
> +	case AF_IB:
> +		((struct sockaddr_ib *) addr)->sib_sid =
> +			cpu_to_be64(((u64) id_priv->id.ps << 16) + ntohs(port));
> +		break;
> +	}

Could you elaborate a bit on how you are mixing the port space and the
SID?

IMHO, after thinking about it for a bit, I would prefer to see the
port space be unused from a user-space perspective when used with
AF_IB.

If a ps is needed in the kernel then it should pick the ps based on
the SID prefix that user space provided.. I guess prior to adding the
mask bits this wouldn't have made sense, but now that they are in it
seems like the way to go.

Jason
--
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	[flat|nested] 41+ messages in thread

* RE: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]             ` <20100325202924.GO29129-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2010-03-25 21:00               ` Sean Hefty
       [not found]                 ` <AC26D518E7AE4BE6BA3BDFC11480F8DB-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 41+ messages in thread
From: Sean Hefty @ 2010-03-25 21:00 UTC (permalink / raw)
  To: 'Jason Gunthorpe'; +Cc: linux-rdma

>Could you elaborate a bit on how you are mixing the port space and the
>SID?

The SID is divided into multiple, disjoint regions.  (Annex 3 defines some of
the regions.)  The port space selects a specific region.

>IMHO, after thinking about it for a bit, I would prefer to see the
>port space be unused from a user-space perspective when used with
>AF_IB.

The rdma_cm_id is associated with a port space on creation, before it's known
what address family will be used.  The kernel code enforces that the SID is
formatted correctly for the port space that was selected.

>If a ps is needed in the kernel then it should pick the ps based on
>the SID prefix that user space provided.. I guess prior to adding the
>mask bits this wouldn't have made sense, but now that they are in it
>seems like the way to go.

I added sib_mask to sockaddr_ib, but it's unused at this point.  I think what
you're saying makes sense, but for RDMA_PS_IB, once it's defined.  RDMA_PS_IB
may need to behave as RDMA_PS_TCP or RDMA_PS_UDP based on the sib_mask and SID,
and ensure that any selected SID is reserved from the correct underlying SID
region.

Does this make sense?

- Sean

--
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	[flat|nested] 41+ messages in thread

* Re: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]                 ` <AC26D518E7AE4BE6BA3BDFC11480F8DB-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2010-03-25 22:04                   ` Jason Gunthorpe
       [not found]                     ` <20100325220435.GP29129-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 41+ messages in thread
From: Jason Gunthorpe @ 2010-03-25 22:04 UTC (permalink / raw)
  To: Sean Hefty; +Cc: linux-rdma

On Thu, Mar 25, 2010 at 02:00:25PM -0700, Sean Hefty wrote:

> >IMHO, after thinking about it for a bit, I would prefer to see the
> >port space be unused from a user-space perspective when used with
> >AF_IB.
> 
> The rdma_cm_id is associated with a port space on creation, before
> it's known what address family will be used.  The kernel code
> enforces that the SID is formatted correctly for the port space that
> was selected.

Does this early association with the port space have any effect?

> >If a ps is needed in the kernel then it should pick the ps based on
> >the SID prefix that user space provided.. I guess prior to adding the
> >mask bits this wouldn't have made sense, but now that they are in it
> >seems like the way to go.
> 
> I added sib_mask to sockaddr_ib, but it's unused at this point.  I
> think what you're saying makes sense, but for RDMA_PS_IB, once it's
> defined.  RDMA_PS_IB may need to behave as RDMA_PS_TCP or
> RDMA_PS_UDP based on the sib_mask and SID, and ensure that any
> selected SID is reserved from the correct underlying SID region.

I would be inclined to ditch the port space concept entirely for
AF_IB. Just ignore the input parameter and always base the selection
on the SID region. It is confusing to that there are two ways to
specify the same thing.

Is there any reason the port space has to be known when the cm_id is
created but before bind?

Jason
--
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	[flat|nested] 41+ messages in thread

* RE: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]                     ` <20100325220435.GP29129-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2010-03-25 22:40                       ` Sean Hefty
       [not found]                         ` <C70579E21917462C89AAEAE3C225A58B-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 41+ messages in thread
From: Sean Hefty @ 2010-03-25 22:40 UTC (permalink / raw)
  To: 'Jason Gunthorpe'; +Cc: linux-rdma

>Does this early association with the port space have any effect?

Doing it early versus later - no.  Doing it at all - yes.

>I would be inclined to ditch the port space concept entirely for
>AF_IB. Just ignore the input parameter and always base the selection
>on the SID region. It is confusing to that there are two ways to
>specify the same thing.

The address family is not sufficient to determine the desired port space.  For
example, AF_INET is usable for RDMA_PS_TCP and RDMA_PS_UDP.

>Is there any reason the port space has to be known when the cm_id is
>created but before bind?

No - but it is still required for transport neutrality.  rdma_create_id() simply
stores the value.

So... the port space could be specified during rdma_bind_addr and
rdma_resolve_addr instead of rdma_create_id, with the port space being
determined based on the sid/mask if AF_IB, rather than given directly.  That
seems more complex to me than just specifying it up front when rdma_create_id is
called.

--
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	[flat|nested] 41+ messages in thread

* Re: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]                         ` <C70579E21917462C89AAEAE3C225A58B-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2010-03-25 23:43                           ` Jason Gunthorpe
  2010-03-26  3:56                           ` Sean Hefty
  1 sibling, 0 replies; 41+ messages in thread
From: Jason Gunthorpe @ 2010-03-25 23:43 UTC (permalink / raw)
  To: Sean Hefty; +Cc: linux-rdma

On Thu, Mar 25, 2010 at 03:40:35PM -0700, Sean Hefty wrote:

> >I would be inclined to ditch the port space concept entirely for
> >AF_IB. Just ignore the input parameter and always base the selection
> >on the SID region. It is confusing to that there are two ways to
> >specify the same thing.
> 
> The address family is not sufficient to determine the desired port space.  For
> example, AF_INET is usable for RDMA_PS_TCP and RDMA_PS_UDP.

Right, but AF_IB has only one 'port space' - SID, so the ps input
parameter should be unused. It is reasonable that port space is an
address family specific input like the protocol input is to socket(2).

For now, what can happen inside the kernel is that a function like
cma_get_port can include:

if (sa_family == AF_IB) {
   if (sib_sid inside SDP_PREFIX)
          ps = &sdp_ps;
   if (sib_sid inside TCP_PREFIX)
          ps = &tcp_ps;
   if (sib_sid inside UDP_PREFIX)
          ps = &udp_ps;
   else -EINVAL; // FIXME, support more cases
}

And the user specifies the port space they want by setting the sib_sid
and sib_sid_mask appropriately.

Ideally want we want in the kernel is a better scheme than seperate
idr tables for managing the SID space in IB - the user API should be
built to support that general notion and the kernel can catch up.

If no bind address is specified then the kernel can use the IB locally
administered SID prefix of 0x2/8.

So the flow is:
 - AF_INET/AF_INET6 *must* specify a port space and use 16 bit port
   addressing
 - AF_IB does not use the port space input
 - AF_IB with no bind address, or a wild card SID, is identical to
   binding to the SID 0x2/8
 - AF_IB with a bind address can bind to any port space by specifying
   the correct SID prefix during bind.

These semantics are intended to make sense as a user space API, not
so much to reflect how the kernel currently works..

Jason
--
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	[flat|nested] 41+ messages in thread

* RE: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]                         ` <C70579E21917462C89AAEAE3C225A58B-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  2010-03-25 23:43                           ` Jason Gunthorpe
@ 2010-03-26  3:56                           ` Sean Hefty
       [not found]                             ` <FD7DFBFAF86D4EA99F82836CBCA8AB33-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  1 sibling, 1 reply; 41+ messages in thread
From: Sean Hefty @ 2010-03-26  3:56 UTC (permalink / raw)
  To: Hefty, Sean, 'Jason Gunthorpe'; +Cc: linux-rdma

>>Is there any reason the port space has to be known when the cm_id is
>>created but before bind?
>
>No - but it is still required for transport neutrality.  rdma_create_id()
>simply stores the value.

To correct this slightly, a user can call listen after calling create_id without
calling bind.  The bind is done internally to listen.

The port space really should be indicated at creation time.  If we can agree on
that, then the kernel simply needs to decide how to handle AF_IB at bind time.

These patches handle it by setting the well known portion of the SID and acting
on the other bits based on them being set.  The mask is unused.  For the
existing port spaces, we can leave this, or require the user provide a SID/mask
that is consistent with the chosen port space.

For RDMA_PS_IB, I think the flow that you outlined in your other email makes
sense.  Let RDMA_PS_IB cover the entire SID range.  When the SID/mask fall into
an existing port space, it needs to reserve a port from within that port space
to avoid collisions.

- Sean

--
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	[flat|nested] 41+ messages in thread

* Re: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]                             ` <FD7DFBFAF86D4EA99F82836CBCA8AB33-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2010-03-26  4:08                               ` Jason Gunthorpe
       [not found]                                 ` <20100326040809.GD9769-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 41+ messages in thread
From: Jason Gunthorpe @ 2010-03-26  4:08 UTC (permalink / raw)
  To: Sean Hefty; +Cc: linux-rdma

On Thu, Mar 25, 2010 at 08:56:23PM -0700, Sean Hefty wrote:
> >>Is there any reason the port space has to be known when the cm_id is
> >>created but before bind?
> >
> >No - but it is still required for transport neutrality.  rdma_create_id()
> >simply stores the value.
> 
> To correct this slightly, a user can call listen after calling create_id without
> calling bind.  The bind is done internally to listen.
> 
> The port space really should be indicated at creation time.  If we can agree on
> that, then the kernel simply needs to decide how to handle AF_IB at bind time.

I still think AF_IB should not have any port space other than
RDMA_PS_IB - since it is functionally inclusive of all the other
cases.

> These patches handle it by setting the well known portion of the SID and acting
> on the other bits based on them being set.  The mask is unused.  For the
> existing port spaces, we can leave this, or require the user provide a SID/mask
> that is consistent with the chosen port space.

See, to me this is very not nice. The address is specified with a
SID/mask, having the kernel ignore the mask and overwrite bits in the
SID makes no sense as an API.
 
> For RDMA_PS_IB, I think the flow that you outlined in your other email makes
> sense.  Let RDMA_PS_IB cover the entire SID range.  When the SID/mask fall into
> an existing port space, it needs to reserve a port from within that port space
> to avoid collisions.

Right :) I just don't understand why you think AF_IB/RDMA_PS_TCP has
to be a supported combination.

Is there some use case you see where having RDMA_PS_TCP/UDP work with
AF_IB is an advantage?

Jason
--
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	[flat|nested] 41+ messages in thread

* RE: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]                                 ` <20100326040809.GD9769-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2010-03-26 16:06                                   ` Sean Hefty
       [not found]                                     ` <57287E48AAAD47A4BD50719B889F4596-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 41+ messages in thread
From: Sean Hefty @ 2010-03-26 16:06 UTC (permalink / raw)
  To: 'Jason Gunthorpe'; +Cc: linux-rdma

>Right :) I just don't understand why you think AF_IB/RDMA_PS_TCP has
>to be a supported combination.

I don't see any reason to prevent it.  It works unless a specific check is added
in the kernel to prevent it.  Do I think it absolutely must be supported?  No -
so I don't have a strong disagreement on this.

It just seems like the code ends up as either:

	if (sa_family == AF_IB) {
		if (ps != PS_IB)
			fail;
		use_ps = get_ps(sid, mask);
	}
or

	if (sa_family == AF_IB) {
		if (get_ps(sid, mask) != ps)
			fail;
		use_ps = ps;
	}

>Is there some use case you see where having RDMA_PS_TCP/UDP work with
>AF_IB is an advantage?

Consider UDP, an application can create an id and join multicast groups using
AF_INET, AF_INET6, and/or AF_IB - whatever addressing scheme is most convenient.

What I have right now for user space support requires application changes to
make use of AF_IB anyway, so only supporting PS_IB isn't a big deal.  The
benefit to existing code is limited to user space path record queries. 

- Sean

--
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	[flat|nested] 41+ messages in thread

* RE: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]                                     ` <57287E48AAAD47A4BD50719B889F4596-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2010-03-26 17:17                                       ` Sean Hefty
       [not found]                                         ` <350558935FCC47B6A5ABA8402109746C-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 41+ messages in thread
From: Sean Hefty @ 2010-03-26 17:17 UTC (permalink / raw)
  To: Hefty, Sean, 'Jason Gunthorpe'; +Cc: linux-rdma

>Consider UDP, an application can create an id and join multicast groups using
>AF_INET, AF_INET6, and/or AF_IB - whatever addressing scheme is most
>convenient.

Actually, the port space doesn't matter when specifying a multicast group.  So,
I can't think of any real advantage to supporting AF_IB/PS_TCP.

--
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	[flat|nested] 41+ messages in thread

* Re: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]                                         ` <350558935FCC47B6A5ABA8402109746C-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2010-03-26 17:20                                           ` Jason Gunthorpe
       [not found]                                             ` <20100326172057.GR29129-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2010-03-27  0:11                                           ` Sean Hefty
  1 sibling, 1 reply; 41+ messages in thread
From: Jason Gunthorpe @ 2010-03-26 17:20 UTC (permalink / raw)
  To: Sean Hefty; +Cc: linux-rdma

On Fri, Mar 26, 2010 at 10:17:13AM -0700, Sean Hefty wrote:
> >Consider UDP, an application can create an id and join multicast groups using
> >AF_INET, AF_INET6, and/or AF_IB - whatever addressing scheme is most
> >convenient.
> 
> Actually, the port space doesn't matter when specifying a multicast
> group.  So, I can't think of any real advantage to supporting
> AF_IB/PS_TCP.

I would actually think that using the TCP/UDP port space at all is
going to be a very rare usage, no sense in making it easy..
 
No SID for multicast, right?

Jason
--
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	[flat|nested] 41+ messages in thread

* RE: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]                                             ` <20100326172057.GR29129-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2010-03-26 17:23                                               ` Sean Hefty
  0 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-26 17:23 UTC (permalink / raw)
  To: 'Jason Gunthorpe'; +Cc: linux-rdma

>No SID for multicast, right?

Correct - the port/sid is ignored when the address specifies a multicast group.

--
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	[flat|nested] 41+ messages in thread

* RE: [RFC] [PATCH 0/22] [for 2.6.36] rdma/cm: add support for native IB addressing
       [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
                     ` (22 preceding siblings ...)
  2010-03-23 19:22   ` [RFC] [PATCH 0/22] [for 2.6.36] rdma/cm: add support for native IB addressing Sean Hefty
@ 2010-03-26 17:33   ` Sean Hefty
  23 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-26 17:33 UTC (permalink / raw)
  To: Hefty, Sean, linux-rdma

To help with discussion, here is a new API that was added to the librdmacm to
support AF_IB.

#define RAI_PASSIVE		1

struct rdma_addrinfo {
	int			ai_flags;
	int			ai_family;
	int			ai_qp_type;
	int			ai_port_space;
	socklen_t		ai_src_len;
	socklen_t		ai_dst_len;
	struct sockaddr		*ai_src_addr;
	struct sockaddr		*ai_dst_addr;
	char			*ai_src_canonname;
	char			*ai_dst_canonname;
	size_t			ai_route_len;
	void			*ai_route;
	size_t			ai_connect_len;
	void			*ai_connect;
	struct rdma_addrinfo	*ai_next;
};

int rdma_getaddrinfo(char *node, char *service,
		     struct rdma_addrinfo *hints,
		     struct rdma_addrinfo **res);

The hope is that applications can replace calls to getaddrinfo with
rdma_getaddrinfo.  The output of getaddrinfo can be fed into the existing APIs,
or apps can make use of a simpler routine which replaces rdma_create_id,
rdma_bind_addr/rdma_resolve_addr, and rdma_resolve_route.

int rdma_create_ep(struct rdma_cm_id **id, struct rdma_addrinfo *res,
		   struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr);

- Sean

--
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	[flat|nested] 41+ messages in thread

* RE: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]                                         ` <350558935FCC47B6A5ABA8402109746C-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  2010-03-26 17:20                                           ` Jason Gunthorpe
@ 2010-03-27  0:11                                           ` Sean Hefty
       [not found]                                             ` <0F1BE18DBBF74165AEA2B3283B01F338-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  1 sibling, 1 reply; 41+ messages in thread
From: Sean Hefty @ 2010-03-27  0:11 UTC (permalink / raw)
  To: Hefty, Sean, 'Jason Gunthorpe', Tom Tucker; +Cc: linux-rdma

>Actually, the port space doesn't matter when specifying a multicast group.  So,
>I can't think of any real advantage to supporting AF_IB/PS_TCP.

Okay - I found one advantage - fewer changes.  :b

I've started adding RDMA_PS_IB.  But the rdma_cm code uses the port space to
select between UD or RC operation, so additional changes are needed.  (I'm doing
them now rather than deferring them, since it affects the user to kernel
interface.)  Since PS IB is not sufficient, I'm adding the qp_type as a
parameter into rdma_create_id, for that purpose instead.  (This change is only
to the kernel API.)

This should allow for eventual support of UC QPs, for which there is an
outstanding request.

- Sean

--
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	[flat|nested] 41+ messages in thread

* Re: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]                                             ` <0F1BE18DBBF74165AEA2B3283B01F338-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
@ 2010-03-27  0:44                                               ` Jason Gunthorpe
       [not found]                                                 ` <20100327004440.GE9769-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 41+ messages in thread
From: Jason Gunthorpe @ 2010-03-27  0:44 UTC (permalink / raw)
  To: Sean Hefty; +Cc: Tom Tucker, linux-rdma

On Fri, Mar 26, 2010 at 05:11:04PM -0700, Sean Hefty wrote:
> >Actually, the port space doesn't matter when specifying a multicast group.  So,
> >I can't think of any real advantage to supporting AF_IB/PS_TCP.
> 
> Okay - I found one advantage - fewer changes.  :b

Lol!

> I've started adding RDMA_PS_IB.  But the rdma_cm code uses the port space to
> select between UD or RC operation, so additional changes are needed.
> (I'm doing

Gross, way too overloaded...

How does UD operation work with the SID anyhow?

> them now rather than deferring them, since it affects the user to kernel
> interface.)  Since PS IB is not sufficient, I'm adding the qp_type as a
> parameter into rdma_create_id, for that purpose instead.  (This change is only
> to the kernel API.)

So where does ai_qp_type get stuffed in user space?

Jason
--
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	[flat|nested] 41+ messages in thread

* RE: [RFC] [PATCH 5/22 v2] [for 2.6.36] rdma/cm: update port reservation to support AF_IB
       [not found]                                                 ` <20100327004440.GE9769-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2010-03-27  1:01                                                   ` Sean Hefty
  0 siblings, 0 replies; 41+ messages in thread
From: Sean Hefty @ 2010-03-27  1:01 UTC (permalink / raw)
  To: 'Jason Gunthorpe'; +Cc: Tom Tucker, linux-rdma

>How does UD operation work with the SID anyhow?

Not sure what you mean here.  The passive side listens on a SID.  Either a REQ
or SIDR REQ can match with that.  For UD, the expectation is that it will be a
SIDR REQ.  (The rdma cm needs a changed to reject whichever is unexpected.)

>So where does ai_qp_type get stuffed in user space?

Right now, there's a new call:

int rdma_create_ep(struct rdma_cm_id **id, struct rdma_addrinfo *res,
		   struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr);

Based on whether RAI_PASSIVE flag is set and the input parameters, this provides
functionality similar to:

rdma_create_id / rdma_bind_addr 
or
rdma_create_id / rdma_resolve_addr / rdma_resolve_route / rdma_create_qp

--
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	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2010-03-27  1:01 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-23 17:48 [RFC] [PATCH 0/22] [for 2.6.36] rdma/cm: add support for native IB addressing Sean Hefty
     [not found] ` <2F3826558E79459EAD2A457A604221C1-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-23 17:52   ` [RFC] [PATCH 1/22] [for 2.6.36] rdma/cm: define native IB address Sean Hefty
2010-03-23 17:54   ` [RFC] [PATCH 2/22] [for 2.6.36] rdma/cm: fix handling of ipv6 addressing in cma_use_port Sean Hefty
2010-03-23 17:55   ` [RFC] [PATCH 3/22] [for 2.6.36] rdma/cm: include AF_IB in loopback and any address checks Sean Hefty
2010-03-23 17:57   ` [RFC] [PATCH 4/22] [for 2.6.36] ib/addr: add AF_IB support to ip_addr_size Sean Hefty
2010-03-23 17:59   ` [RFC] [PATCH 5/22] [for 2.6.36] rdma/cm: update port reservation to support AF_IB Sean Hefty
     [not found]     ` <012F7D9E5E97445E9100EF170212AEE7-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-25 19:05       ` [RFC] [PATCH 5/22 v2] " Sean Hefty
     [not found]         ` <7451BD1514874F3E987E55040776EECC-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-25 20:29           ` Jason Gunthorpe
     [not found]             ` <20100325202924.GO29129-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-03-25 21:00               ` Sean Hefty
     [not found]                 ` <AC26D518E7AE4BE6BA3BDFC11480F8DB-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-25 22:04                   ` Jason Gunthorpe
     [not found]                     ` <20100325220435.GP29129-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-03-25 22:40                       ` Sean Hefty
     [not found]                         ` <C70579E21917462C89AAEAE3C225A58B-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-25 23:43                           ` Jason Gunthorpe
2010-03-26  3:56                           ` Sean Hefty
     [not found]                             ` <FD7DFBFAF86D4EA99F82836CBCA8AB33-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-26  4:08                               ` Jason Gunthorpe
     [not found]                                 ` <20100326040809.GD9769-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-03-26 16:06                                   ` Sean Hefty
     [not found]                                     ` <57287E48AAAD47A4BD50719B889F4596-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-26 17:17                                       ` Sean Hefty
     [not found]                                         ` <350558935FCC47B6A5ABA8402109746C-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-26 17:20                                           ` Jason Gunthorpe
     [not found]                                             ` <20100326172057.GR29129-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-03-26 17:23                                               ` Sean Hefty
2010-03-27  0:11                                           ` Sean Hefty
     [not found]                                             ` <0F1BE18DBBF74165AEA2B3283B01F338-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-27  0:44                                               ` Jason Gunthorpe
     [not found]                                                 ` <20100327004440.GE9769-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-03-27  1:01                                                   ` Sean Hefty
2010-03-23 18:01   ` [RFC] [PATCH 6/22] [for 2.6.36] rdma/cm: Allow user to specify AF_IB when binding Sean Hefty
2010-03-23 18:03   ` [RFC] [PATCH 7/22] [for 2.6.36] rdma/cm: do not modify sa_family when setting loopback address Sean Hefty
2010-03-23 18:04   ` [RFC] [PATCH 8/22] [for 2.6.36] rdma/cm: restrict AF_IB loopback to binding to IB devices only Sean Hefty
2010-03-23 18:06   ` [RFC] [PATCH 9/22] [for 2.6.36] rdma/cm: add support for AF_IB to rdma_resolve_addr Sean Hefty
2010-03-23 18:07   ` [RFC] [PATCH 10/22] [for 2.6.36] rdma/cm: add support for AF_IB to cma_get_service_id Sean Hefty
2010-03-23 18:08   ` [RFC] [PATCH 11/22] [for 2.6.36] rdma/cm: fixup white space Sean Hefty
2010-03-23 18:11   ` [RFC] [PATCH 12/22] [for 2.6.36] rdma/cm: expose private data when using AF_IB Sean Hefty
2010-03-23 18:12   ` [RFC] [PATCH 13/22] [for 2.6.36] rdma/cm: only listen on IB devices " Sean Hefty
2010-03-23 18:14   ` [RFC] [PATCH 14/22] [for 2.6.36] rdma/ucm: support querying for AF_IB addresses Sean Hefty
2010-03-23 18:16   ` [RFC] [PATCH 15/22] [for 2.6.36] ib/sa: export function to pack a path record into wire format Sean Hefty
2010-03-23 18:18   ` [RFC] [PATCH 16/22] [for 2.6.36] rdma/ucm: support querying when IB paths are not reversible Sean Hefty
2010-03-23 18:20   ` [RFC] [PATCH 17/22] [for 2.6.36] rdma/cm: export cma_get_service_id Sean Hefty
2010-03-23 18:23   ` [RFC] [PATCH 18/22] [for 2.6.36] rdma/ucm: add ability to query GID addresses Sean Hefty
2010-03-23 18:25   ` [RFC] [PATCH 19/22] [for 2.6.36] rdma/ucm: name changes to indicate only IP addresses supported Sean Hefty
2010-03-23 18:27   ` [RFC] [PATCH 20/22] [for 2.6.36] rdma/ucm: allow user space to bind to AF_IB Sean Hefty
2010-03-23 18:28   ` [RFC] [PATCH 21/22] [for 2.6.36] rdma/ucm: allow user space to pass AF_IB into resolve Sean Hefty
2010-03-23 18:30   ` [RFC] [PATCH 22/22] [for 2.6.36] rdma/ucm: allow user space to specify AF_IB when joining multicast Sean Hefty
     [not found]     ` <48F1FC4C2F114E928EB38D690091185E-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2010-03-25 19:08       ` [RFC] [PATCH 22/22 v2] " Sean Hefty
2010-03-23 19:22   ` [RFC] [PATCH 0/22] [for 2.6.36] rdma/cm: add support for native IB addressing Sean Hefty
2010-03-26 17:33   ` Sean Hefty

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.