xref: /onnv-gate/usr/src/uts/common/sys/ib/mgt/ibcm/ibcm_trace.h (revision 1093:4dc7aec69dc9)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
23401Shiremath  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef _SYS_IB_MGT_IBCM_IBCM_TRACE_H
280Sstevel@tonic-gate #define	_SYS_IB_MGT_IBCM_IBCM_TRACE_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifdef __cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
360Sstevel@tonic-gate /*
370Sstevel@tonic-gate  * ibcm_trace.h
380Sstevel@tonic-gate  *
390Sstevel@tonic-gate  * This file contains all of the internal data structures and
400Sstevel@tonic-gate  * definitions for IBCM Trace implementation
410Sstevel@tonic-gate  */
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /* Defines event qualifiers for detailed traces per RC connection. */
440Sstevel@tonic-gate typedef enum ibcm_state_rc_trace_qualifier_e {
450Sstevel@tonic-gate 
460Sstevel@tonic-gate 	/* Initial headers */
470Sstevel@tonic-gate 	IBCM_DISPLAY_SID		= 1,
480Sstevel@tonic-gate 	IBCM_DISPLAY_CHAN,
490Sstevel@tonic-gate 	IBCM_DISPLAY_LCID,
500Sstevel@tonic-gate 	IBCM_DISPLAY_LQPN,
510Sstevel@tonic-gate 	IBCM_DISPLAY_RCID,
520Sstevel@tonic-gate 	IBCM_DISPLAY_RQPN,
530Sstevel@tonic-gate 	IBCM_DISPLAY_TM,
540Sstevel@tonic-gate 
550Sstevel@tonic-gate 	/* List possible Incoming MADs */
560Sstevel@tonic-gate 	IBCM_TRACE_INCOMING_REQ,
570Sstevel@tonic-gate 	IBCM_TRACE_INCOMING_REP,
580Sstevel@tonic-gate 	IBCM_TRACE_INCOMING_RTU,
590Sstevel@tonic-gate 	IBCM_TRACE_INCOMING_COMEST,
600Sstevel@tonic-gate 	IBCM_TRACE_INCOMING_MRA,
610Sstevel@tonic-gate 	IBCM_TRACE_INCOMING_REJ,
620Sstevel@tonic-gate 	IBCM_TRACE_INCOMING_LAP,
630Sstevel@tonic-gate 	IBCM_TRACE_INCOMING_APR,
640Sstevel@tonic-gate 	IBCM_TRACE_INCOMING_DREQ,
650Sstevel@tonic-gate 	IBCM_TRACE_INCOMING_DREP,
660Sstevel@tonic-gate 
670Sstevel@tonic-gate 	/* List possible outgoing MADs */
680Sstevel@tonic-gate 	IBCM_TRACE_OUTGOING_REQ,
690Sstevel@tonic-gate 	IBCM_TRACE_OUTGOING_REP,
700Sstevel@tonic-gate 	IBCM_TRACE_OUTGOING_RTU,
710Sstevel@tonic-gate 	IBCM_TRACE_OUTGOING_LAP,
720Sstevel@tonic-gate 	IBCM_TRACE_OUTGOING_APR,
730Sstevel@tonic-gate 	IBCM_TRACE_OUTGOING_MRA,
740Sstevel@tonic-gate 	IBCM_TRACE_OUTGOING_REJ,
750Sstevel@tonic-gate 	IBCM_TRACE_OUTGOING_DREQ,
760Sstevel@tonic-gate 	IBCM_TRACE_OUTGOING_DREP,
770Sstevel@tonic-gate 
780Sstevel@tonic-gate 	/* List of ibmf send completions */
790Sstevel@tonic-gate 	IBCM_TRACE_REQ_POST_COMPLETE,
800Sstevel@tonic-gate 	IBCM_TRACE_REP_POST_COMPLETE,
810Sstevel@tonic-gate 	IBCM_TRACE_RTU_POST_COMPLETE,
820Sstevel@tonic-gate 	IBCM_TRACE_MRA_POST_COMPLETE,
830Sstevel@tonic-gate 	IBCM_TRACE_REJ_POST_COMPLETE,
840Sstevel@tonic-gate 	IBCM_TRACE_LAP_POST_COMPLETE,
850Sstevel@tonic-gate 	IBCM_TRACE_APR_POST_COMPLETE,
860Sstevel@tonic-gate 	IBCM_TRACE_DREQ_POST_COMPLETE,
870Sstevel@tonic-gate 	IBCM_TRACE_DREP_POST_COMPLETE,
880Sstevel@tonic-gate 
890Sstevel@tonic-gate 	/* List possible timeouts. Other timeouts always re-post MADs */
900Sstevel@tonic-gate 	IBCM_TRACE_TIMEOUT_REP,
910Sstevel@tonic-gate 
920Sstevel@tonic-gate 	/* client handler related */
930Sstevel@tonic-gate 	IBCM_TRACE_CALLED_REQ_RCVD_EVENT,
940Sstevel@tonic-gate 	IBCM_TRACE_RET_REQ_RCVD_EVENT,
950Sstevel@tonic-gate 
960Sstevel@tonic-gate 	IBCM_TRACE_CALLED_REP_RCVD_EVENT,
970Sstevel@tonic-gate 	IBCM_TRACE_RET_REP_RCVD_EVENT,
980Sstevel@tonic-gate 
990Sstevel@tonic-gate 	/* client handler related */
1000Sstevel@tonic-gate 	IBCM_TRACE_CALLED_CONN_EST_EVENT,
1010Sstevel@tonic-gate 	IBCM_TRACE_RET_CONN_EST_EVENT,
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate 	IBCM_TRACE_CALLED_CONN_FAIL_EVENT,
1040Sstevel@tonic-gate 	IBCM_TRACE_RET_CONN_FAIL_EVENT,
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate 	IBCM_TRACE_CALLED_CONN_CLOSE_EVENT,
1070Sstevel@tonic-gate 	IBCM_TRACE_RET_CONN_CLOSE_EVENT,
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate 	/* RC QP state change related */
1100Sstevel@tonic-gate 	IBCM_TRACE_INIT_INIT,
1110Sstevel@tonic-gate 	IBCM_TRACE_INIT_INIT_FAIL,
1120Sstevel@tonic-gate 	IBCM_TRACE_INIT_RTR,
1130Sstevel@tonic-gate 	IBCM_TRACE_INIT_RTR_FAIL,
1140Sstevel@tonic-gate 	IBCM_TRACE_RTR_RTS,
1150Sstevel@tonic-gate 	IBCM_TRACE_RTR_RTS_FAIL,
1160Sstevel@tonic-gate 	IBCM_TRACE_RTS_RTS,
1170Sstevel@tonic-gate 	IBCM_TRACE_RTS_RTS_FAIL,
1180Sstevel@tonic-gate 	IBCM_TRACE_ERROR,
1190Sstevel@tonic-gate 	IBCM_TRACE_ERROR_FAIL,
1200Sstevel@tonic-gate 	IBCM_TRACE_SET_ALT,
1210Sstevel@tonic-gate 	IBCM_TRACE_SET_ALT_FAIL,
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate 	/* special event related */
1240Sstevel@tonic-gate 	IBCM_TRACE_STALE_DETECT,
1250Sstevel@tonic-gate 
126*1093Shiremath 	IBCM_TRACE_OUT_REQ_RETRY,
127*1093Shiremath 	IBCM_TRACE_OUT_REP_RETRY,
128*1093Shiremath 	IBCM_TRACE_OUT_LAP_RETRY,
129*1093Shiremath 	IBCM_TRACE_OUT_MRA_RETRY,
130*1093Shiremath 	IBCM_TRACE_OUT_DREQ_RETRY,
131*1093Shiremath 
1320Sstevel@tonic-gate 	/* End Marker */
1330Sstevel@tonic-gate 	IBCM_TRACE_END_MARKER
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate } ibcm_state_rc_trace_qualifier_t;
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate /* Number of traces per connection chunk */
138*1093Shiremath #define		IBCM_MAX_CONN_TRCNT		40
1390Sstevel@tonic-gate #define		IBCM_DEBUG_BUF_SIZE		4096
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate /* If the trace time diff type is changed in the future, modify below */
1420Sstevel@tonic-gate #define		TM_DIFF_MAX			UINT32_MAX
1430Sstevel@tonic-gate typedef		uint32_t			tm_diff_type;
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate /*
1460Sstevel@tonic-gate  * The following structure stores the trace data per connection, and
1470Sstevel@tonic-gate  * defined as a field in ibcm_state_data_t.
1480Sstevel@tonic-gate  *
1490Sstevel@tonic-gate  * conn_trace_options:
1500Sstevel@tonic-gate  *	Stores various active trace options, like whether time stamp stored,
1510Sstevel@tonic-gate  *	detailed trace data stored, etc.,
1520Sstevel@tonic-gate  * conn_qpn:
1530Sstevel@tonic-gate  *	QPN of channel used for connection
1540Sstevel@tonic-gate  * conn_chan:
1550Sstevel@tonic-gate  *	Channel used for connection
1560Sstevel@tonic-gate  * conn_base_tm:
1570Sstevel@tonic-gate  *	Base time stamp in usec, when the first trace for this connection has
1580Sstevel@tonic-gate  *	been recorded. Gethrtime is used to record the base time stamp.
1590Sstevel@tonic-gate  * conn_trace_events:
1600Sstevel@tonic-gate  *	Trace events recorded for the connection
1610Sstevel@tonic-gate  * conn_trace_event_times:
1620Sstevel@tonic-gate  *	Trace event times recorded for the connection
1630Sstevel@tonic-gate  * conn_trace_ind:
1640Sstevel@tonic-gate  *	Index into trace_events, where the next trace event shall be stored
1650Sstevel@tonic-gate  * conn_allocated_trcnt:
1660Sstevel@tonic-gate  *	Allocated number of trace entries
1670Sstevel@tonic-gate  */
1680Sstevel@tonic-gate typedef struct ibcm_conn_trace_s {
169401Shiremath 	hrtime_t		conn_base_tm;
1700Sstevel@tonic-gate 	uint8_t			*conn_trace_events;
1710Sstevel@tonic-gate 	tm_diff_type		*conn_trace_event_times;
1720Sstevel@tonic-gate 	uint8_t			conn_trace_ind;
1730Sstevel@tonic-gate 	uint16_t		conn_allocated_trcnt;
1740Sstevel@tonic-gate } ibcm_conn_trace_t;
1750Sstevel@tonic-gate 
1760Sstevel@tonic-gate /* function that inserts a new trace into ibcm_conn_trace_t */
1770Sstevel@tonic-gate void	ibcm_insert_trace(void *statep,
1780Sstevel@tonic-gate 	    ibcm_state_rc_trace_qualifier_t event_qualifier);
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate /* dumps the connection trace into ibtf_debug_buf */
1810Sstevel@tonic-gate void	ibcm_dump_conn_trace(void *statep);
1820Sstevel@tonic-gate 
1830Sstevel@tonic-gate extern char	ibcm_debug_buf[];
1840Sstevel@tonic-gate 
1850Sstevel@tonic-gate extern kmutex_t	ibcm_trace_mutex;
1860Sstevel@tonic-gate extern kmutex_t	ibcm_trace_print_mutex;
1870Sstevel@tonic-gate extern int	ibcm_conn_max_trcnt;
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate /*
1900Sstevel@tonic-gate  *	ibcm_enable_trace has the following flag bits:
1910Sstevel@tonic-gate  *
1920Sstevel@tonic-gate  *		0	No tracing performed.
1930Sstevel@tonic-gate  *		1	Tracing without timing.
1940Sstevel@tonic-gate  *		2	Trace failed connections.
1950Sstevel@tonic-gate  *		4	Trace all connections.
1960Sstevel@tonic-gate  */
1970Sstevel@tonic-gate extern int	ibcm_enable_trace;
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate extern char	*event_str[];
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate #ifdef	__cplusplus
2020Sstevel@tonic-gate }
2030Sstevel@tonic-gate #endif
2040Sstevel@tonic-gate 
2050Sstevel@tonic-gate #endif /* _SYS_IB_MGT_IBCM_IBCM_TRACE_H */
206