xref: /openbmc/linux/drivers/scsi/scsi_logging.h (revision c5f2e640)
11da177e4SLinus Torvalds #ifndef _SCSI_LOGGING_H
21da177e4SLinus Torvalds #define _SCSI_LOGGING_H
31da177e4SLinus Torvalds 
41da177e4SLinus Torvalds #include <linux/config.h>
51da177e4SLinus Torvalds 
61da177e4SLinus Torvalds /*
71da177e4SLinus Torvalds  * This defines the scsi logging feature.  It is a means by which the user
81da177e4SLinus Torvalds  * can select how much information they get about various goings on, and it
91da177e4SLinus Torvalds  * can be really useful for fault tracing.  The logging word is divided into
101da177e4SLinus Torvalds  * 8 nibbles, each of which describes a loglevel.  The division of things is
111da177e4SLinus Torvalds  * somewhat arbitrary, and the division of the word could be changed if it
121da177e4SLinus Torvalds  * were really needed for any reason.  The numbers below are the only place
131da177e4SLinus Torvalds  * where these are specified.  For a first go-around, 3 bits is more than
141da177e4SLinus Torvalds  * enough, since this gives 8 levels of logging (really 7, since 0 is always
151da177e4SLinus Torvalds  * off).  Cutting to 2 bits might be wise at some point.
161da177e4SLinus Torvalds  */
171da177e4SLinus Torvalds 
181da177e4SLinus Torvalds #define SCSI_LOG_ERROR_SHIFT              0
191da177e4SLinus Torvalds #define SCSI_LOG_TIMEOUT_SHIFT            3
201da177e4SLinus Torvalds #define SCSI_LOG_SCAN_SHIFT               6
211da177e4SLinus Torvalds #define SCSI_LOG_MLQUEUE_SHIFT            9
221da177e4SLinus Torvalds #define SCSI_LOG_MLCOMPLETE_SHIFT         12
231da177e4SLinus Torvalds #define SCSI_LOG_LLQUEUE_SHIFT            15
241da177e4SLinus Torvalds #define SCSI_LOG_LLCOMPLETE_SHIFT         18
251da177e4SLinus Torvalds #define SCSI_LOG_HLQUEUE_SHIFT            21
261da177e4SLinus Torvalds #define SCSI_LOG_HLCOMPLETE_SHIFT         24
271da177e4SLinus Torvalds #define SCSI_LOG_IOCTL_SHIFT              27
281da177e4SLinus Torvalds 
291da177e4SLinus Torvalds #define SCSI_LOG_ERROR_BITS               3
301da177e4SLinus Torvalds #define SCSI_LOG_TIMEOUT_BITS             3
311da177e4SLinus Torvalds #define SCSI_LOG_SCAN_BITS                3
321da177e4SLinus Torvalds #define SCSI_LOG_MLQUEUE_BITS             3
331da177e4SLinus Torvalds #define SCSI_LOG_MLCOMPLETE_BITS          3
341da177e4SLinus Torvalds #define SCSI_LOG_LLQUEUE_BITS             3
351da177e4SLinus Torvalds #define SCSI_LOG_LLCOMPLETE_BITS          3
361da177e4SLinus Torvalds #define SCSI_LOG_HLQUEUE_BITS             3
371da177e4SLinus Torvalds #define SCSI_LOG_HLCOMPLETE_BITS          3
381da177e4SLinus Torvalds #define SCSI_LOG_IOCTL_BITS               3
391da177e4SLinus Torvalds 
401da177e4SLinus Torvalds extern unsigned int scsi_logging_level;
411da177e4SLinus Torvalds 
421da177e4SLinus Torvalds #ifdef CONFIG_SCSI_LOGGING
431da177e4SLinus Torvalds 
441da177e4SLinus Torvalds #define SCSI_LOG_LEVEL(SHIFT, BITS)				\
451da177e4SLinus Torvalds         ((scsi_logging_level >> (SHIFT)) & ((1 << (BITS)) - 1))
461da177e4SLinus Torvalds 
471da177e4SLinus Torvalds #define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD)		\
48c5f2e640Sakpm@osdl.org do {								\
491da177e4SLinus Torvalds         if (unlikely((SCSI_LOG_LEVEL(SHIFT, BITS)) > (LEVEL)))	\
50c5f2e640Sakpm@osdl.org 		do {						\
51c5f2e640Sakpm@osdl.org 			CMD;					\
52c5f2e640Sakpm@osdl.org 		} while (0);					\
53c5f2e640Sakpm@osdl.org } while (0)
541da177e4SLinus Torvalds #else
551da177e4SLinus Torvalds #define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD)
561da177e4SLinus Torvalds #endif /* CONFIG_SCSI_LOGGING */
571da177e4SLinus Torvalds 
581da177e4SLinus Torvalds /*
591da177e4SLinus Torvalds  * These are the macros that are actually used throughout the code to
601da177e4SLinus Torvalds  * log events.  If logging isn't enabled, they are no-ops and will be
611da177e4SLinus Torvalds  * completely absent from the user's code.
621da177e4SLinus Torvalds  */
631da177e4SLinus Torvalds #define SCSI_LOG_ERROR_RECOVERY(LEVEL,CMD)  \
641da177e4SLinus Torvalds         SCSI_CHECK_LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL,CMD);
651da177e4SLinus Torvalds #define SCSI_LOG_TIMEOUT(LEVEL,CMD)  \
661da177e4SLinus Torvalds         SCSI_CHECK_LOGGING(SCSI_LOG_TIMEOUT_SHIFT, SCSI_LOG_TIMEOUT_BITS, LEVEL,CMD);
671da177e4SLinus Torvalds #define SCSI_LOG_SCAN_BUS(LEVEL,CMD)  \
681da177e4SLinus Torvalds         SCSI_CHECK_LOGGING(SCSI_LOG_SCAN_SHIFT, SCSI_LOG_SCAN_BITS, LEVEL,CMD);
691da177e4SLinus Torvalds #define SCSI_LOG_MLQUEUE(LEVEL,CMD)  \
701da177e4SLinus Torvalds         SCSI_CHECK_LOGGING(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS, LEVEL,CMD);
711da177e4SLinus Torvalds #define SCSI_LOG_MLCOMPLETE(LEVEL,CMD)  \
721da177e4SLinus Torvalds         SCSI_CHECK_LOGGING(SCSI_LOG_MLCOMPLETE_SHIFT, SCSI_LOG_MLCOMPLETE_BITS, LEVEL,CMD);
731da177e4SLinus Torvalds #define SCSI_LOG_LLQUEUE(LEVEL,CMD)  \
741da177e4SLinus Torvalds         SCSI_CHECK_LOGGING(SCSI_LOG_LLQUEUE_SHIFT, SCSI_LOG_LLQUEUE_BITS, LEVEL,CMD);
751da177e4SLinus Torvalds #define SCSI_LOG_LLCOMPLETE(LEVEL,CMD)  \
761da177e4SLinus Torvalds         SCSI_CHECK_LOGGING(SCSI_LOG_LLCOMPLETE_SHIFT, SCSI_LOG_LLCOMPLETE_BITS, LEVEL,CMD);
771da177e4SLinus Torvalds #define SCSI_LOG_HLQUEUE(LEVEL,CMD)  \
781da177e4SLinus Torvalds         SCSI_CHECK_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL,CMD);
791da177e4SLinus Torvalds #define SCSI_LOG_HLCOMPLETE(LEVEL,CMD)  \
801da177e4SLinus Torvalds         SCSI_CHECK_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL,CMD);
811da177e4SLinus Torvalds #define SCSI_LOG_IOCTL(LEVEL,CMD)  \
821da177e4SLinus Torvalds         SCSI_CHECK_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL,CMD);
831da177e4SLinus Torvalds 
841da177e4SLinus Torvalds #endif /* _SCSI_LOGGING_H */
85