Linux wireless drivers development
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH mt76-next 15/20] wifi: mt76: mt792x: set up the sniffer when a monitor gets its channel
Date: Fri, 20 Nov 2026 18:44:54 +0100	[thread overview]
Message-ID: <20261120174459.1657382-15-nbd@nbd.name> (raw)
In-Reply-To: <20261120174459.1657382-1-nbd@nbd.name>

mt7921 and mt7925 tune the sniffer of a monitor only in change_chanctx.
For the new channel context of a monitor, mac80211 calls change_chanctx
only on a device with more than one RX chain. On a device with one RX
chain, the sniffer thus stays off the channel of the monitor.

Set up the sniffer when the channel context is assigned.

Fixes: 41ac53c899bd ("wifi: mt76: mt7921: introduce chanctx support")
Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 .../net/wireless/mediatek/mt76/mt7921/main.c  | 25 +++++++++++++++++--
 .../net/wireless/mediatek/mt76/mt7925/main.c  |  8 ++++--
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index a89b4c7f2239..9b13e9c25cf3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -1469,12 +1469,33 @@ static void mt7921_mgd_complete_tx(struct ieee80211_hw *hw,
 	mt7921_abort_roc(mvif->phy, mvif);
 }
 
+static int mt7921_assign_vif_chanctx(struct ieee80211_hw *hw,
+				     struct ieee80211_vif *vif,
+				     struct ieee80211_bss_conf *link_conf,
+				     struct ieee80211_chanctx_conf *ctx)
+{
+	struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+	struct mt792x_dev *dev = mt792x_hw_dev(hw);
+	int ret;
+
+	ret = mt792x_assign_vif_chanctx(hw, vif, link_conf, ctx);
+	if (ret || vif->type != NL80211_IFTYPE_MONITOR)
+		return ret;
+
+	mt792x_mutex_acquire(dev);
+	mt7921_mcu_set_sniffer(dev, vif, true);
+	mt7921_mcu_config_sniffer(mvif, ctx);
+	mt792x_mutex_release(dev);
+
+	return 0;
+}
+
 static int mt7921_switch_vif_chanctx(struct ieee80211_hw *hw,
 				     struct ieee80211_vif_chanctx_switch *vifs,
 				     int n_vifs,
 				     enum ieee80211_chanctx_switch_mode mode)
 {
-	return mt792x_assign_vif_chanctx(hw, vifs->vif, vifs->link_conf,
+	return mt7921_assign_vif_chanctx(hw, vifs->vif, vifs->link_conf,
 					 vifs->new_ctx);
 }
 
@@ -1620,7 +1641,7 @@ const struct ieee80211_ops mt7921_ops = {
 	.add_chanctx = mt7921_add_chanctx,
 	.remove_chanctx = mt7921_remove_chanctx,
 	.change_chanctx = mt7921_change_chanctx,
-	.assign_vif_chanctx = mt792x_assign_vif_chanctx,
+	.assign_vif_chanctx = mt7921_assign_vif_chanctx,
 	.unassign_vif_chanctx = mt792x_unassign_vif_chanctx,
 	.mgd_prepare_tx = mt7921_mgd_prepare_tx,
 	.mgd_complete_tx = mt7921_mgd_complete_tx,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
index bd5375705e98..8c9c77bd97b6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -2760,7 +2760,7 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
 	struct mt792x_bss_conf *mconf;
 	u8 band_idx;
 
-	mutex_lock(&dev->mt76.mutex);
+	mt792x_mutex_acquire(dev);
 
 	if (ieee80211_vif_is_mld(vif)) {
 		mconf = mt792x_vif_to_link(mvif, link_conf->link_id);
@@ -2782,7 +2782,11 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
 
 	mconf->mt76.ctx = ctx;
 	mt76_phy_chandef_set(mvif->phy->mt76, &ctx->def);
-	mutex_unlock(&dev->mt76.mutex);
+	if (vif->type == NL80211_IFTYPE_MONITOR) {
+		mt7925_mcu_set_sniffer(dev, vif, true);
+		mt7925_mcu_config_sniffer(mvif, ctx);
+	}
+	mt792x_mutex_release(dev);
 
 	return 0;
 }
-- 
2.47.3


  parent reply	other threads:[~2026-11-20 17:45 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 17:44 [PATCH mt76-next 01/20] wifi: mt76: mt7925: free the vif links when all links go Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 02/20] wifi: mt76: mt7925: free removed vif links after an RCU grace period Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 03/20] wifi: mt76: remove a replayed station from the driver before the add Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 04/20] wifi: mt76: mt7925: run the reset link replay under the wiphy lock Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 05/20] wifi: mt76: mt7925: take the mutex before the link_info_changed lookup Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 06/20] wifi: mt76: mt7925: hold the mutex for the link lookup in conf_tx Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 07/20] wifi: mt76: mt7925: skip a polled link without a station Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 08/20] wifi: mt76: mt7925: skip a link without a link conf in the MLO PS update Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 09/20] wifi: mt76: mt7925: restore the beacon filter when monitor mode ends Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 10/20] wifi: mt76: usb: do not park the TX worker again under MT76_RESET Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 11/20] wifi: mt76: mt7925: keep the default link in the active links Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 12/20] wifi: mt76: mt7925: read the monitor state under the mutex for deep sleep Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 13/20] wifi: mt76: clear roc_link before the ROC link is freed Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 14/20] wifi: mt76: mt792x: handle all interfaces of a channel context Felix Fietkau
2026-11-20 17:44 ` Felix Fietkau [this message]
2026-11-20 17:44 ` [PATCH mt76-next 16/20] wifi: mt76: buffer Disassociation frames for stations in power save Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 17/20] wifi: mt76: mt7921: read the monitor state under the mutex for deep sleep Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 18/20] wifi: mt76: mt7925: wake the device to unassign a channel context Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 19/20] wifi: mt76: mt7996: keep the firmware log settings across a reload Felix Fietkau
2026-11-20 17:44 ` [PATCH mt76-next 20/20] wifi: mt76: mt7915: " Felix Fietkau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261120174459.1657382-15-nbd@nbd.name \
    --to=nbd@nbd.name \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox