Skip to contentSkip to conversation

ath9k patches

PATCH In review Sujith Manoharan 1 participant 8 messages Oct 6, 2014 – Oct 7, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ath9k patches

From: Sujith Manoharan <[email protected]>

Various fixes for -next.

Sujith Manoharan (6):
ath: Fix smatch warning
ath9k: Fix crash in MCC mode
ath9k: Fix sequence number assignment
ath9k: Use sta_state() callback
ath9k: Enable multi-channel properly
ath9k: Process beacons properly

 drivers/net/wireless/ath/ath9k/ath9k.h   |  6 +++--
 drivers/net/wireless/ath/ath9k/beacon.c  | 12 ++-------
 drivers/net/wireless/ath/ath9k/channel.c |  7 +++---
 drivers/net/wireless/ath/ath9k/main.c    | 43 +++++++++++++++++++++++++-------
 drivers/net/wireless/ath/ath9k/xmit.c    | 34 +++++++++++++++++--------
 drivers/net/wireless/ath/main.c          |  8 +++---
 6 files changed, 71 insertions(+), 39 deletions(-)
Signature · 1 line
2.1.2
#1 lore raw

PATCH 1/6 ath: Fix smatch warning

From: Sujith Manoharan <[email protected]>

drivers/net/wireless/ath/main.c:88 ath_printk()

	 error: we previously assumed 'common->hw' could be null (see line 82)
---
 drivers/net/wireless/ath/main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/main.c +4 -4
index 83f47af..338d723 100644
@@ -79,13 +79,13 @@ void ath_printk(const char *level, const struct ath_common* common,
 	vaf.fmt = fmt;
 	vaf.va = &args;
 
-	if (common && common->hw && common->hw->wiphy)
+	if (common && common->hw && common->hw->wiphy) {
 		printk("%sath: %s: %pV",
 		       level, wiphy_name(common->hw->wiphy), &vaf);
-	else
+		trace_ath_log(common->hw->wiphy, &vaf);
+	} else {
 		printk("%sath: %pV", level, &vaf);
-
-	trace_ath_log(common->hw->wiphy, &vaf);
+	}
 
 	va_end(args);
 }
Signature · 1 line
2.1.2
#2 lore raw

PATCH 2/6 ath9k: Fix crash in MCC mode

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

When a channel context is removed, the hw_queue_base is set to -1, this will result in a panic because ath9k_chanctx_stop_queues() can be called on an interface that is not assigned to any context yet - for example, when trying to scan.

Fix this issue by setting the hw_queue_base to zero when a channel context is removed.

---
 drivers/net/wireless/ath/ath9k/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/main.c +1 -1
index 2051624..6f6a974 100644
@@ -2332,7 +2332,7 @@ static void ath9k_remove_chanctx(struct ieee80211_hw *hw,
 		conf->def.chan->center_freq);
 
 	ctx->assigned = false;
-	ctx->hw_queue_base = -1;
+	ctx->hw_queue_base = 0;
 	ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_UNASSIGN);
 
 	mutex_unlock(&sc->mutex);
Signature · 1 line
2.1.2
#3 lore raw

PATCH 3/6 ath9k: Fix sequence number assignment

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

Currently, ath9k uses a global counter for all frames that need to be assigned a sequence number. QoS-data frames are handled properly since they have a per-tid counter. But, beacons and other management frames use the same counter even if multiple interfaces or contexts are present.

Fix this issue by making the counter per-interface and using it when mac80211 sets IEEE80211_TX_CTL_ASSIGN_SEQ.

---
 drivers/net/wireless/ath/ath9k/ath9k.h  |  4 +++-
 drivers/net/wireless/ath/ath9k/beacon.c | 12 ++----------
 drivers/net/wireless/ath/ath9k/xmit.c   | 34 ++++++++++++++++++++++-----------
 3 files changed, 28 insertions(+), 22 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +3 -1
