[openib-general] [PATCH 2/2] osmtest/osmtest.c: More SA SMInfoRecord tests

Hal Rosenstock halr at voltaire.com
Fri Dec 22 06:25:59 PST 2006


osmtest/osmtest.c: More SA SMInfoRecord tests

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

diff --git a/osm/osmtest/osmtest.c b/osm/osmtest/osmtest.c
index 6afa899..0ccc06c 100644
--- a/osm/osmtest/osmtest.c
+++ b/osm/osmtest/osmtest.c
@@ -69,6 +69,14 @@
 #define POOL_MIN_ITEMS  64
 #define GUID_ARRAY_SIZE 64
 
+typedef struct _osmtest_sm_info_rec
+{
+  ib_net64_t sm_guid;
+  ib_net16_t lid;
+  uint8_t priority;
+  uint8_t sm_state;
+} osmtest_sm_info_rec_t;
+
 typedef struct _osmtest_inform_info
 {
   boolean_t subscribe;
@@ -4756,9 +4764,11 @@ osmtest_get_lft_rec_by_lid( IN osmtest_t
 
 /**********************************************************************
  **********************************************************************/
-ib_api_status_t
+static ib_api_status_t
 osmtest_sminfo_record_request(
         IN osmtest_t * const p_osmt,
+        IN uint8_t method,
+        IN void *p_options,
         IN OUT osmtest_req_context_t * const p_context )
 {
   ib_api_status_t status = IB_SUCCESS;
@@ -4766,6 +4776,7 @@ osmtest_sminfo_record_request(
   osmv_query_req_t req;
   ib_sminfo_record_t record;
   ib_mad_t *p_mad;
+  osmtest_sm_info_rec_t *p_sm_info_opt;
 
   OSM_LOG_ENTER( &p_osmt->log, osmtest_sminfo_record_request );
 
@@ -4783,6 +4794,29 @@ osmtest_sminfo_record_request(
   p_context->p_osmt = p_osmt;
   user.attr_id = IB_MAD_ATTR_SMINFO_RECORD;
   user.attr_offset = cl_ntoh16( ( uint16_t ) ( sizeof( record ) >> 3 ) );
+  p_sm_info_opt = p_options;
+  if (p_sm_info_opt->sm_guid != 0)
+  {
+    record.sm_info.guid = p_sm_info_opt->sm_guid;
+    user.comp_mask |= IB_SMIR_COMPMASK_GUID;
+  }
+  if (p_sm_info_opt->lid != 0)
+  {
+    record.lid = p_sm_info_opt->lid;
+    user.comp_mask |= IB_SMIR_COMPMASK_LID;
+  }
+  if (p_sm_info_opt->priority != 0)
+  {
+    record.sm_info.pri_state = (p_sm_info_opt->priority & 0x0F)<<4;
+    user.comp_mask |= IB_SMIR_COMPMASK_PRIORITY;
+  }
+  if (p_sm_info_opt->sm_state != 0)
+  {
+    record.sm_info.pri_state |= p_sm_info_opt->sm_state & 0x0F;
+    user.comp_mask |= IB_SMIR_COMPMASK_SMSTATE;
+  }
+
+  user.method = method;
   user.p_attr = &record;
 
   req.query_type = OSMV_QUERY_USER_DEFINED;
@@ -4808,9 +4842,12 @@ osmtest_sminfo_record_request(
 
   if( status != IB_SUCCESS )
   {
-    osm_log( &p_osmt->log, OSM_LOG_ERROR,
-             "osmtest_sminfo_record_request: ERR 008D: "
-             "ib_query failed (%s)\n", ib_get_err_str( status ) );
+    if (status != IB_INVALID_PARAMETER)
+    {
+      osm_log( &p_osmt->log, OSM_LOG_ERROR,
+               "osmtest_sminfo_record_request: ERR 008D: "
+               "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 );
@@ -4831,7 +4868,7 @@ osmtest_sminfo_record_request(
 
 /**********************************************************************
  **********************************************************************/
-ib_api_status_t
+static ib_api_status_t
 osmtest_informinfo_request(
 	IN osmtest_t * const p_osmt,
 	IN ib_net16_t attr_id,
@@ -5553,6 +5590,7 @@ osmtest_validate_against_db( IN osmtest_
 {
   ib_api_status_t status = IB_SUCCESS;
   ib_gid_t portgid, mgid;
+  osmtest_sm_info_rec_t sm_info_rec_opt;
   osmtest_inform_info_t inform_info_opt;
   osmtest_inform_info_rec_t inform_info_rec_opt;
 #ifdef VENDOR_RMPP_SUPPORT
@@ -5563,6 +5601,7 @@ osmtest_validate_against_db( IN osmtest_
 #ifdef DUAL_SIDED_RMPP
   osmv_multipath_req_t request;
 #endif
+  int i; 
 #endif
 
   OSM_LOG_ENTER( &p_osmt->log, osmtest_validate_against_db );
@@ -5812,12 +5851,71 @@ osmtest_validate_against_db( IN osmtest_
   if ( status != IB_SUCCESS )
     goto Exit;
 
-  /* SMInfoRecord test */
+  /* SMInfoRecord tests */
+  memset( &sm_info_rec_opt, 0, sizeof( sm_info_rec_opt ) );
+  memset( &context, 0, sizeof( context ) );
+  status = osmtest_sminfo_record_request( p_osmt, IB_MAD_METHOD_SET,
+					  &sm_info_rec_opt, &context );
+  if ( status == IB_SUCCESS )
+  {
+    status = IB_ERROR;
+    goto Exit;
+  }
+  else
+  {
+    osm_log( &p_osmt->log, OSM_LOG_ERROR,
+	     "osmtest_sminfo_request: "
+	     "IS EXPECTED ERROR ^^^^\n");
+  }
+
+  memset( &sm_info_rec_opt, 0, sizeof( sm_info_rec_opt ) );
+  memset( &context, 0, sizeof( context ) );
+  status = osmtest_sminfo_record_request( p_osmt, IB_MAD_METHOD_GETTABLE,
+					  &sm_info_rec_opt, &context );
+  if ( status != IB_SUCCESS )
+    goto Exit;
+
+  memset( &sm_info_rec_opt, 0, sizeof( sm_info_rec_opt ) );
+  sm_info_rec_opt.lid = test_lid;	/* local LID */
   memset( &context, 0, sizeof( context ) );
-  status = osmtest_sminfo_record_request( p_osmt, &context );
+  status = osmtest_sminfo_record_request( p_osmt, IB_MAD_METHOD_GETTABLE,
+					  &sm_info_rec_opt, &context );
   if ( status != IB_SUCCESS )
     goto Exit;
 
+  if (portguid != 0)
+  {
+    memset( &sm_info_rec_opt, 0, sizeof( sm_info_rec_opt ) );
+    sm_info_rec_opt.sm_guid = portguid;	/* local GUID */
+    memset( &context, 0, sizeof( context ) );
+    status = osmtest_sminfo_record_request( p_osmt, IB_MAD_METHOD_GETTABLE,
+					    &sm_info_rec_opt, &context );
+    if ( status != IB_SUCCESS )
+      goto Exit;
+  }
+
+  for (i = 1; i < 16; i++)
+  {
+    memset( &sm_info_rec_opt, 0, sizeof( sm_info_rec_opt ) );
+    sm_info_rec_opt.priority = i;
+    memset( &context, 0, sizeof( context ) );
+    status = osmtest_sminfo_record_request( p_osmt, IB_MAD_METHOD_GETTABLE,
+					    &sm_info_rec_opt, &context );
+    if ( status != IB_SUCCESS )
+      goto Exit;
+  }
+
+  for (i = 1; i < 4; i++)
+  {
+    memset( &sm_info_rec_opt, 0, sizeof( sm_info_rec_opt ) );
+    sm_info_rec_opt.sm_state = i;
+    memset( &context, 0, sizeof( context ) );
+    status = osmtest_sminfo_record_request( p_osmt, IB_MAD_METHOD_GETTABLE,
+					    &sm_info_rec_opt, &context );
+    if ( status != IB_SUCCESS )
+      goto Exit;
+  }
+
   /* InformInfoRecord tests */
   osm_log( &p_osmt->log, OSM_LOG_VERBOSE,
 	   "osmtest_informinfo_request: InformInfoRecord "







More information about the general mailing list