[ofa-general] [PATCH] ibsim: support xmitwait counters

Doron Shoham dorons at Voltaire.COM
Mon Mar 30 05:08:57 PDT 2009


support xmitwait counters

Signed-off-by: Doron Shoham <dorons at voltaire.com>
---
 ibsim/sim.h     |    3 +++
 ibsim/sim_mad.c |   11 ++++++++++-
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/ibsim/sim.h b/ibsim/sim.h
index 5e9b4f0..5a8a92f 100644
--- a/ibsim/sim.h
+++ b/ibsim/sim.h
@@ -111,6 +111,7 @@ enum GS_PERF_COUNTER_SELECT_MASK {
 	GS_PERF_RCV_BYTES_MASK = (1UL << 13),	// PORT_RCV_DATA
 	GS_PERF_XMT_PKTS_MASK = (1UL << 14),	// PORT_XMIT_PKTS
 	GS_PERF_RCV_PKTS_MASK = (1UL << 15),	// PORT_RCV_PKTS
+	GS_PERF_XMT_WAIT_MASK = (1UL << 16),	// PORT_XMIT_WAIT
 };
 
 enum GS_PC_EXT_SELECT_MASK {
@@ -141,6 +142,7 @@ enum GS_PERF_COUNTER_SELECT_LIMIT {
 	GS_PERF_RCV_BYTES_LIMIT = 0xffffffff,
 	GS_PERF_XMT_PKTS_LIMIT = 0xffffffff,
 	GS_PERF_RCV_PKTS_LIMIT = 0xffffffff,
+	GS_PERF_XMT_WAIT_LIMIT = 0xffffffff,
 };
 
 typedef struct Port Port;
@@ -182,6 +184,7 @@ struct Portcounters {
 	uint8_t errs_rcvconstraint;
 	uint16_t errs_rcvswitchrelay;
 	uint8_t errs_excessbufovrrun;
+	uint32_t xmt_wait;
 };
 
 struct Port {
diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c
index d2c313c..f4e7359 100644
--- a/ibsim/sim_mad.c
+++ b/ibsim/sim_mad.c
@@ -567,6 +567,8 @@ static void pc_reset(Portcounters * pc, uint mask)
 		pc->flow_xmt_pkts = 0;
 	if (mask & GS_PERF_RCV_PKTS_MASK)
 		pc->flow_rcv_pkts = 0;
+	if (mask & GS_PERF_XMT_WAIT_MASK)
+		pc->xmt_wait = 0;
 }
 
 static inline uint32_t addval(uint32_t val, uint32_t delta, uint32_t max)
@@ -641,6 +643,9 @@ static int pc_updated(Port ** srcport, Port * destport)
 
 static void pc_sum(Portcounters * totals, Portcounters * pc)
 {
+	totals->xmt_wait =
+	    addval(totals->xmt_wait, pc->xmt_wait,
+		   GS_PERF_XMT_WAIT_LIMIT);
 	totals->flow_xmt_pkts =
 	    addval(totals->flow_xmt_pkts, pc->flow_xmt_pkts,
 		   GS_PERF_XMT_PKTS_LIMIT);
@@ -691,6 +696,7 @@ static void pc_sum(Portcounters * totals, Portcounters * pc)
 
 static void pc_get(Portcounters * pc, uint8_t * data)
 {
+	mad_set_field(data, 0, IB_PC_XMT_WAIT_F, pc->xmt_wait);
 	mad_set_field(data, 0, IB_PC_XMT_PKTS_F, pc->flow_xmt_pkts);
 	mad_set_field(data, 0, IB_PC_XMT_BYTES_F, pc->flow_xmt_bytes);
 	mad_set_field(data, 0, IB_PC_RCV_PKTS_F, pc->flow_rcv_pkts);
@@ -716,7 +722,7 @@ static int do_portcounters(Port * port, unsigned op, uint32_t unused,
 	Node *node = port->node;
 	int portnum = mad_get_field(data, 0, IB_PC_PORT_SELECT_F);
 	Portcounters totals;
-	uint mask;
+	uint mask, mask2;
 	Port *p;
 	int i;
 
@@ -731,6 +737,9 @@ static int do_portcounters(Port * port, unsigned op, uint32_t unused,
 	      node->nodeguid, port->portguid, portnum);
 
 	mask = mad_get_field(data, 0, IB_PC_COUNTER_SELECT_F);
+	mask2 = mad_get_field(data, 0, IB_PC_COUNTER_SELECT2_F);
+	if (mask2)
+		mask |= GS_PERF_XMT_WAIT_MASK;
 
 	if (portnum != 0xff) {
 		if (!(p = node_get_port(node, portnum)))
-- 
1.5.5




More information about the general mailing list