qdio_debug.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright IBM Corp. 2008
  3. *
  4. * Author: Jan Glauber (jang@linux.vnet.ibm.com)
  5. */
  6. #ifndef QDIO_DEBUG_H
  7. #define QDIO_DEBUG_H
  8. #include <asm/debug.h>
  9. #include <asm/qdio.h>
  10. #include "qdio.h"
  11. /* that gives us 15 characters in the text event views */
  12. #define QDIO_DBF_LEN 16
  13. extern debug_info_t *qdio_dbf_setup;
  14. extern debug_info_t *qdio_dbf_error;
  15. #define DBF_ERR 3 /* error conditions */
  16. #define DBF_WARN 4 /* warning conditions */
  17. #define DBF_INFO 6 /* informational */
  18. #undef DBF_EVENT
  19. #undef DBF_ERROR
  20. #undef DBF_DEV_EVENT
  21. #define DBF_EVENT(text...) \
  22. do { \
  23. char debug_buffer[QDIO_DBF_LEN]; \
  24. snprintf(debug_buffer, QDIO_DBF_LEN, text); \
  25. debug_text_event(qdio_dbf_setup, DBF_ERR, debug_buffer); \
  26. } while (0)
  27. static inline void DBF_HEX(void *addr, int len)
  28. {
  29. while (len > 0) {
  30. debug_event(qdio_dbf_setup, DBF_ERR, addr, len);
  31. len -= qdio_dbf_setup->buf_size;
  32. addr += qdio_dbf_setup->buf_size;
  33. }
  34. }
  35. #define DBF_ERROR(text...) \
  36. do { \
  37. char debug_buffer[QDIO_DBF_LEN]; \
  38. snprintf(debug_buffer, QDIO_DBF_LEN, text); \
  39. debug_text_event(qdio_dbf_error, DBF_ERR, debug_buffer); \
  40. } while (0)
  41. static inline void DBF_ERROR_HEX(void *addr, int len)
  42. {
  43. while (len > 0) {
  44. debug_event(qdio_dbf_error, DBF_ERR, addr, len);
  45. len -= qdio_dbf_error->buf_size;
  46. addr += qdio_dbf_error->buf_size;
  47. }
  48. }
  49. #define DBF_DEV_EVENT(level, device, text...) \
  50. do { \
  51. char debug_buffer[QDIO_DBF_LEN]; \
  52. if (debug_level_enabled(device->debug_area, level)) { \
  53. snprintf(debug_buffer, QDIO_DBF_LEN, text); \
  54. debug_text_event(device->debug_area, level, debug_buffer); \
  55. } \
  56. } while (0)
  57. static inline void DBF_DEV_HEX(struct qdio_irq *dev, void *addr,
  58. int len, int level)
  59. {
  60. while (len > 0) {
  61. debug_event(dev->debug_area, level, addr, len);
  62. len -= dev->debug_area->buf_size;
  63. addr += dev->debug_area->buf_size;
  64. }
  65. }
  66. int qdio_allocate_dbf(struct qdio_initialize *init_data,
  67. struct qdio_irq *irq_ptr);
  68. void qdio_setup_debug_entries(struct qdio_irq *irq_ptr,
  69. struct ccw_device *cdev);
  70. void qdio_shutdown_debug_entries(struct qdio_irq *irq_ptr);
  71. int qdio_debug_init(void);
  72. void qdio_debug_exit(void);
  73. #endif