blob: f85f5fa7cefc76889b0fb0c98ac5712707289f39 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Jan Glauber779e6e12008-07-17 17:16:48 +02002/*
Jan Glauber779e6e12008-07-17 17:16:48 +02003 * Copyright IBM Corp. 2008
4 *
5 * Author: Jan Glauber (jang@linux.vnet.ibm.com)
6 */
7#ifndef QDIO_DEBUG_H
8#define QDIO_DEBUG_H
9
10#include <asm/debug.h>
11#include <asm/qdio.h>
12#include "qdio.h"
13
Jan Glauber22f99342008-12-25 13:38:46 +010014/* that gives us 15 characters in the text event views */
Heiko Carstens6423ef62017-05-04 13:39:18 +020015#define QDIO_DBF_LEN 32
Jan Glauber779e6e12008-07-17 17:16:48 +020016
17extern debug_info_t *qdio_dbf_setup;
Jan Glauber22f99342008-12-25 13:38:46 +010018extern debug_info_t *qdio_dbf_error;
Jan Glauber779e6e12008-07-17 17:16:48 +020019
Jan Glauber22f99342008-12-25 13:38:46 +010020#define DBF_ERR 3 /* error conditions */
21#define DBF_WARN 4 /* warning conditions */
22#define DBF_INFO 6 /* informational */
23
24#undef DBF_EVENT
25#undef DBF_ERROR
26#undef DBF_DEV_EVENT
27
28#define DBF_EVENT(text...) \
29 do { \
30 char debug_buffer[QDIO_DBF_LEN]; \
31 snprintf(debug_buffer, QDIO_DBF_LEN, text); \
32 debug_text_event(qdio_dbf_setup, DBF_ERR, debug_buffer); \
33 } while (0)
34
Jan Glauberd3feb482012-09-11 13:42:06 +020035static inline void DBF_HEX(void *addr, int len)
36{
Sebastian Ott94158e52017-10-09 17:49:38 +020037 debug_event(qdio_dbf_setup, DBF_ERR, addr, len);
Jan Glauberd3feb482012-09-11 13:42:06 +020038}
Jan Glauber22f99342008-12-25 13:38:46 +010039
40#define DBF_ERROR(text...) \
41 do { \
42 char debug_buffer[QDIO_DBF_LEN]; \
43 snprintf(debug_buffer, QDIO_DBF_LEN, text); \
44 debug_text_event(qdio_dbf_error, DBF_ERR, debug_buffer); \
45 } while (0)
46
Jan Glauberd3feb482012-09-11 13:42:06 +020047static inline void DBF_ERROR_HEX(void *addr, int len)
48{
Sebastian Ott94158e52017-10-09 17:49:38 +020049 debug_event(qdio_dbf_error, DBF_ERR, addr, len);
Jan Glauberd3feb482012-09-11 13:42:06 +020050}
Jan Glauber22f99342008-12-25 13:38:46 +010051
52#define DBF_DEV_EVENT(level, device, text...) \
53 do { \
54 char debug_buffer[QDIO_DBF_LEN]; \
Hendrik Brueckner8e6a8282013-09-18 17:21:34 +020055 if (debug_level_enabled(device->debug_area, level)) { \
Jan Glauber22f99342008-12-25 13:38:46 +010056 snprintf(debug_buffer, QDIO_DBF_LEN, text); \
57 debug_text_event(device->debug_area, level, debug_buffer); \
58 } \
59 } while (0)
60
Jan Glauberd3feb482012-09-11 13:42:06 +020061static inline void DBF_DEV_HEX(struct qdio_irq *dev, void *addr,
62 int len, int level)
63{
Sebastian Ott94158e52017-10-09 17:49:38 +020064 debug_event(dev->debug_area, level, addr, len);
Jan Glauberd3feb482012-09-11 13:42:06 +020065}
Jan Glauber22f99342008-12-25 13:38:46 +010066
Stefan Raspl613c4e02014-06-12 14:24:45 +020067int qdio_allocate_dbf(struct qdio_initialize *init_data,
Jan Glauber22f99342008-12-25 13:38:46 +010068 struct qdio_irq *irq_ptr);
Jan Glauber779e6e12008-07-17 17:16:48 +020069void qdio_setup_debug_entries(struct qdio_irq *irq_ptr,
70 struct ccw_device *cdev);
Stefan Rasplaa2383f2013-02-26 13:08:34 +010071void qdio_shutdown_debug_entries(struct qdio_irq *irq_ptr);
Jan Glauber779e6e12008-07-17 17:16:48 +020072int qdio_debug_init(void);
73void qdio_debug_exit(void);
Jan Glauber22f99342008-12-25 13:38:46 +010074
Jan Glauber779e6e12008-07-17 17:16:48 +020075#endif