blob: 841ea72e4a4e93a12d397070530191d4b02adb5d [file] [log] [blame]
Holger Denglerdabecb22012-09-10 21:34:26 +02001/*
2 * Copyright IBM Corp. 2012
3 * Author(s): Holger Dengler (hd@linux.vnet.ibm.com)
4 */
5#ifndef ZCRYPT_DEBUG_H
6#define ZCRYPT_DEBUG_H
7
8#include <asm/debug.h>
9#include "zcrypt_api.h"
10
11/* that gives us 15 characters in the text event views */
12#define ZCRYPT_DBF_LEN 16
13
14/* sort out low debug levels early to avoid wasted sprints */
15static inline int zcrypt_dbf_passes(debug_info_t *dbf_grp, int level)
16{
17 return (level <= dbf_grp->level);
18}
19
20#define DBF_ERR 3 /* error conditions */
21#define DBF_WARN 4 /* warning conditions */
22#define DBF_INFO 6 /* informational */
23
24#define RC2WARN(rc) ((rc) ? DBF_WARN : DBF_INFO)
25
26#define ZCRYPT_DBF_COMMON(level, text...) \
27 do { \
28 if (zcrypt_dbf_passes(zcrypt_dbf_common, level)) { \
29 char debug_buffer[ZCRYPT_DBF_LEN]; \
30 snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \
31 debug_text_event(zcrypt_dbf_common, level, \
32 debug_buffer); \
33 } \
34 } while (0)
35
36#define ZCRYPT_DBF_DEVICES(level, text...) \
37 do { \
38 if (zcrypt_dbf_passes(zcrypt_dbf_devices, level)) { \
39 char debug_buffer[ZCRYPT_DBF_LEN]; \
40 snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \
41 debug_text_event(zcrypt_dbf_devices, level, \
42 debug_buffer); \
43 } \
44 } while (0)
45
46#define ZCRYPT_DBF_DEV(level, device, text...) \
47 do { \
48 if (zcrypt_dbf_passes(device->dbf_area, level)) { \
49 char debug_buffer[ZCRYPT_DBF_LEN]; \
50 snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \
51 debug_text_event(device->dbf_area, level, \
52 debug_buffer); \
53 } \
54 } while (0)
55
56int zcrypt_debug_init(void);
57void zcrypt_debug_exit(void);
58
59#endif /* ZCRYPT_DEBUG_H */