689d350c1896f15d04d34834b045c967724ccb7a
[mirror/scst/.git] / iscsi-scst / kernel / iscsi_dbg.h
1 /*
2  *  Copyright (C) 2007 Vladislav Bolkhovitin
3  *  Copyright (C) 2007 CMS Distribution Limited
4  * 
5  *  This program is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU General Public License
7  *  as published by the Free Software Foundation, version 2
8  *  of the License.
9  * 
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  */
15
16 #ifndef ISCSI_DBG_H
17 #define ISCSI_DBG_H
18
19 #define LOG_PREFIX "iscsi-scst"
20
21 #include <scst_debug.h>
22
23 #define TRACE_D_READ            0x80000000
24 #define TRACE_D_WRITE           0x40000000
25 #define TRACE_CONN_OC           0x20000000
26 #define TRACE_D_IOV             0x10000000
27 #define TRACE_D_DUMP_PDU        0x08000000
28 #define TRACE_NET_PG            0x04000000
29
30 #define TRACE_D_DATA            (TRACE_D_READ | TRACE_D_WRITE)
31
32 #define TRACE_ALL_NO_DATA       (TRACE_ALL & ~TRACE_D_IOV & ~TRACE_D_DUMP_PDU & ~TRACE_D_DATA)
33
34 #ifdef DEBUG
35 #define ISCSI_DEFAULT_LOG_FLAGS (TRACE_FUNCTION | TRACE_LINE | TRACE_PID | \
36         TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MGMT_DEBUG | \
37         TRACE_MINOR | TRACE_SPECIAL | TRACE_CONN_OC)
38 #else
39 #define ISCSI_DEFAULT_LOG_FLAGS (TRACE_OUT_OF_MEM | TRACE_MGMT | \
40         TRACE_MINOR | TRACE_SPECIAL)
41 #endif
42
43 #ifdef DEBUG
44 struct msghdr;
45 struct iscsi_pdu;
46 extern void iscsi_dump_iov(struct msghdr *msg);
47 extern void iscsi_dump_pdu(struct iscsi_pdu *pdu);
48 #else
49 #define iscsi_dump_iov(x) do {} while (0)
50 #define iscsi_dump_pdu(x) do {} while (0)
51 #endif
52
53 #if defined(DEBUG) || defined(TRACING)
54 extern unsigned long iscsi_trace_flag;
55 #define trace_flag iscsi_trace_flag
56
57 #define TRACE_CONN_CLOSE(format, args...)                           \
58 do {                                                                \
59   if (trace_flag & TRACE_CONN_OC)                                   \
60   {                                                                 \
61     char *__tflag = LOG_FLAG;                                       \
62     if (debug_print_prefix(trace_flag, LOG_PREFIX, __FUNCTION__,    \
63                 __LINE__) > 0)                                      \
64     {                                                               \
65       __tflag = NO_FLAG;                                            \
66     }                                                               \
67     PRINT(NO_FLAG, "%s" format, __tflag, args);                     \
68   }                                                                 \
69 } while(0)
70
71 #define TRACE_NET_PAGE(format, args...)                             \
72 do {                                                                \
73   if (trace_flag & TRACE_NET_PG)                                    \
74   {                                                                 \
75     char *__tflag = LOG_FLAG;                                       \
76     if (debug_print_prefix(trace_flag, LOG_PREFIX, __FUNCTION__,    \
77                 __LINE__) > 0)                                      \
78     {                                                               \
79       __tflag = NO_FLAG;                                            \
80     }                                                               \
81     PRINT(NO_FLAG, "%s" format, __tflag, args);                     \
82   }                                                                 \
83 } while(0)
84
85 #else /* defined(DEBUG) || defined(TRACING) */
86 #define TRACE_CONN_CLOSE(format, args...) {}
87 #define TRACE_NET_PAGE(format, args...) {}
88 #endif
89
90 #endif