[ofw][patch] Using ib_local_mad instead of SM

Tzachi Dar tzachid at mellanox.co.il
Wed Oct 22 07:09:47 PDT 2008


Hi,

This patch was checked in to both trunk and branch on 1678,1679 with the
following comments / notes:

1 - Using 255 bytes for the allocation for the mads. In general using
such a constant without explanation and / or C_ASSERTS is very error
pronoun. Since this numbers are all over the code (IBAL, low lever
drivers), I didn't change this.

2 - in the case of a failure in local_mad we set the sa_event. This
event is also been set in the up_done which is probably the correct
place to change it. I have removed the first use of this event since it
is wrong.

Thanks
Tzachi


> -----Original Message-----
> From: ofw-bounces at lists.openfabrics.org 
> [mailto:ofw-bounces at lists.openfabrics.org] On Behalf Of Slava Strebkov
> Sent: Wednesday, October 22, 2008 11:39 AM
> To: ofw at lists.openfabrics.org
> Subject: [ofw][patch] Using ib_local_mad instead of SM
> 
>  <<local_mad.patch>> Hi,
> This is a local mad patch with additional status check and 
> print statement
> 
> 
> Index: ulp/ipoib/kernel/ipoib_port.c
> ===================================================================
> --- ulp/ipoib/kernel/ipoib_port.c	(revision 1664)
> +++ ulp/ipoib/kernel/ipoib_port.c	(working copy)
> @@ -450,9 +450,6 @@
>  __port_create_bcast(
>  	IN				ipoib_port_t* const
> p_port );
>  
> -static void
> -__port_info_cb(
> -	IN				ib_query_rec_t
> *p_query_rec );
>  
>  
>  static void
> @@ -5177,10 +5174,10 @@
>  	IN				ipoib_port_t* const
> p_port,
>  	IN		const	ib_pnp_port_rec_t* const
> p_pnp_rec )
>  {
> -	ib_api_status_t			status;
> -	ib_query_req_t			query;
> -	ib_user_query_t			info;
> -	ib_portinfo_record_t	port_rec;
> +	ib_port_info_t		*p_port_info;
> +	ib_mad_t			*mad_in = NULL;
> +	ib_mad_t			*mad_out = NULL;
> +	ib_api_status_t		status = IB_INSUFFICIENT_MEMORY;
>  
>  	IPOIB_ENTER( IPOIB_DBG_INIT );
>  
> @@ -5193,41 +5190,73 @@
>  	KeResetEvent( &p_port->sa_event );
>  	cl_obj_unlock( &p_port->obj );
>  
> -	info.method = IB_MAD_METHOD_GETTABLE;
> -	info.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
> -	info.attr_size = sizeof(ib_portinfo_record_t);
> -	info.comp_mask = IB_PIR_COMPMASK_BASELID;
> -	info.p_attr = &port_rec;
> +	mad_out = (ib_mad_t*)cl_zalloc(256);
> +	if(! mad_out)
> +	{
> +		IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
> +			("failed to allocate mad mad_out\n")); 
> +		goto up_done;
> +	}
> +	mad_in = (ib_mad_t*)cl_zalloc(256);
> +	if(! mad_in)
> +	{
> +		IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
> +			("failed to allocate mad mad_in\n")); 
> +		goto up_done;
> +	}
>  
> -	/* Query requires only the base LID. */
> -	cl_memclr( &port_rec, sizeof(ib_portinfo_record_t) );
> -	port_rec.port_info.base_lid = p_pnp_rec->p_port_attr->lid;
> +	mad_in->attr_id = IB_MAD_ATTR_PORT_INFO;
> +	mad_in->method = IB_MAD_METHOD_GET;
> +	mad_in->base_ver = 1;
> +	mad_in->class_ver =1;
> +	mad_in->mgmt_class = IB_MCLASS_SUBN_LID;
> +	
> +	status = p_port->p_adapter->p_ifc->local_mad(
> +		p_port->ib_mgr.h_ca ,p_port->port_num ,mad_in ,mad_out);
>  
> -	cl_memclr( &query, sizeof(ib_query_req_t) );
> -	query.query_type = IB_QUERY_USER_DEFINED;
> -	query.p_query_input = &info;
> -	query.port_guid = p_port->p_adapter->guids.port_guid.guid;
> -	query.timeout_ms = p_port->p_adapter->params.sa_timeout;
> -	query.retry_cnt = p_port->p_adapter->params.sa_retry_cnt;
> -	query.query_context = p_port;
> -	query.pfn_query_cb = __port_info_cb;
> -
> -	/* reference the object for the multicast query. */
> -	ipoib_port_ref( p_port, ref_port_up );
> -
> -	status = p_port->p_adapter->p_ifc->query(
> -		p_port->p_adapter->h_al, &query, &p_port->ib_mgr.h_query
> );
>  	if( status != IB_SUCCESS )
>  	{
>  		KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE );
>  		ipoib_set_inactive( p_port->p_adapter );
> -		ipoib_port_deref( p_port, ref_port_up );
>  		IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
> -			("ib_query returned %s\n", 
> +			("ib_local_mad returned %s\n",
>  			p_port->p_adapter->p_ifc->get_err_str( 
> status )) );
> -		return;
> +		goto up_done;
>  	}
>  
> +	p_port_info = (ib_port_info_t*)(((ib_smp_t*)mad_out)->data);
> +	p_port->base_lid = p_pnp_rec->p_port_attr->lid;
> +	IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,
> +			("Received port info: link width = %d.\n",
> +			p_port_info->link_width_active) );
> +	p_port->ib_mgr.rate =
> +		ib_port_info_compute_rate( p_port_info );
> +	
> +	ipoib_set_rate( p_port->p_adapter,
> +		p_port_info->link_width_active,
> +	ib_port_info_get_link_speed_active( p_port_info ) );
> +
> +	status = __port_get_bcast( p_port );
> +	if (status != IB_SUCCESS)
> +		IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
> +		(" __port_get_bcast returned
> %s\n",p_port->p_adapter->p_ifc->get_err_str( status )));
> +
> +up_done:
> +	if( status != IB_SUCCESS )
> +	{
> +		if( status != IB_CANCELED )
> +		{
> +			ipoib_set_inactive( p_port->p_adapter );
> +			__endpt_mgr_reset_all( p_port );
> +		}
> +		KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE );
> +	}
> +
> +	if(mad_out)
> +		cl_free(mad_out);
> +	if(mad_in)
> +		cl_free(mad_in);
> +
>  	IPOIB_EXIT( IPOIB_DBG_INIT );
>  }
>  
> @@ -5261,7 +5290,7 @@
>  	IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ENDPT,
>  		("<__endpt_mgr_add_local>:  av_attr.dlid = 
> p_port_info->base_lid = %d\n",p_port_info->base_lid));
>  	av_attr.dlid = p_port_info->base_lid;
> -	av_attr.static_rate = ib_port_info_compute_rate( p_port_info );
> +	av_attr.static_rate = p_port->ib_mgr.rate;
>  	av_attr.path_bits = 0;
>  	status = p_port->p_adapter->p_ifc->create_av(
>  		p_port->ib_mgr.h_pd, &av_attr, &p_endpt->h_av 
> ); @@ -5293,111 +5322,8 @@  }
>  
>  
> -static void
> -__port_info_cb(
> -	IN				ib_query_rec_t
> *p_query_rec )
> -{
> -	ib_api_status_t			status;
> -	ipoib_port_t			*p_port;
> -	ib_portinfo_record_t	*p_port_rec;
>  
> -	IPOIB_ENTER( IPOIB_DBG_INIT );
>  
> -	p_port = (ipoib_port_t*)p_query_rec->query_context;
> -
> -	cl_obj_lock( &p_port->obj );
> -	p_port->ib_mgr.h_query = NULL;
> -
> -	if( p_port->state != IB_QPS_INIT )
> -	{
> -		status = IB_CANCELED;
> -		goto done;
> -	}
> -
> -	status = p_query_rec->status;
> -
> -	switch( status )
> -	{
> -	case IB_SUCCESS:
> -		/* Note that the we report the rate from the port info.
> */
> -		p_port_rec = (ib_portinfo_record_t*)
> -			ib_get_query_result( p_query_rec->p_result_mad,
> 0 );
> -
> -		status = __endpt_mgr_add_local( p_port,
> &p_port_rec->port_info );
> -		if( status == IB_SUCCESS )
> -		{
> -			IPOIB_PRINT( TRACE_LEVEL_INFORMATION,
> IPOIB_DBG_INIT,
> -				("Received port info: link width =
> %d.\n",
> -				p_port_rec->port_info.link_width_active)
> );
> -
> -			p_port->ib_mgr.rate =
> -				ib_port_info_compute_rate(
> &p_port_rec->port_info );
> -
> -			ipoib_set_rate( p_port->p_adapter,
> -				p_port_rec->port_info.link_width_active,
> -				ib_port_info_get_link_speed_active(
> &p_port_rec->port_info ) );
> -
> -			status = __port_get_bcast( p_port );
> -		}
> -		else
> -		{
> -			IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
> -				("__endpt_mgr_add_local returned %s\n",
> -				p_port->p_adapter->p_ifc->get_err_str(
> status )) );
> -		}
> -		break;
> -
> -	case IB_CANCELED:
> -		IPOIB_PRINT(TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,
> -			("Instance destroying - Aborting.\n") );
> -		break;
> -
> -	case IB_TIMEOUT:
> -		NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter,
> -			EVENT_IPOIB_PORT_INFO_TIMEOUT, 0 );
> -		IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,
> -			("Port info query timed out.\n") );
> -		break;
> -
> -	case IB_REMOTE_ERROR:
> -		NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter,
> -			EVENT_IPOIB_PORT_INFO_REJECT, 0 );
> -		IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,
> -			("Port info query rejected by SA.\n") );
> -		break;
> -
> -	default:
> -		NdisWriteErrorLogEntry( p_port->p_adapter->h_adapter,
> -			EVENT_IPOIB_QUERY_PORT_INFO, 1,
> p_query_rec->status );
> -		/* Hopefully we'll get an SM change event that will
> restart things. */
> -		IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,
> -			("Port info query failed.\n") );
> -	}
> -
> -done:
> -	cl_obj_unlock( &p_port->obj );
> -
> -	if( status != IB_SUCCESS )
> -	{
> -		if( status != IB_CANCELED )
> -		{
> -			ipoib_set_inactive( p_port->p_adapter );
> -			__endpt_mgr_reset_all( p_port );
> -		}
> -		KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE );
> -	}
> -
> -	/* Return the response MAD to AL. */
> -	if( p_query_rec->p_result_mad )
> -		p_port->p_adapter->p_ifc->put_mad(
> p_query_rec->p_result_mad );
> -
> -	/* Release the reference taken when issuing the port info query.
> */
> -	ipoib_port_deref( p_port, ref_port_info_cb );
> -
> -	IPOIB_EXIT( IPOIB_DBG_INIT );
> -}
> -
> -
>  static ib_api_status_t
>  __port_get_bcast(
>  	IN				ipoib_port_t* const
> p_port )
> @@ -5812,6 +5738,20 @@
>  	}
>  	cl_obj_unlock( &p_port->obj );
>  	p_port->bc_join_retry_cnt = 0;
> +	if(! p_port->p_local_endpt)
> +	{
> +		ib_port_info_t	port_info;
> +		cl_memclr(&port_info, sizeof(port_info));
> +		port_info.base_lid = p_port->base_lid;
> +		status = __endpt_mgr_add_local( p_port, &port_info );
> +		if( status != IB_SUCCESS )
> +		{
> +			IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
> +				("__endpt_mgr_add_local returned %s\n",
> +				p_port->p_adapter->p_ifc->get_err_str(
> status )) );
> +			goto err;
> +		}
> +	}
>  	status = __endpt_mgr_add_bcast( p_port, p_mcast_rec );
>  	if( status != IB_SUCCESS )
>  	{
> Index: ulp/ipoib/kernel/ipoib_port.h
> ===================================================================
> --- ulp/ipoib/kernel/ipoib_port.h	(revision 1664)
> +++ ulp/ipoib/kernel/ipoib_port.h	(working copy)
> @@ -517,6 +517,7 @@
>  	KDPC					gc_dpc;
>  	KTIMER					gc_timer;
>  	uint32_t				bc_join_retry_cnt;
> +	ib_net16_t				base_lid;
>  	ipoib_hdr_t				hdr[1];	/* Must be last!
> */
>  
>  }	ipoib_port_t;
> 
> 
> Slava
> 



More information about the ofw mailing list