[ofw] [PATCH 6/11] librdmacm: optional conn_param

Hefty, Sean sean.hefty at intel.com
Mon Aug 16 16:19:27 PDT 2010


If the user does not specify connection parameters, use default
settings.

From: Sean Hefty <sean.hefty at intel.com>
---
 trunk/ulp/librdmacm/src/cma.cpp |   65 ++++++++++++++++++++++++++-------------
 1 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/trunk/ulp/librdmacm/src/cma.cpp b/trunk/ulp/librdmacm/src/cma.cpp
index 05c672d..7240c4d 100644
--- a/trunk/ulp/librdmacm/src/cma.cpp
+++ b/trunk/ulp/librdmacm/src/cma.cpp
@@ -745,6 +745,14 @@ static int ucma_valid_param(struct cma_id_private *id_priv,
 		return 0;
 	}
 
+	if (!id_priv->id.qp && !param) {
+		return rdma_seterrno(EINVAL);
+	}
+
+	if (!param) {
+		return 0;
+	}
+
 	if ((param->responder_resources != RDMA_MAX_RESP_RES) &&
 		(param->responder_resources > id_priv->cma_dev->max_responder_resources)) {
 		return rdma_seterrno(EINVAL);
@@ -758,6 +766,27 @@ static int ucma_valid_param(struct cma_id_private *id_priv,
 	return 0;
 }
 
+static void ucma_set_connect_attr(struct cma_id_private *id_priv,
+								  struct rdma_conn_param *param,
+								  WV_CONNECT_PARAM *attr)
+{
+	RtlZeroMemory(attr, sizeof *attr);
+
+	attr->ResponderResources = id_priv->responder_resources;
+	attr->InitiatorDepth = id_priv->initiator_depth;
+
+	if (param) {
+		attr->RetryCount = param->retry_count;
+		attr->RnrRetryCount = param->rnr_retry_count;
+		if ((attr->DataLength = param->private_data_len)) {
+			RtlCopyMemory(attr->Data, param->private_data, attr->DataLength);
+		}
+	} else {
+		attr->RetryCount = 7;
+		attr->RnrRetryCount = 7;
+	}
+}
+
 __declspec(dllexport)
 int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
 {
@@ -772,20 +801,19 @@ int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
 		return ret;
 	}
 
-	id_priv->responder_resources = min(conn_param->responder_resources,
-									   id_priv->cma_dev->max_responder_resources);
-	id_priv->initiator_depth = min(conn_param->initiator_depth,
-								   id_priv->cma_dev->max_initiator_depth);
-
-	RtlZeroMemory(&attr, sizeof attr);
-	attr.ResponderResources = id_priv->responder_resources;
-	attr.InitiatorDepth = id_priv->initiator_depth;
-	attr.RetryCount = conn_param->retry_count;
-	attr.RnrRetryCount = conn_param->rnr_retry_count;
-	if ((attr.DataLength = conn_param->private_data_len)) {
-		RtlCopyMemory(attr.Data, conn_param->private_data, attr.DataLength);
+	if (conn_param && conn_param->responder_resources != RDMA_MAX_RESP_RES) {
+		id_priv->responder_resources = conn_param->responder_resources;
+	} else {
+		id_priv->responder_resources = id_priv->cma_dev->max_responder_resources;
+	}
+	if (conn_param && conn_param->initiator_depth != RDMA_MAX_INIT_DEPTH) {
+		id_priv->initiator_depth = conn_param->initiator_depth;
+	} else {
+		id_priv->initiator_depth = id_priv->cma_dev->max_initiator_depth;
 	}
 
+	ucma_set_connect_attr(id_priv, conn_param, &attr);
+
 	id_priv->state = cma_active_connect;
 	id_priv->refcnt++;
 	id->comp_entry.Busy = 1;
@@ -904,27 +932,20 @@ int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
 		return ret;
 	}
 
-	if (conn_param->initiator_depth == RDMA_MAX_INIT_DEPTH) {
+	if (!conn_param || conn_param->initiator_depth == RDMA_MAX_INIT_DEPTH) {
 		id_priv->initiator_depth = min(id_priv->initiator_depth,
 									   id_priv->cma_dev->max_initiator_depth);
 	} else {
 		id_priv->initiator_depth = conn_param->initiator_depth;
 	}
-	if (conn_param->responder_resources == RDMA_MAX_RESP_RES) {
+	if (!conn_param || conn_param->responder_resources == RDMA_MAX_RESP_RES) {
 		id_priv->responder_resources = min(id_priv->responder_resources,
 										   id_priv->cma_dev->max_responder_resources);
 	} else {
 		id_priv->responder_resources = conn_param->responder_resources;
 	}
 
-	RtlZeroMemory(&attr, sizeof attr);
-	attr.ResponderResources = id_priv->responder_resources;
-	attr.InitiatorDepth = id_priv->initiator_depth;
-	attr.RetryCount = conn_param->retry_count;
-	attr.RnrRetryCount = conn_param->rnr_retry_count;
-	if ((attr.DataLength = conn_param->private_data_len)) {
-		RtlCopyMemory(attr.Data, conn_param->private_data, attr.DataLength);
-	}
+	ucma_set_connect_attr(id_priv, conn_param, &attr);
 
 	id_priv->state = cma_accepting;
 	id_priv->refcnt++;




More information about the ofw mailing list