Skip to contentSkip to conversation

ath5k: more consistent debugging

PATCH In review Bruno Randolf 1 participant 1 message Nov 21, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 ath5k: more consistent debugging

* move all debugging functions to debug.c and debug.h

* consistently use ATH5K_DEBUG instead of AR_DEBUG and AR5K_DEBUG defines

* rename DPRINTF to ATH5K_DBG to be consistent with the other logging functions. ATH5K_DBG honors the debug level set on module load or by debugfs.

* move all instances where the debugging output was controlled by additional defines (ATH_DEBUG_MODES, ATH_DUMP_SKB) to use the debug level too.

* make ATH5K_TRACE honor the debug level as well

* rename all debugging functions to ath5k_debug_xxx. these are static inline {} when ATH5K_DEBUG is 0.

* make ath5k_debug_dump_skb distinguish between RX and TX, so we can choose wether we want to see RX or TX packets. also prepend the phyX name.

* added debugfs entry (ath5k/phyX/debug) to control the debug level for each device.

for base.c
Changes-licensed-under: 3-clause-BSD

for all others...
Changes-licensed-under: ISC

---
 drivers/net/wireless/ath5k/Makefile |    2 +-
 drivers/net/wireless/ath5k/ath5k.h  |   10 --
 drivers/net/wireless/ath5k/base.c   |  226 ++++++++-----------------------
 drivers/net/wireless/ath5k/base.h   |    5 +-
 drivers/net/wireless/ath5k/debug.c  |  258 +++++++++++++++++++++++++++++++++++
 drivers/net/wireless/ath5k/debug.h  |  138 +++++++++++++++++++
 drivers/net/wireless/ath5k/hw.c     |  239 +++++++++-----------------------
 drivers/net/wireless/ath5k/phy.c    |   29 ++--
 8 files changed, 543 insertions(+), 364 deletions(-)
drivers/net/wireless/ath5k/Makefile +1 -1
index f27560b..321641f 100644
@@ -1,2 +1,2 @@
-ath5k-objs		= base.o hw.o regdom.o initvals.o phy.o
+ath5k-objs		= base.o hw.o regdom.o initvals.o phy.o debug.o
 obj-$(CONFIG_ATH5K)	+= ath5k.o
drivers/net/wireless/ath5k/ath5k.h +0 -10
index 1b542f9..1b8ddd9 100644
@@ -25,9 +25,6 @@
  * you've been warned. */
 #define CHAN_DEBUG	0
 
-/* Uncomment this for debuging (warning that it results in TOO much output) */
-/* #define AR5K_DEBUG	1 */
-
 #include <linux/io.h>
 #include <linux/types.h>
 #include <net/mac80211.h>
