[ofw] [RFC] [2/2] ib cm: export CM only interface

Sean Hefty sean.hefty at intel.com
Mon Nov 17 11:53:07 PST 2008


These are the changes to the existing IBAL 'CEP' manager to support exporting the
IB CM interface.  The CEP interface is modified to no longer assume that IBAL QP
objects are passed in through the interface.

These changes are compile tested only.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
Index: al_cm_cep.c
===================================================================
--- al_cm_cep.c	(revision 1722)
+++ al_cm_cep.c	(working copy)
@@ -4433,6 +4433,7 @@
 
 static ib_api_status_t
 __format_req(
+	IN				cep_agent_t* const			p_port_cep,
 	IN				kcep_t* const				p_cep,
 	IN		const	ib_cm_req_t* const			p_cm_req )
 {
@@ -4453,14 +4454,14 @@
 
 	p_req = (mad_cm_req_t*)p_cep->p_mad->p_mad_buf;
 
-	ci_ca_lock_attr( p_cm_req->h_qp->obj.p_ci_ca );
+	ci_ca_lock_attr( p_port_cep->h_ca->obj.p_ci_ca );
 	/*
 	 * Store the local CA's ack timeout for use when computing
 	 * the local ACK timeout.
 	 */
 	p_cep->local_ack_delay =
-		p_cm_req->h_qp->obj.p_ci_ca->p_pnp_attr->local_ack_delay;
-	ci_ca_unlock_attr( p_cm_req->h_qp->obj.p_ci_ca );
+		p_port_cep->h_ca->obj.p_ci_ca->p_pnp_attr->local_ack_delay;
+	ci_ca_unlock_attr( p_port_cep->h_ca->obj.p_ci_ca );
 
 	/* Format the primary path. */
 	__format_req_path( p_cm_req->p_primary_path,
@@ -4480,13 +4481,13 @@
 	/* Set the local communication in the REQ. */
 	p_req->local_comm_id = p_cep->local_comm_id;
 	p_req->sid = p_cm_req->svc_id;
-	p_req->local_ca_guid = p_cm_req->h_qp->obj.p_ci_ca->verbs.guid;
+	p_req->local_ca_guid = p_port_cep->h_ca->obj.p_ci_ca->verbs.guid;
 
 	conn_req_set_lcl_qpn( p_cep->local_qpn, p_req );
 	conn_req_set_resp_res( p_cm_req->resp_res, p_req );
 	conn_req_set_init_depth( p_cm_req->init_depth, p_req );
 	conn_req_set_remote_resp_timeout( p_cm_req->remote_resp_timeout, p_req );
-	conn_req_set_qp_type( p_cm_req->h_qp->type, p_req );
+	conn_req_set_qp_type( p_cm_req->qp_type, p_req );
 	conn_req_set_flow_ctrl( p_cm_req->flow_ctrl, p_req );
 	conn_req_set_starting_psn( p_cep->rq_psn, p_req );
 
@@ -4513,6 +4514,7 @@
 __save_user_req(
 	IN				kcep_t* const				p_cep,
 	IN		const	ib_cm_req_t* const			p_cm_req,
+	IN		const	net32_t						qpn,
 		OUT			cep_agent_t** const			pp_port_cep )
 {
 	cep_agent_t		*p_port_cep;
@@ -4572,8 +4574,8 @@
 	p_cep->av[0].attr.conn.seq_err_retry_cnt = p_cm_req->retry_cnt;
 
 	/* Make sure the paths will work on the desired QP. */
-	if( p_port_cep->h_ca->obj.p_ci_ca->verbs.guid !=
-		p_cm_req->h_qp->obj.p_ci_ca->verbs.guid )
+	if( p_cm_req->h_qp && (p_port_cep->h_ca->obj.p_ci_ca->verbs.guid !=
+		p_cm_req->h_qp->obj.p_ci_ca->verbs.guid) )
 	{
 		AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
 			("Primary path not realizable on given QP.\n") );
@@ -4644,7 +4646,7 @@
 	p_cep->remote_comm_id = 0;
 
 	/* Cache the local QPN. */
-	p_cep->local_qpn = p_cm_req->h_qp->num;
+	p_cep->local_qpn = qpn;
 	p_cep->remote_ca_guid = 0;
 	p_cep->remote_qpn = 0;
 
@@ -4672,10 +4674,11 @@
 
 
 ib_api_status_t
-al_cep_pre_req(
+kal_cep_pre_req(
 	IN				ib_al_handle_t				h_al,
 	IN				net32_t						cid,
 	IN		const	ib_cm_req_t* const			p_cm_req,
+	IN		const	net32_t						qpn,
 		OUT			ib_qp_mod_t* const			p_init )
 {
 	ib_api_status_t		status;
@@ -4713,7 +4716,7 @@
 		p_cep->p_mad = NULL;
 		/* Fall through. */
 	case CEP_STATE_IDLE:
-		status = __save_user_req( p_cep, p_cm_req, &p_port_cep );
+		status = __save_user_req( p_cep, p_cm_req, qpn, &p_port_cep );
 		if( status != IB_SUCCESS )
 			break;
 
@@ -4722,7 +4725,7 @@
 		if( status != IB_SUCCESS )
 			break;
 
-		status = __format_req( p_cep, p_cm_req );
+		status = __format_req( p_port_cep, p_cep, p_cm_req );
 		if( status != IB_SUCCESS )
 		{
 			AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("Invalid pdata length.\n") );
@@ -4757,6 +4760,15 @@
 	return status;
 }
 
+ib_api_status_t
+al_cep_pre_req(
+	IN				ib_al_handle_t				h_al,
+	IN				net32_t						cid,
+	IN		const	ib_cm_req_t* const			p_cm_req,
+		OUT			ib_qp_mod_t* const			p_init )
+{
+	return kal_cep_pre_req(h_al, cid, p_cm_req, p_cm_req->h_qp->num, p_init);
+}
 
 ib_api_status_t
 al_cep_send_req(
@@ -4817,29 +4829,31 @@
 
 static void
 __save_user_rep(
+	IN				cep_agent_t* const			p_port_cep,
 	IN				kcep_t* const				p_cep,
-	IN		const	ib_cm_rep_t* const			p_cm_rep )
+	IN		const	ib_cm_rep_t* const			p_cm_rep,
+	IN		const	net32_t						qpn )
 {
 	AL_ENTER( AL_DBG_CM );
 
 	/* Cache the local QPN. */
-	p_cep->local_qpn = p_cm_rep->h_qp->num;
+	p_cep->local_qpn = qpn;
 	p_cep->rq_psn = p_cep->local_qpn;
 	p_cep->init_depth = p_cm_rep->init_depth;
 
-	ci_ca_lock_attr( p_cm_rep->h_qp->obj.p_ci_ca );
+	ci_ca_lock_attr( p_port_cep->h_ca->obj.p_ci_ca );
 	/* Check the CA's responder resource max and trim if necessary. */
-	if( (p_cm_rep->h_qp->obj.p_ci_ca->p_pnp_attr->max_qp_resp_res <
-		p_cep->resp_res) )
+	if( p_port_cep->h_ca->obj.p_ci_ca->p_pnp_attr->max_qp_resp_res <
+		p_cep->resp_res )
 	{
 		/*
 		 * The CA cannot handle the requested responder resources.
 		 * Set the response to the CA's maximum.
 		 */
 		p_cep->resp_res = 
-			p_cm_rep->h_qp->obj.p_ci_ca->p_pnp_attr->max_qp_resp_res;
+			p_port_cep->h_ca->obj.p_ci_ca->p_pnp_attr->max_qp_resp_res;
 	}
-	ci_ca_unlock_attr( p_cm_rep->h_qp->obj.p_ci_ca );
+	ci_ca_unlock_attr( p_port_cep->h_ca->obj.p_ci_ca );
 
 	p_cep->rnr_nak_timeout = p_cm_rep->rnr_nak_timeout;
 
@@ -4849,6 +4863,7 @@
 
 static ib_api_status_t
 __format_rep(
+	IN				cep_agent_t* const			p_port_cep,
 	IN				kcep_t* const				p_cep,
 	IN		const	ib_cm_rep_t* const			p_cm_rep )
 {
@@ -4898,10 +4913,10 @@
 
 	p_rep->resp_resources = p_cep->resp_res;
 
-	ci_ca_lock_attr( p_cm_rep->h_qp->obj.p_ci_ca );
+	ci_ca_lock_attr( p_port_cep->h_ca->obj.p_ci_ca );
 	conn_rep_set_target_ack_delay(
-		p_cm_rep->h_qp->obj.p_ci_ca->p_pnp_attr->local_ack_delay, p_rep );
-	ci_ca_unlock_attr( p_cm_rep->h_qp->obj.p_ci_ca );
+		p_port_cep->h_ca->obj.p_ci_ca->p_pnp_attr->local_ack_delay, p_rep );
+	ci_ca_unlock_attr( p_port_cep->h_ca->obj.p_ci_ca );
 
 	p_rep->initiator_depth = p_cep->init_depth;
 
@@ -4925,11 +4940,12 @@
 
 
 
-ib_api_status_t
+static ib_api_status_t
 __al_cep_pre_rep(
 	IN				kcep_t						*p_cep,
 	IN				void*						context,
 	IN		const	ib_cm_rep_t* const			p_cm_rep,
+	IN		const	net32_t						qpn,
 		OUT			ib_qp_mod_t* const			p_init )
 {
 	ib_api_status_t		status;
@@ -4956,9 +4972,9 @@
 		if( status != IB_SUCCESS )
 			break;
 
-		__save_user_rep( p_cep, p_cm_rep );
+		__save_user_rep( p_port_cep, p_cep, p_cm_rep, qpn );
 
-		status = __format_rep( p_cep, p_cm_rep );
+		status = __format_rep( p_port_cep, p_cep, p_cm_rep );
 		if( status != IB_SUCCESS )
 		{
 			ib_put_mad( p_cep->p_mad );
@@ -5001,54 +5017,21 @@
 	IN	OUT			net32_t* const				p_cid,
 		OUT			ib_qp_mod_t* const			p_init )
 {
-	ib_api_status_t		status;
-	kcep_t				*p_cep;
-	KLOCK_QUEUE_HANDLE	hdl;
-
-	AL_ENTER( AL_DBG_CM );
-
-	CL_ASSERT( h_al );
-	CL_ASSERT( p_cm_rep );
-	CL_ASSERT( p_init );
-
-	KeAcquireInStackQueuedSpinLock( &gp_cep_mgr->lock, &hdl );
-	if( *p_cid != AL_INVALID_CID )
-	{
-		KeReleaseInStackQueuedSpinLock( &hdl );
-		AL_EXIT( AL_DBG_CM );
-		return IB_RESOURCE_BUSY;
-	}
-
-	p_cep = __lookup_cep( h_al, cid );
-	if( !p_cep )
-	{
-		KeReleaseInStackQueuedSpinLock( &hdl );
-		AL_EXIT( AL_DBG_CM );
-		return IB_INVALID_HANDLE;
-	}
-
-	status = __al_cep_pre_rep( p_cep, context, p_cm_rep, p_init );
-
-	if( status == IB_SUCCESS )
-	{
-		p_cep->pfn_destroy_cb = pfn_destroy_cb;
-		*p_cid = cid;
-	}
-
-	KeReleaseInStackQueuedSpinLock( &hdl );
-	AL_EXIT( AL_DBG_CM );
-	return status;
+	return kal_cep_pre_rep(h_al, cid, NULL, context,
+						   pfn_destroy_cb, p_cm_rep, p_cm_rep->h_qp->num,
+						   p_cid, p_init);
 }
 
 
 ib_api_status_t
-al_cep_pre_rep_ex(
+kal_cep_pre_rep(
 	IN				ib_al_handle_t				h_al,
 	IN				net32_t						cid,
 	IN				al_pfn_cep_cb_t				pfn_cb,
 	IN				void*						context,
 	IN				ib_pfn_destroy_cb_t			pfn_destroy_cb,
 	IN		const	ib_cm_rep_t* const			p_cm_rep,
+	IN		const	net32_t						qpn,
 	IN	OUT			net32_t* const				p_cid,
 		OUT			ib_qp_mod_t* const			p_init )
 {
@@ -5078,11 +5061,11 @@
 		return IB_INVALID_HANDLE;
 	}
 
-	status = __al_cep_pre_rep( p_cep, context, p_cm_rep, p_init );
+	status = __al_cep_pre_rep( p_cep, context, p_cm_rep, qpn, p_init );
 
 	if( status == IB_SUCCESS )
 	{
-		p_cep->pfn_cb = pfn_cb;
+		p_cep->pfn_cb = pfn_cb ? pfn_cb : p_cep->pfn_cb;
 		p_cep->pfn_destroy_cb = pfn_destroy_cb;
 		*p_cid = cid;
 	}
@@ -5977,6 +5960,61 @@
 
 
 ib_api_status_t
+al_cep_get_init_attr(
+	IN				ib_al_handle_t				h_al,
+	IN				net32_t						cid,
+		OUT			ib_qp_mod_t* const			p_init )
+{
+	ib_api_status_t		status;
+	kcep_t				*p_cep;
+	KLOCK_QUEUE_HANDLE	hdl;
+
+	AL_ENTER( AL_DBG_CM );
+
+	KeAcquireInStackQueuedSpinLock( &gp_cep_mgr->lock, &hdl );
+	p_cep = __lookup_cep( h_al, cid );
+	if( !p_cep )
+	{
+		status = IB_INVALID_HANDLE;
+		goto out;
+	}
+
+	switch( p_cep->state )
+	{
+	case CEP_STATE_PRE_REQ:
+	case CEP_STATE_REQ_RCVD:
+	case CEP_STATE_PRE_REP:
+	case CEP_STATE_REQ_SENT:
+	case CEP_STATE_REQ_MRA_RCVD:
+	case CEP_STATE_REQ_MRA_SENT:
+	case CEP_STATE_PRE_REP_MRA_SENT:
+	case CEP_STATE_REP_RCVD:
+	case CEP_STATE_REP_SENT:
+	case CEP_STATE_REP_MRA_RCVD:
+	case CEP_STATE_REP_MRA_SENT:
+	case CEP_STATE_ESTABLISHED:
+		/* Format the INIT qp modify attributes. */
+		cl_memclr(p_init, sizeof(ib_qp_mod_t));
+		p_init->req_state = IB_QPS_INIT;
+		p_init->state.init.primary_port =
+			p_cep->av[p_cep->idx_primary].attr.port_num;
+		p_init->state.init.pkey_index =
+			p_cep->av[p_cep->idx_primary].pkey_index;
+		p_init->state.init.access_ctrl = IB_AC_LOCAL_WRITE;
+		status = IB_SUCCESS;
+		break;
+	default:
+		status = IB_INVALID_STATE;
+		break;
+	}
+
+out:
+	KeReleaseInStackQueuedSpinLock( &hdl );
+	AL_EXIT( AL_DBG_CM );
+	return status;
+}
+
+ib_api_status_t
 al_cep_get_rtr_attr(
 	IN				ib_al_handle_t				h_al,
 	IN				net32_t						cid,





More information about the ofw mailing list