ctcm_dbug.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Copyright IBM Corp. 2001, 2007
  3. * Authors: Peter Tiedemann (ptiedem@de.ibm.com)
  4. *
  5. */
  6. #ifndef _CTCM_DBUG_H_
  7. #define _CTCM_DBUG_H_
  8. /*
  9. * Debug Facility stuff
  10. */
  11. #include <asm/debug.h>
  12. #ifdef DEBUG
  13. #define do_debug 1
  14. #else
  15. #define do_debug 0
  16. #endif
  17. #ifdef DEBUGCCW
  18. #define do_debug_ccw 1
  19. #define DEBUGDATA 1
  20. #else
  21. #define do_debug_ccw 0
  22. #endif
  23. #ifdef DEBUGDATA
  24. #define do_debug_data 1
  25. #else
  26. #define do_debug_data 0
  27. #endif
  28. /* define dbf debug levels similar to kernel msg levels */
  29. #define CTC_DBF_ALWAYS 0 /* always print this */
  30. #define CTC_DBF_EMERG 0 /* system is unusable */
  31. #define CTC_DBF_ALERT 1 /* action must be taken immediately */
  32. #define CTC_DBF_CRIT 2 /* critical conditions */
  33. #define CTC_DBF_ERROR 3 /* error conditions */
  34. #define CTC_DBF_WARN 4 /* warning conditions */
  35. #define CTC_DBF_NOTICE 5 /* normal but significant condition */
  36. #define CTC_DBF_INFO 5 /* informational */
  37. #define CTC_DBF_DEBUG 6 /* debug-level messages */
  38. enum ctcm_dbf_names {
  39. CTCM_DBF_SETUP,
  40. CTCM_DBF_ERROR,
  41. CTCM_DBF_TRACE,
  42. CTCM_DBF_MPC_SETUP,
  43. CTCM_DBF_MPC_ERROR,
  44. CTCM_DBF_MPC_TRACE,
  45. CTCM_DBF_INFOS /* must be last element */
  46. };
  47. struct ctcm_dbf_info {
  48. char name[DEBUG_MAX_NAME_LEN];
  49. int pages;
  50. int areas;
  51. int len;
  52. int level;
  53. debug_info_t *id;
  54. };
  55. extern struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS];
  56. int ctcm_register_dbf_views(void);
  57. void ctcm_unregister_dbf_views(void);
  58. void ctcm_dbf_longtext(enum ctcm_dbf_names dbf_nix, int level, char *text, ...);
  59. static inline const char *strtail(const char *s, int n)
  60. {
  61. int l = strlen(s);
  62. return (l > n) ? s + (l - n) : s;
  63. }
  64. #define CTCM_FUNTAIL strtail((char *)__func__, 16)
  65. #define CTCM_DBF_TEXT(name, level, text) \
  66. do { \
  67. debug_text_event(ctcm_dbf[CTCM_DBF_##name].id, level, text); \
  68. } while (0)
  69. #define CTCM_DBF_HEX(name, level, addr, len) \
  70. do { \
  71. debug_event(ctcm_dbf[CTCM_DBF_##name].id, \
  72. level, (void *)(addr), len); \
  73. } while (0)
  74. #define CTCM_DBF_TEXT_(name, level, text...) \
  75. ctcm_dbf_longtext(CTCM_DBF_##name, level, text)
  76. /*
  77. * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}.
  78. * dev : netdevice with valid name field.
  79. * text: any text string.
  80. */
  81. #define CTCM_DBF_DEV_NAME(cat, dev, text) \
  82. do { \
  83. CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%s) :- %s", \
  84. CTCM_FUNTAIL, dev->name, text); \
  85. } while (0)
  86. #define MPC_DBF_DEV_NAME(cat, dev, text) \
  87. do { \
  88. CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%s) := %s", \
  89. CTCM_FUNTAIL, dev->name, text); \
  90. } while (0)
  91. #define CTCMY_DBF_DEV_NAME(cat, dev, text) \
  92. do { \
  93. if (IS_MPCDEV(dev)) \
  94. MPC_DBF_DEV_NAME(cat, dev, text); \
  95. else \
  96. CTCM_DBF_DEV_NAME(cat, dev, text); \
  97. } while (0)
  98. /*
  99. * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}.
  100. * dev : netdevice.
  101. * text: any text string.
  102. */
  103. #define CTCM_DBF_DEV(cat, dev, text) \
  104. do { \
  105. CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%p) :-: %s", \
  106. CTCM_FUNTAIL, dev, text); \
  107. } while (0)
  108. #define MPC_DBF_DEV(cat, dev, text) \
  109. do { \
  110. CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%p) :=: %s", \
  111. CTCM_FUNTAIL, dev, text); \
  112. } while (0)
  113. #define CTCMY_DBF_DEV(cat, dev, text) \
  114. do { \
  115. if (IS_MPCDEV(dev)) \
  116. MPC_DBF_DEV(cat, dev, text); \
  117. else \
  118. CTCM_DBF_DEV(cat, dev, text); \
  119. } while (0)
  120. #endif