Blame include/opensm/osm_event_plugin.h

Packit 13e616
/*
Packit 13e616
 * Copyright (c) 2013 Mellanox Technologies LTD. All rights reserved.
Packit 13e616
 * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
Packit 13e616
 * Copyright (c) 2007 The Regents of the University of California.
Packit 13e616
 *
Packit 13e616
 * This software is available to you under a choice of one of two
Packit 13e616
 * licenses.  You may choose to be licensed under the terms of the GNU
Packit 13e616
 * General Public License (GPL) Version 2, available from the file
Packit 13e616
 * COPYING in the main directory of this source tree, or the
Packit 13e616
 * OpenIB.org BSD license below:
Packit 13e616
 *
Packit 13e616
 *     Redistribution and use in source and binary forms, with or
Packit 13e616
 *     without modification, are permitted provided that the following
Packit 13e616
 *     conditions are met:
Packit 13e616
 *
Packit 13e616
 *      - Redistributions of source code must retain the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer.
Packit 13e616
 *
Packit 13e616
 *      - Redistributions in binary form must reproduce the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer in the documentation and/or other materials
Packit 13e616
 *        provided with the distribution.
Packit 13e616
 *
Packit 13e616
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit 13e616
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit 13e616
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit 13e616
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
Packit 13e616
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
Packit 13e616
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit 13e616
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit 13e616
 * SOFTWARE.
Packit 13e616
 *
Packit 13e616
 */
Packit 13e616
Packit 13e616
#ifndef _OSM_EVENT_PLUGIN_H_
Packit 13e616
#define _OSM_EVENT_PLUGIN_H_
Packit 13e616
Packit 13e616
#include <time.h>
Packit 13e616
#include <iba/ib_types.h>
Packit 13e616
#include <complib/cl_qlist.h>
Packit 13e616
#include <opensm/osm_config.h>
Packit 13e616
#include <opensm/osm_switch.h>
Packit 13e616
Packit 13e616
#ifdef __cplusplus
Packit 13e616
#  define BEGIN_C_DECLS extern "C" {
Packit 13e616
#  define END_C_DECLS   }
Packit 13e616
#else				/* !__cplusplus */
Packit 13e616
#  define BEGIN_C_DECLS
Packit 13e616
#  define END_C_DECLS
Packit 13e616
#endif				/* __cplusplus */
Packit 13e616
Packit 13e616
BEGIN_C_DECLS
Packit 13e616
/****h* OpenSM Event plugin interface
Packit 13e616
* DESCRIPTION
Packit 13e616
*       Database interface to record subnet events
Packit 13e616
*
Packit 13e616
*       Implementations of this object _MUST_ be thread safe.
Packit 13e616
*
Packit 13e616
* AUTHOR
Packit 13e616
*	Ira Weiny, LLNL
Packit 13e616
*
Packit 13e616
*********/
Packit 13e616
Packit 13e616
#define OSM_EPI_NODE_NAME_LEN (65)
Packit 13e616
Packit 13e616
struct osm_opensm;
Packit 13e616
/** =========================================================================
Packit 13e616
 * Event types
Packit 13e616
 */
Packit 13e616
typedef enum {
Packit 13e616
	OSM_EVENT_ID_PORT_ERRORS = 0,
Packit 13e616
	OSM_EVENT_ID_PORT_DATA_COUNTERS,
Packit 13e616
	OSM_EVENT_ID_PORT_SELECT,
Packit 13e616
	OSM_EVENT_ID_TRAP,
Packit 13e616
	OSM_EVENT_ID_SUBNET_UP,
Packit 13e616
	OSM_EVENT_ID_HEAVY_SWEEP_START,
Packit 13e616
	OSM_EVENT_ID_HEAVY_SWEEP_DONE,
Packit 13e616
	OSM_EVENT_ID_UCAST_ROUTING_DONE,
Packit 13e616
	OSM_EVENT_ID_STATE_CHANGE,
Packit 13e616
	OSM_EVENT_ID_SA_DB_DUMPED,
Packit 13e616
	OSM_EVENT_ID_LFT_CHANGE,
Packit 13e616
	OSM_EVENT_ID_MAX
Packit 13e616
} osm_epi_event_id_t;
Packit 13e616
Packit 13e616
typedef struct osm_epi_port_id {
Packit 13e616
	uint64_t node_guid;
Packit 13e616
	uint8_t port_num;
Packit 13e616
	char node_name[OSM_EPI_NODE_NAME_LEN];
Packit 13e616
} osm_epi_port_id_t;
Packit 13e616
Packit 13e616
typedef enum {
Packit 13e616
	LFT_CHANGED_LFT_TOP = (1 << 0),
Packit 13e616
	LFT_CHANGED_BLOCK = (1 << 1)
Packit 13e616
} osm_epi_lft_change_flags_t;
Packit 13e616
Packit 13e616
typedef enum {
Packit 13e616
	UCAST_ROUTING_NONE,
Packit 13e616
	UCAST_ROUTING_HEAVY_SWEEP,
Packit 13e616
	UCAST_ROUTING_REROUTE
Packit 13e616
} osm_epi_ucast_routing_flags_t;
Packit 13e616
Packit 13e616
typedef struct osm_epi_lft_change_event {
Packit 13e616
	osm_switch_t *p_sw;
Packit 13e616
	osm_epi_lft_change_flags_t flags;
Packit 13e616
	uint16_t lft_top;
Packit 13e616
	uint32_t block_num;
Packit 13e616
} osm_epi_lft_change_event_t;
Packit 13e616
Packit 13e616
/** =========================================================================
Packit 13e616
 * Port error event
Packit 13e616
 * OSM_EVENT_ID_PORT_COUNTER
Packit 13e616
 * This is a difference from the last reading.  NOT an absolute reading.
Packit 13e616
 */
