Skip to contentSkip to conversation

ath9k: Add debug information

PATCH Superseded Sujith Manoharan 2 participants 3 messages Aug 21, 2014 – Aug 22, 2014 Qualcomm Atheros ATH9K wireless driver

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9k: Add debug information

From: Sujith Manoharan <[email protected]>

Add a few statements to debug channel context operation.

---
 drivers/net/wireless/ath/ath9k/channel.c | 54 ++++++++++++++++++++++-
 drivers/net/wireless/ath/ath9k/main.c    | 73 +++++++++++++++++++++++++++-----
 2 files changed, 115 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath9k/channel.c +53 -1
index 0ce9e40..da5b522 100644
@@ -16,6 +16,16 @@
 
 #include "ath9k.h"
 
+static const char *offchannel_state[] = {
+	"ATH_OFFCHANNEL_IDLE",
+	"ATH_OFFCHANNEL_PROBE_SEND",
+	"ATH_OFFCHANNEL_PROBE_WAIT",
+	"ATH_OFFCHANNEL_SUSPEND",
+	"ATH_OFFCHANNEL_ROC_START",
+	"ATH_OFFCHANNEL_ROC_WAIT",
+	"ATH_OFFCHANNEL_ROC_DONE",
+};
+
 /* Set/change channels.  If the channel is really being changed, it's done
  * by reseting the chip.  To accomplish this we must first cleanup any pending
  * DMA, then restart stuff.
@@ -373,13 +383,23 @@ void ath_chanctx_switch(struct ath_softc *sc, struct ath_chanctx *ctx,
 	}
 
 	sc->next_chan = ctx;
-	if (chandef)
+	if (chandef) {
 		ctx->chandef = *chandef;
+		ath_dbg(common, CHAN_CTX,
+			"Assigned next_chan to %d MHz\n", chandef->center_freq1);
+	}
 
 	if (sc->next_chan == &sc->offchannel.chan) {
 		sc->sched.offchannel_duration =
 			TU_TO_USEC(sc->offchannel.duration) +
 			sc->sched.channel_switch_time;
+
+		if (chandef) {
+			ath_dbg(common, CHAN_CTX,
+				"Offchannel duration for chan %d MHz : %u\n",
+				chandef->center_freq1,
+				sc->sched.offchannel_duration);
+		}
 	}
 	spin_unlock_bh(&sc->chan_lock);
 	ieee80211_queue_work(sc->hw, &sc->chanctx_work);
@@ -422,9 +442,12 @@ struct ath_chanctx *ath_chanctx_get_oper_chan(struct ath_softc *sc, bool active)
 void ath_chanctx_offchan_switch(struct ath_softc *sc,
 				struct ieee80211_channel *chan)
 {
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	struct cfg80211_chan_def chandef;
 
 	cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT);
+	ath_dbg(common, CHAN_CTX,
+		"Channel definition created: %d MHz\n", chandef.center_freq1);
 
 	ath_chanctx_switch(sc, &sc->offchannel.chan, &chandef);
 }
@@ -698,19 +721,30 @@ static int ath_scan_channel_duration(struct ath_softc *sc,
 static void
 ath_scan_next_channel(struct ath_softc *sc)
 {
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	struct cfg80211_scan_request *req = sc->offchannel.scan_req;
 	struct ieee80211_channel *chan;
 
 	if (sc->offchannel.scan_idx >= req->n_channels) {
+		ath_dbg(common, CHAN_CTX,
+			"Moving to ATH_OFFCHANNEL_IDLE state, scan_idx: %d, n_channels: %d\n",
+			sc->offchannel.scan_idx,
+			req->n_channels);
+
 		sc->offchannel.state = ATH_OFFCHANNEL_IDLE;
 		ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc, false),
 				   NULL);
 		return;
 	}
 
+	ath_dbg(common, CHAN_CTX,
+		"Moving to ATH_OFFCHANNEL_PROBE_SEND state, scan_idx: %d\n",
+		sc->offchannel.scan_idx);
+
 	chan = req->channels[sc->offchannel.scan_idx++];
 	sc->offchannel.duration = ath_scan_channel_duration(sc, chan);
 	sc->offchannel.state = ATH_OFFCHANNEL_PROBE_SEND;
+
 	ath_chanctx_offchan_switch(sc, chan);
 }
 
@@ -751,6 +785,11 @@ void ath_scan_complete(struct ath_softc *sc, bool abort)
 {
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 
+	if (abort)
+		ath_dbg(common, CHAN_CTX, "HW scan aborted\n");
+	else
+		ath_dbg(common, CHAN_CTX, "HW scan complete\n");
+
 	sc->offchannel.scan_req = NULL;
 	sc->offchannel.scan_vif = NULL;
 	sc->offchannel.state = ATH_OFFCHANNEL_IDLE;
@@ -800,6 +839,7 @@ error:
 
 static void ath_scan_channel_start(struct ath_softc *sc)
 {
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	struct cfg80211_scan_request *req = sc->offchannel.scan_req;
 	int i;
 
@@ -810,12 +850,20 @@ static void ath_scan_channel_start(struct ath_softc *sc)
 
 	}
 
+	ath_dbg(common, CHAN_CTX,
+		"Moving to ATH_OFFCHANNEL_PROBE_WAIT state\n");
+
 	sc->offchannel.state = ATH_OFFCHANNEL_PROBE_WAIT;
 	mod_timer(&sc->offchannel.timer, jiffies + sc->offchannel.duration);
 }
 
 void ath_offchannel_channel_change(struct ath_softc *sc)
 {
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+
+	ath_dbg(common, CHAN_CTX, "%s: state: %s\n",
+		__func__, offchannel_state[sc->offchannel.state]);
+
 	switch (sc->offchannel.state) {
 	case ATH_OFFCHANNEL_PROBE_SEND:
 		if (!sc->offchannel.scan_req)
@@ -854,6 +902,10 @@ void ath_offchannel_timer(unsigned long data)
 {
 	struct ath_softc *sc = (struct ath_softc *)data;
 	struct ath_chanctx *ctx;
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+
+	ath_dbg(common, CHAN_CTX, "%s: state: %s\n",
+		__func__, offchannel_state[sc->offchannel.state]);
 
 	switch (sc->offchannel.state) {
 	case ATH_OFFCHANNEL_PROBE_WAIT:
drivers/net/wireless/ath/ath9k/main.c +62 -11

184 lines not on this page · raw message

Signature · 1 line
2.0.4
#1 lore raw
Quoted 1 line · Sujith Manoharan

Add a few statements to debug channel context operation.

[]

Quoted 7 lines
drivers/net/wireless/ath/ath9k/channel.c +0 -0
index 0ce9e40..da5b522 100644
@@ -16,6 +16,16 @@
 
 #include "ath9k.h"

drivers/net/wireless/ath/ath9k/channel.c line 27

Quoted 10 lines
drivers/net/wireless/ath/ath9k/channel.c +9 -0
 
+static const char *offchannel_state[] = {
+	"ATH_OFFCHANNEL_IDLE",
+	"ATH_OFFCHANNEL_PROBE_SEND",
+	"ATH_OFFCHANNEL_PROBE_WAIT",
+	"ATH_OFFCHANNEL_SUSPEND",
+	"ATH_OFFCHANNEL_ROC_START",
+	"ATH_OFFCHANNEL_ROC_WAIT",
+	"ATH_OFFCHANNEL_ROC_DONE",
+};

Perhaps:
static const char * const offchannel_state[] = {...

It is typically is an unsafe practice to
index an char * array with an enum.

It might be safer to use a lookup function
(and smaller when ath_dbg is not enabled)

Something like:

static const char *offchannel_state_string(enum ath_offchannel_state state) {

#define case_rtn_string(val) case val: return #val
	switch (state) {
	case_rtn_string(ATH_OFFCHANNEL_IDLE);
	case_rtn_string(ATH_OFFCHANNEL_PROBE_SEND);
	case_rtn_string(ATH_OFFCHANNEL_PROBE_WAIT);
	case_rtn_string(ATH_OFFCHANNEL_SUSPEND);
	case_rtn_string(ATH_OFFCHANNEL_ROC_START);
	case_rtn_string(ATH_OFFCHANNEL_ROC_WAIT);
	case_rtn_string(ATH_OFFCHANNEL_ROC_DONE);
	default:
		return "unknown";
	}
}
#2 lore raw
Quoted 13 lines · Joe Perches

Perhaps:
static const char * const offchannel_state[] = {...

It is typically is an unsafe practice to
index an char * array with an enum.

It might be safer to use a lookup function
(and smaller when ath_dbg is not enabled)

Something like:

static const char *offchannel_state_string(enum ath_offchannel_state state) {

Quoted 13 lines
#define case_rtn_string(val) case val: return #val
	switch (state) {
	case_rtn_string(ATH_OFFCHANNEL_IDLE);
	case_rtn_string(ATH_OFFCHANNEL_PROBE_SEND);
	case_rtn_string(ATH_OFFCHANNEL_PROBE_WAIT);
	case_rtn_string(ATH_OFFCHANNEL_SUSPEND);
	case_rtn_string(ATH_OFFCHANNEL_ROC_START);
	case_rtn_string(ATH_OFFCHANNEL_ROC_WAIT);
	case_rtn_string(ATH_OFFCHANNEL_ROC_DONE);
	default:
		return "unknown";
	}
}

This looks better, I'll send a v2. Thanks for the review.

Sujith