2 * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2007 The Regents of the University of California.
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35 #ifndef _OSM_EVENT_PLUGIN_H_
36 #define _OSM_EVENT_PLUGIN_H_
39 #include <iba/ib_types.h>
40 #include <complib/cl_qlist.h>
41 #include <opensm/osm_config.h>
44 # define BEGIN_C_DECLS extern "C" {
45 # define END_C_DECLS }
46 #else /* !__cplusplus */
47 # define BEGIN_C_DECLS
49 #endif /* __cplusplus */
52 /****h* OpenSM Event plugin interface
54 * Database interface to record subnet events
56 * Implementations of this object _MUST_ be thread safe.
63 #define OSM_EPI_NODE_NAME_LEN (128)
66 /** =========================================================================
70 OSM_EVENT_ID_PORT_ERRORS = 0,
71 OSM_EVENT_ID_PORT_DATA_COUNTERS,
72 OSM_EVENT_ID_PORT_SELECT,
74 OSM_EVENT_ID_SUBNET_UP,
78 typedef struct osm_epi_port_id {
81 char node_name[OSM_EPI_NODE_NAME_LEN];
84 /** =========================================================================
86 * OSM_EVENT_ID_PORT_COUNTER
87 * This is a difference from the last reading. NOT an absolute reading.
89 typedef struct osm_epi_pe_event {
90 osm_epi_port_id_t port_id;
91 uint64_t symbol_err_cnt;
92 uint64_t link_err_recover;
95 uint64_t rcv_rem_phys_err;
96 uint64_t rcv_switch_relay_err;
97 uint64_t xmit_discards;
98 uint64_t xmit_constraint_err;
99 uint64_t rcv_constraint_err;
100 uint64_t link_integrity;
101 uint64_t buffer_overrun;
102 uint64_t vl15_dropped;
104 } osm_epi_pe_event_t;
106 /** =========================================================================
107 * Port data counter event
108 * This is a difference from the last reading. NOT an absolute reading.
110 typedef struct osm_epi_dc_event {
111 osm_epi_port_id_t port_id;
116 uint64_t unicast_xmit_pkts;
117 uint64_t unicast_rcv_pkts;
118 uint64_t multicast_xmit_pkts;
119 uint64_t multicast_rcv_pkts;
121 } osm_epi_dc_event_t;
123 /** =========================================================================
125 * This is a difference from the last reading. NOT an absolute reading.
127 typedef struct osm_api_ps_event {
128 osm_epi_port_id_t port_id;
131 } osm_epi_ps_event_t;
133 /** =========================================================================
136 typedef struct osm_epi_trap_event {
137 osm_epi_port_id_t port_id;
143 } osm_epi_trap_event_t;
145 /** =========================================================================
146 * Plugin creators should allocate an object of this type
147 * (named OSM_EVENT_PLUGIN_IMPL_NAME)
148 * The version should be set to OSM_EVENT_PLUGIN_INTERFACE_VER
150 #define OSM_EVENT_PLUGIN_IMPL_NAME "osm_event_plugin"
151 #define OSM_ORIG_EVENT_PLUGIN_INTERFACE_VER 1
152 #define OSM_EVENT_PLUGIN_INTERFACE_VER 2
153 typedef struct osm_event_plugin {
154 const char *osm_version;
155 void *(*create) (struct osm_opensm *osm);
156 void (*delete) (void *plugin_data);
157 void (*report) (void *plugin_data,
158 osm_epi_event_id_t event_id, void *event_data);
159 } osm_event_plugin_t;
161 /** =========================================================================
162 * The plugin structure should be considered opaque
164 typedef struct osm_epi_plugin {
167 osm_event_plugin_t *impl;
175 osm_epi_plugin_t *osm_epi_construct(struct osm_opensm *osm, char *plugin_name);
176 void osm_epi_destroy(osm_epi_plugin_t * plugin);
178 /** =========================================================================
182 osm_epi_create_port_id(osm_epi_port_id_t * port_id, uint64_t node_guid,
183 uint8_t port_num, char *node_name)
185 port_id->node_guid = node_guid;
186 port_id->port_num = port_num;
187 strncpy(port_id->node_name, node_name, OSM_EPI_NODE_NAME_LEN);
188 port_id->node_name[OSM_EPI_NODE_NAME_LEN - 1] = '\0';
192 #endif /* _OSM_EVENT_PLUGIN_H_ */