Skip to contentSkip to conversation

wifi: mac80211: don't reconfigure when the last emulated chanctx is removed

PATCH In review Nerijus Bendžiūnas 2 participants 2 messages Sep 4 – Sep 14 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wifi: mac80211: don't reconfigure when the last emulated chanctx is removed

ieee80211_emulate_remove_chanctx() calls _ieee80211_hw_conf_chan() after the last channel context has been removed. With no context left, ieee80211_calc_hw_conf_chan() falls back to the default channel, so the driver is switched to a channel nobody asked for, and the next context switches it again.

A monitor interface retunes by removing its context and adding a new one, so every retune costs the driver two channel changes. Nothing is transmitting or receiving without a context, and the new context sets the channel, so the extra reconfiguration is unnecessary. Keep clearing radar_enabled so the next configuration starts clean.

Measured on an AR9271 (ath9k_htc), where a channel change is a full chip reset over USB, hopping across the 13 channels in 2.4 GHz, 1000 hops:

drv_config calls median hop p95 hop

  before                     2006      123.5 ms    183 ms
  after                      1006       92.0 ms    105 ms

Delivery of injected frames to a second card was 99.1% before and 98.3% after (3863 and 3835 of 3900).

Assisted-by Claude:claude-fable-5-1

---
Changes in v2:
- Add the Assisted-by tag.
- Rewrite the commit message and shorten the in-code comment. No change to the code.

 net/mac80211/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
net/mac80211/main.c +5 -2
index a59837b9f480..643d59e878c9 100644
@@ -289,9 +289,12 @@ void ieee80211_emulate_remove_chanctx(struct ieee80211_hw *hw,
 {
 	struct ieee80211_local *local = hw_to_local(hw);
 
+	/*
+	 * No context is left, so there is nothing to configure; the next
+	 * context sets the channel. Reconfiguring here would switch the
+	 * driver to the default channel only to switch it again.
+	 */
 	local->hw.conf.radar_enabled = false;
-
-	_ieee80211_hw_conf_chan(local, NULL);
 }
 EXPORT_SYMBOL(ieee80211_emulate_remove_chanctx);
 

base-commit: ca800a9302764c445de0da0e84d2252400a770ee

Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 38 lines · Nerijus Bendžiūnas

ieee80211_emulate_remove_chanctx() calls _ieee80211_hw_conf_chan() after the last channel context has been removed. With no context left, ieee80211_calc_hw_conf_chan() falls back to the default channel, so the driver is switched to a channel nobody asked for, and the next context switches it again.

A monitor interface retunes by removing its context and adding a new one, so every retune costs the driver two channel changes. Nothing is transmitting or receiving without a context, and the new context sets the channel, so the extra reconfiguration is unnecessary. Keep clearing radar_enabled so the next configuration starts clean.

Measured on an AR9271 (ath9k_htc), where a channel change is a full chip reset over USB, hopping across the 13 channels in 2.4 GHz, 1000 hops:

drv_config calls median hop p95 hop

  before                     2006      123.5 ms    183 ms
  after                      1006       92.0 ms    105 ms

Delivery of injected frames to a second card was 99.1% before and 98.3% after (3863 and 3835 of 3900).

Assisted-by Claude:claude-fable-5-1

---
Changes in v2:
- Add the Assisted-by tag.
- Rewrite the commit message and shorten the in-code comment. No change to the code.

 net/mac80211/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
net/mac80211/main.c +0 -0
index a59837b9f480..643d59e878c9 100644

net/mac80211/main.c void ieee80211_emulate_remove_chanctx(struct ieee80211_hw *hw, · line 296

Quoted 8 lines
net/mac80211/main.c +5 -0
@@ -289,9 +289,12 @@ void ieee80211_emulate_remove_chanctx(struct ieee80211_hw *hw,
 {
 	struct ieee80211_local *local = hw_to_local(hw);
 
+	/*
+	 * No context is left, so there is nothing to configure; the next
+	 * context sets the channel. Reconfiguring here would switch the
+	 * driver to the default channel only to switch it again.
+	 */

Don't leave useless LLM comments in the code - clearly that comment was only written by the LLM because of the case you were trying to fix, it's not really related to the code at all ...

Either way though, this is wrong - if regulatory kicks you off a channel then we don't even allow monitor, but this change would leave the monitor on it anyway.

johannes