blob: 5d70bd162ae9598cc078fbc5c948b4d38fe28d74 [file] [log] [blame]
Jan Glauber779e6e12008-07-17 17:16:48 +02001/*
2 * drivers/s390/cio/qdio_debug.h
3 *
4 * Copyright IBM Corp. 2008
5 *
6 * Author: Jan Glauber (jang@linux.vnet.ibm.com)
7 */
8#ifndef QDIO_DEBUG_H
9#define QDIO_DEBUG_H
10
11#include <asm/debug.h>
12#include <asm/qdio.h>
13#include "qdio.h"
14
Jan Glauber22f99342008-12-25 13:38:46 +010015/* that gives us 15 characters in the text event views */
16#define QDIO_DBF_LEN 16
Jan Glauber779e6e12008-07-17 17:16:48 +020017
18extern debug_info_t *qdio_dbf_setup;
Jan Glauber22f99342008-12-25 13:38:46 +010019extern debug_info_t *qdio_dbf_error;
Jan Glauber779e6e12008-07-17 17:16:48 +020020
Jan Glauber22f99342008-12-25 13:38:46 +010021/* sort out low debug levels early to avoid wasted sprints */
22static inline int qdio_dbf_passes(debug_info_t *dbf_grp, int level)
23{
24 return (level <= dbf_grp->level);
25}
26
27#define DBF_ERR 3 /* error conditions */
28#define DBF_WARN 4 /* warning conditions */
29#define DBF_INFO 6 /* informational */
30
31#undef DBF_EVENT
32#undef DBF_ERROR
33#undef DBF_DEV_EVENT
34
35#define DBF_EVENT(text...) \
36 do { \
37 char debug_buffer[QDIO_DBF_LEN]; \
38 snprintf(debug_buffer, QDIO_DBF_LEN, text); \
39 debug_text_event(qdio_dbf_setup, DBF_ERR, debug_buffer); \
40 } while (0)
41
42#define DBF_HEX(addr, len) \
43 do { \
44 debug_event(qdio_dbf_setup, DBF_ERR, (void*)(addr), len); \
45 } while (0)
46
47#define DBF_ERROR(text...) \
48 do { \
49 char debug_buffer[QDIO_DBF_LEN]; \
50 snprintf(debug_buffer, QDIO_DBF_LEN, text); \
51 debug_text_event(qdio_dbf_error, DBF_ERR, debug_buffer); \
52 } while (0)
53
54#define DBF_ERROR_HEX(addr, len) \
55 do { \
56 debug_event(qdio_dbf_error, DBF_ERR, (void*)(addr), len); \
57 } while (0)
58
59
60#define DBF_DEV_EVENT(level, device, text...) \
61 do { \
62 char debug_buffer[QDIO_DBF_LEN]; \
63 if (qdio_dbf_passes(device->debug_area, level)) { \
64 snprintf(debug_buffer, QDIO_DBF_LEN, text); \
65 debug_text_event(device->debug_area, level, debug_buffer); \
66 } \
67 } while (0)
68
69#define DBF_DEV_HEX(level, device, addr, len) \
70 do { \
71 debug_event(device->debug_area, level, (void*)(addr), len); \
72 } while (0)
73
74void qdio_allocate_dbf(struct qdio_initialize *init_data,
75 struct qdio_irq *irq_ptr);
Jan Glauber779e6e12008-07-17 17:16:48 +020076void qdio_setup_debug_entries(struct qdio_irq *irq_ptr,
77 struct ccw_device *cdev);
78void qdio_shutdown_debug_entries(struct qdio_irq *irq_ptr,
79 struct ccw_device *cdev);
80int qdio_debug_init(void);
81void qdio_debug_exit(void);
Jan Glauber22f99342008-12-25 13:38:46 +010082
Jan Glauber779e6e12008-07-17 17:16:48 +020083#endif