[ofa-general] [PATCH] OpenSM: update osmeventplugin example for the new TRAP event.

Ira Weiny weiny2 at llnl.gov
Thu Dec 18 16:48:13 PST 2008


It turns out that I already was using the "OSM_EVENT_ID_TRAP" in the example
plugin.

This makes the use work,
Ira


>From 7b744c38fc2aad67586ade81d65326a139a85681 Mon Sep 17 00:00:00 2001
From: Ira Weiny <weiny2 at llnl.gov>
Date: Thu, 18 Dec 2008 16:16:37 -0800
Subject: [PATCH] OpenSM: update osmeventplugin example for the new TRAP event.


Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
---
 opensm/include/opensm/osm_event_plugin.h   |   12 ------------
 opensm/osmeventplugin/src/osmeventplugin.c |   28 ++++++++++++++++++++--------
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/opensm/include/opensm/osm_event_plugin.h b/opensm/include/opensm/osm_event_plugin.h
index 0922c65..41a5810 100644
--- a/opensm/include/opensm/osm_event_plugin.h
+++ b/opensm/include/opensm/osm_event_plugin.h
@@ -131,18 +131,6 @@ typedef struct osm_api_ps_event {
 } osm_epi_ps_event_t;
 
 /** =========================================================================
- * Trap events
- */
-typedef struct osm_epi_trap_event {
-	osm_epi_port_id_t port_id;
-	uint8_t type;
-	uint32_t prod_type;
-	uint16_t trap_num;
-	uint16_t issuer_lid;
-	time_t time;
-} osm_epi_trap_event_t;
-
-/** =========================================================================
  * Plugin creators should allocate an object of this type
  *    (named OSM_EVENT_PLUGIN_IMPL_NAME)
  * The version should be set to OSM_EVENT_PLUGIN_INTERFACE_VER
diff --git a/opensm/osmeventplugin/src/osmeventplugin.c b/opensm/osmeventplugin/src/osmeventplugin.c
index f0781eb..b4d9ce9 100644
--- a/opensm/osmeventplugin/src/osmeventplugin.c
+++ b/opensm/osmeventplugin/src/osmeventplugin.c
@@ -137,13 +137,21 @@ static void handle_port_select(_log_events_t * log, osm_epi_ps_event_t * ps)
 
 /** =========================================================================
  */
-static void handle_trap_event(_log_events_t * log, osm_epi_trap_event_t * trap)
+static void handle_trap_event(_log_events_t *log, ib_mad_notice_attr_t *p_ntc)
 {
-	fprintf(log->log_file,
-		"Trap event %d from 0x%" PRIx64 " (%s) port %d\n",
-		trap->trap_num,
-		trap->port_id.node_guid,
-		trap->port_id.node_name, trap->port_id.port_num);
+	if (ib_notice_is_generic(p_ntc)) {
+		fprintf(log->log_file,
+			"Generic trap type %d; event %d; from LID 0x%x\n",
+			ib_notice_get_type(p_ntc),
+			cl_ntoh16(p_ntc->g_or_v.generic.trap_num),
+			cl_ntoh16(p_ntc->issuer_lid));
+	} else {
+		fprintf(log->log_file,
+			"Vendor trap type %d; from LID 0x%x\n",
+			ib_notice_get_type(p_ntc),
+			cl_ntoh16(p_ntc->issuer_lid));
+	}
+
 }
 
 /** =========================================================================
@@ -163,13 +171,17 @@ static void report(void *_log, osm_epi_event_id_t event_id, void *event_data)
 		handle_port_select(log, (osm_epi_ps_event_t *) event_data);
 		break;
 	case OSM_EVENT_ID_TRAP:
-		handle_trap_event(log, (osm_epi_trap_event_t *) event_data);
+		handle_trap_event(log, (ib_mad_notice_attr_t *) event_data);
+		break;
+	case OSM_EVENT_ID_SUBNET_UP:
+		fprintf(log->log_file, "Subnet up reported\n");
 		break;
 	case OSM_EVENT_ID_MAX:
 	default:
 		osm_log(log->osmlog, OSM_LOG_ERROR,
-			"Unknown event reported to plugin\n");
+			"Unknown event (%d) reported to plugin\n", event_id);
 	}
+	fflush(log->log_file);
 }
 
 /** =========================================================================
-- 
1.5.4.5




More information about the general mailing list