blob: ff54a7b0b232ca20b0496e53b48fe11e62d2aefb [file] [log] [blame]
Eric Van Hensbergen3ed84912005-09-09 13:04:24 -07001/*
2 * linux/fs/9p/debug.h - V9FS Debug Definitions
3 *
4 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
5 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to:
19 * Free Software Foundation
20 * 51 Franklin Street, Fifth Floor
21 * Boston, MA 02111-1301 USA
22 *
23 */
24
25#define DEBUG_ERROR (1<<0)
26#define DEBUG_CURRENT (1<<1)
27#define DEBUG_9P (1<<2)
28#define DEBUG_VFS (1<<3)
29#define DEBUG_CONV (1<<4)
30#define DEBUG_MUX (1<<5)
31#define DEBUG_TRANS (1<<6)
32#define DEBUG_SLABS (1<<7)
Latchesar Ionkov5174fda2006-03-25 03:07:25 -080033#define DEBUG_FCALL (1<<8)
Eric Van Hensbergen3ed84912005-09-09 13:04:24 -070034
35#define DEBUG_DUMP_PKT 0
36
37extern int v9fs_debug_level;
38
39#define dprintk(level, format, arg...) \
40do { \
41 if((v9fs_debug_level & level)==level) \
42 printk(KERN_NOTICE "-- %s (%d): " \
43 format , __FUNCTION__, current->pid , ## arg); \
44} while(0)
45
46#define eprintk(level, format, arg...) \
47do { \
48 printk(level "v9fs: %s (%d): " \
49 format , __FUNCTION__, current->pid , ## arg); \
50} while(0)
51
52#if DEBUG_DUMP_PKT
53static inline void dump_data(const unsigned char *data, unsigned int datalen)
54{
Latchesar Ionkov531b1092006-01-08 01:05:00 -080055 int i, n;
56 char buf[5*8];
Eric Van Hensbergen3ed84912005-09-09 13:04:24 -070057
Latchesar Ionkov531b1092006-01-08 01:05:00 -080058 n = 0;
59 i = 0;
60 while (i < datalen) {
61 n += snprintf(buf+n, sizeof(buf)-n, "%02x", data[i++]);
62 if (i%4 == 0)
63 n += snprintf(buf+n, sizeof(buf)-n, " ");
64
65 if (i%16 == 0) {
66 dprintk(DEBUG_ERROR, "%s\n", buf);
67 n = 0;
68 }
Eric Van Hensbergen3ed84912005-09-09 13:04:24 -070069 }
Latchesar Ionkov531b1092006-01-08 01:05:00 -080070
71 dprintk(DEBUG_ERROR, "%s\n", buf);
Eric Van Hensbergen3ed84912005-09-09 13:04:24 -070072}
73#else /* DEBUG_DUMP_PKT */
74static inline void dump_data(const unsigned char *data, unsigned int datalen)
75{
76
77}
78#endif /* DEBUG_DUMP_PKT */