[openib-general] [PATCH] Add get Pkey table to smpquery

Ralph Campbell ralphc at pathscale.com
Mon Jan 9 12:38:47 PST 2006


Here is a patch to add the "pkeys" option to smpquery
to display the Pkey table.

Signed-off-by: Ralph Campbell <ralphc at pathscale.com>

Index: diags/src/smpquery.c
===================================================================
--- diags/src/smpquery.c	(revision 4808)
+++ diags/src/smpquery.c	(working copy)
@@ -42,6 +42,7 @@
 #include <stdarg.h>
 #include <time.h>
 #include <string.h>
+#include <netinet/in.h>
 
 #include <common.h>
 #include <umad.h>
@@ -61,13 +62,14 @@
 	op_fn_t *fn;
 } match_rec_t;
 
-static op_fn_t	node_desc, node_info, port_info, switch_info;
+static op_fn_t	node_desc, node_info, port_info, switch_info,
pkey_table;
 
 static match_rec_t match_tbl[] = {
 	{ "nodeinfo", node_info },
 	{ "nodedesc", node_desc },
 	{ "portinfo", port_info },
 	{ "switchinfo", switch_info },
+	{ "pkeys", pkey_table },
 	{0}
 };
 
@@ -157,6 +159,35 @@
 	return 0;
 }
 
+static char *
+pkey_table(ib_portid_t *dest, char **argv, int argc)
+{
+	char data[IB_SMP_DATA_SIZE];
+	uint32_t i, j, n;
+	uint16_t *p;
+
+	/* Get the partition capacity */
+	if (!smp_query(data, dest, IB_ATTR_NODE_INFO, 0, 0))
+		return "node_info query failed";
+	n = _get_field(data, 0, ib_mad_f + IB_NODE_PARTITION_CAP_F);
+
+	for (i = 0; i < (n + 31) / 32; i++) {
+		if (!smp_query(data, dest, IB_ATTR_PKEY_TBL, i, 0))
+			return "pkey table query failed";
+		p = (uint16_t *) data;
+		for (j = 0; j < 32; j += 8, p += 8) {
+			printf("%4u: 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x
\n",
+				(i * 32) + j,
+				ntohs(p[0]), ntohs(p[1]),
+				ntohs(p[2]), ntohs(p[3]),
+				ntohs(p[4]), ntohs(p[5]),
+				ntohs(p[6]), ntohs(p[7]));
+		}
+	}
+
+	return 0;
+}
+
 op_fn_t *
 match_op(char *name)
 {

-- 
Ralph Campbell <ralphc at pathscale.com>




More information about the general mailing list