]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ofed/management/opensm/include/opensm/osm_event_plugin.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ofed / management / opensm / include / opensm / osm_event_plugin.h
1 /*
2  * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
3  * Copyright (c) 2007 The Regents of the University of California.
4  *
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:
10  *
11  *     Redistribution and use in source and binary forms, with or
12  *     without modification, are permitted provided that the following
13  *     conditions are met:
14  *
15  *      - Redistributions of source code must retain the above
16  *        copyright notice, this list of conditions and the following
17  *        disclaimer.
18  *
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.
23  *
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
31  * SOFTWARE.
32  *
33  */
34
35 #ifndef _OSM_EVENT_PLUGIN_H_
36 #define _OSM_EVENT_PLUGIN_H_
37
38 #include <time.h>
39 #include <iba/ib_types.h>
40 #include <complib/cl_qlist.h>
41 #include <opensm/osm_config.h>
42
43 #ifdef __cplusplus
44 #  define BEGIN_C_DECLS extern "C" {
45 #  define END_C_DECLS   }
46 #else                           /* !__cplusplus */
47 #  define BEGIN_C_DECLS
48 #  define END_C_DECLS
49 #endif                          /* __cplusplus */
50
51 BEGIN_C_DECLS
52 /****h* OpenSM Event plugin interface
53 * DESCRIPTION
54 *       Database interface to record subnet events
55 *
56 *       Implementations of this object _MUST_ be thread safe.
57 *
58 * AUTHOR
59 *       Ira Weiny, LLNL
60 *
61 *********/
62
63 #define OSM_EPI_NODE_NAME_LEN (128)
64
65 struct osm_opensm;
66 /** =========================================================================
67  * Event types
68  */
69 typedef enum {
70         OSM_EVENT_ID_PORT_ERRORS = 0,
71         OSM_EVENT_ID_PORT_DATA_COUNTERS,
72         OSM_EVENT_ID_PORT_SELECT,
73         OSM_EVENT_ID_TRAP,
74         OSM_EVENT_ID_SUBNET_UP,
75         OSM_EVENT_ID_MAX
76 } osm_epi_event_id_t;
77
78 typedef struct osm_epi_port_id {
79         uint64_t node_guid;
80         uint8_t port_num;
81         char node_name[OSM_EPI_NODE_NAME_LEN];
82 } osm_epi_port_id_t;
83
84 /** =========================================================================
85  * Port error event
86  * OSM_EVENT_ID_PORT_COUNTER
87  * This is a difference from the last reading.  NOT an absolute reading.
88  */
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;
93         uint64_t link_downed;
94         uint64_t rcv_err;
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;
103         time_t time_diff_s;
104 } osm_epi_pe_event_t;
105
106 /** =========================================================================
107  * Port data counter event
108  * This is a difference from the last reading.  NOT an absolute reading.
109  */
110 typedef struct osm_epi_dc_event {
111         osm_epi_port_id_t port_id;
112         uint64_t xmit_data;
113         uint64_t rcv_data;
114         uint64_t xmit_pkts;
115         uint64_t rcv_pkts;
116         uint64_t unicast_xmit_pkts;
117         uint64_t unicast_rcv_pkts;
118         uint64_t multicast_xmit_pkts;
119         uint64_t multicast_rcv_pkts;
120         time_t time_diff_s;
121 } osm_epi_dc_event_t;
122
123 /** =========================================================================
124  * Port select event
125  * This is a difference from the last reading.  NOT an absolute reading.
126  */
127 typedef struct osm_api_ps_event {
128         osm_epi_port_id_t port_id;
129         uint64_t xmit_wait;
130         time_t time_diff_s;
131 } osm_epi_ps_event_t;
132
133 /** =========================================================================
134  * Trap events
135  */
136 typedef struct osm_epi_trap_event {
137         osm_epi_port_id_t port_id;
138         uint8_t type;
139         uint32_t prod_type;
140         uint16_t trap_num;
141         uint16_t issuer_lid;
142         time_t time;
143 } osm_epi_trap_event_t;
144
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
149  */
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;
160
161 /** =========================================================================
162  * The plugin structure should be considered opaque
163  */
164 typedef struct osm_epi_plugin {
165         cl_list_item_t list;
166         void *handle;
167         osm_event_plugin_t *impl;
168         void *plugin_data;
169         char *plugin_name;
170 } osm_epi_plugin_t;
171
172 /**
173  * functions
174  */
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);
177
178 /** =========================================================================
179  * Helper functions
180  */
181 static inline void
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)
184 {
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';
189 }
190
191 END_C_DECLS
192 #endif                          /* _OSM_EVENT_PLUGIN_H_ */