Skip to contentSkip to conversation

ath5k debugging take 2

PATCH In review Bruno Randolf 2 participants 5 messages Nov 26, 2007 – Nov 28, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

hello!

this is an updated version of my debugging changes. luis i hope i have addressed all your comments.

i have removed dumpstate to make the licensing simpler. now debug.c just contains stuff from base.c which always was dual BSD/GPL.

debug.c and debug.h now includes the original copyright from base.c, but is itself licensed under the GPL. i hope in this case that will not upset the original authors since it is just debugging stuff specific to linux anyways.

bruno

#1 lore raw

PATCH 1/1 ath5k: more consistent debugging

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

* consistently use ATH5K_DEBUG instead of AR_DEBUG and AR5K_DEBUG defines. ATH5K_DEBUG can be set from outside the Makefile via KCFLAGS.

* 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 and is limited by net_ratelimit(). another define ATH5K_DBG_UNLIMIT can be used specifically when we do not want the output to be rate limited.

* 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.

* remove ath5k_hw_dump_state().

* 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.

* add kerneldoc for debugging levels.

base.[ch]:
Changes-licensed-under: 3-clause-BSD

hw.c, ath5k.h, phy.c:
Changes-licensed-under: ISC

debug.[ch]:
Changes-licensed-under: GPL

---
 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  |  200 +++++++++++++++++++++++++++++
 drivers/net/wireless/ath5k/debug.h  |  212 +++++++++++++++++++++++++++++++
 drivers/net/wireless/ath5k/hw.c     |  239 ++++++++++-------------------------
 drivers/net/wireless/ath5k/phy.c    |   29 +++--
 8 files changed, 558 insertions(+), 365 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 +200 -0

200 lines not on this page · raw message

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

212 lines not on this page · raw message

drivers/net/wireless/ath5k/hw.c +68 -171

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
#4 lore raw
In reply to Bruno Randolf
Quoted 6 lines · Bruno Randolf

hello!

this is an updated version of my debugging changes. luis i hope i have addressed all your comments.

Quoted 6 lines

i have removed dumpstate to make the licensing simpler. now debug.c just contains stuff from base.c which always was dual BSD/GPL.

debug.c and debug.h now includes the original copyright from base.c, but is itself licensed under the GPL. i hope in this case that will not upset the original authors since it is just debugging stuff specific to linux anyways.

We have and continue to go out of our way to help OpenBSD despite their huge conspiracy theories that us, the SFLC and even the FSF are out to get them. It was understood that at certain point certain authors may want their new hw-related code licensed under the GPL. We cannot force people to embrace a new licensing policy but just advice to help our brothers. We're not going to say no to this new code if its useful, however, it is important to note that when this happens to files previously licensed under more a more permissive license that's where the buck stops in regards to guaranteeing inclusion of that new code under their code under more permissive licenses. It would still be possible but it would involve tracking down individual segments of files. But since git is pretty smart and keeps track of content rather than files and since we do and if we keep using the Change-licensed-under tag perhaps permissive license users can find an automagic way of knowing what sections of what files are permissive (ISC, BSD) or not (GPL).

But fortunately as you note this is only debug stuff which I do not think they can reap benefit over. Ultimately your changes can be licensed under the GPL if you choose. Its basically your choice. Now I'll review the patch :)

Luis

#2 lore raw

Re: [PATCH 1/1] ath5k: more consistent debugging

In reply to Bruno Randolf
Quoted 28 lines · Bruno Randolf

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

* consistently use ATH5K_DEBUG instead of AR_DEBUG and AR5K_DEBUG defines. ATH5K_DEBUG can be set from outside the Makefile via KCFLAGS.

* 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 and is limited by net_ratelimit(). another define ATH5K_DBG_UNLIMIT can be used specifically when we do not want the output to be rate limited.

* 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.

* remove ath5k_hw_dump_state().

* 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.

* add kerneldoc for debugging levels.

Quoted 8 lines

base.[ch]:
Changes-licensed-under: 3-clause-BSD

hw.c, ath5k.h, phy.c:
Changes-licensed-under: ISC

debug.[ch]:
Changes-licensed-under: GPL

Very nice, I have reviewed the patch quickly and this time it seems to address the license issues correctly provided your intention was to GPL your contributions. Just going to give this a spin and review debug.[ch] a bit more, I'll try to do it tonight.

Luis

#3 lore raw

Re: [PATCH 1/1] ath5k: more consistent debugging

In reply to Bruno Randolf

drivers/net/wireless/ath5k/debug.c

Quoted 5 lines · Bruno Randolf
drivers/net/wireless/ath5k/debug.c new file +0 -0
new file mode 100644
index 0000000..7427506

etc

Quoted 1 line

+#if ATH5K_DEBUG

This would be better as a CONFIG_ATH5K_DEBUG. Also the patch doesn't apply cleanly anymore. That's probably my fault for the delay in response and apologies for that. Other than that it looks fine. Sorry I couldn't test it. I'll try to amend it and test it.

Luis