Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _SCSI_LOGGING_H
0003 #define _SCSI_LOGGING_H
0004 
0005 
0006 /*
0007  * This defines the scsi logging feature.  It is a means by which the user can
0008  * select how much information they get about various goings on, and it can be
0009  * really useful for fault tracing.  The logging word is divided into 10 3-bit
0010  * bitfields, each of which describes a loglevel.  The division of things is
0011  * somewhat arbitrary, and the division of the word could be changed if it
0012  * were really needed for any reason.  The numbers below are the only place
0013  * where these are specified.  For a first go-around, 3 bits is more than
0014  * enough, since this gives 8 levels of logging (really 7, since 0 is always
0015  * off).  Cutting to 2 bits might be wise at some point.
0016  */
0017 
0018 #define SCSI_LOG_ERROR_SHIFT              0
0019 #define SCSI_LOG_TIMEOUT_SHIFT            3
0020 #define SCSI_LOG_SCAN_SHIFT               6
0021 #define SCSI_LOG_MLQUEUE_SHIFT            9
0022 #define SCSI_LOG_MLCOMPLETE_SHIFT         12
0023 #define SCSI_LOG_LLQUEUE_SHIFT            15
0024 #define SCSI_LOG_LLCOMPLETE_SHIFT         18
0025 #define SCSI_LOG_HLQUEUE_SHIFT            21
0026 #define SCSI_LOG_HLCOMPLETE_SHIFT         24
0027 #define SCSI_LOG_IOCTL_SHIFT              27
0028 
0029 #define SCSI_LOG_ERROR_BITS               3
0030 #define SCSI_LOG_TIMEOUT_BITS             3
0031 #define SCSI_LOG_SCAN_BITS                3
0032 #define SCSI_LOG_MLQUEUE_BITS             3
0033 #define SCSI_LOG_MLCOMPLETE_BITS          3
0034 #define SCSI_LOG_LLQUEUE_BITS             3
0035 #define SCSI_LOG_LLCOMPLETE_BITS          3
0036 #define SCSI_LOG_HLQUEUE_BITS             3
0037 #define SCSI_LOG_HLCOMPLETE_BITS          3
0038 #define SCSI_LOG_IOCTL_BITS               3
0039 
0040 extern unsigned int scsi_logging_level;
0041 
0042 #ifdef CONFIG_SCSI_LOGGING
0043 
0044 #define SCSI_LOG_LEVEL(SHIFT, BITS)             \
0045         ((scsi_logging_level >> (SHIFT)) & ((1 << (BITS)) - 1))
0046 
0047 #define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD)     \
0048 do {                                \
0049         if (unlikely((SCSI_LOG_LEVEL(SHIFT, BITS)) > (LEVEL)))  \
0050         do {                        \
0051             CMD;                    \
0052         } while (0);                    \
0053 } while (0)
0054 #else
0055 #define SCSI_LOG_LEVEL(SHIFT, BITS) 0
0056 #define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD) do { } while (0)
0057 #endif /* CONFIG_SCSI_LOGGING */
0058 
0059 /*
0060  * These are the macros that are actually used throughout the code to
0061  * log events.  If logging isn't enabled, they are no-ops and will be
0062  * completely absent from the user's code.
0063  */
0064 #define SCSI_LOG_ERROR_RECOVERY(LEVEL,CMD)  \
0065         SCSI_CHECK_LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL,CMD);
0066 #define SCSI_LOG_TIMEOUT(LEVEL,CMD)  \
0067         SCSI_CHECK_LOGGING(SCSI_LOG_TIMEOUT_SHIFT, SCSI_LOG_TIMEOUT_BITS, LEVEL,CMD);
0068 #define SCSI_LOG_SCAN_BUS(LEVEL,CMD)  \
0069         SCSI_CHECK_LOGGING(SCSI_LOG_SCAN_SHIFT, SCSI_LOG_SCAN_BITS, LEVEL,CMD);
0070 #define SCSI_LOG_MLQUEUE(LEVEL,CMD)  \
0071         SCSI_CHECK_LOGGING(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS, LEVEL,CMD);
0072 #define SCSI_LOG_MLCOMPLETE(LEVEL,CMD)  \
0073         SCSI_CHECK_LOGGING(SCSI_LOG_MLCOMPLETE_SHIFT, SCSI_LOG_MLCOMPLETE_BITS, LEVEL,CMD);
0074 #define SCSI_LOG_LLQUEUE(LEVEL,CMD)  \
0075         SCSI_CHECK_LOGGING(SCSI_LOG_LLQUEUE_SHIFT, SCSI_LOG_LLQUEUE_BITS, LEVEL,CMD);
0076 #define SCSI_LOG_LLCOMPLETE(LEVEL,CMD)  \
0077         SCSI_CHECK_LOGGING(SCSI_LOG_LLCOMPLETE_SHIFT, SCSI_LOG_LLCOMPLETE_BITS, LEVEL,CMD);
0078 #define SCSI_LOG_HLQUEUE(LEVEL,CMD)  \
0079         SCSI_CHECK_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL,CMD);
0080 #define SCSI_LOG_HLCOMPLETE(LEVEL,CMD)  \
0081         SCSI_CHECK_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL,CMD);
0082 #define SCSI_LOG_IOCTL(LEVEL,CMD)  \
0083         SCSI_CHECK_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL,CMD);
0084 
0085 #endif /* _SCSI_LOGGING_H */