1 /*- 2 * Copyright (c) 2006,2007 3 * Damien Bergamini <damien.bergamini@free.fr> 4 * Benjamin Close <Benjamin.Close@clearchain.com> 5 * Copyright (c) 2015 Andriy Voskoboinyk <avos@FreeBSD.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #ifndef __IF_WPI_DEBUG_H__ 21 #define __IF_WPI_DEBUG_H__ 22 23 #ifdef WPI_DEBUG 24 enum { 25 WPI_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ 26 WPI_DEBUG_RECV = 0x00000002, /* basic recv operation */ 27 WPI_DEBUG_STATE = 0x00000004, /* 802.11 state transitions */ 28 WPI_DEBUG_HW = 0x00000008, /* Stage 1 (eeprom) debugging */ 29 WPI_DEBUG_RESET = 0x00000010, /* reset processing */ 30 WPI_DEBUG_FIRMWARE = 0x00000020, /* firmware(9) loading debug */ 31 WPI_DEBUG_BEACON = 0x00000040, /* beacon handling */ 32 WPI_DEBUG_WATCHDOG = 0x00000080, /* watchdog timeout */ 33 WPI_DEBUG_INTR = 0x00000100, /* ISR */ 34 WPI_DEBUG_SCAN = 0x00000200, /* Scan related operations */ 35 WPI_DEBUG_NOTIFY = 0x00000400, /* State 2 Notif intr debug */ 36 WPI_DEBUG_TEMP = 0x00000800, /* TXPower/Temp Calibration */ 37 WPI_DEBUG_CMD = 0x00001000, /* cmd submission */ 38 WPI_DEBUG_TRACE = 0x00002000, /* Print begin and start driver function */ 39 WPI_DEBUG_PWRSAVE = 0x00004000, /* Power save operations */ 40 WPI_DEBUG_EEPROM = 0x00008000, /* EEPROM info */ 41 WPI_DEBUG_NODE = 0x00010000, /* node addition/removal */ 42 WPI_DEBUG_KEY = 0x00020000, /* node key management */ 43 WPI_DEBUG_EDCA = 0x00040000, /* WME info */ 44 WPI_DEBUG_REGISTER = 0x00080000, /* print chipset register */ 45 WPI_DEBUG_BMISS = 0x00100000, /* print number of missed beacons */ 46 WPI_DEBUG_ANY = 0xffffffff 47 }; 48 49 #define DPRINTF(sc, m, ...) do { \ 50 if (sc->sc_debug & (m)) \ 51 printf(__VA_ARGS__); \ 52 } while (0) 53 54 #define TRACE_STR_BEGIN "->%s: begin\n" 55 #define TRACE_STR_DOING "->Doing %s\n" 56 #define TRACE_STR_END "->%s: end\n" 57 #define TRACE_STR_END_ERR "->%s: end in error\n" 58 59 #define WPI_DESC(x) case x: return #x 60 61 static const char *wpi_cmd_str(int cmd) 62 { 63 switch (cmd) { 64 /* Notifications. */ 65 WPI_DESC(WPI_UC_READY); 66 WPI_DESC(WPI_RX_DONE); 67 WPI_DESC(WPI_START_SCAN); 68 WPI_DESC(WPI_SCAN_RESULTS); 69 WPI_DESC(WPI_STOP_SCAN); 70 WPI_DESC(WPI_BEACON_SENT); 71 WPI_DESC(WPI_RX_STATISTICS); 72 WPI_DESC(WPI_BEACON_STATISTICS); 73 WPI_DESC(WPI_STATE_CHANGED); 74 WPI_DESC(WPI_BEACON_MISSED); 75 76 /* Command notifications. */ 77 WPI_DESC(WPI_CMD_RXON); 78 WPI_DESC(WPI_CMD_RXON_ASSOC); 79 WPI_DESC(WPI_CMD_EDCA_PARAMS); 80 WPI_DESC(WPI_CMD_TIMING); 81 WPI_DESC(WPI_CMD_ADD_NODE); 82 WPI_DESC(WPI_CMD_DEL_NODE); 83 WPI_DESC(WPI_CMD_TX_DATA); 84 WPI_DESC(WPI_CMD_MRR_SETUP); 85 WPI_DESC(WPI_CMD_SET_LED); 86 WPI_DESC(WPI_CMD_SET_POWER_MODE); 87 WPI_DESC(WPI_CMD_SCAN); 88 WPI_DESC(WPI_CMD_SCAN_ABORT); 89 WPI_DESC(WPI_CMD_SET_BEACON); 90 WPI_DESC(WPI_CMD_TXPOWER); 91 WPI_DESC(WPI_CMD_BT_COEX); 92 93 default: 94 return "UNKNOWN CMD"; 95 } 96 } 97 98 /* 99 * Translate CSR code to string 100 */ 101 static const char *wpi_get_csr_string(size_t csr) 102 { 103 switch (csr) { 104 WPI_DESC(WPI_HW_IF_CONFIG); 105 WPI_DESC(WPI_INT); 106 WPI_DESC(WPI_INT_MASK); 107 WPI_DESC(WPI_FH_INT); 108 WPI_DESC(WPI_GPIO_IN); 109 WPI_DESC(WPI_RESET); 110 WPI_DESC(WPI_GP_CNTRL); 111 WPI_DESC(WPI_EEPROM); 112 WPI_DESC(WPI_EEPROM_GP); 113 WPI_DESC(WPI_GIO); 114 WPI_DESC(WPI_UCODE_GP1); 115 WPI_DESC(WPI_UCODE_GP2); 116 WPI_DESC(WPI_GIO_CHICKEN); 117 WPI_DESC(WPI_ANA_PLL); 118 WPI_DESC(WPI_DBG_HPET_MEM); 119 default: 120 KASSERT(0, ("Unknown CSR: %d\n", csr)); 121 return "UNKNOWN CSR"; 122 } 123 } 124 125 static const char *wpi_get_prph_string(size_t prph) 126 { 127 switch (prph) { 128 WPI_DESC(WPI_APMG_CLK_CTRL); 129 WPI_DESC(WPI_APMG_PS); 130 WPI_DESC(WPI_APMG_PCI_STT); 131 WPI_DESC(WPI_APMG_RFKILL); 132 default: 133 KASSERT(0, ("Unknown register: %d\n", prph)); 134 return "UNKNOWN PRPH"; 135 } 136 } 137 138 #else 139 #define DPRINTF(sc, m, ...) do { (void) sc; } while (0) 140 #endif 141 142 #endif /* __IF_WPI_DEBUG_H__ */ 143