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

Hal Rosenstock halr at voltaire.com
Wed Dec 27 08:46:36 PST 2006


osmtest/osmtest.c: Add SA SwitchInfoRecord tests

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

diff --git a/osm/osmtest/osmtest.c b/osm/osmtest/osmtest.c
index 0ccc06c..eed390b 100644
--- a/osm/osmtest/osmtest.c
+++ b/osm/osmtest/osmtest.c
@@ -4677,6 +4677,92 @@ osmtest_get_pkeytbl_rec_by_lid( IN osmte
 }
 
 /**********************************************************************
+ * Get SwitchInfo record by LID
+
**********************************************************************/
+ib_api_status_t
+osmtest_get_sw_info_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_switch_info_record_t record;
+  ib_mad_t *p_mad;
+
+  OSM_LOG_ENTER( &p_osmt->log, osmtest_get_sw_info_rec_by_lid );
+
+  if( osm_log_is_active( &p_osmt->log, OSM_LOG_VERBOSE ) )
+  {
+    osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
+             "osmtest_get_sw_info_rec_by_lid: "
+             "Getting SwitchInfo 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;
+  user.comp_mask = IB_SWIR_COMPMASK_LID;
+  user.attr_id = IB_MAD_ATTR_SWITCH_INFO_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_sw_info_rec_by_lid: ERR 006C: "
+             "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_sw_info_rec_by_lid: ERR 006D: "
+             "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_sw_info_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 );
+}
+
+/**********************************************************************
  * Get LFT record by LID
 
**********************************************************************/
 ib_api_status_t
@@ -5820,6 +5906,17 @@ osmtest_validate_against_db( IN osmtest_
   if ( status != IB_SUCCESS )
     goto Exit;
 
+  /* SwitchInfo Record tests */
+  memset( &context, 0, sizeof( context ) );
+  status = osmtest_get_sw_info_rec_by_lid( p_osmt, 0, &context );
+  if ( status != IB_SUCCESS )
+    goto Exit;
+
+  memset( &context, 0, sizeof( context ) );
+  status = osmtest_get_sw_info_rec_by_lid( p_osmt, test_lid, &context
);
+  if ( status != IB_SUCCESS )
+    goto Exit;
+
   /* LFT Record test */
   memset( &context, 0, sizeof( context ) );
   status = osmtest_get_lft_rec_by_lid( p_osmt, test_lid, &context );
@@ -6169,6 +6266,12 @@ osmtest_validate_against_db( IN osmtest_
     if ( status != IB_SUCCESS )
       goto Exit;
 
+    /* Another SwitchInfo Record test */
+    memset( &context, 0, sizeof( context ) );
+    status = osmtest_get_sw_info_rec_by_lid( p_osmt, test_lid, &context
);
+    if ( status != IB_SUCCESS )
+      goto Exit;
+
     /* Another LFT Record test */
     memset( &context, 0, sizeof( context ) );
     status = osmtest_get_lft_rec_by_lid( p_osmt, test_lid, &context );







More information about the general mailing list