xref: /dflybsd-src/sys/dev/netif/wpi/if_wpi_debug.h (revision e4bea86308f3a1bfc279fb58675696f2fb4335d7)
17370bffcSMatthew Dillon /*-
27370bffcSMatthew Dillon  * Copyright (c) 2006,2007
37370bffcSMatthew Dillon  *	Damien Bergamini <damien.bergamini@free.fr>
47370bffcSMatthew Dillon  *	Benjamin Close <Benjamin.Close@clearchain.com>
57370bffcSMatthew Dillon  * Copyright (c) 2015 Andriy Voskoboinyk <avos@FreeBSD.org>
67370bffcSMatthew Dillon  *
77370bffcSMatthew Dillon  * Permission to use, copy, modify, and distribute this software for any
87370bffcSMatthew Dillon  * purpose with or without fee is hereby granted, provided that the above
97370bffcSMatthew Dillon  * copyright notice and this permission notice appear in all copies.
107370bffcSMatthew Dillon  *
117370bffcSMatthew Dillon  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
127370bffcSMatthew Dillon  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
137370bffcSMatthew Dillon  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
147370bffcSMatthew Dillon  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
157370bffcSMatthew Dillon  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
167370bffcSMatthew Dillon  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
177370bffcSMatthew Dillon  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
187370bffcSMatthew Dillon  *
197370bffcSMatthew Dillon  * $FreeBSD$
207370bffcSMatthew Dillon  */
217370bffcSMatthew Dillon 
227370bffcSMatthew Dillon #ifndef __IF_WPI_DEBUG_H__
237370bffcSMatthew Dillon #define __IF_WPI_DEBUG_H__
247370bffcSMatthew Dillon 
257370bffcSMatthew Dillon #ifdef WPI_DEBUG
267370bffcSMatthew Dillon enum {
277370bffcSMatthew Dillon 	WPI_DEBUG_XMIT		= 0x00000001,	/* basic xmit operation */
287370bffcSMatthew Dillon 	WPI_DEBUG_RECV		= 0x00000002,	/* basic recv operation */
297370bffcSMatthew Dillon 	WPI_DEBUG_STATE		= 0x00000004,	/* 802.11 state transitions */
307370bffcSMatthew Dillon 	WPI_DEBUG_HW		= 0x00000008,	/* Stage 1 (eeprom) debugging */
317370bffcSMatthew Dillon 	WPI_DEBUG_RESET		= 0x00000010,	/* reset processing */
327370bffcSMatthew Dillon 	WPI_DEBUG_FIRMWARE	= 0x00000020,	/* firmware(9) loading debug */
337370bffcSMatthew Dillon 	WPI_DEBUG_BEACON	= 0x00000040,	/* beacon handling */
347370bffcSMatthew Dillon 	WPI_DEBUG_WATCHDOG	= 0x00000080,	/* watchdog timeout */
357370bffcSMatthew Dillon 	WPI_DEBUG_INTR		= 0x00000100,	/* ISR */
367370bffcSMatthew Dillon 	WPI_DEBUG_SCAN		= 0x00000200,	/* Scan related operations */
377370bffcSMatthew Dillon 	WPI_DEBUG_NOTIFY	= 0x00000400,	/* State 2 Notif intr debug */
387370bffcSMatthew Dillon 	WPI_DEBUG_TEMP		= 0x00000800,	/* TXPower/Temp Calibration */
397370bffcSMatthew Dillon 	WPI_DEBUG_CMD		= 0x00001000,	/* cmd submission */
407370bffcSMatthew Dillon 	WPI_DEBUG_TRACE		= 0x00002000,	/* Print begin and start driver function */
417370bffcSMatthew Dillon 	WPI_DEBUG_PWRSAVE	= 0x00004000,	/* Power save operations */
427370bffcSMatthew Dillon 	WPI_DEBUG_EEPROM	= 0x00008000,	/* EEPROM info */
437370bffcSMatthew Dillon 	WPI_DEBUG_NODE		= 0x00010000,	/* node addition/removal */
447370bffcSMatthew Dillon 	WPI_DEBUG_KEY		= 0x00020000,	/* node key management */
457370bffcSMatthew Dillon 	WPI_DEBUG_EDCA		= 0x00040000,	/* WME info */
467370bffcSMatthew Dillon 	WPI_DEBUG_REGISTER	= 0x00080000,	/* print chipset register */
477370bffcSMatthew Dillon 	WPI_DEBUG_BMISS		= 0x00100000,	/* print number of missed beacons */
487370bffcSMatthew Dillon 	WPI_DEBUG_ANY		= 0xffffffff
497370bffcSMatthew Dillon };
507370bffcSMatthew Dillon 
517370bffcSMatthew Dillon #define DPRINTF(sc, m, ...) do {		\
527370bffcSMatthew Dillon 	if (sc->sc_debug & (m))			\
53*e4bea863SSascha Wildner 		kprintf(__VA_ARGS__);		\
547370bffcSMatthew Dillon } while (0)
557370bffcSMatthew Dillon 
567370bffcSMatthew Dillon #define TRACE_STR_BEGIN		"->%s: begin\n"
577370bffcSMatthew Dillon #define TRACE_STR_DOING		"->Doing %s\n"
587370bffcSMatthew Dillon #define TRACE_STR_END		"->%s: end\n"
597370bffcSMatthew Dillon #define TRACE_STR_END_ERR	"->%s: end in error\n"
607370bffcSMatthew Dillon 
617370bffcSMatthew Dillon #define WPI_DESC(x) case x:	return #x
627370bffcSMatthew Dillon 
wpi_cmd_str(int cmd)637370bffcSMatthew Dillon static const char *wpi_cmd_str(int cmd)
647370bffcSMatthew Dillon {
657370bffcSMatthew Dillon 	switch (cmd) {
667370bffcSMatthew Dillon 		/* Notifications. */
677370bffcSMatthew Dillon 		WPI_DESC(WPI_UC_READY);
687370bffcSMatthew Dillon 		WPI_DESC(WPI_RX_DONE);
697370bffcSMatthew Dillon 		WPI_DESC(WPI_START_SCAN);
707370bffcSMatthew Dillon 		WPI_DESC(WPI_SCAN_RESULTS);
717370bffcSMatthew Dillon 		WPI_DESC(WPI_STOP_SCAN);
727370bffcSMatthew Dillon 		WPI_DESC(WPI_BEACON_SENT);
737370bffcSMatthew Dillon 		WPI_DESC(WPI_RX_STATISTICS);
747370bffcSMatthew Dillon 		WPI_DESC(WPI_BEACON_STATISTICS);
757370bffcSMatthew Dillon 		WPI_DESC(WPI_STATE_CHANGED);
767370bffcSMatthew Dillon 		WPI_DESC(WPI_BEACON_MISSED);
777370bffcSMatthew Dillon 
787370bffcSMatthew Dillon 		/* Command notifications. */
797370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_RXON);
807370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_RXON_ASSOC);
817370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_EDCA_PARAMS);
827370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_TIMING);
837370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_ADD_NODE);
847370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_DEL_NODE);
857370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_TX_DATA);
867370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_MRR_SETUP);
877370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_SET_LED);
887370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_SET_POWER_MODE);
897370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_SCAN);
907370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_SCAN_ABORT);
917370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_SET_BEACON);
927370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_TXPOWER);
937370bffcSMatthew Dillon 		WPI_DESC(WPI_CMD_BT_COEX);
947370bffcSMatthew Dillon 
957370bffcSMatthew Dillon 	default:
967370bffcSMatthew Dillon 		return "UNKNOWN CMD";
977370bffcSMatthew Dillon 	}
987370bffcSMatthew Dillon }
997370bffcSMatthew Dillon 
1007370bffcSMatthew Dillon /*
1017370bffcSMatthew Dillon  * Translate CSR code to string
1027370bffcSMatthew Dillon  */
wpi_get_csr_string(size_t csr)1037370bffcSMatthew Dillon static const char *wpi_get_csr_string(size_t csr)
1047370bffcSMatthew Dillon {
1057370bffcSMatthew Dillon 	switch (csr) {
1067370bffcSMatthew Dillon 		WPI_DESC(WPI_HW_IF_CONFIG);
1077370bffcSMatthew Dillon 		WPI_DESC(WPI_INT);
1087370bffcSMatthew Dillon 		WPI_DESC(WPI_INT_MASK);
1097370bffcSMatthew Dillon 		WPI_DESC(WPI_FH_INT);
1107370bffcSMatthew Dillon 		WPI_DESC(WPI_GPIO_IN);
1117370bffcSMatthew Dillon 		WPI_DESC(WPI_RESET);
1127370bffcSMatthew Dillon 		WPI_DESC(WPI_GP_CNTRL);
1137370bffcSMatthew Dillon 		WPI_DESC(WPI_EEPROM);
1147370bffcSMatthew Dillon 		WPI_DESC(WPI_EEPROM_GP);
1157370bffcSMatthew Dillon 		WPI_DESC(WPI_GIO);
1167370bffcSMatthew Dillon 		WPI_DESC(WPI_UCODE_GP1);
1177370bffcSMatthew Dillon 		WPI_DESC(WPI_UCODE_GP2);
1187370bffcSMatthew Dillon 		WPI_DESC(WPI_GIO_CHICKEN);
1197370bffcSMatthew Dillon 		WPI_DESC(WPI_ANA_PLL);
1207370bffcSMatthew Dillon 		WPI_DESC(WPI_DBG_HPET_MEM);
1217370bffcSMatthew Dillon 	default:
122*e4bea863SSascha Wildner 		KASSERT(0, ("Unknown CSR: %zu\n", csr));
1237370bffcSMatthew Dillon 		return "UNKNOWN CSR";
1247370bffcSMatthew Dillon 	}
1257370bffcSMatthew Dillon }
1267370bffcSMatthew Dillon 
wpi_get_prph_string(size_t prph)1277370bffcSMatthew Dillon static const char *wpi_get_prph_string(size_t prph)
1287370bffcSMatthew Dillon {
1297370bffcSMatthew Dillon 	switch (prph) {
1307370bffcSMatthew Dillon 		WPI_DESC(WPI_APMG_CLK_CTRL);
1317370bffcSMatthew Dillon 		WPI_DESC(WPI_APMG_PS);
1327370bffcSMatthew Dillon 		WPI_DESC(WPI_APMG_PCI_STT);
1337370bffcSMatthew Dillon 		WPI_DESC(WPI_APMG_RFKILL);
1347370bffcSMatthew Dillon 	default:
135*e4bea863SSascha Wildner 		KASSERT(0, ("Unknown register: %zu\n", prph));
1367370bffcSMatthew Dillon 		return "UNKNOWN PRPH";
1377370bffcSMatthew Dillon 	}
1387370bffcSMatthew Dillon }
1397370bffcSMatthew Dillon 
1407370bffcSMatthew Dillon #else
1417370bffcSMatthew Dillon #define DPRINTF(sc, m, ...)	do { (void) sc; } while (0)
1427370bffcSMatthew Dillon #endif
1437370bffcSMatthew Dillon 
1447370bffcSMatthew Dillon #endif	/* __IF_WPI_DEBUG_H__ */
145