blob: 1d595d17bf11f6b529eca2caafc494721130b32c [file] [log] [blame]
Jan Glauber779e6e12008-07-17 17:16:48 +02001/*
Jan Glauber779e6e12008-07-17 17:16:48 +02002 * 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
9#include <asm/debug.h>
10#include <asm/qdio.h>
11#include "qdio.h"
12
Jan Glauber22f99342008-12-25 13:38:46 +010013/* that gives us 15 characters in the text event views */
Heiko Carstens6423ef62017-05-04 13:39:18 +020014#define QDIO_DBF_LEN 32
Jan Glauber779e6e12008-07-17 17:16:48 +020015
16extern debug_info_t *qdio_dbf_setup;
Jan Glauber22f99342008-12-25 13:38:46 +010017extern debug_info_t *qdio_dbf_error;
Jan Glauber779e6e12008-07-17 17:16:48 +020018
Jan Glauber22f99342008-12-25 13:38:46 +010019#define DBF_ERR 3 /* error conditions */
20#define DBF_WARN 4 /* warning conditions */
21#define DBF_INFO 6 /* informational */
22
23#undef DBF_EVENT
24#undef DBF_ERROR
25#undef DBF_DEV_EVENT
26
27#define DBF_EVENT(text...) \
28 do { \
29 char debug_buffer[QDIO_DBF_LEN]; \
30 snprintf(debug_buffer, QDIO_DBF_LEN, text); \
31 debug_text_event(qdio_dbf_setup, DBF_ERR, debug_buffer); \
32 } while (0)
33
Jan Glauberd3feb482012-09-11 13:42:06 +020034static inline void DBF_HEX(void *addr, int len)
35{
36 while (len > 0) {
37 debug_event(qdio_dbf_setup, DBF_ERR, addr, len);
38 len -= qdio_dbf_setup->buf_size;
39 addr += qdio_dbf_setup->buf_size;
40 }
41}
Jan Glauber22f99342008-12-25 13:38:46 +010042
43#define DBF_ERROR(text...) \
44 do { \
45 char debug_buffer[QDIO_DBF_LEN]; \
46 snprintf(debug_buffer, QDIO_DBF_LEN, text); \
47 debug_text_event(qdio_dbf_error, DBF_ERR, debug_buffer); \
48 } while (0)
49
Jan Glauberd3feb482012-09-11 13:42:06 +020050static inline void DBF_ERROR_HEX(void *addr, int len)
51{
52 while (len > 0) {
53 debug_event(qdio_dbf_error, DBF_ERR, addr, len);
54 len -= qdio_dbf_error->buf_size;
55 addr += qdio_dbf_error->buf_size;
56 }
57}
Jan Glauber22f99342008-12-25 13:38:46 +010058
59#define DBF_DEV_EVENT(level, device, text...) \
60 do { \
61 char debug_buffer[QDIO_DBF_LEN]; \
Hendrik Brueckner8e6a8282013-09-18 17:21:34 +020062 if (debug_level_enabled(device->debug_area, level)) { \
Jan Glauber22f99342008-12-25 13:38:46 +010063 snprintf(debug_buffer, QDIO_DBF_LEN, text); \
64 debug_text_event(device->debug_area, level, debug_buffer); \
65 } \
66 } while (0)
67
Jan Glauberd3feb482012-09-11 13:42:06 +020068static inline void DBF_DEV_HEX(struct qdio_irq *dev, void *addr,
69 int len, int level)
70{
71 while (len > 0) {
72 debug_event(dev->debug_area, level, addr, len);
73 len -= dev->debug_area->buf_size;
74 addr += dev->debug_area->buf_size;
75 }
76}
Jan Glauber22f99342008-12-25 13:38:46 +010077
Stefan Raspl613c4e02014-06-12 14:24:45 +020078int qdio_allocate_dbf(struct qdio_initialize *init_data,
Jan Glauber22f99342008-12-25 13:38:46 +010079 struct qdio_irq *irq_ptr);
Jan Glauber779e6e12008-07-17 17:16:48 +020080void qdio_setup_debug_entries(struct qdio_irq *irq_ptr,
81 struct ccw_device *cdev);
Stefan Rasplaa2383f2013-02-26 13:08:34 +010082void qdio_shutdown_debug_entries(struct qdio_irq *irq_ptr);
Jan Glauber779e6e12008-07-17 17:16:48 +020083int qdio_debug_init(void);
84void qdio_debug_exit(void);
Jan Glauber22f99342008-12-25 13:38:46 +010085
Jan Glauber779e6e12008-07-17 17:16:48 +020086#endif