xref: /titanic_41/usr/src/uts/common/avs/ns/sdbc/sd_trace.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 
27 #ifndef _SD_TRACE_H
28 #define	_SD_TRACE_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 
35 #ifdef _SD_NOTRACE
36 #define	SDALERT(f, cd, len, fba, flg, ret)
37 #define	SDTRACE(f, cd, len, fba, flg, ret)
38 #define	DATA_LOG_CHAIN(ttype, c_ent, stp, ln)
39 #define	DATA_LOG(ttype, c_ent, stp, ln)
40 #else
41 #define	SDALERT(f, cd, len, fba, flg, ret) \
42 	_sd_alert(f, (int)cd, (int)len, (nsc_off_t)fba, (int)flg, (int)ret)
43 #define	SDTRACE(f, cd, len, fba, flg, ret) \
44 	if (_sd_trace_mask & (f)) \
45 		_sd_trace(f, (int)cd, (int)len, (nsc_off_t)fba,\
46 		    (int)flg, (int)ret)
47 #define	DATA_LOG_CHAIN(ttype, c_ent, stp, ln) \
48 	_sd_data_log_chain((int)(ttype), c_ent, (nsc_off_t)(stp), \
49 	    (nsc_size_t)(ln))
50 #if defined(_SD_FBA_DATA_LOG) || defined(lint)
51 #define	DATA_LOG(ttype, c_ent, stp, ln) \
52 	_sd_data_log((int)(ttype), c_ent, (nsc_off_t)(stp), (nsc_size_t)(ln))
53 #else
54 #define	DATA_LOG(ttype, c_ent, stp, ln) \
55 	SDTRACE(ttype, CENTRY_CD(c_ent), \
56 		ln, (nsc_off_t)(BLK_TO_FBA_NUM(CENTRY_BLK(c_ent)) + stp), \
57 		*(int *)((c_ent)->cc_data+FBA_SIZE(stp)), \
58 		*(int *)((c_ent)->cc_data+FBA_SIZE(stp+ln)-4))
59 #endif /* (_SD_FBA_DATA_LOG) */
60 #endif
61 
62 #define	SDT_INV_CD	-1
63 #define	SDT_ANY_CD	-2
64 #define	SDT_INV_BL	0xffffffff
65 
66 typedef struct _sdtr
67 {
68 	ushort_t t_func;	/* function being traced */
69 	ushort_t t_len;		/* allocation type */
70 	nsc_off_t t_fba;	/* fixed block offset */
71 	int t_flg;		/* buffer size requested */
72 	int t_ret;		/* return value */
73 	int t_time;		/* micro_second timer, or lbolt */
74 				/* low order only on LP64 systems */
75 } _sdtr_t;
76 
77 typedef struct _sdtr_table
78 {
79 	int tt_cd;		/* cache device */
80 	int tt_max;		/* entries in table */
81 	int tt_in;		/* entries added */
82 	int tt_out;		/* entries read */
83 	int tt_cnt;		/* unread entries */
84 	int tt_cntout;		/* tt_cnt after dump */
85 	int tt_mask;		/* copy of _sd_trace_mask */
86 	int tt_lost;		/* lost after alert */
87 	char tt_alert;		/* alert signaled */
88 	char tt_lbolt;		/* use 'lbolt' instead of microsec */
89 	char tt_good;		/* use locking (races with end-action) */
90 	char tt_type;		/* memory region 0 or 1 (_SD_MEM_TRACE) */
91 	_sdtr_t tt_buf[1];	/* per-device trace records [0..tt_max] */
92 } _sdtr_table_t;
93 
94 #if defined(_KERNEL)
95 typedef struct _sdbc_trace_s {
96 	_sdtr_table_t	*tbl;	/* points to the trace table for a cd */
97 	kmutex_t	*t_lock;  /* the lock for this cd */
98 	} _sdbc_trace_t;
99 #endif /* _KERNEL */
100 
101 /* sd_adump() flags */
102 #define	SD_SET_SIZE	0x01	/* create log if it doesn't exist */
103 #define	SD_SET_MASK	0x02
104 #define	SD_SET_LBOLT	0x04
105 #define	SD_SET_GOOD	0x08
106 #define	SD_ADUMP_WAIT	0x10	/* wakeup for buffer full or alert */
107 #define	SD_ALERT_WAIT	0x20	/* wakeup for alert messages */
108 
109 /* Trace function, category, mask bits */
110 #define	ST_FUNC		0x000f	/* functions per category */
111 #define	ST_CATMASK	0x0ff0  /* Category mask	*/
112 
113 #define	ST_BCACHE	0x0010	/* BCACHE entry points */
114 #define	ST_BSUB		0x0020	/* BCACHE subroutines */
115 #define	ST_IO		0x0040	/* IO subsystem */
116 #define	ST_CCIO		0x0080	/* concurrent (dual) copy */
117 #define	ST_FT		0x0100	/* Fault-tolerant subsystem */
118 #define	ST_DL		0x0200	/* Data-logging (debug) */
119 #define	ST_STATS	0x0400	/* cache statistics */
120 #define	ST_CKD		0x0800	/* SIMCKD traces */
121 
122 #define	ST_ENTER	0x1000	/* function entry */
123 #define	ST_EXIT		0x2000	/* function exit */
124 #define	ST_INFO		0x4000	/* see t_flg */
125 #define	ST_ALERT	0x8000	/* force write to daemon */
126 
127 /*
128  * dump file pseudo-entries
129  */
130 #define	SDF_LOST	0x0000	/* trace is missing entries */
131 #define	SDF_CD		0x0001	/* new device (following entries) */
132 
133 /*
134  * ST_BCACHE functions
135  */
136 #define	SDF_OPEN	0x00 | ST_BCACHE
137 #define	SDF_CLOSE	0x01 | ST_BCACHE
138 #define	SDF_HALLOC	0x02 | ST_BCACHE
139 #define	SDF_HFREE	0x03 | ST_BCACHE
140 #define	SDF_ALLOCBUF	0x04 | ST_BCACHE
141 #define	SDF_FREEBUF	0x05 | ST_BCACHE
142 #define	SDF_WRITE	0x06 | ST_BCACHE
143 #define	SDF_READ	0x07 | ST_BCACHE
144 #define	SDF_UNCOMMIT	0x08 | ST_BCACHE
145 #define	SDF_ZERO	0x09 | ST_BCACHE
146 #define	SDF_HINT	0x0a | ST_BCACHE
147 #define	SDF_ATTACH	0x0b | ST_BCACHE | ST_FT
148 #define	SDF_DETACH	0x0c | ST_BCACHE | ST_FT
149 #define	SDF_NOTIFY	0x0d | ST_BCACHE
150 
151 /*
152  * ST_BSUB - bcache subroutines
153  */
154 #define	SDF_ENT_GET	0x00 | ST_BSUB
155 #define	SDF_ENT_ALLOC	0x01 | ST_BSUB
156 #define	SDF_READ_EA	0x02 | ST_BSUB
157 #define	SDF_ENT_FREE	0x03 | ST_BSUB
158 #define	SDF_WR_ALLOC	0x04 | ST_BSUB
159 #define	SDF_WR_FREE	0x05 | ST_BSUB
160 #define	SDF_WR_ALLOCONE	0x06 | ST_BSUB
161 
162 
163 /*
164  * SD_IO - I/O subsustem
165  */
166 #define	SDF_FLCLIST	0x00 | ST_IO
167 #define	SDF_FLCENT	0x01 | ST_IO
168 #define	SDF_FLCLIST_EA	0x02 | ST_IO
169 #define	SDF_FLCENT_EA	0x03 | ST_IO
170 #define	SDF_FLDONE	0x04 | ST_IO
171 #define	SDF_IOB_ALLOC	0x05 | ST_IO
172 
173 /*
174  * ST_FT - Fault-tolerant subsystem
175  */
176 #define	SDF_AWAITR	0x00 | ST_FT
177 #define	SDF_RECOVER	0x01 | ST_FT
178 #define	SDF_FT_CLONE	0x02 | ST_FT
179 #define	SDF_REFLECT	0x03 | ST_FT
180 #define	SDF_ONLINE	0x04 | ST_FT
181 
182 /*
183  * ST_STATS - Statistics points
184  */
185 #define	SDF_REPLACE	0x00 | ST_STATS
186 #define	SDF_DISCONNECT	0x01 | ST_STATS
187 
188 /*
189  * ST_INFO
190  */
191 #define	SDF_COVERAGE	0x00 | ST_INFO
192 
193 /*
194  * ST_DL
195  */
196 
197 #define	SDF_ALLOC	0x00 | ST_DL
198 #define	SDF_RD		0x01 | ST_DL
199 #define	SDF_WR		0x02 | ST_DL
200 #define	SDF_WRSYNC	0x03 | ST_DL
201 #define	SDF_FLSHLIST	0x04 | ST_DL
202 #define	SDF_FLSHENT	0x05 | ST_DL
203 #define	SDF_RDIO	0x06 | ST_DL
204 #define	SDF_FLEA	0x07 | ST_DL
205 #define	SDF_FLSTEA	0x08 | ST_DL
206 #define	SDF_WRSYEA	0x09 | ST_DL
207 
208 /*
209  * More entry points
210  */
211 
212 #ifdef _SD_FNAME
213 /*
214  * function category names
215  * 	change these when changing functions above
216  *	compress name to fit in 8 printable characters
217  */
218 char *_bcache_fname[16] =
219 {
220 	"open",
221 	"close",
222 	"al_hndl",
223 	"fr_hndl",
224 	"al_buf",
225 	"fr_buf",
226 	"write",
227 	"read",
228 	"ucommit",
229 	"zero",
230 	"hint",
231 	"attach",
232 	"detach",
233 	"notify",
234 };
235 
236 char *_bsub_fname[16] =
237 {
238 	"get_cent",
239 	"al_cent",
240 	"read_ea",
241 	"fr_cent",
242 	"al_went",
243 	"fr_went",
244 	"al_wone",
245 };
246 
247 char *_io_fname[16] =
248 {
249 	"flclist",
250 	"flcent",
251 	"eaclist",
252 	"eacent",
253 	"fldone",
254 	"get_iob",
255 };
256 
257 char *_ccio_fname[16] =
258 {
259 	"ccio",
260 	"dc_albuf",
261 	"dc_frbuf",
262 	"dc_write",
263 	"dc_read",
264 	"dc_zero",
265 };
266 
267 char *_ft_fname[16] =
268 {
269 	"wait_rec",
270 	"cache_rc",
271 	"ft_clone",
272 	"reflect",
273 	"online",
274 };
275 
276 char *_stats_fname[16] =
277 {
278 	"LRU-repl",
279 	"Disconn",
280 };
281 
282 char *_info_fname[16] =
283 {
284 	"Cover",
285 };
286 
287 char *_dlog_fname[16] =
288 {
289 	"alloc",
290 	"rd",
291 	"wr",
292 	"wrsync",
293 	"flshlist",
294 	"flshent",
295 	"rdio",
296 	"flea",
297 	"flstea",
298 	"wrsyea",
299 };
300 
301 #endif	/* _ST_NAMES */
302 #ifdef _KERNEL
303 
304 extern int _sd_trace_mask;
305 
306 extern void _sdbc_tr_unload(void);
307 extern int _sdbc_tr_load(void);
308 extern int _sdbc_tr_configure(int cd);
309 extern void _sdbc_tr_deconfigure(void);
310 extern int _sd_adump(void *args, int *rvp);
311 extern void _sd_alert(int f, int cd, int len, nsc_off_t fba, int flg, int ret);
312 extern void _sd_trace(int f, int cd, int len, nsc_off_t fba, int flg,
313     int ret);
314 #endif /* _KERNEL */
315 
316 #ifdef __cplusplus
317 }
318 #endif
319 
320 #endif /* _SD_TRACE_H */
321