Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 2 | /* |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 3 | * 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 Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 14 | /* that gives us 15 characters in the text event views */ |
Heiko Carstens | 6423ef6 | 2017-05-04 13:39:18 +0200 | [diff] [blame] | 15 | #define QDIO_DBF_LEN 32 |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 16 | |
| 17 | extern debug_info_t *qdio_dbf_setup; |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 18 | extern debug_info_t *qdio_dbf_error; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 19 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 20 | #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 Glauber | d3feb48 | 2012-09-11 13:42:06 +0200 | [diff] [blame] | 35 | static inline void DBF_HEX(void *addr, int len) |
| 36 | { |
| 37 | while (len > 0) { |
| 38 | debug_event(qdio_dbf_setup, DBF_ERR, addr, len); |
| 39 | len -= qdio_dbf_setup->buf_size; |
| 40 | addr += qdio_dbf_setup->buf_size; |
| 41 | } |
| 42 | } |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 43 | |
| 44 | #define DBF_ERROR(text...) \ |
| 45 | do { \ |
| 46 | char debug_buffer[QDIO_DBF_LEN]; \ |
| 47 | snprintf(debug_buffer, QDIO_DBF_LEN, text); \ |
| 48 | debug_text_event(qdio_dbf_error, DBF_ERR, debug_buffer); \ |
| 49 | } while (0) |
| 50 | |
Jan Glauber | d3feb48 | 2012-09-11 13:42:06 +0200 | [diff] [blame] | 51 | static inline void DBF_ERROR_HEX(void *addr, int len) |
| 52 | { |
| 53 | while (len > 0) { |
| 54 | debug_event(qdio_dbf_error, DBF_ERR, addr, len); |
| 55 | len -= qdio_dbf_error->buf_size; |
| 56 | addr += qdio_dbf_error->buf_size; |
| 57 | } |
| 58 | } |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 59 | |
| 60 | #define DBF_DEV_EVENT(level, device, text...) \ |
| 61 | do { \ |
| 62 | char debug_buffer[QDIO_DBF_LEN]; \ |
Hendrik Brueckner | 8e6a828 | 2013-09-18 17:21:34 +0200 | [diff] [blame] | 63 | if (debug_level_enabled(device->debug_area, level)) { \ |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 64 | snprintf(debug_buffer, QDIO_DBF_LEN, text); \ |
| 65 | debug_text_event(device->debug_area, level, debug_buffer); \ |
| 66 | } \ |
| 67 | } while (0) |
| 68 | |
Jan Glauber | d3feb48 | 2012-09-11 13:42:06 +0200 | [diff] [blame] | 69 | static inline void DBF_DEV_HEX(struct qdio_irq *dev, void *addr, |
| 70 | int len, int level) |
| 71 | { |
| 72 | while (len > 0) { |
| 73 | debug_event(dev->debug_area, level, addr, len); |
| 74 | len -= dev->debug_area->buf_size; |
| 75 | addr += dev->debug_area->buf_size; |
| 76 | } |
| 77 | } |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 78 | |
Stefan Raspl | 613c4e0 | 2014-06-12 14:24:45 +0200 | [diff] [blame] | 79 | int qdio_allocate_dbf(struct qdio_initialize *init_data, |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 80 | struct qdio_irq *irq_ptr); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 81 | void qdio_setup_debug_entries(struct qdio_irq *irq_ptr, |
| 82 | struct ccw_device *cdev); |
Stefan Raspl | aa2383f | 2013-02-26 13:08:34 +0100 | [diff] [blame] | 83 | void qdio_shutdown_debug_entries(struct qdio_irq *irq_ptr); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 84 | int qdio_debug_init(void); |
| 85 | void qdio_debug_exit(void); |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 86 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 87 | #endif |