index bfa0b15..01a7db0 100644
@@ -294,7 +294,6 @@ struct ath_tx_control {
  *  (axq_qnum).
  */
 struct ath_tx {
-	u16 seq_no;
 	u32 txqsetup;
 	spinlock_t txbuflock;
 	struct list_head txbuf;
@@ -563,6 +562,7 @@ int ath_tx_init(struct ath_softc *sc, int nbufs);
 int ath_txq_update(struct ath_softc *sc, int qnum,
 		   struct ath9k_tx_queue_info *q);
 void ath_update_max_aggr_framelen(struct ath_softc *sc, int queue, int txop);
+void ath_assign_seq(struct ath_common *common, struct sk_buff *skb);
 int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
 		 struct ath_tx_control *txctl);
 void ath_tx_cabq(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
@@ -592,6 +592,8 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw,
 struct ath_vif {
 	struct list_head list;
 
+	u16 seq_no;
+
 	/* BSS info */
 	u8 bssid[ETH_ALEN];
 	u16 aid;
drivers/net/wireless/ath/ath9k/beacon.c +2 -10
index a6af855..ecb783b 100644
@@ -144,16 +144,8 @@ static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw,
 	mgmt_hdr->u.beacon.timestamp = avp->tsf_adjust;
 
 	info = IEEE80211_SKB_CB(skb);
-	if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
-		/*
-		 * TODO: make sure the seq# gets assigned properly (vs. other
-		 * TX frames)
-		 */
-		struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
-		sc->tx.seq_no += 0x10;
-		hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
-		hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no);
-	}
+
+	ath_assign_seq(common, skb);
 
 	if (vif->p2p)
 		ath9k_beacon_add_noa(sc, avp, skb);
drivers/net/wireless/ath/ath9k/xmit.c +23 -11
index 151ae49..493a183 100644
@@ -2139,6 +2139,28 @@ static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
 	return bf;
 }
 
