2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Common debugging macros for use with the hisax driver
|
|
|
|
*
|
|
|
|
* Author Frode Isaksen
|
|
|
|
* Copyright 2001 by Frode Isaksen <fisaksen@bewan.com>
|
|
|
|
* 2001 by Kai Germaschewski <kai.germaschewski@gmx.de>
|
2012-02-19 20:52:38 -07:00
|
|
|
*
|
2005-04-16 16:20:36 -06:00
|
|
|
* This software may be used and distributed according to the terms
|
|
|
|
* of the GNU General Public License, incorporated herein by reference.
|
|
|
|
*
|
|
|
|
* How to use:
|
2012-02-19 20:52:38 -07:00
|
|
|
*
|
2005-04-16 16:20:36 -06:00
|
|
|
* Before including this file, you need to
|
|
|
|
* #define __debug_variable my_debug
|
|
|
|
* where my_debug is a variable in your code which
|
|
|
|
* determines the debug bitmask.
|
|
|
|
*
|
|
|
|
* If CONFIG_HISAX_DEBUG is not set, all macros evaluate to nothing
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __HISAX_DEBUG_H__
|
|
|
|
#define __HISAX_DEBUG_H__
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_HISAX_DEBUG
|
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
#define DBG(level, format, arg...) do { \
|
|
|
|
if (level & __debug_variable) \
|
|
|
|
printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \
|
|
|
|
} while (0)
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
#define DBG_PACKET(level, data, count) \
|
|
|
|
if (level & __debug_variable) dump_packet(__func__, data, count)
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
#define DBG_SKB(level, skb) \
|
|
|
|
if ((level & __debug_variable) && skb) dump_packet(__func__, skb->data, skb->len)
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
|
|
|
|
static void __attribute__((unused))
|
2012-02-19 20:52:38 -07:00
|
|
|
dump_packet(const char *name, const u_char *data, int pkt_len)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
#define DUMP_HDR_SIZE 20
|
|
|
|
#define DUMP_TLR_SIZE 8
|
|
|
|
if (pkt_len) {
|
2012-02-19 20:52:38 -07:00
|
|
|
int i, len1, len2;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
printk(KERN_DEBUG "%s: length=%d,data=", name, pkt_len);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2012-02-19 20:52:38 -07:00
|
|
|
if (pkt_len > DUMP_HDR_SIZE + DUMP_TLR_SIZE) {
|
2005-04-16 16:20:36 -06:00
|
|
|
len1 = DUMP_HDR_SIZE;
|
|
|
|
len2 = DUMP_TLR_SIZE;
|
|
|
|
} else {
|
|
|
|
len1 = pkt_len > DUMP_HDR_SIZE ? DUMP_HDR_SIZE : pkt_len;
|
2012-02-19 20:52:38 -07:00
|
|
|
len2 = 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
for (i = 0; i < len1; ++i) {
|
2012-02-19 20:52:38 -07:00
|
|
|
printk("%.2x", data[i]);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
if (len2) {
|
2012-02-19 20:52:38 -07:00
|
|
|
printk("..");
|
2005-04-16 16:20:36 -06:00
|
|
|
for (i = pkt_len-DUMP_TLR_SIZE; i < pkt_len; ++i) {
|
2012-02-19 20:52:38 -07:00
|
|
|
printk("%.2x", data[i]);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
}
|
2012-02-19 20:52:38 -07:00
|
|
|
printk("\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
#undef DUMP_HDR_SIZE
|
|
|
|
#undef DUMP_TLR_SIZE
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define DBG(level, format, arg...) do {} while (0)
|
2012-02-19 20:52:38 -07:00
|
|
|
#define DBG_PACKET(level, data, count) do {} while (0)
|
|
|
|
#define DBG_SKB(level, skb) do {} while (0)
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|