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 */ |
| 14 | #define QDIO_DBF_LEN 16 |
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 | /* sort out low debug levels early to avoid wasted sprints */ |
| 20 | static inline int qdio_dbf_passes(debug_info_t *dbf_grp, int level) |
| 21 | { |
| 22 | return (level <= dbf_grp->level); |
| 23 | } |
| 24 | |
| 25 | #define DBF_ERR 3 /* error conditions */ |
| 26 | #define DBF_WARN 4 /* warning conditions */ |
| 27 | #define DBF_INFO 6 /* informational */ |
| 28 | |
| 29 | #undef DBF_EVENT |
| 30 | #undef DBF_ERROR |
| 31 | #undef DBF_DEV_EVENT |
| 32 | |
| 33 | #define DBF_EVENT(text...) \ |
| 34 | do { \ |
| 35 | char debug_buffer[QDIO_DBF_LEN]; \ |
| 36 | snprintf(debug_buffer, QDIO_DBF_LEN, text); \ |
| 37 | debug_text_event(qdio_dbf_setup, DBF_ERR, debug_buffer); \ |
| 38 | } while (0) |
| 39 | |
Jan Glauber | d3feb48 | 2012-09-11 13:42:06 +0200 | [diff] [blame] | 40 | static inline void DBF_HEX(void *addr, int len) |
| 41 | { |
| 42 | while (len > 0) { |
| 43 | debug_event(qdio_dbf_setup, DBF_ERR, addr, len); |
| 44 | len -= qdio_dbf_setup->buf_size; |
| 45 | addr += qdio_dbf_setup->buf_size; |
| 46 | } |
| 47 | } |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 48 | |
| 49 | #define DBF_ERROR(text...) \ |
| 50 | do { \ |
| 51 | char debug_buffer[QDIO_DBF_LEN]; \ |
| 52 | snprintf(debug_buffer, QDIO_DBF_LEN, text); \ |
| 53 | debug_text_event(qdio_dbf_error, DBF_ERR, debug_buffer); \ |
| 54 | } while (0) |
| 55 | |
Jan Glauber | d3feb48 | 2012-09-11 13:42:06 +0200 | [diff] [blame] | 56 | static inline void DBF_ERROR_HEX(void *addr, int len) |
| 57 | { |
| 58 | while (len > 0) { |
| 59 | debug_event(qdio_dbf_error, DBF_ERR, addr, len); |
| 60 | len -= qdio_dbf_error->buf_size; |
| 61 | addr += qdio_dbf_error->buf_size; |
| 62 | } |
| 63 | } |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 64 | |
| 65 | #define DBF_DEV_EVENT(level, device, text...) \ |
| 66 | do { \ |
| 67 | char debug_buffer[QDIO_DBF_LEN]; \ |
| 68 | if (qdio_dbf_passes(device->debug_area, level)) { \ |
| 69 | snprintf(debug_buffer, QDIO_DBF_LEN, text); \ |
| 70 | debug_text_event(device->debug_area, level, debug_buffer); \ |
| 71 | } \ |
| 72 | } while (0) |
| 73 | |
Jan Glauber | d3feb48 | 2012-09-11 13:42:06 +0200 | [diff] [blame] | 74 | static inline void DBF_DEV_HEX(struct qdio_irq *dev, void *addr, |
| 75 | int len, int level) |
| 76 | { |
| 77 | while (len > 0) { |
| 78 | debug_event(dev->debug_area, level, addr, len); |
| 79 | len -= dev->debug_area->buf_size; |
| 80 | addr += dev->debug_area->buf_size; |
| 81 | } |
| 82 | } |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 83 | |
| 84 | void qdio_allocate_dbf(struct qdio_initialize *init_data, |
| 85 | struct qdio_irq *irq_ptr); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 86 | void qdio_setup_debug_entries(struct qdio_irq *irq_ptr, |
| 87 | struct ccw_device *cdev); |
Stefan Raspl | aa2383f | 2013-02-26 13:08:34 +0100 | [diff] [blame] | 88 | void qdio_shutdown_debug_entries(struct qdio_irq *irq_ptr); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 89 | int qdio_debug_init(void); |
| 90 | void qdio_debug_exit(void); |
Jan Glauber | 22f9934 | 2008-12-25 13:38:46 +0100 | [diff] [blame] | 91 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 92 | #endif |