[ofa-general] Re: [PATCH v2] NOT For inclusion in master: Simple example of mad_fprintf in action.

Ira Weiny weiny2 at llnl.gov
Thu Apr 16 00:18:10 PDT 2009


Just an example of the use of mad_fprintf against v2 of the patch.

Ira

From: Ira Weiny <weiny2 at llnl.gov>
Date: Thu, 16 Apr 2009 00:07:04 -0700
Subject: [PATCH] Simple example of mad_fprintf in action.

Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
---
 infiniband-diags/src/ibnetdiscover.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/infiniband-diags/src/ibnetdiscover.c b/infiniband-diags/src/ibnetdiscover.c
index 25c1f7f..71b478c 100644
--- a/infiniband-diags/src/ibnetdiscover.c
+++ b/infiniband-diags/src/ibnetdiscover.c
@@ -186,6 +186,29 @@ get_node(Node *node, Port *port, ib_portid_t *portid)
 		return -1;
 	decode_port_info(pi, port);
 
+	if (ibdebug || ibverbose) {
+		mad_fprintf(stdout, pi, "Port info (%s):\n"
+			"   %-10s (%M): %m\n"
+			"   %-10s (%M): %m\n"
+			"   %-10s (%M): %m\n"
+			"   %-10s (%M): %m\n"
+			"   %-10s (%M): %m\n"
+			"   %-10s (%M): %m\n",
+			portid2str(portid),
+			"LID", IB_PORT_LID_F, IB_PORT_LID_F,
+			"LMC", IB_PORT_LMC_F, IB_PORT_LMC_F,
+			"state", IB_PORT_STATE_F, IB_PORT_STATE_F,
+			"physstate", IB_PORT_PHYS_STATE_F,
+				IB_PORT_PHYS_STATE_F,
+			"linkwidth", IB_PORT_LINK_WIDTH_ACTIVE_F,
+				IB_PORT_LINK_WIDTH_ACTIVE_F,
+			"linkspeed", IB_PORT_LINK_SPEED_ACTIVE_F,
+				IB_PORT_LINK_SPEED_ACTIVE_F
+			);
+		mad_fprintf(stdout, pi, "%sd%m%d%m\n",
+				"hello", IB_PORT_LID_F, 1, IB_PORT_LMC_F);
+	}
+
 	if (node->type != SWITCH_NODE)
 		return 0;
 
-- 
1.5.4.5




More information about the general mailing list