1/* 2 * Copyright (c) 2013 Mellanox Technologies LTD. All rights reserved. 3 * Copyright (c) 2008 Voltaire, Inc. All rights reserved. 4 * Copyright (c) 2007 The Regents of the University of California. 5 * 6 * This software is available to you under a choice of one of two 7 * licenses. You may choose to be licensed under the terms of the GNU 8 * General Public License (GPL) Version 2, available from the file 9 * COPYING in the main directory of this source tree, or the 10 * OpenIB.org BSD license below: 11 * 12 * Redistribution and use in source and binary forms, with or 13 * without modification, are permitted provided that the following 14 * conditions are met: 15 * 16 * - Redistributions of source code must retain the above 17 * copyright notice, this list of conditions and the following 18 * disclaimer. 19 * 20 * - Redistributions in binary form must reproduce the above 21 * copyright notice, this list of conditions and the following 22 * disclaimer in the documentation and/or other materials 23 * provided with the distribution. 24 * 25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * SOFTWARE. 33 * 34 */ 35 36#ifndef _OSM_EVENT_PLUGIN_H_ 37#define _OSM_EVENT_PLUGIN_H_ 38 39#include <time.h> 40#include <iba/ib_types.h> 41#include <complib/cl_qlist.h> 42#include <opensm/osm_config.h> 43#include <opensm/osm_switch.h> 44 45#ifdef __cplusplus 46# define BEGIN_C_DECLS extern "C" { 47# define END_C_DECLS } 48#else /* !__cplusplus */ 49# define BEGIN_C_DECLS 50# define END_C_DECLS 51#endif /* __cplusplus */ 52 53BEGIN_C_DECLS 54/****h* OpenSM Event plugin interface 55* DESCRIPTION 56* Database interface to record subnet events 57* 58* Implementations of this object _MUST_ be thread safe. 59* 60* AUTHOR 61* Ira Weiny, LLNL 62* 63*********/ 64 65#define OSM_EPI_NODE_NAME_LEN (65) 66 67struct osm_opensm; 68/** ========================================================================= 69 * Event types 70 */ 71typedef enum { 72 OSM_EVENT_ID_PORT_ERRORS = 0, 73 OSM_EVENT_ID_PORT_DATA_COUNTERS, 74 OSM_EVENT_ID_PORT_SELECT, 75 OSM_EVENT_ID_TRAP, 76 OSM_EVENT_ID_SUBNET_UP, 77 OSM_EVENT_ID_HEAVY_SWEEP_START, 78 OSM_EVENT_ID_HEAVY_SWEEP_DONE, 79 OSM_EVENT_ID_UCAST_ROUTING_DONE, 80 OSM_EVENT_ID_STATE_CHANGE, 81 OSM_EVENT_ID_SA_DB_DUMPED, 82 OSM_EVENT_ID_LFT_CHANGE, 83 OSM_EVENT_ID_MAX 84} osm_epi_event_id_t; 85 86typedef struct osm_epi_port_id { 87 uint64_t node_guid; 88 uint8_t port_num; 89 char node_name[OSM_EPI_NODE_NAME_LEN]; 90} osm_epi_port_id_t; 91 92typedef enum { 93 LFT_CHANGED_LFT_TOP = (1 << 0), 94 LFT_CHANGED_BLOCK = (1 << 1) 95} osm_epi_lft_change_flags_t; 96 97typedef enum { 98 UCAST_ROUTING_NONE, 99 UCAST_ROUTING_HEAVY_SWEEP, 100 UCAST_ROUTING_REROUTE 101} osm_epi_ucast_routing_flags_t; 102 103typedef struct osm_epi_lft_change_event { 104 osm_switch_t *p_sw; 105 osm_epi_lft_change_flags_t flags; 106 uint16_t lft_top; 107 uint32_t block_num; 108} osm_epi_lft_change_event_t; 109 110/** ========================================================================= 111 * Port error event 112 * OSM_EVENT_ID_PORT_COUNTER 113 * This is a difference from the last reading. NOT an absolute reading. 114 */ 115typedef struct osm_epi_pe_event { 116 osm_epi_port_id_t port_id; 117 uint64_t symbol_err_cnt; 118 uint64_t link_err_recover; 119 uint64_t link_downed; 120 uint64_t rcv_err; 121 uint64_t rcv_rem_phys_err; 122 uint64_t rcv_switch_relay_err; 123 uint64_t xmit_discards; 124 uint64_t xmit_constraint_err; 125 uint64_t rcv_constraint_err; 126 uint64_t link_integrity; 127 uint64_t buffer_overrun; 128 uint64_t vl15_dropped; 129 uint64_t xmit_wait; 130 time_t time_diff_s; 131} osm_epi_pe_event_t; 132 133/** ========================================================================= 134 * Port data counter event 135 * This is a difference from the last reading. NOT an absolute reading. 136 */ 137typedef struct osm_epi_dc_event { 138 osm_epi_port_id_t port_id; 139 uint64_t xmit_data; 140 uint64_t rcv_data; 141 uint64_t xmit_pkts; 142 uint64_t rcv_pkts; 143 uint64_t unicast_xmit_pkts; 144 uint64_t unicast_rcv_pkts; 145 uint64_t multicast_xmit_pkts; 146 uint64_t multicast_rcv_pkts; 147 time_t time_diff_s; 148} osm_epi_dc_event_t; 149 150/** ========================================================================= 151 * Port select event 152 * This is a difference from the last reading. NOT an absolute reading. 153 */ 154typedef struct osm_api_ps_event { 155 osm_epi_port_id_t port_id; 156 uint64_t xmit_wait; 157 time_t time_diff_s; 158} osm_epi_ps_event_t; 159 160/** ========================================================================= 161 * Plugin creators should allocate an object of this type 162 * (named OSM_EVENT_PLUGIN_IMPL_NAME) 163 * The version should be set to OSM_EVENT_PLUGIN_INTERFACE_VER 164 */ 165#define OSM_EVENT_PLUGIN_IMPL_NAME "osm_event_plugin" 166#define OSM_ORIG_EVENT_PLUGIN_INTERFACE_VER 1 167#define OSM_EVENT_PLUGIN_INTERFACE_VER 2 168typedef struct osm_event_plugin { 169 const char *osm_version; 170 void *(*create) (struct osm_opensm *osm); 171 void (*delete) (void *plugin_data); 172 void (*report) (void *plugin_data, osm_epi_event_id_t event_id, 173 void *event_data); 174} osm_event_plugin_t; 175 176/** ========================================================================= 177 * The plugin structure should be considered opaque 178 */ 179typedef struct osm_epi_plugin { 180 cl_list_item_t list; 181 void *handle; 182 osm_event_plugin_t *impl; 183 void *plugin_data; 184 char *plugin_name; 185} osm_epi_plugin_t; 186 187/** 188 * functions 189 */ 190osm_epi_plugin_t *osm_epi_construct(struct osm_opensm *osm, char *plugin_name); 191void osm_epi_destroy(osm_epi_plugin_t * plugin); 192 193/** ========================================================================= 194 * Helper functions 195 */ 196static inline void 197osm_epi_create_port_id(osm_epi_port_id_t * port_id, uint64_t node_guid, 198 uint8_t port_num, char *node_name) 199{ 200 port_id->node_guid = node_guid; 201 port_id->port_num = port_num; 202 strncpy(port_id->node_name, node_name, OSM_EPI_NODE_NAME_LEN); 203 port_id->node_name[OSM_EPI_NODE_NAME_LEN - 1] = '\0'; 204} 205 206END_C_DECLS 207#endif /* _OSM_EVENT_PLUGIN_H_ */ 208