xref: /openbsd-src/sys/scsi/scsi_debug.h (revision 1a8dbaac879b9f3335ad7fb25429ce63ac1d6bac)
1 /*	$OpenBSD: scsi_debug.h,v 1.22 2020/07/27 19:19:50 krw Exp $	*/
2 /*	$NetBSD: scsi_debug.h,v 1.7 1996/10/12 23:23:16 christos Exp $	*/
3 
4 /*
5  * Written by Julian Elischer (julian@tfs.com)
6  */
7 #ifndef	_SCSI_SCSI_DEBUG_H
8 #define _SCSI_SCSI_DEBUG_H
9 #ifdef _KERNEL
10 
11 /*
12  * These are the new debug bits.  (Sat Oct  2 12:46:46 WST 1993)
13  * the following DEBUG bits are defined to exist in the flags word of
14  * the scsi_link structure.
15  */
16 #define	SDEV_DB1		0x0010	/* scsi commands, errors, data	*/
17 #define	SDEV_DB2		0x0020	/* routine flow tracking */
18 #define	SDEV_DB3		0x0040	/* internal to routine flows	*/
19 #define	SDEV_DB4		0x0080	/* level 4 debugging for this dev */
20 
21 #ifdef	SCSIDEBUG
22 /* targets and LUNs we want to debug */
23 #ifndef SCSIDEBUG_BUSES
24 #define SCSIDEBUG_BUSES		0
25 #endif /* ~SCSIDBUG_BUSES */
26 #ifndef SCSIDEBUG_TARGETS
27 #define	SCSIDEBUG_TARGETS	0
28 #endif /* ~SCSIDEBUG_TARGETS */
29 #ifndef SCSIDEBUG_LUNS
30 #define	SCSIDEBUG_LUNS		0
31 #endif /* ~SCSIDEBUG_LUNS */
32 #ifndef SCSIDEBUG_LEVEL
33 #define	SCSIDEBUG_LEVEL		(SDEV_DB1|SDEV_DB2)
34 #endif /* ~SCSIDEBUG_LEVEL */
35 
36 extern u_int32_t scsidebug_buses, scsidebug_targets, scsidebug_luns;
37 extern int scsidebug_level;
38 
39 extern const char *flagnames[];
40 extern const char *quirknames[];
41 extern const char *devicetypenames[32];
42 
43 struct scsi_xfer;
44 
45 void	scsi_show_sense(struct scsi_xfer *);
46 void	scsi_show_xs(struct scsi_xfer *);
47 void	scsi_show_mem(u_char *, int);
48 void	scsi_show_flags(u_int32_t, const char **);
49 
50 /*
51  * This is the usual debug macro for use with the above bits
52  */
53 #define	SC_DEBUG(link,Level,Printstuff) do {	\
54 	if ((link)->flags & (Level)) {		\
55 		sc_print_addr(link);		\
56 		printf Printstuff;		\
57 	}					\
58 } while (0)
59 #define SC_DEBUGN(link,Level,Printstuff) do {				\
60 	if ((link)->flags & (Level)) {					\
61 		printf Printstuff;					\
62 	}								\
63 } while (0)
64 #define SC_DEBUG_SENSE(xs) do {			\
65 	scsi_show_sense(xs);			\
66 } while (0)
67 #else
68 #define SC_DEBUG(link,level,Printstuff)
69 #define SC_DEBUGN(link,level,Printstuff)
70 #define SC_DEBUG_SENSE(xs)
71 #endif /* SCSIDEBUG */
72 
73 #endif /* _KERNEL */
74 #endif /* _SCSI_SCSI_DEBUG_H */
75