[openib-general] [PATCH 2/2]: osmtest/osmtest.c: Add tests for SA InformInfoRecord and InformInfo
Hal Rosenstock
halr at voltaire.com
Tue Dec 5 07:02:43 PST 2006
osmtest/osmtest.c: Add tests for SA InformInfoRecord and InformInfo
The following patch adds some tests for SA InformInfoRecord and
InformInfo into osmtest.
Signed-off-by: Hal Rosenstock <halr at voltaire.com>
diff --git a/osm/osmtest/osmtest.c b/osm/osmtest/osmtest.c
index a21e8ca..b3f2bb4 100644
--- a/osm/osmtest/osmtest.c
+++ b/osm/osmtest/osmtest.c
@@ -69,6 +69,18 @@
#define POOL_MIN_ITEMS 64
#define GUID_ARRAY_SIZE 64
+typedef struct _osmtest_inform_info
+{
+ boolean_t subscribe;
+ ib_net32_t qpn;
+} osmtest_inform_info_t;
+
+typedef struct _osmtest_inform_info_rec
+{
+ ib_gid_t subscriber_gid;
+ ib_net16_t subscriber_enum;
+} osmtest_inform_info_rec_t;
+
typedef enum _osmtest_token_val
{
OSMTEST_TOKEN_COMMENT = 0,
@@ -4814,6 +4826,119 @@ osmtest_sminfo_record_request(
OSM_LOG_EXIT( &p_osmt->log );
return ( status );
}
+
+/**********************************************************************
+ **********************************************************************/
+ib_api_status_t
+osmtest_informinfo_request(
+ IN osmtest_t * const p_osmt,
+ IN ib_net16_t attr_id,
+ IN uint8_t method,
+ IN void *p_options,
+ 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_inform_info_t rec;
+ ib_inform_info_record_t record;
+ ib_mad_t *p_mad;
+ osmtest_inform_info_t *p_inform_info_opt;
+ osmtest_inform_info_rec_t *p_inform_info_rec_opt;
+
+ OSM_LOG_ENTER( &p_osmt->log, osmtest_informinfo_request );
+
+ /*
+ * Do a blocking query for these records 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( &rec, 0, sizeof( rec ) );
+ memset( &record, 0, sizeof( record ) );
+
+ p_context->p_osmt = p_osmt;
+ user.attr_id = attr_id;
+ if (attr_id == IB_MAD_ATTR_INFORM_INFO_RECORD)
+ {
+ user.attr_offset = cl_ntoh16( ( uint16_t ) ( sizeof( record ) >> 3 ) );
+ p_inform_info_rec_opt = p_options;
+ if (p_inform_info_rec_opt->subscriber_gid.unicast.prefix != 0 &&
+ p_inform_info_rec_opt->subscriber_gid.unicast.interface_id != 0)
+ {
+ record.subscriber_gid = p_inform_info_rec_opt->subscriber_gid;
+ user.comp_mask = IB_IIR_COMPMASK_SUBSCRIBERGID;
+ }
+ record.subscriber_enum = cl_hton16(p_inform_info_rec_opt->subscriber_enum);
+ user.comp_mask |= IB_IIR_COMPMASK_ENUM;
+ user.p_attr = &record;
+ }
+ else
+ {
+ user.attr_offset = cl_ntoh16( ( uint16_t ) ( sizeof( rec ) >> 3 ) );
+ /* comp mask bits below are for InformInfoRecord rather than InformInfo */
+ /* as currently no comp mask bits defined for InformInfo!!! */
+ user.comp_mask = IB_IIR_COMPMASK_SUBSCRIBE;
+ p_inform_info_opt = p_options;
+ rec.subscribe = p_inform_info_opt->subscribe;
+ if (p_inform_info_opt->qpn)
+ {
+ rec.g_or_v.generic.qpn_resp_time_val = cl_hton32(p_inform_info_opt->qpn) >> 8;
+ user.comp_mask |= IB_IIR_COMPMASK_QPN;
+ }
+ user.p_attr = &rec;
+ }
+ user.method = method;
+
+ 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_informinfo_request: ERR 008E: "
+ "ib_query failed (%s)\n", ib_get_err_str( status ) );
+ goto Exit;
+ }
+
+ status = p_context->result.status;
+
+ if( status != IB_SUCCESS )
+ {
+ if (status != IB_INVALID_PARAMETER)
+ {
+ osm_log( &p_osmt->log, OSM_LOG_ERROR,
+ "osmtest_informinfo_request: ERR 008F: "
+ "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_informinfo_request: "
+ "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 );
+}
#endif
/**********************************************************************
@@ -5421,6 +5546,8 @@ osmtest_validate_against_db( IN osmtest_
{
ib_api_status_t status = IB_SUCCESS;
ib_gid_t portgid, mgid;
+ osmtest_inform_info_t inform_info_opt;
+ osmtest_inform_info_rec_t inform_info_rec_opt;
#ifdef VENDOR_RMPP_SUPPORT
ib_net64_t sm_key;
ib_net16_t test_lid;
@@ -5684,6 +5811,121 @@ osmtest_validate_against_db( IN osmtest_
if ( status != IB_SUCCESS )
goto Exit;
+ /* InformInfoRecord tests */
+ memset( &inform_info_opt, 0, sizeof( inform_info_opt ) );
+ memset( &inform_info_rec_opt, 0, sizeof( inform_info_rec_opt ) );
+ memset( &context, 0, sizeof( context ) );
+ status = osmtest_informinfo_request( p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
+ IB_MAD_METHOD_SET, &inform_info_rec_opt, &context );
+ if ( status == IB_SUCCESS )
+ goto Exit;
+ else
+ {
+ osm_log( &p_osmt->log, OSM_LOG_ERROR,
+ "osmtest_informinfo_request: InformInfoRecord "
+ "IS EXPECTED ERROR ^^^^\n");
+ }
+
+ memset( &context, 0, sizeof( context ) );
+ status = osmtest_informinfo_request( p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
+ IB_MAD_METHOD_GETTABLE, &inform_info_rec_opt, &context );
+ if ( status != IB_SUCCESS )
+ goto Exit;
+
+ /* InformInfo tests */
+ memset( &context, 0, sizeof( context ) );
+ status = osmtest_informinfo_request( p_osmt, IB_MAD_ATTR_INFORM_INFO,
+ IB_MAD_METHOD_GET, &inform_info_opt, &context );
+ if ( status == IB_SUCCESS )
+ goto Exit;
+ else
+ {
+ osm_log( &p_osmt->log, OSM_LOG_ERROR,
+ "osmtest_informinfo_request: InformInfo "
+ "IS EXPECTED ERROR ^^^^\n");
+ }
+
+ memset( &context, 0, sizeof( context ) );
+ status = osmtest_informinfo_request( p_osmt, IB_MAD_ATTR_INFORM_INFO,
+ IB_MAD_METHOD_SET, &inform_info_opt, &context );
+ if ( status == IB_SUCCESS )
+ goto Exit;
+ else
+ {
+ osm_log( &p_osmt->log, OSM_LOG_ERROR,
+ "osmtest_informinfo_request: InformInfo UnSubscribe "
+ "IS EXPECTED ERROR ^^^^\n");
+ }
+
+ /* Now subscribe */
+ inform_info_opt.subscribe = TRUE;
+ memset( &context, 0, sizeof( context ) );
+ status = osmtest_informinfo_request( p_osmt, IB_MAD_ATTR_INFORM_INFO,
+ IB_MAD_METHOD_SET, &inform_info_opt, &context );
+ if ( status != IB_SUCCESS )
+ goto Exit;
+
+ /* Now unsubscribe (QPN needs to be 1 to work) */
+ inform_info_opt.subscribe = FALSE;
+ inform_info_opt.qpn = 1;
+ memset( &context, 0, sizeof( context ) );
+ status = osmtest_informinfo_request( p_osmt, IB_MAD_ATTR_INFORM_INFO,
+ IB_MAD_METHOD_SET, &inform_info_opt, &context );
+ if ( status != IB_SUCCESS )
+ goto Exit;
+
+ /* Now subscribe again */
+ inform_info_opt.subscribe = TRUE;
+ inform_info_opt.qpn = 1;
+ memset( &context, 0, sizeof( context ) );
+ status = osmtest_informinfo_request( p_osmt, IB_MAD_ATTR_INFORM_INFO,
+ IB_MAD_METHOD_SET, &inform_info_opt, &context );
+ if ( status != IB_SUCCESS )
+ goto Exit;
+
+ /* Subscribe over existing subscription */
+ inform_info_opt.qpn = 0;
+ memset( &context, 0, sizeof( context ) );
+ status = osmtest_informinfo_request( p_osmt, IB_MAD_ATTR_INFORM_INFO,
+ IB_MAD_METHOD_SET, &inform_info_opt, &context );
+ if ( status != IB_SUCCESS )
+ goto Exit;
+
+ /* More InformInfoRecord tests */
+ /* RID lookup */
+ ib_gid_set_default( &inform_info_rec_opt.subscriber_gid,
+ p_osmt->local_port.port_guid );
+ inform_info_rec_opt.subscriber_enum = 1;
+ memset( &context, 0, sizeof( context ) );
+ status = osmtest_informinfo_request( p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
+ IB_MAD_METHOD_GETTABLE, &inform_info_rec_opt, &context );
+ if ( status != IB_SUCCESS )
+ goto Exit;
+
+ inform_info_rec_opt.subscriber_enum = 0;
+ memset( &context, 0, sizeof( context ) );
+ status = osmtest_informinfo_request( p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
+ IB_MAD_METHOD_GETTABLE, &inform_info_rec_opt, &context );
+ if ( status != IB_SUCCESS )
+ goto Exit;
+
+ /* Get all InformInfoRecords */
+ memset( &inform_info_rec_opt, 0, sizeof( inform_info_rec_opt ) );
+ memset( &context, 0, sizeof( context ) );
+ status = osmtest_informinfo_request( p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
+ IB_MAD_METHOD_GETTABLE, &inform_info_rec_opt, &context );
+ if ( status != IB_SUCCESS )
+ goto Exit;
+
+ /* Cleanup subscriptions before further testing */
+ inform_info_opt.subscribe = FALSE;
+ inform_info_opt.qpn = 1;
+ memset( &context, 0, sizeof( context ) );
+ status = osmtest_informinfo_request( p_osmt, IB_MAD_ATTR_INFORM_INFO,
+ IB_MAD_METHOD_SET, &inform_info_opt, &context );
+ if ( status != IB_SUCCESS )
+ goto Exit;
+
if (lmc != 0)
{
test_lid = cl_ntoh16( p_osmt->local_port.lid + 1 );
More information about the general
mailing list