- Fixes hang in TCP CLOSE/CLOSE_WAIT stages
[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 #define TRACE_CONN_OC_DBG       0x02000000
30
31 #define TRACE_D_DATA            (TRACE_D_READ | TRACE_D_WRITE)
32
33 #define TRACE_ALL_NO_DATA       (TRACE_ALL & ~TRACE_D_IOV & ~TRACE_D_DUMP_PDU & ~TRACE_D_DATA)
34
35 #ifdef DEBUG
36 #define ISCSI_DEFAULT_LOG_FLAGS (TRACE_FUNCTION | TRACE_LINE | TRACE_PID | \
37         TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MGMT_DEBUG | \
38         TRACE_MINOR | TRACE_SPECIAL | TRACE_CONN_OC)
39 #else
40 #define ISCSI_DEFAULT_LOG_FLAGS (TRACE_OUT_OF_MEM | TRACE_MGMT | \
41         TRACE_MINOR | TRACE_SPECIAL)
42 #endif
43
44 #ifdef DEBUG
45 struct msghdr;
46 struct iscsi_pdu;
47 extern void iscsi_dump_iov(struct msghdr *msg);
48 extern void iscsi_dump_pdu(struct iscsi_pdu *pdu);
49 #else
50 #define iscsi_dump_iov(x) do {} while (0)
51 #define iscsi_dump_pdu(x) do {} while (0)
52 #endif
53
54 #if defined(DEBUG) || defined(TRACING)
55 extern unsigned long iscsi_trace_flag;
56 #define trace_flag iscsi_trace_flag
57
58 #define TRACE_CONN_CLOSE(format, args...)                           \
59 do {                                                                \
60   if (trace_flag & TRACE_CONN_OC)                                   \
61   {                                                                 \
62     char *__tflag = LOG_FLAG;                                       \
63     if (debug_print_prefix(trace_flag, LOG_PREFIX, __FUNCTION__,    \
64                 __LINE__) > 0)                                      \
65     {                                                               \
66       __tflag = NO_FLAG;                                            \
67     }                                                               \
68     PRINT(NO_FLAG, "%s" format, __tflag, args);                     \
69   }                                                                 \
70 } while(0)
71
72 #define TRACE_CONN_CLOSE_DBG(format, args...)                       \
73 do {                                                                \
74   if (trace_flag & TRACE_CONN_OC_DBG)                               \
75   {                                                                 \
76     char *__tflag = LOG_FLAG;                                       \
77     if (debug_print_prefix(trace_flag, LOG_PREFIX, __FUNCTION__,    \
78                 __LINE__) > 0)                                      \
79     {                                                               \
80       __tflag = NO_FLAG;                                            \
81     }                                                               \
82     PRINT(NO_FLAG, "%s" format, __tflag, args);                     \
83   }                                                                 \
84 } while(0)
85
86 #define TRACE_NET_PAGE(format, args...)                             \
87 do {                                                                \
88   if (trace_flag & TRACE_NET_PG)                                    \
89   {                                                                 \
90     char *__tflag = LOG_FLAG;                                       \
91     if (debug_print_prefix(trace_flag, LOG_PREFIX, __FUNCTION__,    \
92                 __LINE__) > 0)                                      \
93     {                                                               \
94       __tflag = NO_FLAG;                                            \
95     }                                                               \
96     PRINT(NO_FLAG, "%s" format, __tflag, args);                     \
97   }                                                                 \
98 } while(0)
99
100 #else /* defined(DEBUG) || defined(TRACING) */
101 #define TRACE_CONN_CLOSE(format, args...) {}
102 #define TRACE_NET_PAGE(format, args...) {}
103 #endif
104
105 #endif