[openib-general] [PATCH 4/4] osmtest/osmtest.c: Add SA MFTRecord tests

Hal Rosenstock halr at voltaire.com
Fri Dec 29 09:12:30 PST 2006


osmtest/osmtest.c: Add SA MFTRecord tests

Signed-off-by: Hal Rosenstock <halr at voltaire.com>

diff --git a/osm/osmtest/osmtest.c b/osm/osmtest/osmtest.c
index 3dd229c..ba42fc6 100644
--- a/osm/osmtest/osmtest.c
+++ b/osm/osmtest/osmtest.c
@@ -4854,6 +4854,93 @@ osmtest_get_lft_rec_by_lid( IN osmtest_t
 }
 
 /**********************************************************************
+ * Get MFT record by LID
+ **********************************************************************/
+ib_api_status_t
+osmtest_get_mft_rec_by_lid( IN osmtest_t * const p_osmt,
+                            IN ib_net16_t const  lid,
+                            IN OUT osmtest_req_context_t * const p_context )
+{
+  ib_api_status_t status = IB_SUCCESS;
+  osmv_user_query_t user;
+  osmv_query_req_t req;
+  ib_mft_record_t record;
+  ib_mad_t *p_mad;
+
+  OSM_LOG_ENTER( &p_osmt->log, osmtest_get_mft_rec_by_lid );
+
+  if( osm_log_is_active( &p_osmt->log, OSM_LOG_VERBOSE ) )
+  {
+    osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
+             "osmtest_get_mft_rec_by_lid: "
+             "Getting MFT record for LID 0x%02X\n",
+             cl_ntoh16( lid ) );
+  }
+
+  /*
+   * Do a blocking query for this record in the subnet.
+   * The result is returned in the result field of the caller's
+   * context structure.
+   *
+   * The query structures are locals.
+   */
+  memset( &req, 0, sizeof( req ) );
+  memset( &user, 0, sizeof( user ) );
+  memset( &record, 0, sizeof( record ) );
+
+  record.lid = lid;
+  p_context->p_osmt = p_osmt;
+  if (lid)
+    user.comp_mask = IB_MFTR_COMPMASK_LID;
+  user.attr_id = IB_MAD_ATTR_MFT_RECORD;
+  user.attr_offset = cl_ntoh16( ( uint16_t ) ( sizeof( record ) >> 3 ) );
+  user.p_attr = &record;
+
+  req.query_type = OSMV_QUERY_USER_DEFINED;
+  req.timeout_ms = p_osmt->opt.transaction_timeout;
+  req.retry_cnt = p_osmt->opt.retry_count;
+    
+  req.flags = OSM_SA_FLAGS_SYNC;
+  req.query_context = p_context;
+  req.pfn_query_cb = osmtest_query_res_cb; 
+  req.p_query_input = &user;
+  req.sm_key = 0;
+
+  status = osmv_query_sa( p_osmt->h_bind, &req );
+  if( status != IB_SUCCESS )
+  {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmtest_get_mft_rec_by_lid: ERR 009B: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
+    goto Exit;
+  }
+
+  status = p_context->result.status;
+
+  if( status != IB_SUCCESS )
+  {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+             "osmtest_get_mft_rec_by_lid: ERR 009C: "
+             "ib_query failed (%s)\n", ib_get_err_str( status ) );
+    if( status == IB_REMOTE_ERROR )
+    {
+      p_mad = osm_madw_get_mad_ptr( p_context->result.p_result_madw );
+      osm_log( &p_osmt->log, OSM_LOG_ERROR,
+               "osmtest_get_mft_rec_by_lid: "
+               "Remote error = %s\n",
+               ib_get_mad_status_str( p_mad ));
+
+      status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK );
+    }
+    goto Exit;
+  }
+
+ Exit:
+  OSM_LOG_EXIT( &p_osmt->log );
+  return ( status );
+}
+
+/**********************************************************************
  **********************************************************************/
 static ib_api_status_t
 osmtest_sminfo_record_request(
@@ -5933,6 +6020,17 @@ osmtest_validate_against_db( IN osmtest_
   if ( status != IB_SUCCESS )
     goto Exit;
 
+  /* MFT Record tests */
+  memset( &context, 0, sizeof( context ) );
+  status = osmtest_get_mft_rec_by_lid( p_osmt, 0, &context );
+  if ( status != IB_SUCCESS )
+    goto Exit;
+  
+  memset( &context, 0, sizeof( context ) );
+  status = osmtest_get_mft_rec_by_lid( p_osmt, test_lid, &context );
+  if ( status != IB_SUCCESS )
+    goto Exit;
+
   /* Some LinkRecord tests */
   /* FromLID */
   memset( &context, 0, sizeof( context ) );
@@ -6288,6 +6386,12 @@ osmtest_validate_against_db( IN osmtest_
     if ( status != IB_SUCCESS )
       goto Exit;
 
+    /* Another MFT Record test */
+    memset( &context, 0, sizeof( context ) );
+    status = osmtest_get_mft_rec_by_lid( p_osmt, test_lid, &context );
+    if ( status != IB_SUCCESS )
+      goto Exit;
+
     /* More LinkRecord tests */
     /* FromLID */
     memset( &context, 0, sizeof( context ) );







More information about the general mailing list