[openib-general] [PATCH] Diags/saquery: Add support for querying ServiceRecords
Hal Rosenstock
halr at voltaire.com
Thu Dec 7 14:32:29 PST 2006
Diags/saquery: Add support for querying ServiceRecords
Signed-off-by: Hal Rosenstock <halr at voltaire.com>
diff --git a/diags/ChangeLog b/diags/ChangeLog
index 186059c..318f4b9 100644
--- a/diags/ChangeLog
+++ b/diags/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-07 Hal Rosenstock <halr at voltaire.com>
+
+ * src/saquery.c, man/saquery.8: Add support for
+ querying ServiceRecords
+
2006-11-21 Hal Rosenstock <halr at voltaire.com>
* src/perfquery.c: Add support for PerfMgt ClassPortInfo:
diff --git a/diags/man/saquery.8 b/diags/man/saquery.8
index 853effc..5bbc8a2 100644
--- a/diags/man/saquery.8
+++ b/diags/man/saquery.8
@@ -1,11 +1,11 @@
-.TH SAQUERY 8 "October 9, 2006" "OpenIB" "OpenIB Diagnostics"
+.TH SAQUERY 8 "December 7, 2006" "OpenIB" "OpenIB Diagnostics"
.SH NAME
saquery \- query InfiniBand subnet administration attributes
.SH SYNOPSIS
.B saquery
-[\-h] [\-d] [\-P] [\-N] [\-D] [\-L] i[\-l] [\-G] [\-C] [\-s] [\-g] [\-m] [--src-to-dst <src:dst>] [<name>]
+[\-h] [\-d] [\-P] [\-N] [\-D] [\-S] [\-L] i[\-l] [\-G] [\-C] [\-s] [\-g] [\-m] [--src-to-dst <src:dst>] [<name>]
.SH DESCRIPTION
.PP
@@ -24,6 +24,9 @@ get NodeRecord info
\fB\-D\fR
get NodeDescriptions of CAs only
.TP
+\fB\-S\fR
+get ServiceRecord info
+.TP
\fB\-L\fR
return the Lids of the name specified
.TP
diff --git a/diags/src/saquery.c b/diags/src/saquery.c
index cc39b06..168df01 100644
--- a/diags/src/saquery.c
+++ b/diags/src/saquery.c
@@ -334,6 +334,104 @@ print_multicast_member_record(ib_member_
}
static void
+print_service_record(ib_service_record_t *p_sr)
+{
+ char buf_service_key[35];
+ char buf_service_name[65];
+
+ sprintf(buf_service_key,
+ "0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ p_sr->service_key[0],
+ p_sr->service_key[1],
+ p_sr->service_key[2],
+ p_sr->service_key[3],
+ p_sr->service_key[4],
+ p_sr->service_key[5],
+ p_sr->service_key[6],
+ p_sr->service_key[7],
+ p_sr->service_key[8],
+ p_sr->service_key[9],
+ p_sr->service_key[10],
+ p_sr->service_key[11],
+ p_sr->service_key[12],
+ p_sr->service_key[13],
+ p_sr->service_key[14],
+ p_sr->service_key[15]);
+ strncpy(buf_service_name, (char *)p_sr->service_name, 64);
+ buf_service_name[64] = '\0';
+
+ printf("ServiceRecord dump:\n"
+ "\t\t\t\tServiceID...............0x%016" PRIx64 "\n"
+ "\t\t\t\tServiceGID..............0x%016" PRIx64 " : "
+ "0x%016" PRIx64 "\n"
+ "\t\t\t\tServiceP_Key............0x%X\n"
+ "\t\t\t\tServiceLease............0x%X\n"
+ "\t\t\t\tServiceKey..............%s\n"
+ "\t\t\t\tServiceName.............%s\n"
+ "\t\t\t\tServiceData8.1..........0x%X\n"
+ "\t\t\t\tServiceData8.2..........0x%X\n"
+ "\t\t\t\tServiceData8.3..........0x%X\n"
+ "\t\t\t\tServiceData8.4..........0x%X\n"
+ "\t\t\t\tServiceData8.5..........0x%X\n"
+ "\t\t\t\tServiceData8.6..........0x%X\n"
+ "\t\t\t\tServiceData8.7..........0x%X\n"
+ "\t\t\t\tServiceData8.8..........0x%X\n"
+ "\t\t\t\tServiceData8.9..........0x%X\n"
+ "\t\t\t\tServiceData8.10.........0x%X\n"
+ "\t\t\t\tServiceData8.11.........0x%X\n"
+ "\t\t\t\tServiceData8.12.........0x%X\n"
+ "\t\t\t\tServiceData8.13.........0x%X\n"
+ "\t\t\t\tServiceData8.14.........0x%X\n"
+ "\t\t\t\tServiceData8.15.........0x%X\n"
+ "\t\t\t\tServiceData8.16.........0x%X\n"
+ "\t\t\t\tServiceData16.1.........0x%X\n"
+ "\t\t\t\tServiceData16.2.........0x%X\n"
+ "\t\t\t\tServiceData16.3.........0x%X\n"
+ "\t\t\t\tServiceData16.4.........0x%X\n"
+ "\t\t\t\tServiceData16.5.........0x%X\n"
+ "\t\t\t\tServiceData16.6.........0x%X\n"
+ "\t\t\t\tServiceData16.7.........0x%X\n"
+ "\t\t\t\tServiceData16.8.........0x%X\n"
+ "\t\t\t\tServiceData32.1.........0x%X\n"
+ "\t\t\t\tServiceData32.2.........0x%X\n"
+ "\t\t\t\tServiceData32.3.........0x%X\n"
+ "\t\t\t\tServiceData32.4.........0x%X\n"
+ "\t\t\t\tServiceData64.1.........0x%016" PRIx64 "\n"
+ "\t\t\t\tServiceData64.2.........0x%016" PRIx64 "\n"
+ "",
+ cl_ntoh64( p_sr->service_id ),
+ cl_ntoh64( p_sr->service_gid.unicast.prefix ),
+ cl_ntoh64( p_sr->service_gid.unicast.interface_id ),
+ cl_ntoh16( p_sr->service_pkey ),
+ cl_ntoh32( p_sr->service_lease ),
+ buf_service_key,
+ buf_service_name,
+ p_sr->service_data8[0], p_sr->service_data8[1],
+ p_sr->service_data8[2], p_sr->service_data8[3],
+ p_sr->service_data8[4], p_sr->service_data8[5],
+ p_sr->service_data8[6], p_sr->service_data8[7],
+ p_sr->service_data8[8], p_sr->service_data8[9],
+ p_sr->service_data8[10], p_sr->service_data8[11],
+ p_sr->service_data8[12], p_sr->service_data8[13],
+ p_sr->service_data8[14], p_sr->service_data8[15],
+ cl_ntoh16(p_sr->service_data16[0]),
+ cl_ntoh16(p_sr->service_data16[1]),
+ cl_ntoh16(p_sr->service_data16[2]),
+ cl_ntoh16(p_sr->service_data16[3]),
+ cl_ntoh16(p_sr->service_data16[4]),
+ cl_ntoh16(p_sr->service_data16[5]),
+ cl_ntoh16(p_sr->service_data16[6]),
+ cl_ntoh16(p_sr->service_data16[7]),
+ cl_ntoh32(p_sr->service_data32[0]),
+ cl_ntoh32(p_sr->service_data32[1]),
+ cl_ntoh32(p_sr->service_data32[2]),
+ cl_ntoh32(p_sr->service_data32[3]),
+ cl_ntoh64(p_sr->service_data64[0]),
+ cl_ntoh64(p_sr->service_data64[1])
+ );
+}
+
+static void
return_mad(void)
{
/*
@@ -645,6 +743,26 @@ print_multicast_group_records(osm_bind_h
return (status);
}
+static ib_api_status_t
+print_service_records(osm_bind_handle_t bind_handle)
+{
+ int i = 0;
+ ib_service_record_t *service_record = NULL;
+ ib_net16_t attr_offset = ib_get_attr_offset(sizeof(*service_record));
+ ib_api_status_t status;
+
+ status = get_all_records(bind_handle, IB_MAD_ATTR_SERVICE_RECORD, attr_offset, 0);
+ if (status != IB_SUCCESS)
+ return (status);
+
+ for (i = 0; i < result.result_cnt; i++) {
+ service_record = osmv_get_query_svc_rec(result.p_result_madw, i);
+ print_service_record(service_record);
+ }
+ return_mad();
+ return (status);
+}
+
static osm_bind_handle_t
get_bind_handle(void)
{
@@ -729,12 +847,13 @@ clean_up(void)
static void
usage(void)
{
- fprintf(stderr, "Usage: %s [-h -d -P -N -D -L -l -G -C -s -g -m --src-to-dst <src:dst>] [<name>]\n", argv0);
+ fprintf(stderr, "Usage: %s [-h -d -P -N -D -S -L -l -G -C -s -g -m --src-to-dst <src:dst>] [<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, " -D get NodeDescriptions of CAs only\n");
+ fprintf(stderr, " -S get ServiceRecord info\n");
fprintf(stderr, " -L return the Lids of the name specified\n");
fprintf(stderr, " -l return the unique Lid of the name specified\n");
fprintf(stderr, " -G return the Guids of the name specified\n");
@@ -758,7 +877,7 @@ main(int argc, char **argv)
ib_net16_t dst_lid;
ib_api_status_t status;
- static char const str_opts[] = "PNDLlGCsgmdh";
+ static char const str_opts[] = "PNDLlGCSsgmdh";
static const struct option long_opts [] = {
{"P", 0, 0, 'P'},
{"N", 0, 0, 'N'},
@@ -771,6 +890,7 @@ main(int argc, char **argv)
{"m", 0, 0, 'm'},
{"d", 0, 0, 'd'},
{"C", 0, 0, 'C'},
+ {"S", 0, 0, 'S'},
{"help", 0, 0, 'h'},
{"src-to-dst", 1, 0, 1},
{ }
@@ -806,6 +926,9 @@ main(int argc, char **argv)
case 'C':
query_type = IB_MAD_ATTR_CLASS_PORT_INFO;
break;
+ case 'S':
+ query_type = IB_MAD_ATTR_SERVICE_RECORD;
+ break;
case 'N':
query_type = IB_MAD_ATTR_NODE_RECORD;
break;
@@ -871,6 +994,9 @@ main(int argc, char **argv)
case IB_MAD_ATTR_MCMEMBER_RECORD:
status = print_multicast_group_records(bind_handle, members);
break;
+ case IB_MAD_ATTR_SERVICE_RECORD:
+ status = print_service_records(bind_handle);
+ break;
default:
fprintf(stderr, "Unknown query type %d\n", query_type);
status = IB_UNKNOWN_ERROR;
More information about the general
mailing list