scsi_logging.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef _SCSI_LOGGING_H
  2. #define _SCSI_LOGGING_H
  3. /*
  4. * This defines the scsi logging feature. It is a means by which the user
  5. * can select how much information they get about various goings on, and it
  6. * can be really useful for fault tracing. The logging word is divided into
  7. * 8 nibbles, each of which describes a loglevel. The division of things is
  8. * somewhat arbitrary, and the division of the word could be changed if it
  9. * were really needed for any reason. The numbers below are the only place
  10. * where these are specified. For a first go-around, 3 bits is more than
  11. * enough, since this gives 8 levels of logging (really 7, since 0 is always
  12. * off). Cutting to 2 bits might be wise at some point.
  13. */
  14. #define SCSI_LOG_ERROR_SHIFT 0
  15. #define SCSI_LOG_TIMEOUT_SHIFT 3
  16. #define SCSI_LOG_SCAN_SHIFT 6
  17. #define SCSI_LOG_MLQUEUE_SHIFT 9
  18. #define SCSI_LOG_MLCOMPLETE_SHIFT 12
  19. #define SCSI_LOG_LLQUEUE_SHIFT 15
  20. #define SCSI_LOG_LLCOMPLETE_SHIFT 18
  21. #define SCSI_LOG_HLQUEUE_SHIFT 21
  22. #define SCSI_LOG_HLCOMPLETE_SHIFT 24
  23. #define SCSI_LOG_IOCTL_SHIFT 27
  24. #define SCSI_LOG_ERROR_BITS 3
  25. #define SCSI_LOG_TIMEOUT_BITS 3
  26. #define SCSI_LOG_SCAN_BITS 3
  27. #define SCSI_LOG_MLQUEUE_BITS 3
  28. #define SCSI_LOG_MLCOMPLETE_BITS 3
  29. #define SCSI_LOG_LLQUEUE_BITS 3
  30. #define SCSI_LOG_LLCOMPLETE_BITS 3
  31. #define SCSI_LOG_HLQUEUE_BITS 3
  32. #define SCSI_LOG_HLCOMPLETE_BITS 3
  33. #define SCSI_LOG_IOCTL_BITS 3
  34. extern unsigned int scsi_logging_level;
  35. #ifdef CONFIG_SCSI_LOGGING
  36. #define SCSI_LOG_LEVEL(SHIFT, BITS) \
  37. ((scsi_logging_level >> (SHIFT)) & ((1 << (BITS)) - 1))
  38. #define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD) \
  39. do { \
  40. if (unlikely((SCSI_LOG_LEVEL(SHIFT, BITS)) > (LEVEL))) \
  41. do { \
  42. CMD; \
  43. } while (0); \
  44. } while (0)
  45. #else
  46. #define SCSI_LOG_LEVEL(SHIFT, BITS) 0
  47. #define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD)
  48. #endif /* CONFIG_SCSI_LOGGING */
  49. /*
  50. * These are the macros that are actually used throughout the code to
  51. * log events. If logging isn't enabled, they are no-ops and will be
  52. * completely absent from the user's code.
  53. */
  54. #define SCSI_LOG_ERROR_RECOVERY(LEVEL,CMD) \
  55. SCSI_CHECK_LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL,CMD);
  56. #define SCSI_LOG_TIMEOUT(LEVEL,CMD) \
  57. SCSI_CHECK_LOGGING(SCSI_LOG_TIMEOUT_SHIFT, SCSI_LOG_TIMEOUT_BITS, LEVEL,CMD);
  58. #define SCSI_LOG_SCAN_BUS(LEVEL,CMD) \
  59. SCSI_CHECK_LOGGING(SCSI_LOG_SCAN_SHIFT, SCSI_LOG_SCAN_BITS, LEVEL,CMD);
  60. #define SCSI_LOG_MLQUEUE(LEVEL,CMD) \
  61. SCSI_CHECK_LOGGING(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS, LEVEL,CMD);
  62. #define SCSI_LOG_MLCOMPLETE(LEVEL,CMD) \
  63. SCSI_CHECK_LOGGING(SCSI_LOG_MLCOMPLETE_SHIFT, SCSI_LOG_MLCOMPLETE_BITS, LEVEL,CMD);
  64. #define SCSI_LOG_LLQUEUE(LEVEL,CMD) \
  65. SCSI_CHECK_LOGGING(SCSI_LOG_LLQUEUE_SHIFT, SCSI_LOG_LLQUEUE_BITS, LEVEL,CMD);
  66. #define SCSI_LOG_LLCOMPLETE(LEVEL,CMD) \
  67. SCSI_CHECK_LOGGING(SCSI_LOG_LLCOMPLETE_SHIFT, SCSI_LOG_LLCOMPLETE_BITS, LEVEL,CMD);
  68. #define SCSI_LOG_HLQUEUE(LEVEL,CMD) \
  69. SCSI_CHECK_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL,CMD);
  70. #define SCSI_LOG_HLCOMPLETE(LEVEL,CMD) \
  71. SCSI_CHECK_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL,CMD);
  72. #define SCSI_LOG_IOCTL(LEVEL,CMD) \
  73. SCSI_CHECK_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL,CMD);
  74. #endif /* _SCSI_LOGGING_H */