[openib-general] [PATCH 1/2] Diags/libibmad: Support optional PortExtendedCounters

Hal Rosenstock halr at voltaire.com
Sat Oct 21 06:44:35 PDT 2006


Diags/libibmad: Support optional PortExtendedCounters

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

Index: include/infiniband/mad.h
===================================================================
--- include/infiniband/mad.h	(revision 9921)
+++ include/infiniband/mad.h	(working copy)
@@ -502,6 +502,22 @@ enum MAD_FIELDS {
 	IB_VEND2_OUI_F,
 	IB_VEND2_DATA_F,
 
+	/*
+	 * PortCountersExtended
+	 */
+	IB_PC_EXT_FIRST_F,
+	IB_PC_EXT_PORT_SELECT_F = IB_PC_EXT_FIRST_F,
+	IB_PC_EXT_COUNTER_SELECT_F,
+	IB_PC_EXT_XMT_BYTES_F,
+	IB_PC_EXT_RCV_BYTES_F,
+	IB_PC_EXT_XMT_PKTS_F,
+	IB_PC_EXT_RCV_PKTS_F,
+	IB_PC_EXT_XMT_UPKTS_F,
+	IB_PC_EXT_RCV_UPKTS_F,
+	IB_PC_EXT_XMT_MPKTS_F,
+	IB_PC_EXT_RCV_MPKTS_F,
+	IB_PC_EXT_LAST_F,
+
 	IB_FIELD_LAST_	/* must be last */
 };
 
@@ -782,6 +798,10 @@ uint8_t *port_performance_query(void *rc
 				uint timeout);
 uint8_t *port_performance_reset(void *rcvbuf, ib_portid_t *dest, int port,
 				uint mask, uint timeout);