@@ -90,12 +87,6 @@
 #define ATH5K_ERR(_sc, _fmt, ...) \
 	ATH5K_PRINTK_LIMIT(_sc, KERN_ERR, _fmt, ##__VA_ARGS__)
 
-#ifdef AR5K_DEBUG
-#define AR5K_TRACE              printk(KERN_DEBUG "%s:%d\n", __func__, __LINE__)
-#else
-#define AR5K_TRACE
-#endif
-
 /*
  * Some tuneable values (these should be changeable by the user)
  */
@@ -1114,7 +1105,6 @@ extern void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, u32 i
 /* Regulatory Domain/Channels Setup */
 extern u16 ath5k_get_regdomain(struct ath5k_hw *ah);
 /* Misc functions */
-extern void ath5k_hw_dump_state(struct ath5k_hw *ah);
 extern int ath5k_hw_get_capability(struct ath5k_hw *ah, enum ath5k_capability_type cap_type, u32 capability, u32 *result);
 
 
drivers/net/wireless/ath5k/base.c +58 -168

440 lines not on this page · raw message

drivers/net/wireless/ath5k/base.h +4 -1
index c13e54b..39a2fda 100644
@@ -47,6 +47,7 @@
 #include <linux/if_ether.h>
 
 #include "ath5k.h"
+#include "debug.h"
 
 #define	ATH_RXBUF	40		/* number of RX buffers */
 #define	ATH_TXBUF	200		/* number of TX buffers */
@@ -100,7 +101,9 @@ struct ath5k_softc {
 	enum ieee80211_if_types	opmode;
 	struct ath5k_hw		*ah;		/* Atheros HW */
 
-	int			debug;
+#if ATH5K_DEBUG
+	struct ath5k_dbg_info	debug;		/* debug info */
+#endif
 
 	struct ath5k_buf	*bufptr;	/* allocated buffer ptr */
 	struct ath5k_desc	*desc;		/* TX/RX descriptors */
drivers/net/wireless/ath5k/debug.c new file +258 -0

258 lines not on this page · raw message

drivers/net/wireless/ath5k/debug.h new file +138 -0

138 lines not on this page · raw message

drivers/net/wireless/ath5k/hw.c +69 -170

661 lines not on this page · raw message

drivers/net/wireless/ath5k/phy.c +15 -14
index a4968b6..3c2a67c 100644
@@ -24,6 +24,7 @@
 #include "ath5k.h"
 #include "reg.h"
 #include "base.h"
+#include "debug.h"
 
 /* Struct to hold initial RF register values (RF Banks) */
 struct ath5k_ini_rf {
@@ -880,11 +881,11 @@ static s32 ath5k_hw_rfregs_gain_adjust(struct ath5k_hw *ah)
 	}
 
 done:
-#ifdef AR5K_DEBUG
-	ATH5K_PRINTF("ret %d, gain step %u, current gain %u, target gain %u\n",
+	ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_CALIBRATE,
+		"ret %d, gain step %u, current gain %u, target gain %u\n",
 		ret, ah->ah_gain.g_step_idx, ah->ah_gain.g_current,
 		ah->ah_gain.g_target);
-#endif
+
 	return ret;
 }
 
@@ -1222,7 +1223,7 @@ enum ath5k_rfgain ath5k_hw_get_rf_gain(struct ath5k_hw *ah)
 {
 	u32 data, type;
 
-	AR5K_TRACE;
+	ATH5K_TRACE(ah->ah_sc);
 
 	if (ah->ah_rf_banks == NULL || !ah->ah_gain.g_active ||
 			ah->ah_version <= AR5K_AR5211)
@@ -1661,7 +1662,7 @@ static int ath5k_hw_rf511x_calibrate(struct ath5k_hw *ah,
 {
 	u32 i_pwr, q_pwr;
 	s32 iq_corr, i_coff, i_coffd, q_coff, q_coffd;
-	AR5K_TRACE;
+	ATH5K_TRACE(ah->ah_sc);
 
 	if (ah->ah_calibration == false ||
 			ath5k_hw_reg_read(ah, AR5K_PHY_IQ) & AR5K_PHY_IQ_RUN)
@@ -1718,7 +1719,7 @@ int ath5k_hw_phy_calibrate(struct ath5k_hw *ah,
 
 int ath5k_hw_phy_disable(struct ath5k_hw *ah)
 {
-	AR5K_TRACE;
+	ATH5K_TRACE(ah->ah_sc);
 	/*Just a try M.F.*/
 	ath5k_hw_reg_write(ah, AR5K_PHY_ACT_DISABLE, AR5K_PHY_ACT);
 
@@ -1738,7 +1739,7 @@ u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan)
 	u32 srev;
 	u16 ret;
 
-	AR5K_TRACE;
+	ATH5K_TRACE(ah->ah_sc);
 
 	/*
 	 * Set the radio chip access register
@@ -1780,7 +1781,7 @@ u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan)
 void /*TODO:Boundary check*/
 ath5k_hw_set_def_antenna(struct ath5k_hw *ah, unsigned int ant)
 {
-	AR5K_TRACE;
+	ATH5K_TRACE(ah->ah_sc);
 	/*Just a try M.F.*/
 	if (ah->ah_version != AR5K_AR5210)
 		ath5k_hw_reg_write(ah, ant, AR5K_DEFAULT_ANTENNA);
@@ -1788,7 +1789,7 @@ ath5k_hw_set_def_antenna(struct ath5k_hw *ah, unsigned int ant)
 
 unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw *ah)
 {
-	AR5K_TRACE;
+	ATH5K_TRACE(ah->ah_sc);
 	/*Just a try M.F.*/
 	if (ah->ah_version != AR5K_AR5210)
 		return ath5k_hw_reg_read(ah, AR5K_DEFAULT_ANTENNA);
@@ -1848,7 +1849,7 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
 	bool tpc = ah->ah_txpower.txp_tpc;
 	unsigned int i;
 
-	AR5K_TRACE;
+	ATH5K_TRACE(ah->ah_sc);
 	if (txpower > AR5K_TUNE_MAX_TXPOWER) {
 		ATH5K_ERR(ah->ah_sc, "invalid tx power: %u\n", txpower);
 		return -EINVAL;
@@ -1902,9 +1903,9 @@ int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, unsigned int power)
 	/*Just a try M.F.*/
 	struct ieee80211_channel *channel = &ah->ah_current_channel;
 
-	AR5K_TRACE;
-#ifdef AR5K_DEBUG
-	ATH5K_PRINTF("changing txpower to %d\n", power);
-#endif
+	ATH5K_TRACE(ah->ah_sc);
+	ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_TXPOWER,
+		"changing txpower to %d\n", power);
+
 	return ath5k_hw_txpower(ah, channel, power);
 }
Signature · 1 line
1.5.3.4