diff mbox

[RFC,6/22,for,2.6.36] rdma/cm: Allow user to specify AF_IB when binding

Message ID FFD5426A776B40B9B53DEEB2B812B56B@amr.corp.intel.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Hefty, Sean March 23, 2010, 6:01 p.m. UTC
None
diff mbox

Patch

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);