[ofw] [PATCH 3/11] librdmacm: allow PD parameter to be optional

Hefty, Sean sean.hefty at intel.com
Mon Aug 16 16:17:12 PDT 2010


From: Sean Hefty <sean.hefty at intel.com>
---
 trunk/ulp/librdmacm/include/rdma/rdma_cma.h |   10 +++++-----
 trunk/ulp/librdmacm/src/cma.cpp             |   20 ++++++++++++++++----
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/trunk/ulp/librdmacm/include/rdma/rdma_cma.h b/trunk/ulp/librdmacm/include/rdma/rdma_cma.h
index 4604560..3836483 100644
--- a/trunk/ulp/librdmacm/include/rdma/rdma_cma.h
+++ b/trunk/ulp/librdmacm/include/rdma/rdma_cma.h
@@ -74,15 +74,15 @@ enum rdma_cm_event_type
 enum rdma_port_space
 {
 	RDMA_PS_IPOIB	= 0x0002,
-	RDMA_PS_IB		= 0x0003,
+	RDMA_PS_IB		= 0x0003,
 	RDMA_PS_TCP		= 0x0106,
 	RDMA_PS_UDP		= 0x0111,
 };
 
-#define RDMA_IB_IP_PS_MASK   0xFFFFFFFFFFFF0000ULL
-#define RDMA_IB_IP_PORT_MASK 0x000000000000FFFFULL
-#define RDMA_IB_IP_PS_TCP    0x0000000001060000ULL
-#define RDMA_IB_IP_PS_UDP    0x0000000001110000ULL
+#define RDMA_IB_IP_PS_MASK   0xFFFFFFFFFFFF0000ULL
+#define RDMA_IB_IP_PORT_MASK 0x000000000000FFFFULL
+#define RDMA_IB_IP_PS_TCP    0x0000000001060000ULL
+#define RDMA_IB_IP_PS_UDP    0x0000000001110000ULL
 
 /*
  * Global qkey value for UDP QPs and multicast groups created via the 
diff --git a/trunk/ulp/librdmacm/src/cma.cpp b/trunk/ulp/librdmacm/src/cma.cpp
index 2698bde..3c7bed2 100644
--- a/trunk/ulp/librdmacm/src/cma.cpp
+++ b/trunk/ulp/librdmacm/src/cma.cpp
@@ -79,6 +79,7 @@ struct cma_id_private
 struct cma_device
 {
 	struct ibv_context	*verbs;
+	struct ibv_pd		*pd;
 	uint64_t			guid;
 	int					port_cnt;
 	uint8_t				max_initiator_depth;
@@ -134,6 +135,13 @@ static int ucma_acquire(void)
 			goto err4;
 		}
 
+		cma_dev->pd = ibv_alloc_pd(cma_dev->verbs);
+		if (cma_dev->pd == NULL) {
+			ibv_close_device(cma_dev->verbs);
+			ret = -1;
+			goto err4;
+		}
+
 		++i;
 		ret = ibv_query_device(cma_dev->verbs, &attr);
 		if (ret) {
@@ -151,8 +159,9 @@ out:
 	return 0;
 
 err4:
-	while (i) {
-		ibv_close_device(cma_dev_array[--i].verbs);
+	while (i--) {
+		ibv_dealloc_pd(cma_dev_array[i].pd);
+		ibv_close_device(cma_dev_array[i].verbs);
 	}
 	delete cma_dev_array;
 err3:
@@ -172,6 +181,7 @@ void ucma_release(void)
 	EnterCriticalSection(&lock);
 	if (--ref == 0) {
 		for (i = 0; i < cma_dev_cnt; i++) {
+			ibv_dealloc_pd(cma_dev_array[i].pd);
 			ibv_close_device(cma_dev_array[i].verbs);
 		}
 		delete cma_dev_array;
@@ -635,8 +645,10 @@ int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd,
 	int ret;
 
 	id_priv = CONTAINING_RECORD(id, struct cma_id_private, id);
-	if (id->verbs != pd->context) {
-		return -1;
+	if (!pd) {
+		pd = id_priv->cma_dev->pd;
+	} else if (id->verbs != pd->context) {
+		return rdma_seterrno(EINVAL);
 	}
 
 	qp = ibv_create_qp(pd, qp_init_attr);




More information about the ofw mailing list