[openib-general] [PATCH] diags/smpquery: support for querying SL2VL and VLArbitration tables

Sasha Khapyorsky sashak at voltaire.com
Sun Mar 19 12:21:02 PST 2006


Hello,

There is support for querying SL2VLMapping and VLArbitration tables -
'sl2vl' and 'vlarb' operations are added to smpquery.

Sasha.


Support for SL2VLMapping and VLArbitration tables querying.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---

 diags/src/smpquery.c |  133 +++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 119 insertions(+), 14 deletions(-)

diff --git a/diags/src/smpquery.c b/diags/src/smpquery.c
index 3ce3e9a..6f8d0c9 100644
--- a/diags/src/smpquery.c
+++ b/diags/src/smpquery.c
@@ -53,6 +53,7 @@
 #define	DEBUG	if (verbose>1) IBWARN
 #define IBERROR(fmt, args...)	iberror(__FUNCTION__, fmt, ## args)
 
+
 static int dest_type = IB_DEST_LID;
 static int verbose;
 
@@ -61,16 +62,21 @@ typedef char *(op_fn_t)(ib_portid_t *des
 typedef struct match_rec {
 	char *name;
 	op_fn_t *fn;
+	unsigned opt_portnum;
 } match_rec_t;
 
-static op_fn_t	node_desc, node_info, port_info, switch_info, pkey_table;
 
-static match_rec_t match_tbl[] = {
+static op_fn_t	node_desc, node_info, port_info, switch_info, pkey_table,
+	sl2vl_table, vlarb_table;
+
+static const match_rec_t match_tbl[] = {
 	{ "nodeinfo", node_info },
 	{ "nodedesc", node_desc },
-	{ "portinfo", port_info },
+	{ "portinfo", port_info , 1 },
 	{ "switchinfo", switch_info },
-	{ "pkeys", pkey_table },
+	{ "pkeys", pkey_table , 1 },
+	{ "sl2vl", sl2vl_table , 1 },
+	{ "vlarb", vlarb_table , 1 },
 	{0}
 };
 
@@ -214,22 +220,122 @@ pkey_table(ib_portid_t *dest, char **arg
 	return 0;
 }
 
-op_fn_t *
-match_op(char *name)
+static char *sl2vl_dump_table_entry(ib_portid_t *dest, int in, int out)
 {
-	match_rec_t *r;
+	char buf[2048];
+	char data[IB_SMP_DATA_SIZE];
+	int portnum = (in << 8) | out;
+
+	if (!smp_query(data, dest, IB_ATTR_SLVL_TABLE, portnum, 0))
+		return "smp query failed";
 
+	mad_dump_sltovl(buf, sizeof buf, data, sizeof data);
+	printf("ports: in %2d, out %2d: ", in, out);
+	printf("%s", buf);
+	return 0;
+}
+
+static char *
+sl2vl_table(ib_portid_t *dest, char **argv, int argc)
+{
+	char data[IB_SMP_DATA_SIZE];
+	int type, num_ports, portnum = 0;
+	int i;
+	char *ret;
+
+	if (argc > 0)
+		portnum = strtol(argv[0], 0, 0);
+
+	if (!smp_query(data, dest, IB_ATTR_NODE_INFO, 0, 0))
+		return "node info query failed";
+
+	mad_decode_field(data, IB_NODE_TYPE_F, &type);
+	mad_decode_field(data, IB_NODE_NPORTS_F, &num_ports);
+	if (portnum > num_ports)
+		return "invalid port number";
+
+	printf("# SL2VL table: %s\n", portid2str(dest));
+	printf("#                 SL: |");
+	for (i = 0 ; i < 16 ; i++)
+		printf("%2d|", i);
+	printf("\n");
+
+	if (type != IB_NODE_SWITCH)
+		return sl2vl_dump_table_entry(dest, 0, 0);
+
+	for (i = 0 ; i <= num_ports ; i++) {
+		ret = sl2vl_dump_table_entry(dest, i, portnum);
+		if (ret)
+			return ret;
+	}
+	return 0;
+}
+
+static char *vlarb_dump_table_entry(ib_portid_t *dest, int portnum, int offset)
+{
+	char buf[2048];
+	char data[IB_SMP_DATA_SIZE];
+	if (!smp_query(data, dest, IB_ATTR_VL_ARBITRATION,
+			(offset << 16) | portnum, 0))
+		return "smp query failed";
+	mad_dump_vlarbitration(buf, sizeof(buf), data, sizeof(data));
+	printf("%s", buf);
+	return 0;
+}
+
+static char *vlarb_dump_table(ib_portid_t *dest, int portnum,
+	char *name, int offset, char *data, int size_field)
+{
+	int size;
+	char *ret;
+	mad_decode_field(data,size_field, &size);
+	printf("# %s priority VL Arbitratoin Table:", name);
+	if ( (ret = vlarb_dump_table_entry(dest, portnum, offset)) ||
+		(size > 32 &&
+		(ret = vlarb_dump_table_entry(dest, portnum, offset + 1))) )
+		return ret;
+	return 0;
+}
+
+static char *
+vlarb_table(ib_portid_t *dest, char **argv, int argc)
+{
+	char data[IB_SMP_DATA_SIZE];
+	int portnum = 0;
+	char *ret;
+
+	if (argc > 0)
+		portnum = strtol(argv[0], 0, 0);
+
+	if (!smp_query(data, dest, IB_ATTR_PORT_INFO, portnum, 0))
+		return "node info query failed";
+
+	printf("# VLArbitration tables: %s port %d\n",
+			portid2str(dest), portnum);
+	if ( (ret = vlarb_dump_table(dest, portnum, "Low", 1,
+				data, IB_PORT_VL_ARBITRATION_LOW_CAP_F)) ||
+		(ret = vlarb_dump_table(dest, portnum, "High", 3,
+				data, IB_PORT_VL_ARBITRATION_HIGH_CAP_F)) )
+		return ret;
+
+	return 0;
+}
+
+static op_fn_t *
+match_op(char *name)
+{
+	const match_rec_t *r;
 	for (r = match_tbl; r->name; r++)
 		if (!strcmp(r->name, name))
 			return r->fn;
-
 	return 0;
 }
 
-void
+static void
 usage(void)
 {
 	char *basename;
+	const match_rec_t *r;
 
 	if (!(basename = strrchr(argv0, '/')))
 		basename = argv0;
@@ -240,11 +346,10 @@ usage(void)
 			"-t(imeout) timeout_ms] <op> <dest dr_path|lid|guid> [op params]\n",
 			basename);
 	fprintf(stderr, "\tsupported ops:\n");
-	fprintf(stderr, "\t\tnodeinfo <addr>\n");
-	fprintf(stderr, "\t\tnodedesc <addr>\n");
-	fprintf(stderr, "\t\tportinfo <addr> [<portnum>]\n");
-	fprintf(stderr, "\t\tswitchinfo <addr>\n");
-	fprintf(stderr, "\t\tpkeys <addr> [<portnum>]\n");
+	for (r = match_tbl ; r->name ; r++) {
+		fprintf(stderr, "\t\t%s <addr>%s\n", r->name,
+				r->opt_portnum ? " [<portnum>]" : "");
+	}
 	fprintf(stderr, "\n\texamples:\n");
 	fprintf(stderr, "\t\t%s portinfo 3 1\t\t\t\t# switchinfo by lid, with port modifier\n", basename);
 	fprintf(stderr, "\t\t%s -G switchinfo 0x2C9000100D051 1\t# switchinfo by guid\n", basename);



More information about the general mailing list