Reverted refactoring of 'interrogate' cmds to 'query'
[acx-mac80211.git] / acx_log.h
blob549c0fe22b3c69a00fc90fa769e91db8c5b66638
1 #ifndef _ACX_LOG_H_
2 #define _ACX_LOG_H_
4 /*
5 * acx_log.h: logging constants and functions.
7 * Copyright (c) 2008, Francis Galiegue <fgaliegue@gmail.com> for the ACX100
8 * driver project.
10 * This file is licensed under GPL version 2.
14 * For KERN_*, and printk()
16 #include <linux/kernel.h>
19 * The acx_debug.h file defines the log level and default log mask.
21 #include "acx_debug.h"
23 #define ACX_LOG_LEVEL ACX_DEBUG
26 * TODO() and FIXME() macros
27 * these macros that inform the user (via printk) if we have possibly
28 * broken or incomplete code
31 #ifdef TODO
32 # undef TODO
33 #endif
34 #define TODO() \
35 do { \
36 printk(KERN_INFO "TODO: Incomplete code in %s() at %s:%d\n", \
37 __FUNCTION__, __FILE__, __LINE__); \
38 } while (0)
40 #ifdef FIXME
41 # undef FIXME
42 #endif
43 #define FIXME() \
44 do { \
45 printk(KERN_INFO "FIXME: Possibly broken code in %s() at %s:%d\n", \
46 __FUNCTION__, __FILE__, __LINE__); \
47 } while (0)
50 * Helpers to log MAC addresses
53 #define MACSTR "%02X:%02X:%02X:%02X:%02X:%02X"
54 #define MAC(bytevector) \
55 ((unsigned char *)bytevector)[0], \
56 ((unsigned char *)bytevector)[1], \
57 ((unsigned char *)bytevector)[2], \
58 ((unsigned char *)bytevector)[3], \
59 ((unsigned char *)bytevector)[4], \
60 ((unsigned char *)bytevector)[5]
63 * What to log.
65 #define L_LOCK 0x0001 /* Locking */
66 #define L_INIT 0x0002 /* Card initialization */
67 #define L_IRQ 0x0004 /* Interrupt handling */
68 #define L_ASSOC 0x0008 /* Assocation (network join) and station log */
69 #define L_FUNC 0x0010 /* Function enter/leave */
70 #define L_XFER 0x0020 /* TX management */
71 #define L_DATA 0x0040 /* Data transfer */
72 #define L_IOCTL 0x0080 /* Log ioctl calls */
73 #define L_CTL 0x0100 /* Log of low-level ctl commands */
74 #define L_BUFR 0x0200 /* Debug rx buffer mgmt (ring buffer etc.) */
75 #define L_XFER_BEACON 0x0400 /* Also log beacon packets */
76 #define L_BUFT 0x0800 /* Debug tx buffer mgmt (ring buffer etc.) */
77 #define L_USBRXTX 0x1000 /* Debug USB rx/tx operations */
78 #define L_BUF (L_BUFR|L_BUFT)
79 #define L_REALLYVERBOSE 0x2000 /* Flood me, baby! */
80 #define L_ANY 0xffff
82 #define ACX_DEFAULT_MSG (L_INIT|L_ASSOC|L_FUNC|L_IRQ)
84 * Log levels.
86 #define LOG_WARNING 0
87 #define LOG_INFO 1
88 #define LOG_DEBUG 2
90 #define MAX_LOG_LEVEL 2
93 * Function declarations.
95 * The acx_log_dump() function also dumps a buffer taken as an argument.
98 void acx_log(int level, int what, const char *fmt, ...);
99 void acx_log_dump(int level, int what, const void *buf, ssize_t buflen,
100 const char *fmt, ...);
103 * This one needs to be a macro! We don't want nested va_start()/va_end()
104 * calls...
107 #define acx_log_ratelimited(level, what, fmt...) do { \
108 if (!printk_ratelimit()) \
109 acx_log(level, what, fmt); \
110 } while (0)
112 #if ACX_LOG_LEVEL == 2
114 #define __FUNCTION_ENTER 0
115 #define __FUNCTION_EXIT 1
116 #define __FUNCTION_EXIT_WITHARG 2
118 void __function_enter_exit(const char *, int, int);
120 #define FN_ENTER do { \
121 __function_enter_exit(__func__, __FUNCTION_ENTER, 0); \
122 } while (0)
124 #define FN_EXIT0 do { \
125 __function_enter_exit(__func__, __FUNCTION_EXIT, 0); \
126 } while (0)
128 #define FN_EXIT1(retcode) do { \
129 __function_enter_exit(__func__, __FUNCTION_EXIT_WITHARG, retcode); \
130 } while (0)
132 #else
134 #define FN_ENTER do {} while(0)
135 #define FN_EXIT do {} while(0)
136 #define FN_EXIT1(retcode) do {} while(0)
138 #endif /* ACX_LOG_LEVEL == 2 */
140 #endif /* _ACX_LOG_H_ */