[ofa-general] [PATCH V3] Add ib_trap_str function to ib_types.h and use it in INFO prints of OpenSM

Ira Weiny weiny2 at llnl.gov
Thu Jul 24 10:11:13 PDT 2008


>From 1f810dd6ae9a73549cacdbb26f464e6132675592 Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Tue, 22 Jul 2008 16:31:36 -0700
Subject: [PATCH] Add ib_trap_str function to ib_types.h and use it in INFO prints of OpenSM


Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
 opensm/include/iba/ib_types.h |    2 +
 opensm/opensm/libopensm.map   |    1 +
 opensm/opensm/osm_helper.c    |   44 +++++++++++++++++++++++++++++++++++++++++
 opensm/opensm/osm_inform.c    |    3 +-
 opensm/opensm/osm_trap_rcv.c  |   10 +++++++-
 5 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/opensm/include/iba/ib_types.h b/opensm/include/iba/ib_types.h
index 09ec257..fffce00 100644
--- a/opensm/include/iba/ib_types.h
+++ b/opensm/include/iba/ib_types.h
@@ -7219,6 +7219,8 @@ typedef struct _ib_mad_notice_attr	// Total Size calc  Accumulated
 #define TRAP_144_MASK_LINK_WIDTH_ENABLE_CHANGE (CL_HTON16(0x0002))
 #define TRAP_144_MASK_NODE_DESCRIPTION_CHANGE  (CL_HTON16(0x0001))
 
+char * OSM_API ib_get_trap_str(uint16_t trap_num);
+
 /****f* IBA Base: Types/ib_notice_is_generic
 * NAME
 *	ib_notice_is_generic
diff --git a/opensm/opensm/libopensm.map b/opensm/opensm/libopensm.map
index 759a4e8..7cd2aba 100644
--- a/opensm/opensm/libopensm.map
+++ b/opensm/opensm/libopensm.map
@@ -17,6 +17,7 @@ OPENSM_1.5 {
 		ib_get_sm_method_str;
 		ib_get_sm_attr_str;
 		ib_get_sa_attr_str;
+		ib_get_trap_str;
 		osm_dump_port_info;
 		osm_dump_portinfo_record;
 		osm_dump_guidinfo_record;
diff --git a/opensm/opensm/osm_helper.c b/opensm/opensm/osm_helper.c
index 21ff51c..cc76d5c 100644
--- a/opensm/opensm/osm_helper.c
+++ b/opensm/opensm/osm_helper.c
@@ -2338,3 +2338,47 @@ const char *osm_get_sm_mgr_state_str(IN uint16_t state)
 		__osm_sm_mgr_state_str[state] :
 		__osm_sm_mgr_state_str[ARR_SIZE(__osm_sm_mgr_state_str) - 1];
 }
+
+char * OSM_API
+ib_get_trap_str(uint16_t trap_num)
+{
+	switch(trap_num)
+	{
+		case 64:
+			return ("GID in service");
+		case 65:
+			return ("GID out of service");
+		case 66:
+			return ("New mcast group created");
+		case 67:
+			return ("Mcast group deleted");
+		case 68:
+			return ("UnPath, Path no longer valid");
+		case 69:
+			return ("RePath, Path recomputed");
+		case 128:
+			return ("Link state change");
+		case 129:
+			return ("Local Link integrity threshold reached");
+		case 130:
+			return ("Excessive Buffer Overrun Threshold reached");
+		case 131:
+			return ("Flow Control Update watchdog timer expired");
+		case 144:
+			return ("CapabilityMask, NodeDescription, Link [Width|Speed] Enabled changed");
+		case 145:
+			return ("System Image GUID changed");
+		case 256:
+			return ("Bad M_Key");
+		case 257:
+			return ("Bad P_Key");
+		case 258:
+			return ("Bad Q_Key");
+		case 259:
+			return ("Bad P_Key (switch external port)");
+		default:
+			break;
+	}
+	return ("Unknown");
+}
+
diff --git a/opensm/opensm/osm_inform.c b/opensm/opensm/osm_inform.c
index e6146f7..ebc13bb 100644
--- a/opensm/opensm/osm_inform.c
+++ b/opensm/opensm/osm_inform.c
@@ -581,11 +581,12 @@ osm_report_notice(IN osm_log_t * const p_log,
 	/* an official Event information log */
 	if (ib_notice_is_generic(p_ntc)) {
 		OSM_LOG(p_log, OSM_LOG_INFO,
-			"Reporting Generic Notice type:%u num:%u"
+			"Reporting Generic Notice type:%u num:%u (%s)"
 			" from LID:%u GID:0x%016" PRIx64
 			",0x%016" PRIx64 "\n",
 			ib_notice_get_type(p_ntc),
 			cl_ntoh16(p_ntc->g_or_v.generic.trap_num),
+			ib_get_trap_str(cl_ntoh16(p_ntc->g_or_v.generic.trap_num)),
 			cl_ntoh16(p_ntc->issuer_lid),
 			cl_ntoh64(p_ntc->issuer_gid.unicast.prefix),
 			cl_ntoh64(p_ntc->issuer_gid.unicast.interface_id)
diff --git a/opensm/opensm/osm_trap_rcv.c b/opensm/opensm/osm_trap_rcv.c
index ae7ab05..03cbd26 100644
--- a/opensm/opensm/osm_trap_rcv.c
+++ b/opensm/opensm/osm_trap_rcv.c
@@ -327,11 +327,14 @@ __osm_trap_rcv_process_request(IN osm_sm_t * sm,
 			    || (p_ntci->g_or_v.generic.trap_num ==
 				CL_HTON16(131)))
 				OSM_LOG(sm->p_log, OSM_LOG_ERROR,
-					"Received Generic Notice type:0x%02X num:%u Producer:%u (%s) "
+					"Received Generic Notice type:0x%02X "
+					"num:%u (%s) Producer:%u (%s) "
 					"from LID:%u Port %d TID:0x%016"
 					PRIx64 "\n", ib_notice_get_type(p_ntci),
 					cl_ntoh16(p_ntci->g_or_v.generic.
 						  trap_num),
+					ib_get_trap_str(cl_ntoh16(p_ntci->g_or_v.generic.
+						  trap_num)),
 					cl_ntoh32(ib_notice_get_prod_type
 						  (p_ntci)),
 					ib_get_producer_type_str
@@ -342,11 +345,14 @@ __osm_trap_rcv_process_request(IN osm_sm_t * sm,
 				    );
 			else
 				OSM_LOG(sm->p_log, OSM_LOG_ERROR,
-					"Received Generic Notice type:0x%02X num:%u Producer:%u (%s) "
+					"Received Generic Notice type:0x%02X "
+					"num:%u (%s) Producer:%u (%s) "
 					"from LID:%u TID:0x%016" PRIx64
 					"\n", ib_notice_get_type(p_ntci),
 					cl_ntoh16(p_ntci->g_or_v.generic.
 						  trap_num),
+					ib_get_trap_str(cl_ntoh16(p_ntci->g_or_v.generic.
+						  trap_num)),
 					cl_ntoh32(ib_notice_get_prod_type
 						  (p_ntci)),
 					ib_get_producer_type_str
-- 
1.5.4.5




More information about the general mailing list