Packit 13e616
typedef struct osm_epi_pe_event {
Packit 13e616
	osm_epi_port_id_t port_id;
Packit 13e616
	uint64_t symbol_err_cnt;
Packit 13e616
	uint64_t link_err_recover;
Packit 13e616
	uint64_t link_downed;
Packit 13e616
	uint64_t rcv_err;
Packit 13e616
	uint64_t rcv_rem_phys_err;
Packit 13e616
	uint64_t rcv_switch_relay_err;
Packit 13e616
	uint64_t xmit_discards;
Packit 13e616
	uint64_t xmit_constraint_err;
Packit 13e616
	uint64_t rcv_constraint_err;
Packit 13e616
	uint64_t link_integrity;
Packit 13e616
	uint64_t buffer_overrun;
Packit 13e616
	uint64_t vl15_dropped;
Packit 13e616
	uint64_t xmit_wait;
Packit 13e616
	time_t time_diff_s;
Packit 13e616
} osm_epi_pe_event_t;
Packit 13e616
Packit 13e616
/** =========================================================================
Packit 13e616
 * Port data counter event
Packit 13e616
 * This is a difference from the last reading.  NOT an absolute reading.
Packit 13e616
 */
Packit 13e616
typedef struct osm_epi_dc_event {
Packit 13e616
	osm_epi_port_id_t port_id;
Packit 13e616
	uint64_t xmit_data;
Packit 13e616
	uint64_t rcv_data;
Packit 13e616
	uint64_t xmit_pkts;
Packit 13e616
	uint64_t rcv_pkts;
Packit 13e616
	uint64_t unicast_xmit_pkts;
Packit 13e616
	uint64_t unicast_rcv_pkts;
Packit 13e616
	uint64_t multicast_xmit_pkts;
Packit 13e616
	uint64_t multicast_rcv_pkts;
Packit 13e616
	time_t time_diff_s;
Packit 13e616
} osm_epi_dc_event_t;
Packit 13e616
Packit 13e616
/** =========================================================================
Packit 13e616
 * Port select event
Packit 13e616
 * This is a difference from the last reading.  NOT an absolute reading.
Packit 13e616
 */
Packit 13e616
typedef struct osm_api_ps_event {
Packit 13e616
	osm_epi_port_id_t port_id;
Packit 13e616
	uint64_t xmit_wait;
Packit 13e616
	time_t time_diff_s;
Packit 13e616
} osm_epi_ps_event_t;
Packit 13e616
Packit 13e616
/** =========================================================================
Packit 13e616
 * Plugin creators should allocate an object of this type
Packit 13e616
 *    (named OSM_EVENT_PLUGIN_IMPL_NAME)
Packit 13e616
 * The version should be set to OSM_EVENT_PLUGIN_INTERFACE_VER
Packit 13e616
 */
Packit 13e616
#define OSM_EVENT_PLUGIN_IMPL_NAME "osm_event_plugin"
Packit 13e616
#define OSM_ORIG_EVENT_PLUGIN_INTERFACE_VER 1
Packit 13e616
#define OSM_EVENT_PLUGIN_INTERFACE_VER 2
Packit 13e616
typedef struct osm_event_plugin {
Packit 13e616
	const char *osm_version;
Packit 13e616
	void *(*create) (struct osm_opensm *osm);
Packit 13e616
	void (*delete) (void *plugin_data);
Packit 13e616
	void (*report) (void *plugin_data, osm_epi_event_id_t event_id,
Packit 13e616
			void *event_data);
Packit 13e616
} osm_event_plugin_t;
Packit 13e616
Packit 13e616
/** =========================================================================
Packit 13e616
 * The plugin structure should be considered opaque
Packit 13e616
 */
Packit 13e616
typedef struct osm_epi_plugin {
Packit 13e616
	cl_list_item_t list;
Packit 13e616
	void *handle;
Packit 13e616
	osm_event_plugin_t *impl;
Packit 13e616
	void *plugin_data;
Packit 13e616
	char *plugin_name;
Packit 13e616
} osm_epi_plugin_t;
Packit 13e616
Packit 13e616
/**
Packit 13e616
 * functions
Packit 13e616
 */
Packit 13e616
osm_epi_plugin_t *osm_epi_construct(struct osm_opensm *osm, char *plugin_name);
Packit 13e616
void osm_epi_destroy(osm_epi_plugin_t * plugin);
Packit 13e616
Packit 13e616
/** =========================================================================
Packit 13e616
 * Helper functions
Packit 13e616
 */
Packit 13e616
static inline void
Packit 13e616
osm_epi_create_port_id(osm_epi_port_id_t * port_id, uint64_t node_guid,
Packit 13e616
		       uint8_t port_num, char *node_name)
Packit 13e616
{
Packit 13e616
	port_id->node_guid = node_guid;
Packit 13e616
	port_id->port_num = port_num;
Packit 13e616
	strncpy(port_id->node_name, node_name, OSM_EPI_NODE_NAME_LEN);
Packit 13e616
	port_id->node_name[OSM_EPI_NODE_NAME_LEN - 1] = '\0';
Packit 13e616
}
Packit 13e616
Packit 13e616
END_C_DECLS
Packit 13e616
#endif				/* _OSM_EVENT_PLUGIN_H_ */