[ofw] Using ib_local_mad instead of SM query

Slava Strebkov slavas at voltaire.com
Wed Oct 15 04:28:18 PDT 2008


Agreed.
__endpt_mgr_add_local is called now from _bcast_cb, when join bcast
completed successfully.



Index: ulp/ipoib/kernel/ipoib_port.c
===================================================================
--- ulp/ipoib/kernel/ipoib_port.c	(revision 1648)
+++ ulp/ipoib/kernel/ipoib_port.c	(working copy)
@@ -451,11 +451,8 @@
 	IN				ipoib_port_t* const
p_port );
 
 static void
-__port_info_cb(
-	IN				ib_query_rec_t
*p_query_rec );
 
 
-static void
 __bcast_get_cb(
 	IN				ib_query_rec_t
*p_query_rec );
 
@@ -5073,10 +5070,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 );
 
@@ -5089,41 +5086,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_INFORMATION,
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_INFORMATION,
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 );
 }
 
@@ -5155,7 +5184,7 @@
 	av_attr.port_num = p_port->port_num;
 	av_attr.sl = 0;
 	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 );
@@ -5187,111 +5216,7 @@
 }
 
 
-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 )
@@ -5706,6 +5631,13 @@
 	}
 	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 );
+	}
 	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 1648)
+++ 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;


-----Original Message-----
From: Alex Estrin [mailto:alex.estrin at qlogic.com] 
Sent: Sunday, October 12, 2008 6:09 PM
To: Slava Strebkov; ofw at lists.openfabrics.org
Subject: RE: [ofw] Using ib_local_mad instead of SM query

Hi Slava,

I think calling __endpt_mgr_add_local() after __port_get_bcast() most
likely will introduce racing condition
because __port_get_bcast() is async call and completes in __bcast_cb()
where adapter moves to active state and ready to process data packets.
I would consider possibility to call __endpt_mgr_add_local() from within
__bcast_cb() to ensure proper initialization ordering.

Thanks,
Alex.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: local_mad.diff
Type: application/octet-stream
Size: 8289 bytes
Desc: local_mad.diff
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20081015/0662b659/attachment.obj>


More information about the ofw mailing list