blob: 8609269ca195773f40206daad643a57455d64031 [file] [log] [blame]
Hank Janssenab057782009-07-13 15:19:28 -07001/*
2 *
3 * Copyright (c) 2009, Microsoft Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
17 *
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
21 *
22 */
23
24
25#ifndef _LOGGING_H_
26#define _LOGGING_H_
27
Bill Pemberton454f18a2009-07-27 16:47:24 -040028/* #include <linux/init.h> */
29/* #include <linux/module.h> */
Hank Janssenab057782009-07-13 15:19:28 -070030
31#include "osd.h"
32
33#define VMBUS 0x0001
34#define STORVSC 0x0002
35#define NETVSC 0x0004
36#define INPUTVSC 0x0008
37#define BLKVSC 0x0010
38#define VMBUS_DRV 0x0100
39#define STORVSC_DRV 0x0200
40#define NETVSC_DRV 0x0400
41#define INPUTVSC_DRV 0x0800
42#define BLKVSC_DRV 0x1000
43
44#define ALL_MODULES (VMBUS |\
45 STORVSC |\
46 NETVSC |\
47 INPUTVSC |\
48 BLKVSC |\
49 VMBUS_DRV |\
50 STORVSC_DRV |\
51 NETVSC_DRV |\
52 INPUTVSC_DRV|\
53 BLKVSC_DRV)
54
Bill Pemberton454f18a2009-07-27 16:47:24 -040055/* Logging Level */
Greg Kroah-Hartmana14bd582009-07-16 12:35:07 -070056#define ERROR_LVL 3
57#define WARNING_LVL 4
58#define INFO_LVL 6
59#define DEBUG_LVL 7
Hank Janssenab057782009-07-13 15:19:28 -070060#define DEBUG_LVL_ENTEREXIT 8
61#define DEBUG_RING_LVL 9
62
63extern unsigned int vmbus_loglevel;
64
65#define ASSERT(expr) \
66 if (!(expr)) { \
Greg Kroah-Hartmana14bd582009-07-16 12:35:07 -070067 printk(KERN_CRIT "Assertion failed! %s,%s,%s,line=%d\n", \
68 #expr, __FILE__, __func__, __LINE__); \
Hank Janssenab057782009-07-13 15:19:28 -070069 __asm__ __volatile__("int3"); \
70 }
71
72#define DPRINT(mod, lvl, fmt, args...) do {\
Greg Kroah-Hartmana14bd582009-07-16 12:35:07 -070073 if ((mod & (HIWORD(vmbus_loglevel))) && \
74 (lvl <= LOWORD(vmbus_loglevel))) \
75 printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\
Hank Janssenab057782009-07-13 15:19:28 -070076 } while (0)
77
78#define DPRINT_DBG(mod, fmt, args...) do {\
Greg Kroah-Hartmana14bd582009-07-16 12:35:07 -070079 if ((mod & (HIWORD(vmbus_loglevel))) && \
80 (DEBUG_LVL <= LOWORD(vmbus_loglevel))) \
81 printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\
Hank Janssenab057782009-07-13 15:19:28 -070082 } while (0)
83
84#define DPRINT_INFO(mod, fmt, args...) do {\
Greg Kroah-Hartmana14bd582009-07-16 12:35:07 -070085 if ((mod & (HIWORD(vmbus_loglevel))) && \
86 (INFO_LVL <= LOWORD(vmbus_loglevel))) \
87 printk(KERN_INFO #mod": " fmt "\n", ## args);\
Hank Janssenab057782009-07-13 15:19:28 -070088 } while (0)
89
90#define DPRINT_WARN(mod, fmt, args...) do {\
Greg Kroah-Hartmana14bd582009-07-16 12:35:07 -070091 if ((mod & (HIWORD(vmbus_loglevel))) && \
92 (WARNING_LVL <= LOWORD(vmbus_loglevel))) \
93 printk(KERN_WARNING #mod": WARNING! " fmt "\n", ## args);\
Hank Janssenab057782009-07-13 15:19:28 -070094 } while (0)
95
96#define DPRINT_ERR(mod, fmt, args...) do {\
Greg Kroah-Hartmana14bd582009-07-16 12:35:07 -070097 if ((mod & (HIWORD(vmbus_loglevel))) && \
98 (ERROR_LVL <= LOWORD(vmbus_loglevel))) \
99 printk(KERN_ERR #mod": %s() ERROR!! " fmt "\n", \
100 __func__, ## args);\
Hank Janssenab057782009-07-13 15:19:28 -0700101 } while (0)
102
103#ifdef DEBUG
104#define DPRINT_ENTER(mod) do {\
Greg Kroah-Hartmana14bd582009-07-16 12:35:07 -0700105 if ((mod & (HIWORD(vmbus_loglevel))) && \
106 (DEBUG_LVL_ENTEREXIT <= LOWORD(vmbus_loglevel))) \
107 printk(KERN_DEBUG "["#mod"]: %s() enter\n", __func__);\
Hank Janssenab057782009-07-13 15:19:28 -0700108 } while (0)
109
110#define DPRINT_EXIT(mod) do {\
Greg Kroah-Hartmana14bd582009-07-16 12:35:07 -0700111 if ((mod & (HIWORD(vmbus_loglevel))) && \
112 (DEBUG_LVL_ENTEREXIT <= LOWORD(vmbus_loglevel))) \
113 printk(KERN_DEBUG "["#mod"]: %s() exit\n", __func__);\
Hank Janssenab057782009-07-13 15:19:28 -0700114 } while (0)
115#else
116#define DPRINT_ENTER(mod)
117#define DPRINT_EXIT(mod)
118#endif
119
Bill Pemberton454f18a2009-07-27 16:47:24 -0400120#endif /* _LOGGING_H_ */