1 #ifndef __NET_DEBUG_H 2 #define __NET_DEBUG_H 3 4 #include "hal_trace.h" 5 #include "net_defs.h" 6 7 enum { 8 DUMP_PREFIX_NONE, 9 DUMP_PREFIX_ADDRESS, 10 DUMP_PREFIX_OFFSET 11 }; 12 13 #define wlan_debug(fmt, ...) TRACE(fmt, ##__VA_ARGS__) 14 15 //#define NET_ASSERT(cond, ...) { if (!(cond)) {wlan_debug("wlan assert %s line %d \n",__func__, __LINE__); while(1); } } 16 #define NET_ASSERT(cond, ...) {ASSERT(cond, "net assert")} 17 18 extern uint32_t kernel_debug_level; 19 20 21 #define KERN_ALERT 0 22 #define KERN_CRITICAL 1 23 #define KERN_ERR 2 24 #define KERN_WARN 3 25 #define KERN_INFO 4 26 #define KERN_DEBUG 5 27 #define KERN_LOUD 6 28 29 //#define KERN_DBG_LEVEL KERN_INFO 30 31 //#define printk TRACE 32 #define printk(level, str, ...) \ 33 ({ \ 34 if ((level) <= kernel_debug_level) \ 35 TRACE(str, ##__VA_ARGS__); \ 36 }) 37 38 #define BUILD_BUG_ON(condition) 39 40 #define WARN_ON(condition) \ 41 ({ \ 42 int __ret_warn_on = !!(condition); \ 43 if (unlikely(__ret_warn_on)){ \ 44 wlan_debug("WARN_ON:%s %d \n", __func__, __LINE__); \ 45 }\ 46 unlikely(__ret_warn_on); \ 47 }) 48 49 50 #ifndef WARN 51 #define WARN(condition, format...) ({ \ 52 int __ret_warn_on = !!(condition); \ 53 if (unlikely(__ret_warn_on)) \ 54 wlan_debug(format); \ 55 unlikely(__ret_warn_on); \ 56 }) 57 #endif 58 #ifndef MAC2STR 59 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] 60 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" 61 #endif 62 63 #ifndef WARN_ON_ONCE 64 #define WARN_ON_ONCE(condition) ({ \ 65 static bool __warned; \ 66 int __ret_warn_once = !!(condition); \ 67 \ 68 if (unlikely(__ret_warn_once)) \ 69 if (WARN_ON(!__warned)) \ 70 __warned = true; \ 71 unlikely(__ret_warn_once); \ 72 }) 73 74 #endif 75 76 #define BUG() 77 78 #define BUG_ON(cond) ASSERT(!(cond), "ASSERT:%s line:%d", __func__, __LINE__) 79 extern uint32_t rt_get_PSP (void); 80 //#define ENTER() printk(KERN_DEBUG, "Enter:%s %d\n", __func__, __LINE__); 81 //#define LEAVE() printk(KERN_DEBUG, "Leave:%s %d\n", __func__, __LINE__); 82 #define ENTER() 83 #define LEAVE() 84 85 extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, 86 const void *buf, size_t len); 87 88 #endif /* __NET_DEBUG_H */ 89