ctcm_dbug.h (3335B)
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Copyright IBM Corp. 2001, 2007 4 * Authors: Peter Tiedemann (ptiedem@de.ibm.com) 5 * 6 */ 7 8#ifndef _CTCM_DBUG_H_ 9#define _CTCM_DBUG_H_ 10 11/* 12 * Debug Facility stuff 13 */ 14 15#include <asm/debug.h> 16 17#ifdef DEBUG 18 #define do_debug 1 19#else 20 #define do_debug 0 21#endif 22#ifdef DEBUGCCW 23 #define do_debug_ccw 1 24 #define DEBUGDATA 1 25#else 26 #define do_debug_ccw 0 27#endif 28#ifdef DEBUGDATA 29 #define do_debug_data 1 30#else 31 #define do_debug_data 0 32#endif 33 34/* define dbf debug levels similar to kernel msg levels */ 35#define CTC_DBF_ALWAYS 0 /* always print this */ 36#define CTC_DBF_EMERG 0 /* system is unusable */ 37#define CTC_DBF_ALERT 1 /* action must be taken immediately */ 38#define CTC_DBF_CRIT 2 /* critical conditions */ 39#define CTC_DBF_ERROR 3 /* error conditions */ 40#define CTC_DBF_WARN 4 /* warning conditions */ 41#define CTC_DBF_NOTICE 5 /* normal but significant condition */ 42#define CTC_DBF_INFO 5 /* informational */ 43#define CTC_DBF_DEBUG 6 /* debug-level messages */ 44 45enum ctcm_dbf_names { 46 CTCM_DBF_SETUP, 47 CTCM_DBF_ERROR, 48 CTCM_DBF_TRACE, 49 CTCM_DBF_MPC_SETUP, 50 CTCM_DBF_MPC_ERROR, 51 CTCM_DBF_MPC_TRACE, 52 CTCM_DBF_INFOS /* must be last element */ 53}; 54 55struct ctcm_dbf_info { 56 char name[DEBUG_MAX_NAME_LEN]; 57 int pages; 58 int areas; 59 int len; 60 int level; 61 debug_info_t *id; 62}; 63 64extern struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS]; 65 66int ctcm_register_dbf_views(void); 67void ctcm_unregister_dbf_views(void); 68__printf(3, 4) 69void ctcm_dbf_longtext(enum ctcm_dbf_names dbf_nix, int level, char *text, ...); 70 71static inline const char *strtail(const char *s, int n) 72{ 73 int l = strlen(s); 74 return (l > n) ? s + (l - n) : s; 75} 76 77#define CTCM_FUNTAIL strtail((char *)__func__, 16) 78 79#define CTCM_DBF_TEXT(name, level, text) \ 80 do { \ 81 debug_text_event(ctcm_dbf[CTCM_DBF_##name].id, level, text); \ 82 } while (0) 83 84#define CTCM_DBF_HEX(name, level, addr, len) \ 85 do { \ 86 debug_event(ctcm_dbf[CTCM_DBF_##name].id, \ 87 level, (void *)(addr), len); \ 88 } while (0) 89 90#define CTCM_DBF_TEXT_(name, level, text...) \ 91 ctcm_dbf_longtext(CTCM_DBF_##name, level, text) 92 93/* 94 * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}. 95 * dev : netdevice with valid name field. 96 * text: any text string. 97 */ 98#define CTCM_DBF_DEV_NAME(cat, dev, text) \ 99 do { \ 100 CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%s) :- %s", \ 101 CTCM_FUNTAIL, dev->name, text); \ 102 } while (0) 103 104#define MPC_DBF_DEV_NAME(cat, dev, text) \ 105 do { \ 106 CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%s) := %s", \ 107 CTCM_FUNTAIL, dev->name, text); \ 108 } while (0) 109 110#define CTCMY_DBF_DEV_NAME(cat, dev, text) \ 111 do { \ 112 if (IS_MPCDEV(dev)) \ 113 MPC_DBF_DEV_NAME(cat, dev, text); \ 114 else \ 115 CTCM_DBF_DEV_NAME(cat, dev, text); \ 116 } while (0) 117 118/* 119 * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}. 120 * dev : netdevice. 121 * text: any text string. 122 */ 123#define CTCM_DBF_DEV(cat, dev, text) \ 124 do { \ 125 CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%p) :-: %s", \ 126 CTCM_FUNTAIL, dev, text); \ 127 } while (0) 128 129#define MPC_DBF_DEV(cat, dev, text) \ 130 do { \ 131 CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%p) :=: %s", \ 132 CTCM_FUNTAIL, dev, text); \ 133 } while (0) 134 135#define CTCMY_DBF_DEV(cat, dev, text) \ 136 do { \ 137 if (IS_MPCDEV(dev)) \ 138 MPC_DBF_DEV(cat, dev, text); \ 139 else \ 140 CTCM_DBF_DEV(cat, dev, text); \ 141 } while (0) 142 143#endif