+uint8_t *port_performance_ext_query(void *rcvbuf, ib_portid_t *dest, int port,
+				    uint timeout);
+uint8_t *port_performance_ext_reset(void *rcvbuf, ib_portid_t *dest, int port,
+				    uint mask, uint timeout);
 uint8_t *port_samples_control_query(void *rcvbuf, ib_portid_t *dest, int port,
 				    uint timeout);
 uint8_t *port_samples_result_query(void *rcvbuf, ib_portid_t *dest, int port,
@@ -800,7 +820,7 @@ ib_mad_dump_fn
 	mad_dump_node_type,
 	mad_dump_sltovl, mad_dump_vlarbitration,
 	mad_dump_nodedesc, mad_dump_nodeinfo, mad_dump_portinfo, mad_dump_switchinfo,
-	mad_dump_perfcounters;
+	mad_dump_perfcounters, mad_dump_perfcounters_ext;
 
 int	_mad_dump(ib_mad_dump_fn *fn, char *name, void *val, int valsz);
 char *	_mad_dump_field(ib_field_t *f, char *name, char *buf, int bufsz,
Index: src/gs.c
===================================================================
--- src/gs.c	(revision 9827)
+++ src/gs.c	(working copy)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004,2005 Voltaire Inc.  All rights reserved.
+ * Copyright (c) 2004-2006 Voltaire Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -67,6 +67,7 @@ pma_query(void *rcvbuf, ib_portid_t *des
 	rpc.method = IB_MAD_METHOD_GET;
 	rpc.attr.id = id;
 
+	/* Same for attribute IDs */
 	mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
 	rpc.attr.mod = 0;
 	rpc.timeout = timeout;
@@ -92,9 +93,9 @@ port_performance_query(void *rcvbuf, ib_
 	return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_COUNTERS);
 }
 
-uint8_t *
-port_performance_reset(void *rcvbuf, ib_portid_t *dest, int port, uint mask,
-		       uint timeout)
+static uint8_t *
+performance_reset(void *rcvbuf, ib_portid_t *dest, int port, uint mask,
+		  uint timeout, uint id)
 {
 	ib_rpc_t rpc = {0};
 	int lid = dest->lid;
@@ -111,17 +112,17 @@ port_performance_reset(void *rcvbuf, ib_
 	
 	rpc.mgtclass = IB_PERFORMANCE_CLASS;
 	rpc.method = IB_MAD_METHOD_SET;
-	rpc.attr.id = IB_GSI_PORT_COUNTERS;
+	rpc.attr.id = id;
 
 	memset(rcvbuf, 0, IB_MAD_SIZE);
-	
+
+	/* Same for attribute IDs */
 	mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
 	mad_set_field(rcvbuf, 0, IB_PC_COUNTER_SELECT_F, mask);
 	rpc.attr.mod = 0;
 	rpc.timeout = timeout;
 	rpc.datasz = IB_PC_DATA_SZ;
 	rpc.dataoffs = IB_PC_DATA_OFFS;
-
 	dest->qp = 1;
 	if (!dest->qkey)
 		dest->qkey = IB_DEFAULT_QP1_QKEY;
@@ -130,6 +131,26 @@ port_performance_reset(void *rcvbuf, ib_
 }
 
 uint8_t *
+port_performance_reset(void *rcvbuf, ib_portid_t *dest, int port, uint mask,
+		       uint timeout)
+{
+	return performance_reset(rcvbuf, dest, port, mask, timeout, IB_GSI_PORT_COUNTERS);
+}
+
+uint8_t *
+port_performance_ext_query(void *rcvbuf, ib_portid_t *dest, int port, uint timeout)
+{
+	return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_COUNTERS_EXT);
+}
+
+uint8_t *
+port_performance_ext_reset(void *rcvbuf, ib_portid_t *dest, int port, uint mask,
+			   uint timeout)
+{
+	return performance_reset(rcvbuf, dest, port, mask, timeout, IB_GSI_PORT_COUNTERS_EXT);
+}
+
+uint8_t *
 port_samples_control_query(void *rcvbuf, ib_portid_t *dest, int port, uint timeout)
 {
 	return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_SAMPLES_CONTROL);
Index: src/fields.c
===================================================================
--- src/fields.c	(revision 9827)
+++ src/fields.c	(working copy)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004,2005 Voltaire Inc.  All rights reserved.
+ * Copyright (c) 2004-2006 Voltaire Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -340,6 +340,20 @@ ib_field_t ib_mad_f [] = {
 	[IB_VEND2_OUI_F]		{BE_OFFS(36*8, 24), "OUI", mad_dump_array},
 	[IB_VEND2_DATA_F]		{40*8, (256-40)*8, "Vendor2Data", mad_dump_array},
 
+	/*
+	 * Extended port counters
+	 */
+	[IB_PC_EXT_PORT_SELECT_F]	{BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
+	[IB_PC_EXT_COUNTER_SELECT_F]	{BITSOFFS(16, 16), "CounterSelect", mad_dump_hex},
+	[IB_PC_EXT_XMT_BYTES_F]		{64, 64, "PortXmitData", mad_dump_uint},
+	[IB_PC_EXT_RCV_BYTES_F]		{128, 64, "PortRcvData", mad_dump_uint},
+	[IB_PC_EXT_XMT_PKTS_F]		{192, 64, "PortXmitPkts", mad_dump_uint},
+	[IB_PC_EXT_RCV_PKTS_F]		{256, 64, "PortRcvPkts", mad_dump_uint}, 
+	[IB_PC_EXT_XMT_UPKTS_F]		{320, 64, "PortUnicastXmitPkts", mad_dump_uint},
+	[IB_PC_EXT_RCV_UPKTS_F]		{384, 64, "PortUnicastRcvPkts", mad_dump_uint},
+	[IB_PC_EXT_XMT_MPKTS_F]		{448, 64, "PortMulticastXmitPkts", mad_dump_uint},
+	[IB_PC_EXT_RCV_MPKTS_F]		{512, 64, "PortMulticastPkts", mad_dump_uint},
+
 };
 
 void
Index: src/dump.c
===================================================================
--- src/dump.c	(revision 9827)
+++ src/dump.c	(working copy)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004,2005 Voltaire Inc.  All rights reserved.
+ * Copyright (c) 2004-2006 Voltaire Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -771,6 +771,12 @@ mad_dump_perfcounters(char *buf, int buf
 	_dump_fields(buf, bufsz, val, IB_PC_FIRST_F, IB_PC_LAST_F);
 }
 
+void
+mad_dump_perfcounters_ext(char *buf, int bufsz, void *val, int valsz)
+{
+	_dump_fields(buf, bufsz, val, IB_PC_EXT_FIRST_F, IB_PC_EXT_LAST_F);
+}
+
 /************************/
 
 char *
Index: libibmad.ver
===================================================================
--- libibmad.ver	(revision 9921)
+++ libibmad.ver	(working copy)
@@ -6,4 +6,4 @@
 # API_REV - advance on any added API
 # RUNNING_REV - advance any change to the vendor files
 # AGE - number of backward versions the API still supports
-LIBVERSION=2:0:1
+LIBVERSION=3:0:2
Index: src/libibmad.map
===================================================================
--- src/libibmad.map	(revision 9827)
+++ src/libibmad.map	(working copy)
@@ -1,4 +1,4 @@
-IBMAD_1.2 {
+IBMAD_1.3 {
 	global:
 		_mad_dump;
 		_mad_dump_field;
@@ -21,6 +21,7 @@ IBMAD_1.2 {
 		mad_dump_nodeinfo;
 		mad_dump_opervls;
 		mad_dump_perfcounters;
+		mad_dump_perfcounters_ext;
 		mad_dump_physportstate;
 		mad_dump_portcapmask;
 		mad_dump_portinfo;
@@ -43,6 +44,8 @@ IBMAD_1.2 {
 		perf_classportinfo_query;
 		port_performance_query;
 		port_performance_reset;
+		port_performance_ext_query;
+		port_performance_ext_reset;
 		port_samples_control_query;
 		port_samples_result_query;
 		mad_build_pkt;







More information about the general mailing list