+void ath_assign_seq(struct ath_common *common, struct sk_buff *skb)
+{
+	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+	struct ieee80211_vif *vif = info->control.vif;
+	struct ath_vif *avp;
+
+	if (!(info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ))
+		return;
+
+	if (!vif)
+		return;
+
+	avp = (struct ath_vif *)vif->drv_priv;
+
+	if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
+		avp->seq_no += 0x10;
+
+	hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
+	hdr->seq_ctrl |= cpu_to_le16(avp->seq_no);
+}
+
 static int ath_tx_prepare(struct ieee80211_hw *hw, struct sk_buff *skb,
 			  struct ath_tx_control *txctl)
 {
@@ -2162,17 +2184,7 @@ static int ath_tx_prepare(struct ieee80211_hw *hw, struct sk_buff *skb,
 	if (info->control.hw_key)
 		frmlen += info->control.hw_key->icv_len;
 
-	/*
-	 * As a temporary workaround, assign seq# here; this will likely need
-	 * to be cleaned up to work better with Beacon transmission and virtual
-	 * BSSes.
-	 */
-	if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
-		if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
-			sc->tx.seq_no += 0x10;
-		hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
-		hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no);
-	}
+	ath_assign_seq(ath9k_hw_common(sc->sc_ah), skb);
 
 	if ((vif && vif->type != NL80211_IFTYPE_AP &&
 	            vif->type != NL80211_IFTYPE_AP_VLAN) ||
Signature · 1 line
2.1.2
#4 lore raw

PATCH 4/6 ath9k: Use sta_state() callback

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

Instead of using the sta_add()/sta_remove() callbacks, use the sta_state() callback since this gives more fine-grained control.

---
 drivers/net/wireless/ath/ath9k/main.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +26 -2
index 6f6a974..902807e 100644
@@ -1547,6 +1547,31 @@ static int ath9k_sta_remove(struct ieee80211_hw *hw,
 	return 0;
 }
 
+static int ath9k_sta_state(struct ieee80211_hw *hw,
+			   struct ieee80211_vif *vif,
+			   struct ieee80211_sta *sta,
+			   enum ieee80211_sta_state old_state,
+			   enum ieee80211_sta_state new_state)
+{
+	struct ath_softc *sc = hw->priv;
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+	int ret = 0;
+
+	if (old_state == IEEE80211_STA_AUTH &&
+	    new_state == IEEE80211_STA_ASSOC) {
+		ret = ath9k_sta_add(hw, vif, sta);
+		ath_dbg(common, CONFIG,
+			"Add station: %pM\n", sta->addr);
+	} else if (old_state == IEEE80211_STA_ASSOC &&
+		   new_state == IEEE80211_STA_AUTH) {
+		ret = ath9k_sta_remove(hw, vif, sta);
+		ath_dbg(common, CONFIG,
+			"Remove station: %pM\n", sta->addr);
+	}
+
+	return ret;
+}
+
 static void ath9k_sta_set_tx_filter(struct ath_hw *ah,
 				    struct ath_node *an,
 				    bool set)
@@ -2471,8 +2496,7 @@ struct ieee80211_ops ath9k_ops = {
 	.remove_interface   = ath9k_remove_interface,
 	.config 	    = ath9k_config,
 	.configure_filter   = ath9k_configure_filter,
-	.sta_add	    = ath9k_sta_add,
-	.sta_remove	    = ath9k_sta_remove,
+	.sta_state          = ath9k_sta_state,
 	.sta_notify         = ath9k_sta_notify,
 	.conf_tx 	    = ath9k_conf_tx,
 	.bss_info_changed   = ath9k_bss_info_changed,
Signature · 1 line
2.1.2
#5 lore raw

PATCH 5/6 ath9k: Enable multi-channel properly

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

In MCC mode, currently the decision to enable the multi-channel state machine is done based on the association status if one of the interfaces assigned to a context is in station mode.

This allows the driver to switch to the other context before the current station is able to complete the 4-way handshake in case it is required and this causes problems.

Instead, enable multi-channel mode when the station moves to the authorized state. This disallows an early switch to the other channel.

---
 drivers/net/wireless/ath/ath9k/ath9k.h   |  2 +-
 drivers/net/wireless/ath/ath9k/channel.c |  4 ++--
 drivers/net/wireless/ath/ath9k/main.c    | 13 +++++++------
 3 files changed, 10 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -1
index 01a7db0..aff5e4c 100644
@@ -362,7 +362,7 @@ enum ath_chanctx_event {
 	ATH_CHANCTX_EVENT_BEACON_SENT,
 	ATH_CHANCTX_EVENT_TSF_TIMER,
 	ATH_CHANCTX_EVENT_BEACON_RECEIVED,
-	ATH_CHANCTX_EVENT_ASSOC,
+	ATH_CHANCTX_EVENT_AUTHORIZED,
 	ATH_CHANCTX_EVENT_SWITCH,
 	ATH_CHANCTX_EVENT_ASSIGN,
 	ATH_CHANCTX_EVENT_UNASSIGN,
drivers/net/wireless/ath/ath9k/channel.c +2 -2
index 945c898..16bed6a 100644
@@ -171,7 +171,7 @@ static const char *chanctx_event_string(enum ath_chanctx_event ev)
 		case_rtn_string(ATH_CHANCTX_EVENT_BEACON_SENT);
 		case_rtn_string(ATH_CHANCTX_EVENT_TSF_TIMER);
 		case_rtn_string(ATH_CHANCTX_EVENT_BEACON_RECEIVED);
-		case_rtn_string(ATH_CHANCTX_EVENT_ASSOC);
+		case_rtn_string(ATH_CHANCTX_EVENT_AUTHORIZED);
 		case_rtn_string(ATH_CHANCTX_EVENT_SWITCH);
 		case_rtn_string(ATH_CHANCTX_EVENT_ASSIGN);
 		case_rtn_string(ATH_CHANCTX_EVENT_UNASSIGN);
@@ -510,7 +510,7 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
 
 		ath_chanctx_setup_timer(sc, tsf_time);
 		break;
-	case ATH_CHANCTX_EVENT_ASSOC:
+	case ATH_CHANCTX_EVENT_AUTHORIZED:
 		if (sc->sched.state != ATH_CHANCTX_STATE_FORCE_ACTIVE ||
 		    avp->chanctx != sc->cur_chan)
 			break;
drivers/net/wireless/ath/ath9k/main.c +7 -6
index 902807e..446bc46 100644
@@ -1569,6 +1569,13 @@ static int ath9k_sta_state(struct ieee80211_hw *hw,
 			"Remove station: %pM\n", sta->addr);
 	}
 
+	if (ath9k_is_chanctx_enabled()) {
+		if (old_state == IEEE80211_STA_ASSOC &&
+		    new_state == IEEE80211_STA_AUTHORIZED)
+			ath_chanctx_event(sc, vif,
+					  ATH_CHANCTX_EVENT_AUTHORIZED);
+	}
+
 	return ret;
 }
 
@@ -1761,12 +1768,6 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
 		avp->assoc = bss_conf->assoc;
 
 		ath9k_calculate_summary_state(sc, avp->chanctx);
-
-		if (ath9k_is_chanctx_enabled()) {
-			if (bss_conf->assoc)
-				ath_chanctx_event(sc, vif,
-						  ATH_CHANCTX_EVENT_ASSOC);
-		}
 	}
 
 	if (changed & BSS_CHANGED_IBSS) {
Signature · 1 line
2.1.2
#6 lore raw

PATCH 6/6 ath9k: Process beacons properly

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

When the current operating channel context has been marked as ATH_CHANCTX_STATE_FORCE_ACTIVE, do not process beacons that might be received, since we have to wait for the station to become authorized.

---
 drivers/net/wireless/ath/ath9k/channel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/channel.c +2 -1
index 16bed6a..55f2369 100644
@@ -492,7 +492,8 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
 		break;
 	case ATH_CHANCTX_EVENT_BEACON_RECEIVED:
 		if (!test_bit(ATH_OP_MULTI_CHANNEL, &common->op_flags) ||
-		    sc->cur_chan == &sc->offchannel.chan)
+		    sc->cur_chan == &sc->offchannel.chan ||
+		    sc->sched.state == ATH_CHANCTX_STATE_FORCE_ACTIVE)
 			break;
 
 		ath_chanctx_adjust_tbtt_delta(sc);
