xref: /titanic_52/usr/src/uts/common/sys/ib/mgt/ibcm/ibcm_trace.h (revision 9d3d2ed09c8e9ba0b2ba44fdd1dd300b2c3f9e8e)
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 	IBCM_TRACE_OUT_REQ_RETRY,
127 	IBCM_TRACE_OUT_REP_RETRY,
128 	IBCM_TRACE_OUT_LAP_RETRY,
129 	IBCM_TRACE_OUT_MRA_RETRY,
130 	IBCM_TRACE_OUT_DREQ_RETRY,
131 
132 	/* End Marker */
133 	IBCM_TRACE_END_MARKER
134 
135 } ibcm_state_rc_trace_qualifier_t;
136 
137 /* Number of traces per connection chunk */
138 #define		IBCM_MAX_CONN_TRCNT		40
139 #define		IBCM_DEBUG_BUF_SIZE		4096
140 
141 /* If the trace time diff type is changed in the future, modify below */
142 #define		TM_DIFF_MAX			UINT32_MAX
143 typedef		uint32_t			tm_diff_type;
144 
145 /*
146  * The following structure stores the trace data per connection, and
147  * defined as a field in ibcm_state_data_t.
148  *
149  * conn_trace_options:
150  *	Stores various active trace options, like whether time stamp stored,
151  *	detailed trace data stored, etc.,
152  * conn_qpn:
153  *	QPN of channel used for connection
154  * conn_chan:
155  *	Channel used for connection
156  * conn_base_tm:
157  *	Base time stamp in usec, when the first trace for this connection has
158  *	been recorded. Gethrtime is used to record the base time stamp.
159  * conn_trace_events:
160  *	Trace events recorded for the connection
161  * conn_trace_event_times:
162  *	Trace event times recorded for the connection
163  * conn_trace_ind:
164  *	Index into trace_events, where the next trace event shall be stored
165  * conn_allocated_trcnt:
166  *	Allocated number of trace entries
167  */
168 typedef struct ibcm_conn_trace_s {
169 	hrtime_t		conn_base_tm;
170 	uint8_t			*conn_trace_events;
171 	tm_diff_type		*conn_trace_event_times;
172 	uint8_t			conn_trace_ind;
173 	uint16_t		conn_allocated_trcnt;
174 } ibcm_conn_trace_t;
175 
176 /* function that inserts a new trace into ibcm_conn_trace_t */
177 void	ibcm_insert_trace(void *statep,
178 	    ibcm_state_rc_trace_qualifier_t event_qualifier);
179 
180 /* dumps the connection trace into ibtf_debug_buf */
181 void	ibcm_dump_conn_trace(void *statep);
182 
183 extern char	ibcm_debug_buf[];
184 
185 extern kmutex_t	ibcm_trace_mutex;
186 extern kmutex_t	ibcm_trace_print_mutex;
187 extern int	ibcm_conn_max_trcnt;
188 
189 /*
190  *	ibcm_enable_trace has the following flag bits:
191  *
192  *		0	No tracing performed.
193  *		1	Tracing without timing.
194  *		2	Trace failed connections.
195  *		4	Trace all connections.
196  */
197 extern int	ibcm_enable_trace;
198 
199 extern char	*event_str[];
200 
201 #ifdef	__cplusplus
202 }
203 #endif
204 
205 #endif /* _SYS_IB_MGT_IBCM_IBCM_TRACE_H */
206