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 _PERFMGR_EVENT_DB_H_
36 #define _PERFMGR_EVENT_DB_H_
38 #ifdef ENABLE_OSM_PERF_MGR
42 #include <iba/ib_types.h>
43 #include <complib/cl_qmap.h>
44 #include <complib/cl_passivelock.h>
47 # define BEGIN_C_DECLS extern "C" {
48 # define END_C_DECLS }
49 #else /* !__cplusplus */
50 # define BEGIN_C_DECLS
52 #endif /* __cplusplus */
57 /****h* OpenSM/PerfMgr Event Database
59 * Database interface to record subnet events
61 * Implementations of this object _MUST_ be thread safe.
68 PERFMGR_EVENT_DB_SUCCESS = 0,
69 PERFMGR_EVENT_DB_FAIL,
70 PERFMGR_EVENT_DB_NOMEM,
71 PERFMGR_EVENT_DB_GUIDNOTFOUND,
72 PERFMGR_EVENT_DB_PORTNOTFOUND,
73 PERFMGR_EVENT_DB_NOT_IMPL
76 /** =========================================================================
80 uint64_t symbol_err_cnt;
81 uint64_t link_err_recover;
84 uint64_t rcv_rem_phys_err;
85 uint64_t rcv_switch_relay_err;
86 uint64_t xmit_discards;
87 uint64_t xmit_constraint_err;
88 uint64_t rcv_constraint_err;
89 uint64_t link_integrity;
90 uint64_t buffer_overrun;
91 uint64_t vl15_dropped;
93 } perfmgr_db_err_reading_t;
95 /** =========================================================================
96 * Port data count reading
99 uint64_t xmit_data; /* can be used for std or extended */
100 uint64_t rcv_data; /* can be used for std or extended */
101 uint64_t xmit_pkts; /* can be used for std or extended */
102 uint64_t rcv_pkts; /* can be used for std or extended */
103 uint64_t unicast_xmit_pkts;
104 uint64_t unicast_rcv_pkts;
105 uint64_t multicast_xmit_pkts;
106 uint64_t multicast_rcv_pkts;
108 } perfmgr_db_data_cnt_reading_t;
110 /** =========================================================================
116 } perfmgr_db_ps_reading_t;
118 /** =========================================================================
119 * Dump output options
122 PERFMGR_EVENT_DB_DUMP_HR = 0, /* Human readable */
123 PERFMGR_EVENT_DB_DUMP_MR /* Machine readable */
126 /** =========================================================================
127 * Port counter object.
128 * Store all the port counters for a single port.
130 typedef struct _db_port {
131 perfmgr_db_err_reading_t err_total;
132 perfmgr_db_err_reading_t err_previous;
133 perfmgr_db_data_cnt_reading_t dc_total;
134 perfmgr_db_data_cnt_reading_t dc_previous;
138 /** =========================================================================
139 * group port counters for ports into the nodes
141 #define NODE_NAME_SIZE (IB_NODE_DESCRIPTION_SIZE << 1)
142 typedef struct _db_node {
143 cl_map_item_t map_item; /* must be first */
147 char node_name[NODE_NAME_SIZE];
150 /** =========================================================================
151 * all nodes in the system.
154 cl_qmap_t pc_data; /* stores type (_db_node_t *) */
156 struct osm_perfmgr *perfmgr;
162 perfmgr_db_t *perfmgr_db_construct(struct osm_perfmgr *perfmgr);
163 void perfmgr_db_destroy(perfmgr_db_t * db);
165 perfmgr_db_err_t perfmgr_db_create_entry(perfmgr_db_t * db, uint64_t guid,
166 uint8_t num_ports, char *node_name);
168 perfmgr_db_err_t perfmgr_db_add_err_reading(perfmgr_db_t * db, uint64_t guid,
170 perfmgr_db_err_reading_t * reading);
171 perfmgr_db_err_t perfmgr_db_get_prev_err(perfmgr_db_t * db, uint64_t guid,
173 perfmgr_db_err_reading_t * reading);
174 perfmgr_db_err_t perfmgr_db_clear_prev_err(perfmgr_db_t * db, uint64_t guid,
177 perfmgr_db_err_t perfmgr_db_add_dc_reading(perfmgr_db_t * db, uint64_t guid,
179 perfmgr_db_data_cnt_reading_t *
181 perfmgr_db_err_t perfmgr_db_get_prev_dc(perfmgr_db_t * db, uint64_t guid,
183 perfmgr_db_data_cnt_reading_t *
185 perfmgr_db_err_t perfmgr_db_clear_prev_dc(perfmgr_db_t * db, uint64_t guid,
188 void perfmgr_db_clear_counters(perfmgr_db_t * db);
189 perfmgr_db_err_t perfmgr_db_dump(perfmgr_db_t * db, char *file,
190 perfmgr_db_dump_t dump_type);
191 void perfmgr_db_print_by_name(perfmgr_db_t * db, char *nodename, FILE *fp);
192 void perfmgr_db_print_by_guid(perfmgr_db_t * db, uint64_t guid, FILE *fp);
194 /** =========================================================================
195 * helper functions to fill in the various db objects from wire objects
198 void perfmgr_db_fill_err_read(ib_port_counters_t * wire_read,
199 perfmgr_db_err_reading_t * reading);
200 void perfmgr_db_fill_data_cnt_read_pc(ib_port_counters_t * wire_read,
201 perfmgr_db_data_cnt_reading_t * reading);
202 void perfmgr_db_fill_data_cnt_read_epc(ib_port_counters_ext_t * wire_read,
203 perfmgr_db_data_cnt_reading_t * reading);
207 #endif /* ENABLE_OSM_PERF_MGR */
209 #endif /* _PERFMGR_PM_DB_H_ */