Signature · 1 line
2.1.2
#7 lore raw

Re: [PATCH 6/6] ath9k: Process beacons properly

Quoted 18 lines · Sujith Manoharan

From: Sujith Manoharan <[email protected]>

When the current operating channel context has been marked as ATH_CHANCTX_STATE_FORCE_ACTIVE, do not process beacons that might be received, since we have to wait for the station to become authorized.

---
 drivers/net/wireless/ath/ath9k/channel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/channel.c +0 -0
index 16bed6a..55f2369 100644

drivers/net/wireless/ath/ath9k/channel.c void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, · line 497

Quoted 7 lines
drivers/net/wireless/ath/ath9k/channel.c +2 -1
@@ -492,7 +492,8 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
 		break;
 	case ATH_CHANCTX_EVENT_BEACON_RECEIVED:
 		if (!test_bit(ATH_OP_MULTI_CHANNEL, &common->op_flags) ||
-		    sc->cur_chan == &sc->offchannel.chan)
+		    sc->cur_chan == &sc->offchannel.chan ||
+		    sc->sched.state == ATH_CHANCTX_STATE_FORCE_ACTIVE)
 			break;

The check for FORCE_ACTIVE needs to be done after we set beacon_miss/beacon_pending to zero.

Also, since we now have a small window where we start receiving beacons while waiting for the handshake to complete, we end up rearming the timer based on the cached tsf_val of the current channel. But, since it will be zero the first time the context becomes active, the timeout value is assigned spurious values.

I'll address both these issues and send a v2.

Sujith