[openib-general] [PATCH 2/3] CMA Changes and iWARP CM

Sean Hefty mshefty at ichips.intel.com
Fri Mar 10 15:30:39 PST 2006


> +static int iw_conn_req_handler(struct iw_cm_id *cm_id, 
> +			       struct iw_cm_event *iw_event)
> +{
> +	struct rdma_cm_id* new_cm_id;
> +	struct rdma_id_private *listen_id, *conn_id;
> +	struct sockaddr_in* sin;
> +	int ret;
> +
> +	listen_id = cm_id->context;
> +	atomic_inc(&listen_id->dev_remove);
> +	if (!cma_comp(listen_id, CMA_LISTEN)) {
> +		ret = -ECONNABORTED;
> +		goto out;
> +	}
> +
> +	/* Create a new RDMA id the new IW CM ID */
> +	new_cm_id = rdma_create_id(listen_id->id.event_handler, 
> +				   listen_id->id.context,
> +				   RDMA_PS_TCP);
> +	if (!new_cm_id) {
> +		ret = -ENOMEM;
> +		goto out;
> +	}
> +	conn_id = container_of(new_cm_id, struct rdma_id_private, id);
> +	atomic_inc(&conn_id->dev_remove);
> +	conn_id->state = CMA_CONNECT;
> +
> +	/* New connection inherits device and address from parent */
> +	memcpy(&new_cm_id->route.addr.dev_addr,
> +	       &listen_id->id.route.addr.dev_addr,
> +	       sizeof(new_cm_id->route.addr.dev_addr));
> +	/* New connection inherits device from parent */
> +	ret = cma_acquire_dev(conn_id);
> +	if (ret)
> +		goto out;

We need some additional cleanup here before jumping to out:

cma_release_remove(conn_id);
rdma_destroy_id(&conn_id->id);

> +
> +	conn_id->cm_id.iw = cm_id;
> +	cm_id->context = conn_id;
> +	cm_id->cm_handler = cma_iw_handler;
> +
> +	sin = (struct sockaddr_in*)&new_cm_id->route.addr.src_addr;
> +	*sin = iw_event->local_addr;
> +
> +	sin = (struct sockaddr_in*)&new_cm_id->route.addr.dst_addr;
> +	*sin = iw_event->remote_addr;
> +
> +	ret = cma_notify_user(conn_id, RDMA_CM_EVENT_CONNECT_REQUEST, 0,
> +			      iw_event->private_data,
> +			      iw_event->private_data_len);
> +	if (ret) {
> +		/* Destroy the CM ID by returning a non-zero value. */
> +		conn_id->cm_id.iw = NULL;
> +		cma_exch(conn_id, CMA_DESTROYING);
> +		cma_release_remove(conn_id);
> +		rdma_destroy_id(&conn_id->id);
> +	}
> +
> +out:
> +	cma_release_remove(listen_id);
> +	return ret;
> +}
> +

{snip]

> +static int cma_connect_iw(struct rdma_id_private *id_priv,
> +			  struct rdma_conn_param *conn_param)
> +{
> +	struct iw_cm_id* cm_id;
> +	struct sockaddr_in* sin;
> +	int ret;
> +
> +	cm_id = iw_create_cm_id(id_priv->id.device, cma_iw_handler, id_priv);
> +	if (IS_ERR(cm_id)) {
> +		ret = PTR_ERR(cm_id);
> +		goto out;
> +	}
> +
> +	id_priv->cm_id.iw = cm_id;
> +
> +	sin = (struct sockaddr_in*)&id_priv->id.route.addr.src_addr;
> +	cm_id->local_addr = *sin;
> +
> +	sin = (struct sockaddr_in*)&id_priv->id.route.addr.dst_addr;
> +	cm_id->remote_addr = *sin;
> +
> +	cm_id->qp = id_priv->id.qp;
> +	cm_id->qp_num = id_priv->qp_num;

It still looks unnatural for the client who creates the cm_id to need to set the 
local_addr, remote_addr, qp, and qp_num in the cm_id files.  I think that these 
should be parameters into iw_cm_connect() if the lower layer needs them.

{snip}

> +	case RDMA_TRANSPORT_IWARP:
> +		id_priv->cm_id.iw->qp = id_priv->id.qp;
> +		id_priv->cm_id.iw->qp_num = id_priv->qp_num;
> +
> +		ret = iw_cm_accept(id_priv->cm_id.iw, conn_param->private_data,
> +				   conn_param->private_data_len);

Same comment as previous.

- Sean



More information about the general mailing list