[Openib-windows] [PATCH] MTHCA/MT23108: Fix SMP cache

Fab Tillier ftillier at silverstorm.com
Mon Apr 24 21:59:25 PDT 2006


Hi Leonid,

The HCA driver implements caching for SMP queries, and handles some Set()
requests that are no-ops.

The current code is broken, checking the method rather than the management
class, resulting in the caching never being used.

The reason for handling these requests from the cache is to avoid the command
interface transaction so that we can respond faster to an SM sweep.  I have seen
instances where the SM times out on a sweep because local MADs don't respond
fast enough on a busy system.  This attempts to handle the problem, but is
really a work around until the local MAD interface becomes asynchronous.

Anyhow, attached is a patch that fixes the caching.

- Fab

Index: hw/mthca/kernel/hca_smp.c
===================================================================
--- hw/mthca/kernel/hca_smp.c	(revision 323)
+++ hw/mthca/kernel/hca_smp.c	(working copy)
@@ -73,14 +73,13 @@
 	 */
 	if( p_mad_in->method == IB_MAD_METHOD_SET )
 	{
-		if( !cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
+		if( cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
 			&p_cache->guid_block[idx].tbl, sizeof(ib_guid_info_t) )
)
 		{
 			/* The set is requesting a change. */
 			return FALSE;
 		}
 	}
-	CL_ASSERT( p_mad_in->method == IB_MAD_METHOD_GET );
 
 	/* Setup the response mad. */
 	cl_memcpy( p_mad_out, p_mad_in, MAD_BLOCK_SIZE );
@@ -125,14 +124,13 @@
 	 */
 	if( p_mad_in->method == IB_MAD_METHOD_SET )
 	{
-		if( !cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
+		if( cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
 			&p_cache->pkey_tbl[idx].tbl,
sizeof(ib_pkey_table_info_t) ) )
 		{
 			/* The set is requesting a change. */
 			return FALSE;
 		}
 	}
-	CL_ASSERT( p_mad_in->method == IB_MAD_METHOD_GET );
 
 	/* Setup the response mad. */
 	cl_memcpy( p_mad_out, p_mad_in, MAD_BLOCK_SIZE );
@@ -165,14 +163,13 @@
 	 */
 	if( p_mad_in->method == IB_MAD_METHOD_SET )
 	{
-		if( !cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
+		if( cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
 			&p_cache->sl_vl.tbl, sizeof(ib_slvl_table_t) ) )
 		{
 			/* The set is requesting a change. */
 			return FALSE;
 		}
 	}
-	CL_ASSERT( p_mad_in->method == IB_MAD_METHOD_GET );
 
 	/* Setup the response mad. */
 	cl_memcpy( p_mad_out, p_mad_in, MAD_BLOCK_SIZE );
@@ -217,14 +214,13 @@
 	 */
 	if( p_mad_in->method == IB_MAD_METHOD_SET )
 	{
-		if( !cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
+		if( cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
 			&p_cache->vl_arb[idx].tbl, sizeof(ib_vl_arb_table_t) ) )
 		{
 			/* The set is requesting a change. */
 			return FALSE;
 		}
 	}
-	CL_ASSERT( p_mad_in->method == IB_MAD_METHOD_GET );
 
 	/* Setup the response mad. */
 	cl_memcpy( p_mad_out, p_mad_in, MAD_BLOCK_SIZE );
@@ -314,8 +310,8 @@
 	IN		const	ib_mad_t
*p_mad_in,
 		OUT			ib_mad_t
