Skip to contentSkip to conversation

ath9k patches

PATCH Superseded Sujith Manoharan 1 participant 12 messages Sep 5, 2014 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

v3 cover ath9k patches

From: Sujith Manoharan <[email protected]>

Pending patches, meant for 3.18.

Sujith Manoharan (11):
ath9k: Fix beacon configuration for channel contexts
ath9k: Fix beacons for managed mode
ath9k: Fix panic when adding an AP interface
ath9k: Fix NoA start time calculation
ath9k: Fix offchannel duration calculation
ath9k: Add CTWindow support
ath9k: Fix RX filter calculation
ath9k: Fix ath_startrecv()
ath9k: Fix COMP_BAR filter
ath9k: Fix RX filters in channel contexts
ath9k: Fix interface accounting

 drivers/net/wireless/ath/ath9k/ath9k.h   |  9 +++++---
 drivers/net/wireless/ath/ath9k/beacon.c  | 14 +++++++++++-
 drivers/net/wireless/ath/ath9k/channel.c | 39 +++++++++++++++++++++++++++-----
 drivers/net/wireless/ath/ath9k/debug.c   |  2 +-
 drivers/net/wireless/ath/ath9k/init.c    |  5 ++--
 drivers/net/wireless/ath/ath9k/main.c    | 30 ++++++++++++------------
 drivers/net/wireless/ath/ath9k/recv.c    | 31 +++++++++++++++----------
 drivers/net/wireless/ath/ath9k/tx99.c    |  2 +-
 drivers/net/wireless/ath/ath9k/wow.c     |  2 +-
 9 files changed, 92 insertions(+), 42 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH v3 1/11 ath9k: Fix beacon configuration for channel contexts

From: Sujith Manoharan <[email protected]>

In channel context mode, when a new context is added, mac80211 issues a bss_info_changed() notfication when preparing the connection for the new interface/context.

But, this is done prior to the mgd_prepare_tx() call which is where we switch to the new context. Since the current context will be different when the earlier bss_info_changed() is handled, the beacon information for the VIF is not updated, but discarded since the rules for the current context disallows it.

In the subsequent association process for the new context/vif, this becomes a problem because the beacon parameters are invalid. This causes problems with the TSF timer, causing large jumps.

To fix this, check if the beacon info is being updated for a different context and if so, allow it without any checks since we limit the max. interfaces to two anyway.

---
 drivers/net/wireless/ath/ath9k/beacon.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/wireless/ath/ath9k/beacon.c +12 -0
