Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 1 | /* |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 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 | |
| 9 | #include <asm/debug.h> |
| 10 | #include <asm/qdio.h> |
| 11 | #include "qdio.h" |
| 12 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 13 | /* that gives us 15 characters in the text event views */ |
Heiko Carstens | 6423ef6 | 2017-05-04 13:39:18 +0200 | [diff] [blame] | 14 | #define QDIO_DBF_LEN 32 |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 15 | |
| 16 | extern debug_info_t *qdio_dbf_setup; |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 17 | extern debug_info_t *qdio_dbf_error; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 18 | |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 19 | #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 Glauber | d3feb48 | 2012-09-11 13:42:06 +0200 | [diff] [blame] | 34 | static 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 Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 42 | |
| 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 Glauber | d3feb48 | 2012-09-11 13:42:06 +0200 | [diff] [blame] | 50 | static 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 Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 58 | |
| 59 | #define DBF_DEV_EVENT(level, device, text...) \ |
| 60 | do { \ |
| 61 | char debug_buffer[QDIO_DBF_LEN]; \ |
Hendrik Brueckner | 8e6a828 | 2013-09-18 17:21:34 +0200 | [diff] [blame] | 62 | if (debug_level_enabled(device->debug_area, level)) { \ |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 63 | snprintf(debug_buffer, QDIO_DBF_LEN, text); \ |
| 64 | debug_text_event(device->debug_area, level, debug_buffer); \ |
| 65 | } \ |
| 66 | } while (0) |
| 67 | |
Jan Glauber | d3feb48 | 2012-09-11 13:42:06 +0200 | [diff] [blame] | 68 | static 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 Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 77 | |
Stefan Raspl | 613c4e0 | 2014-06-12 14:24:45 +0200 | [diff] [blame] | 78 | int qdio_allocate_dbf(struct qdio_initialize *init_data, |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 79 | struct qdio_irq *irq_ptr); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 80 | void qdio_setup_debug_entries(struct qdio_irq *irq_ptr, |
| 81 | struct ccw_device *cdev); |
Stefan Raspl | aa2383f | 2013-02-26 13:08:34 +0100 | [diff] [blame] | 82 | void qdio_shutdown_debug_entries(struct qdio_irq *irq_ptr); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 83 | int qdio_debug_init(void); |
| 84 | void qdio_debug_exit(void); |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 85 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 86 | #endif |