*p_mad_out )
 {
-	if( p_mad_in->method != IB_MCLASS_SUBN_DIR &&
-		p_mad_in->method != IB_MCLASS_SUBN_LID )
+	if( p_mad_in->mgmt_class != IB_MCLASS_SUBN_DIR &&
+		p_mad_in->mgmt_class != IB_MCLASS_SUBN_LID )
 	{
 		return FALSE;
 	}
@@ -448,8 +444,8 @@
 	IN		const	uint8_t
port_num,
 	IN		const	ib_mad_t
*p_mad_out )
 {
-	if( p_mad_out->method != IB_MCLASS_SUBN_DIR &&
-		p_mad_out->method != IB_MCLASS_SUBN_LID )
+	if( p_mad_out->mgmt_class != IB_MCLASS_SUBN_DIR &&
+		p_mad_out->mgmt_class != IB_MCLASS_SUBN_LID )
 	{
 		return;
 	}
@@ -458,7 +454,6 @@
 	if( p_mad_out->status )
 		return;
 
-
 	switch( p_mad_out->attr_id )
 	{
 	case IB_MAD_ATTR_GUID_INFO:
Index: hw/mthca/kernel/hca_smp.c
===================================================================
--- hw/mthca/kernel/hca_smp.c	(revision 323)
+++ hw/mthca/kernel/hca_smp.c	(working copy)
@@ -73,14 +73,13 @@
 	 */
 	if( p_mad_in->method == IB_MAD_METHOD_SET )
 	{
-		if( !cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
+		if( cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
 			&p_cache->guid_block[idx].tbl, sizeof(ib_guid_info_t) )
)
 		{
 			/* The set is requesting a change. */
 			return FALSE;
 		}
 	}
-	CL_ASSERT( p_mad_in->method == IB_MAD_METHOD_GET );
 
 	/* Setup the response mad. */
 	cl_memcpy( p_mad_out, p_mad_in, MAD_BLOCK_SIZE );
@@ -125,14 +124,13 @@
 	 */
 	if( p_mad_in->method == IB_MAD_METHOD_SET )
 	{
-		if( !cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
+		if( cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
 			&p_cache->pkey_tbl[idx].tbl,
sizeof(ib_pkey_table_info_t) ) )
 		{
 			/* The set is requesting a change. */
 			return FALSE;
 		}
 	}
-	CL_ASSERT( p_mad_in->method == IB_MAD_METHOD_GET );
 
 	/* Setup the response mad. */
 	cl_memcpy( p_mad_out, p_mad_in, MAD_BLOCK_SIZE );
@@ -165,14 +163,13 @@
 	 */
 	if( p_mad_in->method == IB_MAD_METHOD_SET )
 	{
-		if( !cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
+		if( cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
 			&p_cache->sl_vl.tbl, sizeof(ib_slvl_table_t) ) )
 		{
 			/* The set is requesting a change. */
 			return FALSE;
 		}
 	}
-	CL_ASSERT( p_mad_in->method == IB_MAD_METHOD_GET );
 
 	/* Setup the response mad. */
 	cl_memcpy( p_mad_out, p_mad_in, MAD_BLOCK_SIZE );
@@ -217,14 +214,13 @@
 	 */
 	if( p_mad_in->method == IB_MAD_METHOD_SET )
 	{
-		if( !cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
+		if( cl_memcmp( ib_smp_get_payload_ptr( (ib_smp_t*)p_mad_in ),
 			&p_cache->vl_arb[idx].tbl, sizeof(ib_vl_arb_table_t) ) )
 		{
 			/* The set is requesting a change. */
 			return FALSE;
 		}
 	}
-	CL_ASSERT( p_mad_in->method == IB_MAD_METHOD_GET );
 
 	/* Setup the response mad. */
 	cl_memcpy( p_mad_out, p_mad_in, MAD_BLOCK_SIZE );
@@ -314,8 +310,8 @@
 	IN		const	ib_mad_t
*p_mad_in,
 		OUT			ib_mad_t
*p_mad_out )
 {
-	if( p_mad_in->method != IB_MCLASS_SUBN_DIR &&
-		p_mad_in->method != IB_MCLASS_SUBN_LID )
+	if( p_mad_in->mgmt_class != IB_MCLASS_SUBN_DIR &&
+		p_mad_in->mgmt_class != IB_MCLASS_SUBN_LID )
 	{
 		return FALSE;
 	}
@@ -448,8 +444,8 @@
 	IN		const	uint8_t
port_num,
 	IN		const	ib_mad_t
*p_mad_out )
 {
-	if( p_mad_out->method != IB_MCLASS_SUBN_DIR &&
-		p_mad_out->method != IB_MCLASS_SUBN_LID )
+	if( p_mad_out->mgmt_class != IB_MCLASS_SUBN_DIR &&
+		p_mad_out->mgmt_class != IB_MCLASS_SUBN_LID )
 	{
 		return;
 	}
@@ -458,7 +454,6 @@
 	if( p_mad_out->status )
 		return;
 
-
 	switch( p_mad_out->attr_id )
 	{
 	case IB_MAD_ATTR_GUID_INFO:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hca_smp.patch
Type: application/octet-stream
Size: 5742 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20060424/c9f187e2/attachment.obj>


More information about the ofw mailing list