index b2f56d8..83f2f2f 100644
@@ -514,6 +514,18 @@ static bool ath9k_allow_beacon_config(struct ath_softc *sc,
 				      struct ieee80211_vif *vif)
 {
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+	struct ath_vif *avp = (void *)vif->drv_priv;
+
+	if (ath9k_is_chanctx_enabled()) {
+		/*
+		 * If the VIF is not present in the current channel context,
+		 * then we can't do the usual opmode checks. Allow the
+		 * beacon config for the VIF to be updated in this case and
+		 * return immediately.
+		 */
+		if (sc->cur_chan != avp->chanctx)
+			return true;
+	}
 
 	if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) {
 		if ((vif->type != NL80211_IFTYPE_AP) ||
Signature · 1 line
2.1.0
#2 lore raw

PATCH v3 2/11 ath9k: Fix beacons for managed mode

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

If the current opmode is managed, the ATH_OP_BEACONS flag needs to be set only when there is a primary station interface and it is associated/active.

---
 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 d9be831..0b3d4d8 100644
@@ -1067,8 +1067,8 @@ void ath9k_calculate_summary_state(struct ath_softc *sc,
 	if (ah->opmode == NL80211_IFTYPE_STATION) {
 		bool changed = (iter_data.primary_sta != ctx->primary_sta);
 
-		iter_data.beacons = true;
 		if (iter_data.primary_sta) {
+			iter_data.beacons = true;
 			ath9k_set_assoc_state(sc, iter_data.primary_sta,
 					      changed);
 			if (!ctx->primary_sta ||
Signature · 1 line
2.1.0
#3 lore raw

PATCH v3 3/11 ath9k: Fix panic when adding an AP interface

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

If a station interface is already assigned to a context and is active and a second interface of type AP is added, then beaconing on the new interface has to be begin only after the BSS_CHANGED_BEACON_ENABLED flag is sent by mac80211 to the driver.

But, since we issue ATH_CHANCTX_EVENT_ENABLE_MULTICHANNEL as soon as a new channel context is added, a switch occurs almost immediately before BSS_CHANGED_BEACON_ENABLED is received. When a HW reset is done for the new context, beacons are enabled for the interface since "enable_beacon" in the BSS config maintained in mac80211 is true - but the driver hasn't been notified yet. This causes a panic, since the beacon interval is zero for this interface and ath9k_cmn_beacon_config_ap() doesn't have a safety check.

Fix this panic by checking if the beacon params has been cached for this context and use the "enable_beacon" flag maintained locally in the driver. Also, recalculate the summary data after the beacon params have been cached when BSS_CHANGED_BEACON_ENABLED is received.

---
 drivers/net/wireless/ath/ath9k/main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +5 -3
index 0b3d4d8..2333776 100644
@@ -916,8 +916,6 @@ static void ath9k_vif_iter(struct ath9k_vif_iter_data *iter_data,
 	switch (vif->type) {
 	case NL80211_IFTYPE_AP:
 		iter_data->naps++;
-		if (vif->bss_conf.enable_beacon)
-			iter_data->beacons = true;
 		break;
 	case NL80211_IFTYPE_STATION:
 		iter_data->nstations++;
@@ -1021,6 +1019,7 @@ void ath9k_calculate_summary_state(struct ath_softc *sc,
 	struct ath_hw *ah = sc->sc_ah;
 	struct ath_common *common = ath9k_hw_common(ah);
 	struct ath9k_vif_iter_data iter_data;
+	struct ath_beacon_config *cur_conf;
 
 	ath_chanctx_check_active(sc, ctx);
 
@@ -1037,8 +1036,11 @@ void ath9k_calculate_summary_state(struct ath_softc *sc,
 	ath_hw_setbssidmask(common);
 
 	if (iter_data.naps > 0) {
+		cur_conf = &ctx->beacon;
 		ath9k_hw_set_tsfadjust(ah, true);
 		ah->opmode = NL80211_IFTYPE_AP;
+		if (cur_conf->enable_beacon)
+			iter_data.beacons = true;
 	} else {
 		ath9k_hw_set_tsfadjust(ah, false);
 
@@ -1695,9 +1697,9 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
 	if ((changed & BSS_CHANGED_BEACON_ENABLED) ||
 	    (changed & BSS_CHANGED_BEACON_INT) ||
 	    (changed & BSS_CHANGED_BEACON_INFO)) {
+		ath9k_beacon_config(sc, vif, changed);
 		if (changed & BSS_CHANGED_BEACON_ENABLED)
 			ath9k_calculate_summary_state(sc, avp->chanctx);
-		ath9k_beacon_config(sc, vif, changed);
 	}
 
 	if ((avp->chanctx == sc->cur_chan) &&
Signature · 1 line
2.1.0
#4 lore raw

PATCH v3 4/11 ath9k: Fix NoA start time calculation

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

The start time field in the NoA attribute needs to be updated based on the TSF timer when an absence notification is sent by the P2P GO. When two channel contexts are active, continuous, cyclic NoA is announced by setting the count value to 255, but the start time is updated only once, for one beacon and the same value is sent in all subsequent beacons, even though the timestamp keeps moving.

Fix this by removing the check for 'periodic_noa_duration' and assign the interface's start_time/duration values directly when there is more than one active context.

---
 drivers/net/wireless/ath/ath9k/channel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/channel.c +2 -2
index 409f912..047a76f 100644
@@ -377,13 +377,13 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
 		    tsf_time - avp->periodic_noa_start > BIT(30))
 			avp->periodic_noa_duration = 0;
 
-		if (ctx->active && !avp->periodic_noa_duration) {
+		if (ctx->active) {
 			avp->periodic_noa_start = tsf_time;
 			avp->periodic_noa_duration =
 				TU_TO_USEC(cur_conf->beacon_interval) / 2 -
 				sc->sched.channel_switch_time;
 			noa_changed = true;
-		} else if (!ctx->active && avp->periodic_noa_duration) {
+		} else if (!ctx->active) {
 			avp->periodic_noa_duration = 0;
 			noa_changed = true;
 		}
Signature · 1 line
2.1.0
#5 lore raw

PATCH v3 5/11 ath9k: Fix offchannel duration calculation

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

Currently, different units are used for handling sc->offchannel.duration. In scan mode, it contains jiffies and in RoC mode, milliseconds is used. This causes confusion since in ath_chanctx_switch(), TU_TO_USEC is used to determine the offchannel duration, resulting in incorrect values. Fix this by using jiffies in both modes.

---
 drivers/net/wireless/ath/ath9k/channel.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/channel.c +5 -4
index 047a76f..7a6ca44 100644
@@ -601,7 +601,7 @@ static void ath_chanctx_switch(struct ath_softc *sc, struct ath_chanctx *ctx,
 
 	if (sc->next_chan == &sc->offchannel.chan) {
 		sc->sched.offchannel_duration =
-			TU_TO_USEC(sc->offchannel.duration) +
+			jiffies_to_usecs(sc->offchannel.duration) +
 			sc->sched.channel_switch_time;
 
 		if (chandef) {
@@ -688,7 +688,8 @@ void ath_offchannel_next(struct ath_softc *sc)
 	} else if (sc->offchannel.roc_vif) {
 		vif = sc->offchannel.roc_vif;
 		sc->offchannel.chan.txpower = vif->bss_conf.txpower;
-		sc->offchannel.duration = sc->offchannel.roc_duration;
+		sc->offchannel.duration =
+			msecs_to_jiffies(sc->offchannel.roc_duration);
 		sc->offchannel.state = ATH_OFFCHANNEL_ROC_START;
 		ath_chanctx_offchan_switch(sc, sc->offchannel.roc_chan);
 	} else {
@@ -959,8 +960,8 @@ static void ath_offchannel_channel_change(struct ath_softc *sc)
 			break;
 
 		sc->offchannel.state = ATH_OFFCHANNEL_ROC_WAIT;
-		mod_timer(&sc->offchannel.timer, jiffies +
-			  msecs_to_jiffies(sc->offchannel.duration));
+		mod_timer(&sc->offchannel.timer,
+			  jiffies + sc->offchannel.duration);
 		ieee80211_ready_on_channel(sc->hw);
 		break;
 	case ATH_OFFCHANNEL_ROC_DONE:
Signature · 1 line
2.1.0
#6 lore raw

PATCH v3 6/11 ath9k: Add CTWindow support

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

Since CTWindow can be used for improving discoverability, fill this field in the NoA Attribute properly.

---
 drivers/net/wireless/ath/ath9k/ath9k.h   |  2 ++
 drivers/net/wireless/ath/ath9k/channel.c | 26 ++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/init.c    |  5 +++--
 3 files changed, 31 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +2 -0
index c690601..b4ac51e 100644
@@ -572,6 +572,8 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw,
 /* VIFs */
 /********/
 
+#define P2P_DEFAULT_CTWIN 10
+
 struct ath_vif {
 	struct list_head list;
 
drivers/net/wireless/ath/ath9k/channel.c +26 -0
index 7a6ca44..e73d305 100644
@@ -1166,6 +1166,30 @@ static void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif *vif)
 	ath9k_update_p2p_ps_timer(sc, avp);
 }
 
+static u8 ath9k_get_ctwin(struct ath_softc *sc, struct ath_vif *avp)
+{
+	struct ath_beacon_config *cur_conf = &sc->cur_chan->beacon;
+	u8 switch_time, ctwin;
+
+	/*
+	 * Channel switch in multi-channel mode is deferred
+	 * by a quarter beacon interval when handling
+	 * ATH_CHANCTX_EVENT_BEACON_PREPARE, so the P2P-GO
+	 * interface is guaranteed to be discoverable
+	 * for that duration after a TBTT.
+	 */
+	switch_time = cur_conf->beacon_interval / 4;
+
+	ctwin = avp->vif->bss_conf.p2p_noa_attr.oppps_ctwindow;
+	if (ctwin && (ctwin < switch_time))
+		return ctwin;
+
+	if (switch_time < P2P_DEFAULT_CTWIN)
+		return 0;
+
+	return P2P_DEFAULT_CTWIN;
+}
+
 void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp,
 			  struct sk_buff *skb)
 {
@@ -1198,6 +1222,8 @@ void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp,
 	memset(noa, 0, noa_len);
 
 	noa->index = avp->noa_index;
+	noa->oppps_ctwindow = ath9k_get_ctwin(sc, avp);
+
 	if (avp->periodic_noa_duration) {
 		u32 interval = TU_TO_USEC(sc->cur_chan->beacon.beacon_interval);
 
drivers/net/wireless/ath/ath9k/init.c +3 -2
index ca10a8b..1950c04 100644
@@ -763,8 +763,9 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
 	if (AR_SREV_9160_10_OR_LATER(sc->sc_ah) || ath9k_modparam_nohwcrypt)
 		hw->flags |= IEEE80211_HW_MFP_CAPABLE;
 
-	hw->wiphy->features |= (NL80211_FEATURE_ACTIVE_MONITOR |
-				NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE);
+	hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR |
+			       NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE |
+			       NL80211_FEATURE_P2P_GO_CTWIN;
 
 	if (!config_enabled(CONFIG_ATH9K_TX99)) {
 		hw->wiphy->interface_modes =
Signature · 1 line
2.1.0
#7 lore raw

PATCH v3 7/11 ath9k: Fix RX filter calculation

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

If multiple channel contexts are active, then the opmode can be different in each context. Since the RX filter is calculated in ath_startrecv() before switching to the new opmode, the wrong filters are chosen.

Fix this by calling ath9k_calculate_summary_state() before the RX module is started.

---
 drivers/net/wireless/ath/ath9k/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/main.c +2 -1
index 2333776..5d9f4d7 100644
@@ -224,6 +224,8 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
 	struct ath_common *common = ath9k_hw_common(ah);
 	unsigned long flags;
 
+	ath9k_calculate_summary_state(sc, sc->cur_chan);
+
 	if (ath_startrecv(sc) != 0) {
 		ath_err(common, "Unable to restart recv logic\n");
 		return false;
@@ -233,7 +235,6 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
 			       sc->cur_chan->txpower, &sc->curtxpow);
 
 	clear_bit(ATH_OP_HW_RESET, &common->op_flags);
-	ath9k_calculate_summary_state(sc, sc->cur_chan);
 
 	if (!sc->cur_chan->offchannel && start) {
 		/* restore per chanctx TSF timer */
Signature · 1 line
2.1.0
#8 lore raw

PATCH v3 8/11 ath9k: Fix ath_startrecv()

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

Since ath_startrecv() doesn't return an error value, cleanup the callsites.

---
 drivers/net/wireless/ath/ath9k/ath9k.h | 2 +-
 drivers/net/wireless/ath/ath9k/main.c  | 8 +-------
 drivers/net/wireless/ath/ath9k/recv.c  | 6 ++----
 3 files changed, 4 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -1
index b4ac51e..12cdabb 100644
@@ -527,7 +527,7 @@ static inline void ath_chanctx_check_active(struct ath_softc *sc,
 #endif /* CONFIG_ATH9K_CHANNEL_CONTEXT */
 
 int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan);
-int ath_startrecv(struct ath_softc *sc);
+void ath_startrecv(struct ath_softc *sc);
 bool ath_stoprecv(struct ath_softc *sc);
 u32 ath_calcrxfilter(struct ath_softc *sc);
 int ath_rx_init(struct ath_softc *sc, int nbufs);
drivers/net/wireless/ath/ath9k/main.c +1 -7
index 5d9f4d7..18e5e91 100644
@@ -225,15 +225,9 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
 	unsigned long flags;
 
 	ath9k_calculate_summary_state(sc, sc->cur_chan);
-
-	if (ath_startrecv(sc) != 0) {
-		ath_err(common, "Unable to restart recv logic\n");
-		return false;
-	}
-
+	ath_startrecv(sc);
 	ath9k_cmn_update_txpow(ah, sc->curtxpow,
 			       sc->cur_chan->txpower, &sc->curtxpow);
-
 	clear_bit(ATH_OP_HW_RESET, &common->op_flags);
 
 	if (!sc->cur_chan->offchannel && start) {
drivers/net/wireless/ath/ath9k/recv.c +2 -4
index 2aaf233..04b02b5 100644
@@ -433,14 +433,14 @@ u32 ath_calcrxfilter(struct ath_softc *sc)
 
 }
 
-int ath_startrecv(struct ath_softc *sc)
+void ath_startrecv(struct ath_softc *sc)
 {
 	struct ath_hw *ah = sc->sc_ah;
 	struct ath_rxbuf *bf, *tbf;
 
 	if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
 		ath_edma_start_recv(sc);
-		return 0;
+		return;
 	}
 
 	if (list_empty(&sc->rx.rxbuf))
@@ -463,8 +463,6 @@ int ath_startrecv(struct ath_softc *sc)
 start_recv:
 	ath_opmode_init(sc);
 	ath9k_hw_startpcureceive(ah, sc->cur_chan->offchannel);
-
-	return 0;
 }
 
 static void ath_flushrecv(struct ath_softc *sc)
Signature · 1 line
2.1.0
#9 lore raw

PATCH v3 9/11 ath9k: Fix COMP_BAR filter

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

ATH9K_RX_FILTER_COMP_BAR is used to receive BAR completion frames and is set if the current channel is HT. When channel contexts are enabled, instead of using the mac80211 helpers, check if the current channel definition is HT.

---
 drivers/net/wireless/ath/ath9k/recv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/recv.c +1 -1
index 04b02b5..63fbc3e 100644
@@ -412,7 +412,7 @@ u32 ath_calcrxfilter(struct ath_softc *sc)
 	    (sc->rx.rxfilter & FIF_PSPOLL))
 		rfilt |= ATH9K_RX_FILTER_PSPOLL;
 
-	if (conf_is_ht(&sc->hw->conf))
+	if (sc->cur_chandef.width != NL80211_CHAN_WIDTH_20_NOHT)
 		rfilt |= ATH9K_RX_FILTER_COMP_BAR;
 
 	if (sc->nvifs > 1 || (sc->rx.rxfilter & FIF_OTHER_BSS)) {
Signature · 1 line
2.1.0
#10 lore raw

PATCH v3 10/11 ath9k: Fix RX filters in channel contexts

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

Maintain the RX filter on a per-channel-context basis and not globally. Not doing so was resulting in incorrect filter calculation.

---
 drivers/net/wireless/ath/ath9k/ath9k.h |  3 ++-
 drivers/net/wireless/ath/ath9k/main.c  |  5 ++++-
 drivers/net/wireless/ath/ath9k/recv.c  | 21 +++++++++++++++------
 3 files changed, 21 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +2 -1
index 12cdabb..4f3da18 100644
@@ -314,7 +314,6 @@ struct ath_rx {
 	bool discard_next;
 	u32 *rxlink;
 	u32 num_pkts;
-	unsigned int rxfilter;
 	struct list_head rxbuf;
 	struct ath_descdma rxdma;
 	struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX];
@@ -350,6 +349,8 @@ struct ath_chanctx {
 	bool active;
 	bool assigned;
 	bool switch_after_beacon;
+
+	unsigned int rxfilter;
 };
 
 enum ath_chanctx_event {
drivers/net/wireless/ath/ath9k/main.c +4 -1
index 18e5e91..a202859 100644
@@ -1427,7 +1427,10 @@ static void ath9k_configure_filter(struct ieee80211_hw *hw,
 	changed_flags &= SUPPORTED_FILTERS;
 	*total_flags &= SUPPORTED_FILTERS;
 
-	sc->rx.rxfilter = *total_flags;
+	spin_lock_bh(&sc->chan_lock);
+	sc->cur_chan->rxfilter = *total_flags;
+	spin_unlock_bh(&sc->chan_lock);
+
 	ath9k_ps_wakeup(sc);
 	rfilt = ath_calcrxfilter(sc);
 	ath9k_hw_setrxfilter(sc->sc_ah, rfilt);
drivers/net/wireless/ath/ath9k/recv.c +15 -6
index 63fbc3e..68e56d6 100644
@@ -387,7 +387,9 @@ u32 ath_calcrxfilter(struct ath_softc *sc)
 	if (sc->hw->conf.radar_enabled)
 		rfilt |= ATH9K_RX_FILTER_PHYRADAR | ATH9K_RX_FILTER_PHYERR;
 
-	if (sc->rx.rxfilter & FIF_PROBE_REQ)
+	spin_lock_bh(&sc->chan_lock);
+
+	if (sc->cur_chan->rxfilter & FIF_PROBE_REQ)
 		rfilt |= ATH9K_RX_FILTER_PROBEREQ;
 
 	/*
@@ -398,24 +400,24 @@ u32 ath_calcrxfilter(struct ath_softc *sc)
 	if (sc->sc_ah->is_monitoring)
 		rfilt |= ATH9K_RX_FILTER_PROM;
 
-	if (sc->rx.rxfilter & FIF_CONTROL)
+	if (sc->cur_chan->rxfilter & FIF_CONTROL)
 		rfilt |= ATH9K_RX_FILTER_CONTROL;
 
 	if ((sc->sc_ah->opmode == NL80211_IFTYPE_STATION) &&
 	    (sc->nvifs <= 1) &&
-	    !(sc->rx.rxfilter & FIF_BCN_PRBRESP_PROMISC))
+	    !(sc->cur_chan->rxfilter & FIF_BCN_PRBRESP_PROMISC))
 		rfilt |= ATH9K_RX_FILTER_MYBEACON;
 	else
 		rfilt |= ATH9K_RX_FILTER_BEACON;
 
 	if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
-	    (sc->rx.rxfilter & FIF_PSPOLL))
+	    (sc->cur_chan->rxfilter & FIF_PSPOLL))
 		rfilt |= ATH9K_RX_FILTER_PSPOLL;
 
 	if (sc->cur_chandef.width != NL80211_CHAN_WIDTH_20_NOHT)
 		rfilt |= ATH9K_RX_FILTER_COMP_BAR;
 
-	if (sc->nvifs > 1 || (sc->rx.rxfilter & FIF_OTHER_BSS)) {
+	if (sc->nvifs > 1 || (sc->cur_chan->rxfilter & FIF_OTHER_BSS)) {
 		/* This is needed for older chips */
 		if (sc->sc_ah->hw_version.macVersion <= AR_SREV_VERSION_9160)
 			rfilt |= ATH9K_RX_FILTER_PROM;
@@ -429,6 +431,8 @@ u32 ath_calcrxfilter(struct ath_softc *sc)
 	    test_bit(ATH_OP_SCANNING, &common->op_flags))
 		rfilt |= ATH9K_RX_FILTER_BEACON;
 
+	spin_unlock_bh(&sc->chan_lock);
+
 	return rfilt;
 
 }
@@ -865,8 +869,13 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
 	 * everything but the rate is checked here, the rate check is done
 	 * separately to avoid doing two lookups for a rate for each frame.
 	 */
-	if (!ath9k_cmn_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error, sc->rx.rxfilter))
+	spin_lock_bh(&sc->chan_lock);
+	if (!ath9k_cmn_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error,
+				 sc->cur_chan->rxfilter)) {
+		spin_unlock_bh(&sc->chan_lock);
 		return -EINVAL;
+	}
+	spin_unlock_bh(&sc->chan_lock);
 
 	if (ath_is_mybeacon(common, hdr)) {
 		RX_STAT_INC(rx_beacons);
Signature · 1 line
2.1.0
#11 lore raw

PATCH v3 11/11 ath9k: Fix interface accounting

In reply to Sujith Manoharan

From: Sujith Manoharan <[email protected]>

Currently, the interface count is maintained globally, but this causes problems in RX filter calculation. Make the interface count a per-channel-context variable to fix this.

---
 drivers/net/wireless/ath/ath9k/ath9k.h  | 2 +-
 drivers/net/wireless/ath/ath9k/beacon.c | 2 +-
 drivers/net/wireless/ath/ath9k/debug.c  | 2 +-
 drivers/net/wireless/ath/ath9k/main.c   | 6 +++---
 drivers/net/wireless/ath/ath9k/recv.c   | 4 ++--
 drivers/net/wireless/ath/ath9k/tx99.c   | 2 +-
 drivers/net/wireless/ath/ath9k/wow.c    | 2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -1
index 4f3da18..46a1d2e 100644
@@ -350,6 +350,7 @@ struct ath_chanctx {
 	bool assigned;
 	bool switch_after_beacon;
 
+	short nvifs;
 	unsigned int rxfilter;
 };
 
@@ -963,7 +964,6 @@ struct ath_softc {
 	bool ps_enabled;
 	bool ps_idle;
 	short nbcnvifs;
-	short nvifs;
 	unsigned long ps_usecount;
 
 	struct ath_rx rx;
drivers/net/wireless/ath/ath9k/beacon.c +1 -1
index 83f2f2f..a6af855 100644
@@ -183,7 +183,7 @@ static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw,
 	spin_unlock_bh(&cabq->axq_lock);
 
 	if (skb && cabq_depth) {
-		if (sc->nvifs > 1) {
+		if (sc->cur_chan->nvifs > 1) {
 			ath_dbg(common, BEACON,
 				"Flushing previous cabq traffic\n");
 			ath_draintxq(sc, cabq);
drivers/net/wireless/ath/ath9k/debug.c +1 -1
index d227936..5d8b5ea 100644
@@ -838,7 +838,7 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf,
 			iter_data.nmeshes, iter_data.nwds);
 		len += scnprintf(buf + len, sizeof(buf) - len,
 			" ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
-			iter_data.nadhocs, sc->nvifs, sc->nbcnvifs);
+			iter_data.nadhocs, sc->cur_chan->nvifs, sc->nbcnvifs);
 	}
 
 	if (len > sizeof(buf))
drivers/net/wireless/ath/ath9k/main.c +3 -3
index a202859..cdf1e7d 100644
@@ -1117,7 +1117,7 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
 	mutex_lock(&sc->mutex);
 
 	if (config_enabled(CONFIG_ATH9K_TX99)) {
-		if (sc->nvifs >= 1) {
+		if (sc->cur_chan->nvifs >= 1) {
 			mutex_unlock(&sc->mutex);
 			return -EOPNOTSUPP;
 		}
@@ -1125,7 +1125,7 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
 	}
 
 	ath_dbg(common, CONFIG, "Attach a VIF of type: %d\n", vif->type);
-	sc->nvifs++;
+	sc->cur_chan->nvifs++;
 
 	if (ath9k_uses_beacons(vif->type))
 		ath9k_beacon_assign_slot(sc, vif);
@@ -1207,7 +1207,7 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
 
 	ath9k_p2p_remove_vif(sc, vif);
 
-	sc->nvifs--;
+	sc->cur_chan->nvifs--;
 	sc->tx99_vif = NULL;
 	if (!ath9k_is_chanctx_enabled())
 		list_del(&avp->list);
drivers/net/wireless/ath/ath9k/recv.c +2 -2
index 68e56d6..957a877 100644
@@ -404,7 +404,7 @@ u32 ath_calcrxfilter(struct ath_softc *sc)
 		rfilt |= ATH9K_RX_FILTER_CONTROL;
 
 	if ((sc->sc_ah->opmode == NL80211_IFTYPE_STATION) &&
-	    (sc->nvifs <= 1) &&
+	    (sc->cur_chan->nvifs <= 1) &&
 	    !(sc->cur_chan->rxfilter & FIF_BCN_PRBRESP_PROMISC))
 		rfilt |= ATH9K_RX_FILTER_MYBEACON;
 	else
@@ -417,7 +417,7 @@ u32 ath_calcrxfilter(struct ath_softc *sc)
 	if (sc->cur_chandef.width != NL80211_CHAN_WIDTH_20_NOHT)
 		rfilt |= ATH9K_RX_FILTER_COMP_BAR;
 
-	if (sc->nvifs > 1 || (sc->cur_chan->rxfilter & FIF_OTHER_BSS)) {
+	if (sc->cur_chan->nvifs > 1 || (sc->cur_chan->rxfilter & FIF_OTHER_BSS)) {
 		/* This is needed for older chips */
 		if (sc->sc_ah->hw_version.macVersion <= AR_SREV_VERSION_9160)
 			rfilt |= ATH9K_RX_FILTER_PROM;
drivers/net/wireless/ath/ath9k/tx99.c +1 -1
index 2397292..8a69d08 100644
@@ -174,7 +174,7 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
 	ssize_t len;
 	int r;
 
-	if (sc->nvifs > 1)
+	if (sc->cur_chan->nvifs > 1)
 		return -EOPNOTSUPP;
 
 	len = min(count, sizeof(buf) - 1);
drivers/net/wireless/ath/ath9k/wow.c +1 -1
index 33531d9..5f30e58 100644
@@ -232,7 +232,7 @@ int ath9k_suspend(struct ieee80211_hw *hw,
 		goto fail_wow;
 	}
 
-	if (sc->nvifs > 1) {
+	if (sc->cur_chan->nvifs > 1) {
 		ath_dbg(common, WOW, "WoW for multivif is not yet supported\n");
 		ret = 1;
 		goto fail_wow;
Signature · 1 line
2.1.0