[openib-general] [PATCH 1/2] rdma_cm: add support to join IPOIB multicast groups

Sean Hefty sean.hefty at intel.com
Tue Jan 23 13:16:46 PST 2007


Add to the rdma_cm an IPOIB port space that allows interoperability with
IPoIB multicast traffic.  Use of the RDMA_PS_IPOIB is limited to multicast
join/leave.

Rename the RDMA_UD_QKEY to RDMA_UDP_QKEY to signify that the qkey is only
used with the RDMA_PS_UDP port space.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
This patch differs from those posted by Or by limiting the ipoib port space
to multicast traffic only.

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 5cbef6a..6797e54 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -71,6 +71,7 @@ static struct workqueue_struct *cma_wq;
 static DEFINE_IDR(sdp_ps);
 static DEFINE_IDR(tcp_ps);
 static DEFINE_IDR(udp_ps);
+static DEFINE_IDR(ipoib_ps);
 
 struct cma_device {
 	struct list_head	list;
@@ -1822,6 +1823,9 @@ static int cma_get_port(struct rdma_id_private *id_priv)
 	case RDMA_PS_UDP:
 		ps = &udp_ps;
 		break;
+	case RDMA_PS_IPOIB:
+		ps = &ipoib_ps;
+		break;
 	default:
 		return -EPROTONOSUPPORT;
 	}
@@ -1936,7 +1940,7 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
 			event.status = ib_event->param.sidr_rep_rcvd.status;
 			break;
 		}
-		if (rep->qkey != RDMA_UD_QKEY) {
+		if (rep->qkey != RDMA_UDP_QKEY) {
 			event.event = RDMA_CM_EVENT_UNREACHABLE;
 			event.status = -EINVAL;
 			break;
@@ -2231,7 +2235,7 @@ static int cma_send_sidr_rep(struct rdma_id_private *id_priv,
 	rep.status = status;
 	if (status == IB_SIDR_SUCCESS) {
 		rep.qp_num = id_priv->qp_num;
-		rep.qkey = RDMA_UD_QKEY;
+		rep.qkey = RDMA_UDP_QKEY;
 	}
 	rep.private_data = private_data;
 	rep.private_data_len = private_data_len;
@@ -2426,7 +2430,10 @@ static int cma_join_ib_multicast(struct rdma_id_private *id_priv,
 		return ret;
 
 	ip_ib_mc_map(sin->sin_addr.s_addr, mc_map);
-	mc_map[7] = 0x01;			/* Use RDMA CM signature */
+	if (id_priv->id.ps == RDMA_PS_UDP) {
+		mc_map[7] = 0x01;		/* Use RDMA CM signature */
+		rec.qkey = cpu_to_be32(RDMA_UDP_QKEY);
+	}
 	mc_map[8] = ib_addr_get_pkey(dev_addr) >> 8;
 	mc_map[9] = (unsigned char) ib_addr_get_pkey(dev_addr);
 
@@ -2434,7 +2441,6 @@ static int cma_join_ib_multicast(struct rdma_id_private *id_priv,
 	ib_addr_get_sgid(dev_addr, &rec.port_gid);
 	rec.pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr));
 	rec.join_state = 1;
-	rec.qkey = cpu_to_be32(RDMA_UD_QKEY);
 
 	comp_mask = IB_SA_MCMEMBER_REC_MGID | IB_SA_MCMEMBER_REC_PORT_GID |
 		    IB_SA_MCMEMBER_REC_PKEY | IB_SA_MCMEMBER_REC_JOIN_STATE |
@@ -2646,6 +2652,7 @@ static void cma_cleanup(void)
 	idr_destroy(&sdp_ps);
 	idr_destroy(&tcp_ps);
 	idr_destroy(&udp_ps);
+	idr_destroy(&ipoib_ps);
 }
 
 module_init(cma_init);
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 6b43672..c7a4de7 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -257,7 +257,7 @@ static int ucma_event_handler(struct rdma_cm_id *cm_id,
 	ucma_set_event_context(ctx, event, uevent);
 	uevent->resp.event = event->event;
 	uevent->resp.status = event->status;
-	if (cm_id->ps == RDMA_PS_UDP)
+	if (cm_id->ps == RDMA_PS_UDP || cm_id->ps == RDMA_PS_IPOIB)
 		ucma_copy_ud_event(&uevent->resp.param.ud, &event->param.ud);
 	else
 		ucma_copy_conn_event(&uevent->resp.param.conn,
diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h
index 2f96f33..2d6a770 100644
--- a/include/rdma/rdma_cm.h
+++ b/include/rdma/rdma_cm.h
@@ -58,6 +58,7 @@ enum rdma_cm_event_type {
 
 enum rdma_port_space {
 	RDMA_PS_SDP  = 0x0001,
+	RDMA_PS_IPOIB= 0x0002,
 	RDMA_PS_TCP  = 0x0106,
 	RDMA_PS_UDP  = 0x0111,
 	RDMA_PS_SCTP = 0x0183
diff --git a/include/rdma/rdma_cm_ib.h b/include/rdma/rdma_cm_ib.h
index 9b176df..950424b 100644
--- a/include/rdma/rdma_cm_ib.h
+++ b/include/rdma/rdma_cm_ib.h
@@ -44,7 +44,7 @@
 int rdma_set_ib_paths(struct rdma_cm_id *id,
 		      struct ib_sa_path_rec *path_rec, int num_paths);
 
-/* Global qkey for UD QPs and multicast groups. */
-#define RDMA_UD_QKEY 0x01234567
+/* Global qkey for UDP QPs and multicast groups. */
+#define RDMA_UDP_QKEY 0x01234567
 
 #endif /* RDMA_CM_IB_H */





More information about the general mailing list