[openib-general] [PATCH] diags/saquery: Add SA PortInfoRecord:CapabilityMask IsSM query

Hal Rosenstock halr at voltaire.com
Mon Jul 10 03:07:46 PDT 2006


diags/saquery: Add SA PortInfoRecord:CapabilityMask IsSM query

This patch is predicated on SA client API change for user defined
queries supporting attribute modifier.

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

Index: src/saquery.c
===================================================================
--- src/saquery.c	(revision 8461)
+++ src/saquery.c	(working copy)
@@ -181,6 +181,26 @@ print_path_record(ib_path_rec_t *p_pr)
 }
 
 static void
+print_portinfo_record(ib_portinfo_record_t *p_pir)
+{
+	const ib_port_info_t * const p_pi = &p_pir->port_info;
+
+        printf("\nPortInfoRecord dump:\n"
+	       "\t\t\t\tEndPortLid..............0x%X\n"
+	       "\t\t\t\tPortNum.................0x%X\n"
+	       "\t\t\t\tbase_lid................0x%X\n"
+	       "\t\t\t\tmaster_sm_base_lid......0x%X\n"
+	       "\t\t\t\tcapability_mask.........0x%X\n"
+	       "",
+	       cl_ntoh16(p_pir->lid),
+	       p_pir->port_num,
+	       cl_ntoh16( p_pi->base_lid ),
+	       cl_ntoh16( p_pi->master_sm_base_lid ),
+	       cl_ntoh32( p_pi->capability_mask )
+               );
+}
+
+static void
 return_mad(void)
 {
 	/*
@@ -233,6 +253,51 @@ get_all_records(osm_bind_handle_t bind_h
 	return (status);
 }
 
+/*
+ * Get the portinfo records available with IsSM CapabilityMask bit on.
+ */
+static ib_api_status_t
+get_issm_records(osm_bind_handle_t bind_handle)
+{
+	ib_api_status_t   status;
+	osmv_query_req_t  req;
+	osmv_user_query_t user;
+	ib_portinfo_record_t attr;
+
+	memset( &req, 0, sizeof( req ) );
+	memset( &user, 0, sizeof( user ) );
+	memset( &attr, 0, sizeof ( attr ) );
+	attr.port_info.capability_mask = IB_PORT_CAP_IS_SM;
+
+	user.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
+	user.attr_offset = ib_get_attr_offset(sizeof(ib_portinfo_record_t));
+	user.attr_mod = cl_ntoh32(1 << 31);	/* enhanced query */
+	user.comp_mask = IB_PIR_COMPMASK_CAPMASK;
+	user.p_attr = &attr;
+
+	req.query_type = OSMV_QUERY_USER_DEFINED;
+	req.timeout_ms = 100;
+	req.retry_cnt = 1;
+	req.flags = OSM_SA_FLAGS_SYNC;
+	req.query_context = NULL;
+	req.pfn_query_cb = query_res_cb;
+	req.p_query_input = &user;
+	req.sm_key = 0;
+
+	if ((status = osmv_query_sa(bind_handle, &req)) != IB_SUCCESS) {
+		fprintf(stderr, "Query SA failed: %s\n",
+			ib_get_err_str(status));
+		return (status);
+	}
+
+	if (result.status != IB_SUCCESS) {
+		fprintf(stderr, "Query result returned: %s\n",
+			ib_get_err_str(result.status));
+		return (result.status);
+	}
+	return (status);
+}
+
 static ib_api_status_t
 print_node_records(osm_bind_handle_t bind_handle)
 {
@@ -276,6 +341,25 @@ print_path_records(osm_bind_handle_t bin
 	return (status);
 }
 
+ib_api_status_t
+print_portinfo_records(osm_bind_handle_t bind_handle)
+{
+	int                   i = 0;
+	ib_portinfo_record_t *portinfo_record = NULL;
+	ib_api_status_t       status;
+
+	status = get_issm_records(bind_handle);
+	if (status != IB_SUCCESS)
+		return (status);
+
+	for (i = 0; i < result.result_cnt; i++) {
+		portinfo_record = osmv_get_query_portinfo_rec(result.p_result_madw, i);
+		print_portinfo_record(portinfo_record);
+	}
+	return_mad();
+	return (status);
+}
+
 static osm_bind_handle_t
 get_bind_handle(void)
 {
@@ -342,13 +426,14 @@ clean_up(void)
 static void
 usage(void)
 {
-	fprintf(stderr, "Usage: %s [-h -d -P -N -L -G][<name>]\n", argv0);
+	fprintf(stderr, "Usage: %s [-h -d -P -N -L -G -s][<name>]\n", argv0);
 	fprintf(stderr, "   Queries node records by default\n");
 	fprintf(stderr, "   -d enable debugging\n");
 	fprintf(stderr, "   -P get PathRecord info\n");
 	fprintf(stderr, "   -N get NodeRecord info\n");
 	fprintf(stderr, "   -L Return just the Lid of the name specified\n");
 	fprintf(stderr, "   -G Return just the Guid of the name specified\n");
+	fprintf(stderr, "   -s Return the PortInfoRecords with isSM capability mask bit on\n");
 	exit(-1);
 }
 
@@ -358,12 +443,13 @@ main(int argc, char **argv)
 	int                ch = 0;
 	osm_bind_handle_t  bind_handle;
 
-	static char const str_opts[] = "PNLGdh";
+	static char const str_opts[] = "PNLGsdh";
 	static const struct option long_opts [] = {
 	   {"P", 0, 0, 'P'},
 	   {"N", 0, 0, 'N'},
 	   {"L", 0, 0, 'L'},
 	   {"G", 0, 0, 'G'},
+	   {"s", 0, 0, 's'},
 	   {"d", 0, 0, 'd'},
 	   {"help", 0, 0, 'h'},
 	   { }
@@ -385,6 +471,9 @@ main(int argc, char **argv)
 		case 'G':
 			node_print_desc = GUID_ONLY;
 			break;
+		case 's':
+			query_type = IB_MAD_ATTR_PORTINFO_RECORD;
+			break;
 		case 'd':
 			osm_debug = 1;
 			break;
@@ -408,6 +497,9 @@ main(int argc, char **argv)
 	case IB_MAD_ATTR_PATH_RECORD:
 		print_path_records(bind_handle);
 		break;
+	case IB_MAD_ATTR_PORTINFO_RECORD:
+		print_portinfo_records(bind_handle);
+		break;
 	default:
 		fprintf(stderr, "Unknown query type %d\n", query_type);
 		break;







More information about the general mailing list