xref: /illumos-gate/usr/src/uts/common/sys/ib/mgt/ibcm/ibcm_trace.h (revision 24b28d0419f5763eb5a6bad72f99ae67fa2a8921)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_IB_MGT_IBCM_IBCM_TRACE_H
28 #define	_SYS_IB_MGT_IBCM_IBCM_TRACE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * ibcm_trace.h
38  *
39  * This file contains all of the internal data structures and
40  * definitions for IBCM Trace implementation
41  */
42 
43 /* Defines event qualifiers for detailed traces per RC connection. */
44 typedef enum ibcm_state_rc_trace_qualifier_e {
45 
46 	/* Initial headers */
47 	IBCM_DISPLAY_SID		= 1,
48 	IBCM_DISPLAY_CHAN,
49 	IBCM_DISPLAY_LCID,
50 	IBCM_DISPLAY_LQPN,
51 	IBCM_DISPLAY_RCID,
52 	IBCM_DISPLAY_RQPN,
53 	IBCM_DISPLAY_TM,
54 
55 	/* List possible Incoming MADs */
56 	IBCM_TRACE_INCOMING_REQ,
57 	IBCM_TRACE_INCOMING_REP,
58 	IBCM_TRACE_INCOMING_RTU,
59 	IBCM_TRACE_INCOMING_COMEST,
60 	IBCM_TRACE_INCOMING_MRA,
61 	IBCM_TRACE_INCOMING_REJ,
62 	IBCM_TRACE_INCOMING_LAP,
63 	IBCM_TRACE_INCOMING_APR,
64 	IBCM_TRACE_INCOMING_DREQ,
65 	IBCM_TRACE_INCOMING_DREP,
66 
67 	/* List possible outgoing MADs */
68 	IBCM_TRACE_OUTGOING_REQ,
69 	IBCM_TRACE_OUTGOING_REP,
70 	IBCM_TRACE_OUTGOING_RTU,
71 	IBCM_TRACE_OUTGOING_LAP,
72 	IBCM_TRACE_OUTGOING_APR,
73 	IBCM_TRACE_OUTGOING_MRA,
74 	IBCM_TRACE_OUTGOING_REJ,
75 	IBCM_TRACE_OUTGOING_DREQ,
76 	IBCM_TRACE_OUTGOING_DREP,
77 
78 	/* List of ibmf send completions */
79 	IBCM_TRACE_REQ_POST_COMPLETE,
80 	IBCM_TRACE_REP_POST_COMPLETE,
81 	IBCM_TRACE_RTU_POST_COMPLETE,
82 	IBCM_TRACE_MRA_POST_COMPLETE,
83 	IBCM_TRACE_REJ_POST_COMPLETE,
84 	IBCM_TRACE_LAP_POST_COMPLETE,
85 	IBCM_TRACE_APR_POST_COMPLETE,
86 	IBCM_TRACE_DREQ_POST_COMPLETE,
87 	IBCM_TRACE_DREP_POST_COMPLETE,
88 
89 	/* List possible timeouts. Other timeouts always re-post MADs */
90 	IBCM_TRACE_TIMEOUT_REP,
91 
92 	/* client handler related */
93 	IBCM_TRACE_CALLED_REQ_RCVD_EVENT,
94 	IBCM_TRACE_RET_REQ_RCVD_EVENT,
95 
96 	IBCM_TRACE_CALLED_REP_RCVD_EVENT,
97 	IBCM_TRACE_RET_REP_RCVD_EVENT,
98 
99 	/* client handler related */
100 	IBCM_TRACE_CALLED_CONN_EST_EVENT,
101 	IBCM_TRACE_RET_CONN_EST_EVENT,
102 
103 	IBCM_TRACE_CALLED_CONN_FAIL_EVENT,
104 	IBCM_TRACE_RET_CONN_FAIL_EVENT,
105 
106 	IBCM_TRACE_CALLED_CONN_CLOSE_EVENT,
107 	IBCM_TRACE_RET_CONN_CLOSE_EVENT,
108 
109 	/* RC QP state change related */
110 	IBCM_TRACE_INIT_INIT,
111 	IBCM_TRACE_INIT_INIT_FAIL,
112 	IBCM_TRACE_INIT_RTR,
113 	IBCM_TRACE_INIT_RTR_FAIL,
114 	IBCM_TRACE_RTR_RTS,
115 	IBCM_TRACE_RTR_RTS_FAIL,
116 	IBCM_TRACE_RTS_RTS,
117 	IBCM_TRACE_RTS_RTS_FAIL,
118 	IBCM_TRACE_ERROR,
119 	IBCM_TRACE_ERROR_FAIL,
120 	IBCM_TRACE_SET_ALT,
121 	IBCM_TRACE_SET_ALT_FAIL,
122 
123 	/* special event related */
124 	IBCM_TRACE_STALE_DETECT,
125 
126 	/* End Marker */
127 	IBCM_TRACE_END_MARKER
128 
129 } ibcm_state_rc_trace_qualifier_t;
130 
131 /* Number of traces per connection chunk */
132 #define		IBCM_MAX_CONN_TRCNT		32
133 #define		IBCM_DEBUG_BUF_SIZE		4096
134 
135 /* If the trace time diff type is changed in the future, modify below */
136 #define		TM_DIFF_MAX			UINT32_MAX
137 typedef		uint32_t			tm_diff_type;
138 
139 /*
140  * The following structure stores the trace data per connection, and
141  * defined as a field in ibcm_state_data_t.
142  *
143  * conn_trace_options:
144  *	Stores various active trace options, like whether time stamp stored,
145  *	detailed trace data stored, etc.,
146  * conn_qpn:
147  *	QPN of channel used for connection
148  * conn_chan:
149  *	Channel used for connection
150  * conn_base_tm:
151  *	Base time stamp in usec, when the first trace for this connection has
152  *	been recorded. Gethrtime is used to record the base time stamp.
153  * conn_trace_events:
154  *	Trace events recorded for the connection
155  * conn_trace_event_times:
156  *	Trace event times recorded for the connection
157  * conn_trace_ind:
158  *	Index into trace_events, where the next trace event shall be stored
159  * conn_allocated_trcnt:
160  *	Allocated number of trace entries
161  */
162 typedef struct ibcm_conn_trace_s {
163 	hrtime_t		conn_base_tm;
164 	uint8_t			*conn_trace_events;
165 	tm_diff_type		*conn_trace_event_times;
166 	uint8_t			conn_trace_ind;
167 	uint16_t		conn_allocated_trcnt;
168 } ibcm_conn_trace_t;
169 
170 /* function that inserts a new trace into ibcm_conn_trace_t */
171 void	ibcm_insert_trace(void *statep,
172 	    ibcm_state_rc_trace_qualifier_t event_qualifier);
173 
174 /* dumps the connection trace into ibtf_debug_buf */
175 void	ibcm_dump_conn_trace(void *statep);
176 
177 extern char	ibcm_debug_buf[];
178 
179 extern kmutex_t	ibcm_trace_mutex;
180 extern kmutex_t	ibcm_trace_print_mutex;
181 extern int	ibcm_conn_max_trcnt;
182 
183 /*
184  *	ibcm_enable_trace has the following flag bits:
185  *
186  *		0	No tracing performed.
187  *		1	Tracing without timing.
188  *		2	Trace failed connections.
189  *		4	Trace all connections.
190  */
191 extern int	ibcm_enable_trace;
192 
193 extern char	*event_str[];
194 
195 #ifdef	__cplusplus
196 }
197 #endif
198 
199 #endif /* _SYS_IB_MGT_IBCM_IBCM_TRACE_H */
200