xref: /original-bsd/sys/dev/scsi/sdtrace.h (revision 928b21ed)
1 /*
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * %sccs.include.redist.c%
10  *
11  *	@(#)sdtrace.h	5.1 (Berkeley) 07/10/92
12  *
13  * $Header: sdtrace.h,v 1.5 92/07/10 07:00:38 torek Exp $ (LBL)
14  */
15 
16 /*
17  * SCSI disk command tracing
18  */
19 
20 #if defined(SDTRACE) || !defined(KERNEL)
21 struct sdtrace {
22 	struct	timeval time;	/* timestamp */
23 	u_int	block;		/* disk block */
24 	u_int	bcount;		/* # bytes transferred */
25 	u_char	tcode;		/* trace code */
26 	u_char	target;		/* target number */
27 	u_char	unit;		/* unit number on target */
28 	u_char	read;		/* read operation */
29 };
30 
31 #define	T_START		0x01
32 #define	T_MKCDB		0x02
33 #define	T_INTR		0x03
34 #endif
35 
36 #ifdef SDTRACE
37 /* Allow kernel config to override number of entries */
38 #ifndef NSDOPBUF
39 #define	NSDOPBUF 1024
40 #endif
41 
42 struct	sdtrace sdopbuf[NSDOPBUF];
43 struct	sdtrace *sdopptr = sdopbuf;
44 int	nsdopbuf = NSDOPBUF;	/* for sdtrace */
45 u_long	sdopcnt;
46 
47 #define	SD_TRACE(code, sc, bp) { \
48 	if (++sdopptr >= &sdopbuf[NSDOPBUF]) \
49 		sdopptr = sdopbuf; \
50 	microtime(&sdopptr->time); \
51 	sdopptr->tcode = code; \
52 	sdopptr->read = bp->b_flags & B_READ; \
53 	sdopptr->block = bp->b_blkno; \
54 	sdopptr->bcount = bp->b_bcount; \
55 	sdopptr->target = sc->sc_unit.u_targ; \
56 	sdopptr->unit = sc->sc_unit.u_unit; \
57 	++sdopcnt; \
58 }
59 #else
60 #define	SD_TRACE(code, sc, bp) { }
61 #endif
62