[openib-general] [PATCH] diags/saquery: Add support to query multicast groups

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


diags/saquery: Add support to query multicast groups

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

Index: diags/src/saquery.c
===================================================================
--- diags/src/saquery.c	(revision 8461)
+++ diags/src/saquery.c	(working copy)
@@ -181,6 +181,26 @@ print_path_record(ib_path_rec_t *p_pr)
 }
 
 static void
+print_multicast_group_record(ib_member_rec_t *p_mcmr)
+{
+	        printf("\nMCMemberRecord group dump:\n"
+		       "\t\t\t\tMGID....................0x%016" PRIx64 " : "
+		       "0x%016" PRIx64 "\n"
+		       "\t\t\t\tMlid....................0x%X\n"
+		       "\t\t\t\tMtu.....................0x%X\n"
+		       "\t\t\t\tpkey....................0x%X\n"
+		       "\t\t\t\tRate....................0x%X\n"
+		       "",
+		       cl_ntoh64( p_mcmr->mgid.unicast.prefix ),
+		       cl_ntoh64( p_mcmr->mgid.unicast.interface_id ),
+		       cl_ntoh16( p_mcmr->mlid ),
+		       p_mcmr->mtu,
+		       cl_ntoh16( p_mcmr->pkey ),
+		       p_mcmr->rate
+		       );
+}
+
+static void
 return_mad(void)
 {
 	/*
@@ -276,6 +296,26 @@ print_path_records(osm_bind_handle_t bin
 	return (status);
 }
 
+static ib_api_status_t
+print_multicast_group_records(osm_bind_handle_t bind_handle)
+{
+	int               i = 0;
+	ib_member_rec_t  *mcast_record = NULL;
+	ib_net16_t        attr_offset = ib_get_attr_offset(sizeof(*mcast_record));
+	ib_api_status_t   status;
+
+	status = get_all_records(bind_handle, IB_MAD_ATTR_MCMEMBER_RECORD, attr_offset);
+	if (status != IB_SUCCESS)
+		return (status);
+
+	for (i = 0; i < result.result_cnt; i++) {
+		mcast_record = osmv_get_query_mc_rec(result.p_result_madw, i);
+		print_multicast_group_record(mcast_record);
+	}
+	return_mad();
+	return (status);
+}
+
 static osm_bind_handle_t
 get_bind_handle(void)
 {
@@ -349,6 +389,7 @@ usage(void)
 	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, "   -g get multicast group info\n");
 	exit(-1);
 }
 
@@ -358,12 +399,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[] = "PNLGgdh";
 	static const struct option long_opts [] = {
 	   {"P", 0, 0, 'P'},
 	   {"N", 0, 0, 'N'},
 	   {"L", 0, 0, 'L'},
 	   {"G", 0, 0, 'G'},
+	   {"g", 0, 0, 'g'},
 	   {"d", 0, 0, 'd'},
 	   {"help", 0, 0, 'h'},
 	   { }
@@ -385,6 +427,9 @@ main(int argc, char **argv)
 		case 'G':
 			node_print_desc = GUID_ONLY;
 			break;
+		case 'g':
+			query_type = IB_MAD_ATTR_MCMEMBER_RECORD;
+			break;
 		case 'd':
 			osm_debug = 1;
 			break;
@@ -408,6 +453,9 @@ main(int argc, char **argv)
 	case IB_MAD_ATTR_PATH_RECORD:
 		print_path_records(bind_handle);
 		break;
+	case IB_MAD_ATTR_MCMEMBER_RECORD:
+		print_multicast_group_records(bind_handle);
+		break;
 	default:
 		fprintf(stderr, "Unknown query type %d\n", query_type);
 		break;







More information about the general mailing list