[ofw] [PATCH 3/7] ib/cm: export CM only interface

Sean Hefty sean.hefty at intel.com
Thu Jan 22 13:12:25 PST 2009


>If you fix just al_destroy_cep you would be OK, but you don't resolve the lack
>of clarity in using the CEP's lock to protect the CID member of the QP.  You
>can change that, though I don't know if there are any potential pitfalls in
>holding the QP's lock when making CEP manager calls - you have to make sure
>when you destroy the CEP that the CEP's destroy callback doesn't try to take
>the same lock.  You might be able to just hold the lock after making the CEP
>calls, only long enough to check/set the CID member.  Or you might be able to
>work things out with interlocked operations.

I have no way to test the ND code, but here's what I added to al_ndi_cm.c:

__ndi_send_req():

	cl_spinlock_acquire( &h_qp->obj.lock );
	if( h_qp->obj.state != CL_DESTROYING && p_qp->cid == AL_INVALID_CID )
	{
		status = al_create_cep( qp_get_al( h_qp ), __ndi_cm_handler,
						&h_qp->obj, deref_al_obj,
						&p_qp->cid );
	}
	else 
	{
		status = IB_INVALID_HANDLE;
	}
	cl_spinlock_release( &h_qp->obj.lock );


__ndi_send_rep():

	/* prepare Passive CEP for connection */
	p_qp = (al_conn_qp_t*)h_qp;
	cl_spinlock_acquire( &h_qp->obj.lock );
	if( h_qp->obj.state != CL_DESTROYING && p_qp->cid == AL_INVALID_CID )
	{
		status = kal_config_cep(qp_get_al( h_qp ), p_rep->cid,
						__ndi_cm_handler,
						&h_qp->obj, deref_al_obj);
		if( status == IB_SUCCESS )
		{
			ref_al_obj( &h_qp->obj ); /* Take CEP reference. */
			status = kal_cep_pre_rep(qp_get_al( h_qp ), p_rep->cid,
							 &cm_rep, 
	
QP_ATTRIB_RNR_NAK_TIMEOUT, &qp_mod );
			if( status == IB_SUCCESS )
			{
				p_qp->cid = p_rep->cid;
			}
		}
	}
	else 
	{
		status = IB_INVALID_HANDLE;
	}
	cl_spinlock_release( &h_qp->obj.lock );

I also fixed al_destroy_cep() to read the *p_cid under lock.  The requirement is
that the QP lock can be held when trying to acquire the CEP mgr lock, but I
haven't been able to verify that this is done in the existing code.

The other area of the code that I would like to cleanup is getting callers to
invoke al_destroy_cep() only once for a given CID.  But this looks much more
difficult to achieve.

- Sean




More information about the ofw mailing list