1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef __HISAX_DEBUG_H__
23#define __HISAX_DEBUG_H__
24
25
26#ifdef CONFIG_HISAX_DEBUG
27
28#define DBG(level, format, arg...) do { \
29 if (level & __debug_variable) \
30 printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \
31 } while (0)
32
33#define DBG_PACKET(level, data, count) \
34 if (level & __debug_variable) dump_packet(__func__, data, count)
35
36#define DBG_SKB(level, skb) \
37 if ((level & __debug_variable) && skb) dump_packet(__func__, skb->data, skb->len)
38
39
40static void __attribute__((unused))
41dump_packet(const char *name, const u_char *data, int pkt_len)
42{
43#define DUMP_HDR_SIZE 20
44#define DUMP_TLR_SIZE 8
45 if (pkt_len) {
46 int i, len1, len2;
47
48 printk(KERN_DEBUG "%s: length=%d,data=", name, pkt_len);
49
50 if (pkt_len > DUMP_HDR_SIZE + DUMP_TLR_SIZE) {
51 len1 = DUMP_HDR_SIZE;
52 len2 = DUMP_TLR_SIZE;
53 } else {
54 len1 = pkt_len > DUMP_HDR_SIZE ? DUMP_HDR_SIZE : pkt_len;
55 len2 = 0;
56 }
57 for (i = 0; i < len1; ++i) {
58 printk("%.2x", data[i]);
59 }
60 if (len2) {
61 printk("..");
62 for (i = pkt_len-DUMP_TLR_SIZE; i < pkt_len; ++i) {
63 printk("%.2x", data[i]);
64 }
65 }
66 printk("\n");
67 }
68#undef DUMP_HDR_SIZE
69#undef DUMP_TLR_SIZE
70}
71
72#else
73
74#define DBG(level, format, arg...) do {} while (0)
75#define DBG_PACKET(level, data, count) do {} while (0)
76#define DBG_SKB(level, skb) do {} while (0)
77
78#endif
79
80#endif
81